From patchwork Tue Apr 5 03:35:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 8746871 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ACBD6C0553 for ; Tue, 5 Apr 2016 03:38:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5440202F0 for ; Tue, 5 Apr 2016 03:38:56 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 7CC7020142 for ; Tue, 5 Apr 2016 03:38:55 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5A7752658EB; Tue, 5 Apr 2016 05:38:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 00057265472; Tue, 5 Apr 2016 05:36:43 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7FA93261A03; Tue, 5 Apr 2016 05:36:31 +0200 (CEST) Received: from mailout.easymail.ca (mailout.easymail.ca [64.68.201.169]) by alsa0.perex.cz (Postfix) with ESMTP id 9CEFB261A03 for ; Tue, 5 Apr 2016 05:36:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id DFE45EA66; Mon, 4 Apr 2016 23:36:09 -0400 (EDT) X-Quarantine-ID: X-Virus-Scanned: Debian amavisd-new at mailout.easymail.ca X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (easymail-mailout.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U11+DF7mnf99; Mon, 4 Apr 2016 23:36:09 -0400 (EDT) Received: from mail.gonehiking.org (c-73-181-52-62.hsd1.co.comcast.net [73.181.52.62]) by mailout.easymail.ca (Postfix) with ESMTPA id 70F5EEAAA; Mon, 4 Apr 2016 23:36:08 -0400 (EDT) Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 1C7E49F3E9; Mon, 4 Apr 2016 21:36:08 -0600 (MDT) From: Shuah Khan To: mchehab@osg.samsung.com, laurent.pinchart@ideasonboard.com, perex@perex.cz, tiwai@suse.com, hans.verkuil@cisco.com, chehabrafael@gmail.com, javier@osg.samsung.com, jh1009.sung@samsung.com, ricard.wanderlof@axis.com, julian@jusst.de, pierre-louis.bossart@linux.intel.com, clemens@ladisch.de, dominic.sacre@gmx.de, takamichiho@gmail.com, johan@oljud.se, geliangtang@163.com Date: Mon, 4 Apr 2016 21:35:58 -0600 Message-Id: <7788c0ae7eea624d5d855358d781cd99a3e3f95f.1459825702.git.shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Shuah Khan , linux-media@vger.kernel.org Subject: [alsa-devel] [RFC PATCH v2 3/5] media: uvcvideo change to use Media Device Allocator API X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Change uvcvideo to use Media Device Allocator API and new Media Controller media_device_unregister_put() interface. Signed-off-by: Shuah Khan --- drivers/media/usb/uvc/uvc_driver.c | 36 ++++++++++++++++++++++-------------- drivers/media/usb/uvc/uvcvideo.h | 3 ++- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 451e84e9..95e30c4 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1674,9 +1674,10 @@ static void uvc_delete(struct uvc_device *dev) if (dev->vdev.dev) v4l2_device_unregister(&dev->vdev); #ifdef CONFIG_MEDIA_CONTROLLER - if (media_devnode_is_registered(&dev->mdev.devnode)) - media_device_unregister(&dev->mdev); - media_device_cleanup(&dev->mdev); + if (media_devnode_is_registered(&dev->mdev->devnode)) { + media_device_unregister_put(dev->mdev); + media_device_put(dev->mdev->dev); + } #endif list_for_each_safe(p, n, &dev->chains) { @@ -1929,17 +1930,20 @@ static int uvc_probe(struct usb_interface *intf, /* Initialize the media device and register the V4L2 device. */ #ifdef CONFIG_MEDIA_CONTROLLER - dev->mdev.dev = &intf->dev; - strlcpy(dev->mdev.model, dev->name, sizeof(dev->mdev.model)); + dev->mdev = media_device_get(&intf->dev); + if (!dev->mdev) + goto media_device_get_error; + dev->mdev->dev = &intf->dev; + strlcpy(dev->mdev->model, dev->name, sizeof(dev->mdev->model)); if (udev->serial) - strlcpy(dev->mdev.serial, udev->serial, - sizeof(dev->mdev.serial)); - strcpy(dev->mdev.bus_info, udev->devpath); - dev->mdev.hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); - dev->mdev.driver_version = LINUX_VERSION_CODE; - media_device_init(&dev->mdev); - - dev->vdev.mdev = &dev->mdev; + strlcpy(dev->mdev->serial, udev->serial, + sizeof(dev->mdev->serial)); + strcpy(dev->mdev->bus_info, udev->devpath); + dev->mdev->hw_revision = le16_to_cpu(udev->descriptor.bcdDevice); + dev->mdev->driver_version = LINUX_VERSION_CODE; + media_device_init(dev->mdev); + + dev->vdev.mdev = dev->mdev; #endif if (v4l2_device_register(&intf->dev, &dev->vdev) < 0) goto error; @@ -1958,7 +1962,7 @@ static int uvc_probe(struct usb_interface *intf, #ifdef CONFIG_MEDIA_CONTROLLER /* Register the media device node */ - if (media_device_register(&dev->mdev) < 0) + if (media_device_register(dev->mdev) < 0) goto error; #endif /* Save our data pointer in the interface data. */ @@ -1976,6 +1980,10 @@ static int uvc_probe(struct usb_interface *intf, return 0; error: +#ifdef CONFIG_MEDIA_CONTROLLER + media_device_put(&intf->dev); +media_device_get_error: +#endif uvc_unregister_video(dev); return -ENODEV; } diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index 7e4d3ee..a5ef719 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -543,7 +544,7 @@ struct uvc_device { /* Video control interface */ #ifdef CONFIG_MEDIA_CONTROLLER - struct media_device mdev; + struct media_device *mdev; #endif struct v4l2_device vdev; __u16 uvc_version;