From patchwork Fri Aug 19 10:23:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 9290013 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 1F03E600CB for ; Fri, 19 Aug 2016 10:24:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11A7229333 for ; Fri, 19 Aug 2016 10:24:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06D5329398; Fri, 19 Aug 2016 10:24:11 +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 A9B9C29333 for ; Fri, 19 Aug 2016 10:24:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754510AbcHSKYH (ORCPT ); Fri, 19 Aug 2016 06:24:07 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:46816 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754245AbcHSKYG (ORCPT ); Fri, 19 Aug 2016 06:24:06 -0400 Received: from lanttu.localdomain (unknown [192.168.15.166]) by hillosipuli.retiisi.org.uk (Postfix) with ESMTP id ADC22600AD; Fri, 19 Aug 2016 13:24:01 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org, hverkuil@xs4all.nl Cc: m.chehab@osg.samsung.com, shuahkh@osg.samsung.com, laurent.pinchart@ideasonboard.com Subject: [RFC v2 09/17] media-device: struct media_device requires struct device Date: Fri, 19 Aug 2016 13:23:40 +0300 Message-Id: <1471602228-30722-10-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1471602228-30722-1-git-send-email-sakari.ailus@linux.intel.com> References: <1471602228-30722-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 The media device always has a device around. Require one as an argument for media_device_alloc(). Signed-off-by: Sakari Ailus Acked-by: Hans Verkuil --- drivers/media/media-device.c | 12 ++++++++++-- include/media/media-device.h | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index d527491..6c8b689 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -699,15 +699,22 @@ void media_device_init(struct media_device *mdev) } EXPORT_SYMBOL_GPL(media_device_init); -struct media_device *media_device_alloc(void) +struct media_device *media_device_alloc(struct device *dev) { struct media_device *mdev; + dev = get_device(dev); + if (!dev) + return NULL; + mdev = kzalloc(sizeof(*mdev), GFP_KERNEL); - if (!mdev) + if (!mdev) { + put_device(dev); return NULL; + } media_devnode_init(&mdev->devnode); + mdev->dev = dev; media_device_init(mdev); return mdev; @@ -720,6 +727,7 @@ void media_device_cleanup(struct media_device *mdev) mdev->entity_internal_idx_max = 0; media_entity_graph_walk_cleanup(&mdev->pm_count_walk); mutex_destroy(&mdev->graph_mutex); + put_device(mdev->dev); } EXPORT_SYMBOL_GPL(media_device_cleanup); diff --git a/include/media/media-device.h b/include/media/media-device.h index d1d45ab..8ccc8e8 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -199,6 +199,8 @@ void media_device_init(struct media_device *mdev); /** * media_device_alloc() - Allocate and initialise a media device * + * @dev: The associated struct device pointer + * * Allocate and initialise a media device. Returns a media device. * The media device is refcounted, and this function returns a media * device the refcount of which is one (1). @@ -206,7 +208,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(void); +struct media_device *media_device_alloc(struct device *dev); /** * media_device_get() - Get a reference to a media device