From patchwork Sat Aug 20 11:37:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Rankin X-Patchwork-Id: 274 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Sat, 20 Aug 2011 11:37:51 +0000 Received: from casper.infradead.org [85.118.1.10] by gaivota with IMAP (fetchmail-6.3.20) for (single-drop); Sat, 20 Aug 2011 04:50:34 -0700 (PDT) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qujs6-0007Sm-Tf; Sat, 20 Aug 2011 11:37:51 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753473Ab1HTLhc (ORCPT + 1 other); Sat, 20 Aug 2011 07:37:32 -0400 Received: from nm2.bt.bullet.mail.ukl.yahoo.com ([217.146.183.200]:35838 "HELO nm2.bt.bullet.mail.ukl.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753031Ab1HTLhb (ORCPT ); Sat, 20 Aug 2011 07:37:31 -0400 Received: from [217.146.183.195] by nm2.bt.bullet.mail.ukl.yahoo.com with NNFMP; 20 Aug 2011 11:37:30 -0000 Received: from [217.146.183.204] by tm1.bt.bullet.mail.ukl.yahoo.com with NNFMP; 20 Aug 2011 11:37:30 -0000 Received: from [127.0.0.1] by omp1002.bt.mail.ukl.yahoo.com with NNFMP; 20 Aug 2011 11:37:30 -0000 X-Yahoo-Newman-Id: 312314.4071.bm@omp1002.bt.mail.ukl.yahoo.com Received: (qmail 72264 invoked from network); 20 Aug 2011 11:37:30 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=DKIM-Signature:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type; b=w82e0la74NeCjcf2R0kLMXIthwk61fjF3mkRAPFqVrwXcBKnHcGhOXwpAL95C+oYmpTdtQdbQNoTrsVYz7QCkiq4rev8qQTLwA5kCBCzTojoCF4V9+oS0LOdN0XzNiNP5FIW6wRuRaKFuN0p2NuTU2a2QqqUn+fNLWhax9bNP3Q= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1313840249; bh=qG5jkz7PdIny49jPQo53AE5hk1m+SWXCvvXUt6YK7wY=; h=X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type; b=n5cqAIHU4+eYOynuVKtHzN4EuuHswNMlUxfI9Gkvm1n74sAA/7v1EdE5yYjNFrsNOmqduIyTJzUcSHRoFe18psfYBCTbOpLOL33Isfoq7EI6dy55yiThIYMDNUTvn/zoyfAiQnY5PMi2HAlXC0Rh9mESCwzObs2w/PcAjhbqF8g= X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: QX6A014VM1kuZf14X_wDIz9B1yF9EsSyaqPqZUxh3Ef7ubQ xK1LUpcUODaIB5iMIUYZY4ow1D26PQBCB53NxpmFBYJH5cyiz.TDsWA3OdWu _mYDhhjc_GSX5qfiffz8rGqiXHoOTtqyCc9Nct3_iP7jvijsgiRq9iM6siOl BXtJrOO2GjEBPcFvxHLExWc_nzZh6RNEIW8kVrD.jSV_JW8MwnLh_qmo4mpo NQKIbJFb.IEBTnTibiUT2Fkv.FKwa8aF1.YtSjyBMch2z9XaeDU6fdeK_Cwg FH9CHwVC9_sd4FioN2HfHcwneS.hOdqp_UQxmRrYvLmWI9H0sfaT0aumBYhe 6bxdg2LMo4JiibVb8pOvPbYLzzOmvv8z3fyN7dPx0N9N.xXLERX6aythe7nG FaA-- X-Yahoo-SMTP: dMK34oyswBBlfKesWTI5ovDjFOUFE6shtILt.ZXnUEjQHhWq Received: from wellhouse.underworld (rankincj@86.182.26.38 with login) by smtp823.mail.ird.yahoo.com with SMTP; 20 Aug 2011 04:37:29 -0700 PDT Received: from volcano.underworld (volcano.underworld [192.168.0.3]) by wellhouse.underworld (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p7KBbRcn011475 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 20 Aug 2011 12:37:28 +0100 Message-ID: <4E4F9C77.6010008@yahoo.com> Date: Sat, 20 Aug 2011 12:37:27 +0100 From: Chris Rankin User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110707 Thunderbird/5.0 MIME-Version: 1.0 To: Mauro Carvalho Chehab CC: Devin Heitmueller , linux-media@vger.kernel.org, Antti Palosaari Subject: [PATCH 6/6] EM28xx - don't sleep on disconnect References: <4E4D5157.2080406@yahoo.com> <4E4D8DFD.5060800@yahoo.com> <4E4DFA65.4090508@redhat.com> In-Reply-To: <4E4DFA65.4090508@redhat.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The DVB framework will try to power-down an adapter that no-one is using any more, but this assumes that the adapter is still connected to the machine. That's not always true for a USB adapter, so disable the sleep operations when the adapter has been physically unplugged. This prevents I2C write failures with error -19 from appearing occasionally in the dmesg log. Signed-off-by: Chris Rankin --- linux-3.0/drivers/media/common/tuners/tda18271-fe.c.orig 2011-08-18 16:55:53.000000000 +0100 +++ linux-3.0/drivers/media/common/tuners/tda18271-fe.c 2011-08-18 23:12:55.000000000 +0100 @@ -1230,7 +1230,7 @@ return 0; } -static struct dvb_tuner_ops tda18271_tuner_ops = { +static const struct dvb_tuner_ops tda18271_tuner_ops = { .info = { .name = "NXP TDA18271HD", .frequency_min = 45000000, --- linux-3.0/drivers/media/dvb/frontends/cxd2820r_core.c.orig 2011-08-18 16:56:02.000000000 +0100 +++ linux-3.0/drivers/media/dvb/frontends/cxd2820r_core.c 2011-08-18 23:14:06.000000000 +0100 @@ -778,7 +778,7 @@ } EXPORT_SYMBOL(cxd2820r_get_tuner_i2c_adapter); -static struct dvb_frontend_ops cxd2820r_ops[2]; +static const struct dvb_frontend_ops cxd2820r_ops[2]; struct dvb_frontend *cxd2820r_attach(const struct cxd2820r_config *cfg, struct i2c_adapter *i2c, struct dvb_frontend *fe) @@ -844,7 +844,7 @@ } EXPORT_SYMBOL(cxd2820r_attach); -static struct dvb_frontend_ops cxd2820r_ops[2] = { +static const struct dvb_frontend_ops cxd2820r_ops[2] = { { /* DVB-T/T2 */ .info = { --- linux-3.0/drivers/media/video/em28xx/em28xx-dvb.c.orig 2011-08-17 08:52:30.000000000 +0100 +++ linux-3.0/drivers/media/video/em28xx/em28xx-dvb.c 2011-08-18 23:17:42.000000000 +0100 @@ -720,6 +720,12 @@ goto ret; } +static inline void prevent_sleep(struct dvb_frontend_ops *ops) { + ops->set_voltage = NULL; + ops->sleep = NULL; + ops->tuner_ops.sleep = NULL; +} + static int dvb_fini(struct em28xx *dev) { if (!dev->board.has_dvb) { @@ -728,8 +734,17 @@ } if (dev->dvb) { - unregister_dvb(dev->dvb); - kfree(dev->dvb); + struct em28xx_dvb *dvb = dev->dvb; + + if (dev->state & DEV_DISCONNECTED) { + /* We cannot tell the device to sleep + * once it has been unplugged. */ + prevent_sleep(&dvb->fe[0]->ops); + prevent_sleep(&dvb->fe[1]->ops); + } + + unregister_dvb(dvb); + kfree(dvb); dev->dvb = NULL; }