From patchwork Sat Mar 5 01:43:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew de Quincey X-Patchwork-Id: 611631 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p251i5go016430 for ; Sat, 5 Mar 2011 01:44:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760253Ab1CEBoD (ORCPT ); Fri, 4 Mar 2011 20:44:03 -0500 Received: from mail-wy0-f174.google.com ([74.125.82.174]:44343 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760230Ab1CEBoB (ORCPT ); Fri, 4 Mar 2011 20:44:01 -0500 Received: by wyg36 with SMTP id 36so2682301wyg.19 for ; Fri, 04 Mar 2011 17:44:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.134.207 with SMTP id s57mr1121709wei.25.1299289440006; Fri, 04 Mar 2011 17:44:00 -0800 (PST) Received: by 10.216.3.13 with HTTP; Fri, 4 Mar 2011 17:43:59 -0800 (PST) X-Originating-IP: [82.71.49.12] In-Reply-To: References: <4D7163FD.9030604@iki.fi> <4D716ECA.4060900@iki.fi> Date: Sat, 5 Mar 2011 01:43:59 +0000 Message-ID: Subject: Re: [patch] Fix AF9015 Dual tuner i2c write failures From: adq To: Antti Palosaari Cc: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 05 Mar 2011 01:44:06 +0000 (UTC) diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c index 31c0a0e..d9f32fe 100644 --- a/drivers/media/dvb/dvb-usb/af9015.c +++ b/drivers/media/dvb/dvb-usb/af9015.c @@ -1083,6 +1083,24 @@ static int af9015_i2c_init(struct dvb_usb_device *d) return ret; } +static int af9015_lock_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) +{ + int result; + struct dvb_usb_adapter *adap = fe->dvb->priv; + struct af9015_state *state = adap->dev->priv; + + if (enable) + if (mutex_lock_interruptible(&adap->dev->usb_mutex)) + return -EAGAIN; + + result = state->i2c_gate_ctrl[adap->id](fe, enable); + + if (!enable) + mutex_unlock(&adap->dev->usb_mutex); + + return result; +} + static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap) { int ret; @@ -1116,6 +1134,11 @@ static int af9015_af9013_frontend_attach(struct dvb_usb_adapter *adap) /* attach demodulator */ adap->fe = dvb_attach(af9013_attach, &af9015_af9013_config[adap->id], i2c_adap); + + if (adap->fe && adap->fe->ops.i2c_gate_ctrl) { + state->i2c_gate_ctrl[adap->id] = adap->fe->ops.i2c_gate_ctrl; + adap->fe->ops.i2c_gate_ctrl = af9015_lock_i2c_gate_ctrl; + } return adap->fe == NULL ? -ENODEV : 0; } diff --git a/drivers/media/dvb/dvb-usb/af9015.h b/drivers/media/dvb/dvb-usb/af9015.h index f20cfa6..094b1e3 100644 --- a/drivers/media/dvb/dvb-usb/af9015.h +++ b/drivers/media/dvb/dvb-usb/af9015.h @@ -102,6 +102,7 @@ struct af9015_state { struct i2c_adapter i2c_adap; /* I2C adapter for 2nd FE */ u8 rc_repeat; u32 rc_keycode; + int (*i2c_gate_ctrl[2])(struct dvb_frontend *fe, int enable); }; struct af9015_config {