From patchwork Tue Oct 14 14:58:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 5080731 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 8964AC11AC for ; Tue, 14 Oct 2014 15:00:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFAF820154 for ; Tue, 14 Oct 2014 15:00:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C423C20148 for ; Tue, 14 Oct 2014 15:00:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932335AbaJNPAW (ORCPT ); Tue, 14 Oct 2014 11:00:22 -0400 Received: from resqmta-po-04v.sys.comcast.net ([96.114.154.163]:49262 "EHLO resqmta-po-04v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932558AbaJNO7e (ORCPT ); Tue, 14 Oct 2014 10:59:34 -0400 Received: from resomta-po-18v.sys.comcast.net ([96.114.154.242]) by resqmta-po-04v.sys.comcast.net with comcast id 32x81p0095E3ZMc012zZ9r; Tue, 14 Oct 2014 14:59:33 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by resomta-po-18v.sys.comcast.net with comcast id 32zY1p00k0MU7Qa012zYHX; Tue, 14 Oct 2014 14:59:33 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 3264B40A3A; Tue, 14 Oct 2014 08:59:32 -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.com, hverkuil@xs4all.nl, ramakrmu@cisco.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, perex@perex.cz, tiwai@suse.de, prabhakar.csengg@gmail.com, tim.gardner@canonical.com, linux@eikelenboom.it Cc: Shuah Khan , linux-media@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] media: au0828-core changes to create and destroy media Date: Tue, 14 Oct 2014 08:58:42 -0600 Message-Id: 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=1413298773; bh=CGwwd1B0xqxi4q6Xl6m+EgUun6OWfrztJexPC/RdVJM=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=ugdKLlaWc9IFf8g5Kga4/BvtxbjGXdSnDGmn6g3Puzish/GiSYhARM7Nphi7gAErg AH1+yylJXCfqlCBRx9SeYOCB+su0IfJDRDMzPsTT9RTDxpYhXrRRPlJTuE+W9USVPO oTS4+GV5DUGBKtDzsXlHDZdW0W1MS/c9Xg062GNJ9I0JSoQMcfbQzwOmmj2aG+AILG XkKPw8WkBh2J7sk6xkhFnrohT9ZUlX4xu1DlB6JbzKAQ5+F/bOsrNMBOYf21dghqum ECVGczDiUfK0TeIQ/ui1bUxl0+g4FLZFTgsGos2x/QfFuQGDkJxjzlPyvMBzMQfAIr 5O3+edikAah6A== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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;