From patchwork Tue Apr 29 19:49:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 4088901 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 0948AC0ACC for ; Tue, 29 Apr 2014 19:51:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2131720218 for ; Tue, 29 Apr 2014 19:51:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3326920172 for ; Tue, 29 Apr 2014 19:51:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934073AbaD2Tvh (ORCPT ); Tue, 29 Apr 2014 15:51:37 -0400 Received: from qmta09.emeryville.ca.mail.comcast.net ([76.96.30.96]:35675 "EHLO qmta09.emeryville.ca.mail.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965170AbaD2TuS (ORCPT ); Tue, 29 Apr 2014 15:50:18 -0400 Received: from omta04.emeryville.ca.mail.comcast.net ([76.96.30.35]) by qmta09.emeryville.ca.mail.comcast.net with comcast id vtxj1n0030lTkoCA9vqHVF; Tue, 29 Apr 2014 19:50:17 +0000 Received: from mail.gonehiking.org ([50.134.149.16]) by omta04.emeryville.ca.mail.comcast.net with comcast id vvqG1n0080MU7Qa8QvqGC2; Tue, 29 Apr 2014 19:50:17 +0000 Received: from lorien.sisa.samsung.com (lorien-wl.internal [192.168.1.40]) by mail.gonehiking.org (Postfix) with ESMTP id 0E3853FC77; Tue, 29 Apr 2014 13:50:16 -0600 (MDT) From: Shuah Khan To: gregkh@linuxfoundation.org, m.chehab@samsung.com, tj@kernel.org, olebowle@gmx.com Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 3/4] media/em28xx: changes to create token for tuner access Date: Tue, 29 Apr 2014 13:49:25 -0600 Message-Id: <019bbf54a8ccbd236bbdfd552919d9a11a006db9.1398797955.git.shuah.kh@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=1398801017; bh=bZQfMzLHGBk/HAw9ikgSgouZcZ15cO48ir1SBfBqN0A=; h=Received:Received:Received:From:To:Subject:Date:Message-Id; b=tpuoaILvKQyoTjZZSLpovTGid7ptErisd7vFTlVhZW5ZW9gyvMwW/Q79/VK6u/yYm 6ayNwQQAdqd2pI7D9WU/8oklMKEwvqqxvY3KMMvD4r6i88mmlPgmYPM/vhwjd4wenD +8Lg3I/ixAxUuGRWrNVoKTHQURPqIq+b0opGshBNq2zNAA4enAMCmC4hobqOzhAw84 TA4OBZ7svrrog3Ezq1l8dYcPeMQA7IDnwoGqDggP7V/gMVoa/gZOVgOo3WDlgFG/k8 8GdFCPVntEII1BFDXrtVv86IU0jkvrYEn+CyRBAc1R6FvWPXZ+Y5RcNyD60T3S4jHm Ret/EDCkEbPJA== 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.4 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 Changes add a new tuner_tkn field to struct em28xx and create a token devres to allow sharing tuner function across analog and digital functions. Tuner token is created during probe in em28xx_usb_probe() and destroyed during disconnect in em28xx_release_resources(). Signed-off-by: Shuah Khan --- drivers/media/usb/em28xx/em28xx-cards.c | 41 +++++++++++++++++++++++++++++++ drivers/media/usb/em28xx/em28xx.h | 4 +++ 2 files changed, 45 insertions(+) diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 50aa5a5..01c1955 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -2428,6 +2428,37 @@ static struct em28xx_hash_table em28xx_i2c_hash[] = { }; /* NOTE: introduce a separate hash table for devices with 16 bit eeproms */ +/* interfaces to create and destroy token resources */ +static int em28xx_create_token_resources(struct em28xx *dev) +{ + int rc = 0, len; + char buf[64]; + + /* create token devres for tuner */ + len = snprintf(buf, sizeof(buf), + "tuner:%s-%s-%d", + dev_name(&dev->udev->dev), + dev->udev->bus->bus_name, + dev->tuner_addr); + + dev->tuner_tkn = devm_kzalloc(&dev->udev->dev, len + 1, GFP_KERNEL); + if (!dev->tuner_tkn) + return -ENOMEM; + + strcpy(dev->tuner_tkn, buf); + rc = devm_token_create(&dev->udev->dev, dev->tuner_tkn); + if (rc) + return rc; + + em28xx_info("Tuner token created\n"); + return rc; +} + +static void em28xx_destroy_token_resources(struct em28xx *dev) +{ + devm_token_destroy(&dev->udev->dev, dev->tuner_tkn); +} + int em28xx_tuner_callback(void *ptr, int component, int command, int arg) { struct em28xx_i2c_bus *i2c_bus = ptr; @@ -2949,6 +2980,9 @@ static void em28xx_release_resources(struct em28xx *dev) em28xx_i2c_unregister(dev, 1); em28xx_i2c_unregister(dev, 0); + /* destroy token resources */ + em28xx_destroy_token_resources(dev); + usb_put_dev(dev->udev); /* Mark device as unused */ @@ -3431,6 +3465,13 @@ static int em28xx_usb_probe(struct usb_interface *interface, kref_init(&dev->ref); + /* create token resources before requesting for modules */ + if (em28xx_create_token_resources(dev)) { + em28xx_errdev("Error creating token resources!\n"); + retval = -ENOMEM; + goto err_free; + } + request_modules(dev); /* Should be the last thing to do, to avoid newer udev's to diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index 2051fc9..e82f868 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -547,6 +548,9 @@ struct em28xx { int devno; /* marks the number of this device */ enum em28xx_chip_id chip_id; + /* token resources */ + char *tuner_tkn; /* tuner token id */ + unsigned int is_em25xx:1; /* em25xx/em276x/7x/8x family bridge */ unsigned char disconnected:1; /* device has been diconnected */ unsigned int has_video:1;