From patchwork Wed Mar 9 08:54:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 8544111 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EDA3B9F2B4 for ; Wed, 9 Mar 2016 08:54:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FEEC20251 for ; Wed, 9 Mar 2016 08:54:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8368D20220 for ; Wed, 9 Mar 2016 08:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752798AbcCIIyP (ORCPT ); Wed, 9 Mar 2016 03:54:15 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:37853 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752425AbcCIIyP (ORCPT ); Wed, 9 Mar 2016 03:54:15 -0500 Received: by mail-wm0-f43.google.com with SMTP id p65so61000095wmp.0 for ; Wed, 09 Mar 2016 00:54:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=tmQFbfb6sGWpTuSqZ4tKm/5VDNYtnHtPNteXZ3XKhF0=; b=SrF+EfC2cPTDvD62nblR3C9HZtN14PzzaeeZn1oi47qD2fPbxJN+UpPWuJqvHsXi1D Kh7AfjjOmK/fhf/v/6e07fqdWMpcuO+bnEExahunJmf+3XrsLZghYhcHdY6Jzsw/AHYJ lvx4HnI+GihZ+8YwQIfYMgwomMqsTr+IziQXE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tmQFbfb6sGWpTuSqZ4tKm/5VDNYtnHtPNteXZ3XKhF0=; b=VIbZIlllgLVjKA+HkS32UeKaGjJLqBJDoUQn8tSR7FffHS3BQyc97USieHiCkfO1CN 5hrcPgYDrWF4MrCPFMpjT86MzChYhJ+aSZRtE6mlli1OGuHcsSGSbYHmRh/ospGMHLGT lFW7CydiWQbOCf+ZT/TtiA7+8O/8DNvbUnewLsZ2ESjwGAK4xgaBzSQeN1oUuWwSLrTC LGUcRfhOPY0DH0XioPOfusatDW1lh4sA8SeURUUn2QWAlQ+JEGC5/cby0yMtd4Q4x5Gj NFxscEuomubgzQ7qRvaHPqTManMV8XCXyPvSa0//8CzEcuOfxggHU7rHjzFzUrD886EL P3tg== X-Gm-Message-State: AD7BkJJkj+TAhS4kK/EVuAheyjCeTTxK3Pt/I2uMiuUeafUYkmWEj7jxintHZ7sNAW2l8SDy X-Received: by 10.28.170.137 with SMTP id t131mr25128135wme.32.1457513653571; Wed, 09 Mar 2016 00:54:13 -0800 (PST) Received: from lmenx321.st.com. ([80.12.42.141]) by smtp.gmail.com with ESMTPSA id i1sm6780212wjs.45.2016.03.09.00.54.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Mar 2016 00:54:12 -0800 (PST) From: Benjamin Gaignard To: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, sumit.semwal@linaro.org, john.stultz@linaro.org Cc: Benjamin Gaignard Subject: [PATCH] dmabuf: allow exporter to define customs ioctls Date: Wed, 9 Mar 2016 09:54:02 +0100 Message-Id: <1457513642-10859-1-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In addition of the already existing operations allow exporter to use it own custom ioctls. Signed-off-by: Benjamin Gaignard --- drivers/dma-buf/dma-buf.c | 3 +++ include/linux/dma-buf.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 9810d1d..6abd129 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -291,6 +291,9 @@ static long dma_buf_ioctl(struct file *file, return 0; default: + if (dmabuf->ops->ioctl) + return dmabuf->ops->ioctl(dmabuf, cmd, arg); + return -ENOTTY; } } diff --git a/include/linux/dma-buf.h b/include/linux/dma-buf.h index 532108e..b6f9837 100644 --- a/include/linux/dma-buf.h +++ b/include/linux/dma-buf.h @@ -70,6 +70,9 @@ struct dma_buf_attachment; * @vmap: [optional] creates a virtual mapping for the buffer into kernel * address space. Same restrictions as for vmap and friends apply. * @vunmap: [optional] unmaps a vmap from the buffer + * @ioctl: [optional] ioctls supported by the exporter. + * It is up to the exporter to do the proper copy_{from/to}_user + * calls. Should return -EINVAL in case of error. */ struct dma_buf_ops { int (*attach)(struct dma_buf *, struct device *, @@ -104,6 +107,8 @@ struct dma_buf_ops { void *(*vmap)(struct dma_buf *); void (*vunmap)(struct dma_buf *, void *vaddr); + + int (*ioctl)(struct dma_buf *, unsigned int cmd, unsigned long arg); }; /**