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: 8746781 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 041A29F3D1 for ; Tue, 5 Apr 2016 03:37:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CF992028D for ; Tue, 5 Apr 2016 03:37:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C00F20303 for ; Tue, 5 Apr 2016 03:37:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753853AbcDEDgO (ORCPT ); Mon, 4 Apr 2016 23:36:14 -0400 Received: from mailout.easymail.ca ([64.68.201.169]:50248 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752360AbcDEDgL (ORCPT ); Mon, 4 Apr 2016 23:36:11 -0400 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" X-Spam-Score: -3.694 X-Spam-Level: X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 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 Cc: Shuah Khan , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org Subject: [RFC PATCH v2 3/5] media: uvcvideo change to use Media Device Allocator API 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: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.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;