From patchwork Thu Jul 14 22:35:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 9230807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8AF9E60574 for ; Thu, 14 Jul 2016 22:35:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A7A8281DB for ; Thu, 14 Jul 2016 22:35:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F84928308; Thu, 14 Jul 2016 22:35:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 989B0281DB for ; Thu, 14 Jul 2016 22:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752307AbcGNWfe (ORCPT ); Thu, 14 Jul 2016 18:35:34 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:40477 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752160AbcGNWfZ (ORCPT ); Thu, 14 Jul 2016 18:35:25 -0400 Received: from lanttu.localdomain (lanttu-e.localdomain [192.168.1.64]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id 53D02600A4; Fri, 15 Jul 2016 01:35:17 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: mchehab@osg.samsung.com, shuahkh@osg.samsung.com, laurent.pinchart@ideasonboard.com, hverkuil@xs4all.nl Subject: [RFC 08/16] media: Provide a way to the driver to set a private pointer Date: Fri, 15 Jul 2016 01:35:03 +0300 Message-Id: <1468535711-13836-9-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1468535711-13836-1-git-send-email-sakari.ailus@linux.intel.com> References: <1468535711-13836-1-git-send-email-sakari.ailus@linux.intel.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that the media device can be allocated dynamically, drivers have no longer a way to conveniently obtain the driver private data structure. Provide one again in the form of a private pointer passed to the media_device_alloc() function. Signed-off-by: Sakari Ailus --- drivers/media/media-device.c | 3 ++- include/media/media-device.h | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 1eadf02..eae57c6 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -701,7 +701,7 @@ void media_device_init(struct media_device *mdev) } EXPORT_SYMBOL_GPL(media_device_init); -struct media_device *media_device_alloc(struct device *dev) +struct media_device *media_device_alloc(struct device *dev, void *priv) { struct media_device *mdev; @@ -719,6 +719,7 @@ struct media_device *media_device_alloc(struct device *dev) mdev->dev = dev; media_device_init(mdev); + mdev->priv = priv; return mdev; } diff --git a/include/media/media-device.h b/include/media/media-device.h index 5bf97e5..8582e23 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -283,6 +283,7 @@ struct media_entity_notify { * struct media_device - Media device * @dev: Parent device * @devnode: Media device node + * @priv: A pointer to driver private data * @driver_name: Optional device driver name. If not set, calls to * %MEDIA_IOC_DEVICE_INFO will return dev->driver->name. * This is needed for USB drivers for example, as otherwise @@ -348,6 +349,7 @@ struct media_device { /* dev->driver_data points to this struct. */ struct device *dev; struct media_devnode devnode; + void *priv; char model[32]; char driver_name[32]; @@ -431,6 +433,7 @@ void media_device_init(struct media_device *mdev); * media_device_alloc() - Allocate and initialise a media device * * @dev: The associated struct device pointer + * @priv: pointer to a driver private data structure * * Allocate and initialise a media device. Returns a media device. * The media device is refcounted, and this function returns a media @@ -439,7 +442,7 @@ void media_device_init(struct media_device *mdev); * References are taken and given using media_device_get() and * media_device_put(). */ -struct media_device *media_device_alloc(struct device *dev); +struct media_device *media_device_alloc(struct device *dev, void *priv); /** * media_device_get() - Get a reference to a media device @@ -466,6 +469,16 @@ struct media_device *media_device_alloc(struct device *dev); } while (0) /** + * media_device_priv() - Obtain the driver private pointer + * + * Returns a pointer passed to the media_device_alloc() function. + */ +static inline void *media_device_priv(struct media_device *mdev) +{ + return mdev->priv; +} + +/** * media_device_cleanup() - Cleanups a media device element * * @mdev: pointer to struct &media_device