From patchwork Mon Feb 15 17:37:22 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Ringel X-Patchwork-Id: 79443 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1FHcTCu013128 for ; Mon, 15 Feb 2010 17:38:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755906Ab0BORi3 (ORCPT ); Mon, 15 Feb 2010 12:38:29 -0500 Received: from mail-in-01.arcor-online.net ([151.189.21.41]:43814 "EHLO mail-in-01.arcor-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755886Ab0BORiU (ORCPT ); Mon, 15 Feb 2010 12:38:20 -0500 Received: from mail-in-16-z2.arcor-online.net (mail-in-16-z2.arcor-online.net [151.189.8.33]) by mx.arcor.de (Postfix) with ESMTP id 2C875332C53; Mon, 15 Feb 2010 18:38:19 +0100 (CET) Received: from mail-in-14.arcor-online.net (mail-in-14.arcor-online.net [151.189.21.54]) by mail-in-16-z2.arcor-online.net (Postfix) with ESMTP id 1C312254684; Mon, 15 Feb 2010 18:38:19 +0100 (CET) Received: from localhost.localdomain (dslb-188-103-172-103.pools.arcor-ip.net [188.103.172.103]) (Authenticated sender: stefan.ringel@arcor.de) by mail-in-14.arcor-online.net (Postfix) with ESMTPA id 91B2028B08E; Mon, 15 Feb 2010 18:38:18 +0100 (CET) X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-14.arcor-online.net 91B2028B08E DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arcor.de; s=mail-in; t=1266255498; bh=Xo0qis7a9mBbb+j4YFC8+E2dSNQCySEuaVUuKcHFD1Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=LllJ/S7eNQiFsJwCKpNkbXgT4mShKlxqFAMmgtiE/pqLGZVKDTUHns3r/k0f0F/Bg 1GTurbe9PXnrI7OFr/nlJTaAtxb1qALB4/4kvCB/VuLsOyNMh/vSsLxDW5ThUK/kpx SUAxDI9sx+bwsxPVNg3z0C0e9I6Hlu1+OCrZt5fw= From: stefan.ringel@arcor.de To: linux-media@vger.kernel.org Cc: mchehab@redhat.com, dheitmueller@kernellabs.com, Stefan Ringel Subject: [PATCH 09/11] zl10353: tm6000: bugfix reading problems with tm6000 i2c host Date: Mon, 15 Feb 2010 18:37:22 +0100 Message-Id: <1266255444-7422-9-git-send-email-stefan.ringel@arcor.de> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1266255444-7422-8-git-send-email-stefan.ringel@arcor.de> References: <1266255444-7422-1-git-send-email-stefan.ringel@arcor.de> <1266255444-7422-2-git-send-email-stefan.ringel@arcor.de> <1266255444-7422-3-git-send-email-stefan.ringel@arcor.de> <1266255444-7422-4-git-send-email-stefan.ringel@arcor.de> <1266255444-7422-5-git-send-email-stefan.ringel@arcor.de> <1266255444-7422-6-git-send-email-stefan.ringel@arcor.de> <1266255444-7422-7-git-send-email-stefan.ringel@arcor.de> <1266255444-7422-8-git-send-email-stefan.ringel@arcor.de> 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.3 (demeter.kernel.org [140.211.167.41]); Mon, 15 Feb 2010 17:38:30 +0000 (UTC) diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c index 8c61271..9716d7e 100644 --- a/drivers/media/dvb/frontends/zl10353.c +++ b/drivers/media/dvb/frontends/zl10353.c @@ -74,7 +74,7 @@ static int zl10353_write(struct dvb_frontend *fe, u8 *ibuf, int ilen) return 0; } -static int zl10353_read_register(struct zl10353_state *state, u8 reg) +static int zl10353_read1_register(struct zl10353_state *state, u8 reg) { int ret; u8 b0[1] = { reg }; @@ -97,6 +97,41 @@ static int zl10353_read_register(struct zl10353_state *state, u8 reg) return b1[0]; } +static int zl10353_read2_register(struct zl10353_state *state, u8 reg) +{ + int ret; + u8 b0[1] = { reg - 1 }; + u8 b1[1] = { 0 }; + struct i2c_msg msg[2] = { { .addr = state->config.demod_address, + .flags = 0, + .buf = b0, .len = 1 }, + { .addr = state->config.demod_address, + .flags = I2C_M_RD, + .buf = b1, .len = 2 } }; + + ret = i2c_transfer(state->i2c, msg, 2); + + if (ret != 2) { + printk("%s: readreg error (reg=%d, ret==%i)\n", + __func__, reg, ret); + return ret; + } + + return b1[1]; +} + +static int zl10353_read_register(struct zl10353_state *state, u8 reg) +{ + int ret; + + if ((state->i2c->id == I2C_HW_B_TM6000) && (reg % 2 == 0)) + ret = zl10353_read2_register(state, reg); + else + ret = zl10353_read1_register(state, reg); + + return ret; +} + static void zl10353_dump_regs(struct dvb_frontend *fe) { struct zl10353_state *state = fe->demodulator_priv;