From patchwork Fri Mar 16 20:02:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 10379 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1S8dOg-0000Nd-G5 for patchwork@linuxtv.org; Fri, 16 Mar 2012 21:05:10 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-3) with esmtp for id 1S8dOe-00048A-FQ; Fri, 16 Mar 2012 21:05:09 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932618Ab2CPUEY (ORCPT ); Fri, 16 Mar 2012 16:04:24 -0400 Received: from mail-gy0-f174.google.com ([209.85.160.174]:47680 "EHLO mail-gy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932614Ab2CPUCZ (ORCPT ); Fri, 16 Mar 2012 16:02:25 -0400 Received: by ghrr11 with SMTP id r11so4594166ghr.19 for ; Fri, 16 Mar 2012 13:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=23APqqP7glE5nLN1LGNH1WshauX/N9bGw2z7cN8xneU=; b=VgUw+E9CkTUz6Nonmp0JfnXWDopfrwMbAcMtGlkCx2ZFX7+aETkL2M/NZyGt3lT+40 PIYN93xpnUu+ngfQofd8Ap+/HN2ms8ApaiuBi8GRsbM3wQmaGSjjGtgBQzp8TgPdOmvP 6ils/XcqO5p+UZWbc3pXhEpUFRAKRL7TzOdANoObcZj8Wc0tK3jJycPsnn4ApbPyoCO9 MN7SSYQKFz20vqa1qXPEVvwA3seItyivCqBmMtQr1EOZz00/E9WvXd2Pn15c3BBggj1H 6fkDtM1U/s81VaNf7Jpm/eapYUQLKdBBygWYi258uNp1YkgLNp7OU4h8iM8vNwK7lEIe pMVQ== Received: by 10.182.75.103 with SMTP id b7mr3707159obw.54.1331928145176; Fri, 16 Mar 2012 13:02:25 -0700 (PDT) Received: from localhost (ppp-70-129-134-19.dsl.rcsntx.swbell.net. [70.129.134.19]) by mx.google.com with ESMTPS id m3sm2300623oem.7.2012.03.16.13.02.23 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Mar 2012 13:02:24 -0700 (PDT) From: Rob Clark To: linaro-mm-sig@lists.linaro.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org Cc: patches@linaro.org, sumit.semwal@linaro.org, daniel@ffwll.ch, airlied@redhat.com, Rob Clark Subject: [PATCH] dma-buf: add get_dma_buf() Date: Fri, 16 Mar 2012 15:02:24 -0500 Message-Id: <1331928144-30628-1-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.5.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.3.16.195725 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_1600_1699 0, BODY_SIZE_2000_LESS 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, DATE_TZ_NEG_0500 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' From: Rob Clark Works in a similar way to get_file(), and is needed in cases such as when the exporter needs to also keep a reference to the dmabuf (that is later released with a dma_buf_put()), and possibly other similar cases. Signed-off-by: Rob Clark Reviewed-by: Kyungmin Park --- Minor update on original to add a missing #include include/linux/dma-buf.h | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index 891457a..bc4203dc 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -30,6 +30,7 @@ #include #include #include +#include struct dma_buf; struct dma_buf_attachment; @@ -110,6 +111,20 @@ struct dma_buf_attachment { void *priv; }; +/** + * get_dma_buf - convenience wrapper for get_file. + * @dmabuf: [in] pointer to dma_buf + * + * Increments the reference count on the dma-buf, needed in case of drivers + * that either need to create additional references to the dmabuf on the + * kernel side. For example, an exporter that needs to keep a dmabuf ptr + * so that subsequent exports don't create a new dmabuf. + */ +static inline void get_dma_buf(struct dma_buf *dmabuf) +{ + get_file(dmabuf->file); +} + #ifdef CONFIG_DMA_SHARED_BUFFER struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, struct device *dev);