From patchwork Mon Sep 22 15:00:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 4948381 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 69606BEEA5 for ; Mon, 22 Sep 2014 15:08:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3CDEC2010E for ; Mon, 22 Sep 2014 15:08:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E89762010C for ; Mon, 22 Sep 2014 15:08:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753998AbaIVPIM (ORCPT ); Mon, 22 Sep 2014 11:08:12 -0400 Received: from resqmta-po-03v.sys.comcast.net ([96.114.154.162]:43039 "EHLO resqmta-po-03v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754154AbaIVPHQ (ORCPT ); Mon, 22 Sep 2014 11:07:16 -0400 Received: from resomta-po-19v.sys.comcast.net ([96.114.154.243]) by resqmta-po-03v.sys.comcast.net with comcast id uF0e1o0025FMDhs01F1AVL; Mon, 22 Sep 2014 15:01:10 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by resomta-po-19v.sys.comcast.net with comcast id uF191o00U0MU7Qa01F19f1; Mon, 22 Sep 2014 15:01:10 +0000 Received: from lorien.internal (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 3C2D33FF0F; Mon, 22 Sep 2014 09:01:09 -0600 (MDT) From: Shuah Khan To: m.chehab@samsung.com, akpm@linux-foundation.org, gregkh@linuxfoundation.org, crope@iki.fi, olebowle@gmx.com, dheitmueller@kernellabs.co, hverkuil@xs4all.nl, ramakrmu@cisco.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 5/5] media: au0828-core changes to create and destroy media token res Date: Mon, 22 Sep 2014 09:00:49 -0600 Message-Id: <80d31dd3dbe205c9a462aa6dcae2c25de332259a.1411397045.git.shuahkh@osg.samsung.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: In-Reply-To: References: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1411398070; bh=CGwwd1B0xqxi4q6Xl6m+EgUun6OWfrztJexPC/RdVJM=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=SHW0YLqsF0BlofqwN6Rty+UzY6strvvuN/wcb4fC3LyPGNGHh58MWus3dYgZusffo I86R8iOLH5RLeV07Q/Zc2CGGZ72TKDPPujNyxJxEE50gUs91Ihg/ffO5g8ZdFSLLIg QZF7MGm+O0XE6OUTygYBFH4GsEJ79NKuAx7fk0zTs8uPQ+0X760usnP+h8uvHrMP1C Kh/v8ax2gXBalikJujyhFJ2KNFDbvITSPZj6dz9MuDyvK1zz6hT7AAz8JYLo4O7s/2 5wvE/44gHdIkuCS/f95YP8gx0evJ+60PE5ahg0MGcpGfvcCZfMxi/pGBpAWSIkqt8D LT1vCA8RnI1tw== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.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 Changed au0828-core to create media token resource in its usb_probe() and destroy it from usb_disconnect() interfaces. It creates the resource on the main struct device which is the parent device for the interface usb device. This is the main struct device that is common for all the drivers that control the media device, including the non-media sound drivers. Signed-off-by: Shuah Khan --- drivers/media/usb/au0828/au0828-core.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c index bc06480..189e435 100644 --- a/drivers/media/usb/au0828/au0828-core.c +++ b/drivers/media/usb/au0828/au0828-core.c @@ -26,6 +26,7 @@ #include #include #include +#include /* * 1 = General debug messages @@ -127,6 +128,17 @@ static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value, return status; } +/* interfaces to create and destroy media tknres */ +static int au0828_create_media_tknres(struct au0828_dev *dev) +{ + return media_tknres_create(&dev->usbdev->dev); +} + +static int au0828_destroy_media_tknres(struct au0828_dev *dev) +{ + return media_tknres_destroy(&dev->usbdev->dev); +} + static void au0828_usb_release(struct au0828_dev *dev) { /* I2C */ @@ -157,6 +169,8 @@ static void au0828_usb_disconnect(struct usb_interface *interface) /* Digital TV */ au0828_dvb_unregister(dev); + au0828_destroy_media_tknres(dev); + usb_set_intfdata(interface, NULL); mutex_lock(&dev->mutex); dev->usbdev = NULL; @@ -215,6 +229,13 @@ static int au0828_usb_probe(struct usb_interface *interface, dev->usbdev = usbdev; dev->boardnr = id->driver_info; + /* create media token resource */ + if (au0828_create_media_tknres(dev)) { + mutex_unlock(&dev->lock); + kfree(dev); + return -ENOMEM; + } + #ifdef CONFIG_VIDEO_AU0828_V4L2 dev->v4l2_dev.release = au0828_usb_v4l2_release; @@ -223,6 +244,7 @@ static int au0828_usb_probe(struct usb_interface *interface, if (retval) { pr_err("%s() v4l2_device_register failed\n", __func__); + au0828_destroy_media_tknres(dev); mutex_unlock(&dev->lock); kfree(dev); return retval; @@ -232,6 +254,7 @@ static int au0828_usb_probe(struct usb_interface *interface, if (retval) { pr_err("%s() v4l2_ctrl_handler_init failed\n", __func__); + au0828_destroy_media_tknres(dev); mutex_unlock(&dev->lock); kfree(dev); return retval;