From patchwork Thu Oct 2 05:20:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schwarzott X-Patchwork-Id: 5016211 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 467129F348 for ; Thu, 2 Oct 2014 05:21:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6CBF020122 for ; Thu, 2 Oct 2014 05:21:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75B9D2011B for ; Thu, 2 Oct 2014 05:21:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751429AbaJBFVX (ORCPT ); Thu, 2 Oct 2014 01:21:23 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:42965 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750998AbaJBFVW (ORCPT ); Thu, 2 Oct 2014 01:21:22 -0400 Received: from gauss.fritz.box (aftr-88-217-180-132.dynamic.mnet-online.de [88.217.180.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zzam) by smtp.gentoo.org (Postfix) with ESMTPSA id 3E27E34028F; Thu, 2 Oct 2014 05:21:21 +0000 (UTC) From: Matthias Schwarzott To: linux-media@vger.kernel.org, mchehab@osg.samsung.com, crope@iki.fi Cc: Matthias Schwarzott Subject: [PATCH V3 02/13] cx231xx: use own i2c_client for eeprom access Date: Thu, 2 Oct 2014 07:20:54 +0200 Message-Id: <1412227265-17453-3-git-send-email-zzam@gentoo.org> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1412227265-17453-1-git-send-email-zzam@gentoo.org> References: <1412227265-17453-1-git-send-email-zzam@gentoo.org> 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 This is a preparation for deleting the otherwise useless i2c_clients that are allocated for all the i2c master adapters. Signed-off-by: Matthias Schwarzott Reviewed-by: Antti Palosaari --- drivers/media/usb/cx231xx/cx231xx-cards.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c index 791f00c..092fb85 100644 --- a/drivers/media/usb/cx231xx/cx231xx-cards.c +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c @@ -980,23 +980,20 @@ static void cx231xx_config_tuner(struct cx231xx *dev) } -static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len) +static int read_eeprom(struct cx231xx *dev, struct i2c_client *client, + u8 *eedata, int len) { int ret = 0; - u8 addr = 0xa0 >> 1; u8 start_offset = 0; int len_todo = len; u8 *eedata_cur = eedata; int i; - struct i2c_msg msg_write = { .addr = addr, .flags = 0, + struct i2c_msg msg_write = { .addr = client->addr, .flags = 0, .buf = &start_offset, .len = 1 }; - struct i2c_msg msg_read = { .addr = addr, .flags = I2C_M_RD }; - - /* mutex_lock(&dev->i2c_lock); */ - cx231xx_enable_i2c_port_3(dev, false); + struct i2c_msg msg_read = { .addr = client->addr, .flags = I2C_M_RD }; /* start reading at offset 0 */ - ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_write, 1); + ret = i2c_transfer(client->adapter, &msg_write, 1); if (ret < 0) { cx231xx_err("Can't read eeprom\n"); return ret; @@ -1006,7 +1003,7 @@ static int read_eeprom(struct cx231xx *dev, u8 *eedata, int len) msg_read.len = (len_todo > 64) ? 64 : len_todo; msg_read.buf = eedata_cur; - ret = i2c_transfer(&dev->i2c_bus[1].i2c_adap, &msg_read, 1); + ret = i2c_transfer(client->adapter, &msg_read, 1); if (ret < 0) { cx231xx_err("Can't read eeprom\n"); return ret; @@ -1062,9 +1059,14 @@ void cx231xx_card_setup(struct cx231xx *dev) { struct tveeprom tvee; static u8 eeprom[256]; + struct i2c_client client; + + memset(&client, 0, sizeof(client)); + client.adapter = &dev->i2c_bus[1].i2c_adap; + client.addr = 0xa0 >> 1; - read_eeprom(dev, eeprom, sizeof(eeprom)); - tveeprom_hauppauge_analog(&dev->i2c_bus[1].i2c_client, + read_eeprom(dev, &client, eeprom, sizeof(eeprom)); + tveeprom_hauppauge_analog(&client, &tvee, eeprom + 0xc0); break; }