From patchwork Mon Dec 17 01:12:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ira Krufky X-Patchwork-Id: 15923 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1TkPFm-00006a-EJ for patchwork@linuxtv.org; Mon, 17 Dec 2012 02:12:22 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-2) with esmtp for id 1TkPFj-0004ye-HB; Mon, 17 Dec 2012 02:12:22 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751442Ab2LQBMR (ORCPT ); Sun, 16 Dec 2012 20:12:17 -0500 Received: from mail.hauppauge.com ([167.206.143.4]:3351 "EHLO mail.hauppauge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751368Ab2LQBMR (ORCPT ); Sun, 16 Dec 2012 20:12:17 -0500 Received: from 24.193.167.210 [24.193.167.210] by mail.hauppauge.com with XWall v3.41e ; Sun, 16 Dec 2012 20:10:41 -0500 From: Michael Krufky To: linux-media@vger.kernel.org Cc: mchehab@redhat.com, crope@iki.fi, Michael Krufky Subject: [PATCH] tda10071: make sure both tuner and demod i2c addresses are specified Date: Sun, 16 Dec 2012 20:12:04 -0500 Message-Id: <1355706724-25663-1-git-send-email-mkrufky@linuxtv.org> X-Mailer: git-send-email 1.7.10.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.12.17.5719 X-PMX-Spam: Gauge=X, Probability=10%, Report=' HASHBUSTER_BLOCK_V2 0.5, MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HASHBUSTER_BLOCK_V2_1 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SXL_RIP_ERROR_SERVFAIL , __SXL_SIG_ERROR_SERVFAIL , __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' display an error message if either tuner_i2c_addr or demod_i2c_addr are not specified in the tda10071_config structure Signed-off-by: Michael Krufky --- drivers/media/dvb-frontends/tda10071.c | 18 +++++++++++++++--- drivers/media/dvb-frontends/tda10071.h | 4 ++-- drivers/media/pci/cx23885/cx23885-dvb.c | 2 +- drivers/media/usb/em28xx/em28xx-dvb.c | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c index 7103629..02f9234 100644 --- a/drivers/media/dvb-frontends/tda10071.c +++ b/drivers/media/dvb-frontends/tda10071.c @@ -30,7 +30,7 @@ static int tda10071_wr_regs(struct tda10071_priv *priv, u8 reg, u8 *val, u8 buf[len+1]; struct i2c_msg msg[1] = { { - .addr = priv->cfg.i2c_address, + .addr = priv->cfg.demod_i2c_addr, .flags = 0, .len = sizeof(buf), .buf = buf, @@ -59,12 +59,12 @@ static int tda10071_rd_regs(struct tda10071_priv *priv, u8 reg, u8 *val, u8 buf[len]; struct i2c_msg msg[2] = { { - .addr = priv->cfg.i2c_address, + .addr = priv->cfg.demod_i2c_addr, .flags = 0, .len = 1, .buf = ®, }, { - .addr = priv->cfg.i2c_address, + .addr = priv->cfg.demod_i2c_addr, .flags = I2C_M_RD, .len = sizeof(buf), .buf = buf, @@ -1202,6 +1202,18 @@ struct dvb_frontend *tda10071_attach(const struct tda10071_config *config, goto error; } + /* make sure demod i2c address is specified */ + if (!config->demod_i2c_addr) { + dev_dbg(&i2c->dev, "%s: invalid demod i2c address!\n", __func__); + goto error; + } + + /* make sure tuner i2c address is specified */ + if (!config->tuner_i2c_addr) { + dev_dbg(&i2c->dev, "%s: invalid tuner i2c address!\n", __func__); + goto error; + } + /* setup the priv */ priv->i2c = i2c; memcpy(&priv->cfg, config, sizeof(struct tda10071_config)); diff --git a/drivers/media/dvb-frontends/tda10071.h b/drivers/media/dvb-frontends/tda10071.h index a20d5c4..bff1c38 100644 --- a/drivers/media/dvb-frontends/tda10071.h +++ b/drivers/media/dvb-frontends/tda10071.h @@ -28,10 +28,10 @@ struct tda10071_config { * Default: none, must set * Values: 0x55, */ - u8 i2c_address; + u8 demod_i2c_addr; /* Tuner I2C address. - * Default: 0x14 + * Default: none, must set * Values: 0x14, 0x54, ... */ u8 tuner_i2c_addr; diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c index cf84c53..a1aae56 100644 --- a/drivers/media/pci/cx23885/cx23885-dvb.c +++ b/drivers/media/pci/cx23885/cx23885-dvb.c @@ -662,7 +662,7 @@ static struct mt2063_config terratec_mt2063_config[] = { }; static const struct tda10071_config hauppauge_tda10071_config = { - .i2c_address = 0x05, + .demod_i2c_addr = 0x05, .tuner_i2c_addr = 0x54, .i2c_wr_max = 64, .ts_mode = TDA10071_TS_SERIAL, diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c index 63f2e70..e800881 100644 --- a/drivers/media/usb/em28xx/em28xx-dvb.c +++ b/drivers/media/usb/em28xx/em28xx-dvb.c @@ -714,7 +714,8 @@ static struct tda18271_config em28xx_cxd2820r_tda18271_config = { }; static const struct tda10071_config em28xx_tda10071_config = { - .i2c_address = 0x55, /* (0xaa >> 1) */ + .demod_i2c_addr = 0x55, /* (0xaa >> 1) */ + .tuner_i2c_addr = 0x14, .i2c_wr_max = 64, .ts_mode = TDA10071_TS_SERIAL, .spec_inv = 0,