From patchwork Fri Mar 16 16:04:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 10375 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1S8ZeC-0007nB-Vr for patchwork@linuxtv.org; Fri, 16 Mar 2012 17:04:57 +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-2) with esmtp for id 1S8ZeC-0005CQ-H7; Fri, 16 Mar 2012 17:04:56 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031435Ab2CPQEx (ORCPT ); Fri, 16 Mar 2012 12:04:53 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:43118 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031330Ab2CPQEv (ORCPT ); Fri, 16 Mar 2012 12:04:51 -0400 Received: by gghe5 with SMTP id e5so4339306ggh.19 for ; Fri, 16 Mar 2012 09:04:51 -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=ppVZz8hU4kruT8aF8CkUxNtay3nrWuh5XvLrpW+tOfk=; b=H1fTj0Mf0/MjV97FT2tRe9qhdRGC4nFfxJsuGd18gunRsbcTAe+OHDyDroB27/DBAF bCfJAEMcDetfJR9p/mf9qApNsKb4xgO7buzSjSxS/I5DPRa6QakeFIxW/ZAkMPfV/IWa 6BmZ+4j7l9UxeIcL/1o51KNtDyfZ9KwfNnnh60D4Xd1y+MLwUIafhVtGmPiJtbhTOQyu Y66gzgKYwizCJfCkL/rciNOWqTrcqEfVTpSHKHwGio9rcCoUJ8JWHJLkibpYPeu4v2Jj bALj9kd8SHQ87ipVxoFn/UnogiTgytz+/fR+xkJvAPCtFb98K7GQfWYI9ssCXbbF+5jx tbNw== Received: by 10.60.30.66 with SMTP id q2mr3643828oeh.25.1331913891064; Fri, 16 Mar 2012 09:04:51 -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 s2sm4000119oea.2.2012.03.16.09.04.44 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Mar 2012 09:04:44 -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 11:04:41 -0500 Message-Id: <1331913881-13105-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.155131 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_1400_1499 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: Dave Airlie --- include/linux/dma-buf.h | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index cbdff81..25eb287 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -132,6 +132,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);