From patchwork Sun Nov 7 15:53:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 306942 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 oA7FsgYq024868 for ; Sun, 7 Nov 2010 15:54:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753408Ab0KGPyk (ORCPT ); Sun, 7 Nov 2010 10:54:40 -0500 Received: from zone0.gcu-squad.org ([212.85.147.21]:11998 "EHLO services.gcu-squad.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753309Ab0KGPyk (ORCPT ); Sun, 7 Nov 2010 10:54:40 -0500 Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=endymion.delvare) by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1PF7fC-0001Rp-Oe (TLSv1:AES128-SHA:128) (envelope-from ) ; Sun, 07 Nov 2010 17:00:15 +0100 Date: Sun, 7 Nov 2010 16:53:44 +0100 From: Jean Delvare To: LMML Cc: Mauro Carvalho Chehab , Michel Ludwig , Stefan Ringel Subject: [PATCH 1/2] TM6000: Clean-up i2c initialization Message-ID: <20101107165344.4243b602@endymion.delvare> X-Mailer: Claws Mail 3.7.5 (GTK+ 2.20.1; x86_64-unknown-linux-gnu) Mime-Version: 1.0 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 (demeter1.kernel.org [140.211.167.41]); Sun, 07 Nov 2010 15:54:42 +0000 (UTC) --- linux-2.6.36-rc7.orig/drivers/staging/tm6000/tm6000-i2c.c 2010-10-13 09:56:21.000000000 +0200 +++ linux-2.6.36-rc7/drivers/staging/tm6000/tm6000-i2c.c 2010-10-13 10:52:26.000000000 +0200 @@ -313,21 +313,11 @@ static u32 functionality(struct i2c_adap msleep(10); \ } -static struct i2c_algorithm tm6000_algo = { +static const struct i2c_algorithm tm6000_algo = { .master_xfer = tm6000_i2c_xfer, .functionality = functionality, }; -static struct i2c_adapter tm6000_adap_template = { - .owner = THIS_MODULE, - .name = "tm6000", - .algo = &tm6000_algo, -}; - -static struct i2c_client tm6000_client_template = { - .name = "tm6000 internal", -}; - /* ----------------------------------------------------------- */ /* @@ -337,17 +327,20 @@ static struct i2c_client tm6000_client_t int tm6000_i2c_register(struct tm6000_core *dev) { unsigned char eedata[256]; + int rc; - dev->i2c_adap = tm6000_adap_template; + dev->i2c_adap.owner = THIS_MODULE; + dev->i2c_adap.algo = &tm6000_algo; dev->i2c_adap.dev.parent = &dev->udev->dev; - strcpy(dev->i2c_adap.name, dev->name); + strlcpy(dev->i2c_adap.name, dev->name, sizeof(dev->i2c_adap.name)); dev->i2c_adap.algo_data = dev; - i2c_add_adapter(&dev->i2c_adap); + i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev); + rc = i2c_add_adapter(&dev->i2c_adap); + if (rc) + return rc; - dev->i2c_client = tm6000_client_template; dev->i2c_client.adapter = &dev->i2c_adap; - - i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev); + strlcpy(dev->i2c_client.name, "tm6000 internal", I2C_NAME_SIZE); tm6000_i2c_eeprom(dev, eedata, sizeof(eedata));