From patchwork Thu May 14 11:46:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Valentin X-Patchwork-Id: 23749 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4EBqg4W020072 for ; Thu, 14 May 2009 11:52:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756056AbZENLwh (ORCPT ); Thu, 14 May 2009 07:52:37 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756237AbZENLwg (ORCPT ); Thu, 14 May 2009 07:52:36 -0400 Received: from smtp.nokia.com ([192.100.105.134]:42025 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756056AbZENLwg (ORCPT ); Thu, 14 May 2009 07:52:36 -0400 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx09.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id n4EBpwEd014937; Thu, 14 May 2009 06:52:30 -0500 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 14 May 2009 14:52:03 +0300 Received: from vaebe101.NOE.Nokia.com ([10.160.244.11]) by vaebh104.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 14 May 2009 14:52:03 +0300 Received: from localhost.localdomain ([172.21.41.99]) by vaebe101.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 14 May 2009 14:52:02 +0300 From: Eduardo Valentin To: Hans Verkuil , Mauro Carvalho Chehab Cc: "Nurkkala Eero.An (EXT-Offcode/Oulu)" , "linux-media@vger.kernel.org" , Eduardo Valentin Subject: [PATCH v3 3/7] v4l2_subdev i2c: Add i2c board info to v4l2_i2c_new_subdev Date: Thu, 14 May 2009 14:46:57 +0300 Message-Id: <1242301622-29672-4-git-send-email-eduardo.valentin@nokia.com> X-Mailer: git-send-email 1.6.2.GIT In-Reply-To: <1242301622-29672-3-git-send-email-eduardo.valentin@nokia.com> References: <1242301622-29672-1-git-send-email-eduardo.valentin@nokia.com> <1242301622-29672-2-git-send-email-eduardo.valentin@nokia.com> <1242301622-29672-3-git-send-email-eduardo.valentin@nokia.com> X-OriginalArrivalTime: 14 May 2009 11:52:02.0301 (UTC) FILETIME=[6511CAD0:01C9D48A] X-Nokia-AV: Clean Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Device drivers of v4l2_subdev devices may want to have i2c board info data. This patch adds an helper function to allow bridge drivers to pass board specific data to v4l2_subdev drivers. Signed-off-by: Eduardo Valentin --- drivers/media/video/v4l2-common.c | 33 +++++++++++++++++++++++++++------ include/media/v4l2-common.h | 6 ++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c index 389f7b2..ac30c46 100644 --- a/drivers/media/video/v4l2-common.c +++ b/drivers/media/video/v4l2-common.c @@ -864,9 +864,9 @@ static struct i2c_client *v4l2_i2c_legacy_find_client(struct i2c_adapter *adap, /* Load an i2c sub-device. */ -struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, - struct i2c_adapter *adapter, - const char *module_name, const char *client_type, u8 addr) +static struct v4l2_subdev *__v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, + struct i2c_adapter *adapter, const char *module_name, + const char *client_type, u8 addr, struct i2c_board_info *i) { struct v4l2_subdev *sd = NULL; struct i2c_client *client; @@ -882,9 +882,13 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26) /* Setup the i2c board info with the device type and the device address. */ - memset(&info, 0, sizeof(info)); - strlcpy(info.type, client_type, sizeof(info.type)); - info.addr = addr; + if (!i) { + memset(&info, 0, sizeof(info)); + strlcpy(info.type, client_type, sizeof(info.type)); + info.addr = addr; + } else { + memcpy(&info, i, sizeof(info)); + } /* Create the i2c client */ client = i2c_new_device(adapter, &info); @@ -922,8 +926,25 @@ error: #endif return sd; } + +struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, + struct i2c_adapter *adapter, + const char *module_name, const char *client_type, u8 addr) +{ + return __v4l2_i2c_new_subdev(v4l2_dev, adapter, module_name, + client_type, addr, NULL); +} EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev); +struct v4l2_subdev *v4l2_i2c_new_subdev_board_info(struct v4l2_device *v4l2_dev, + struct i2c_adapter *adapter, const char *module_name, + struct i2c_board_info *i) +{ + return __v4l2_i2c_new_subdev(v4l2_dev, adapter, module_name, + NULL, 0, i); +} +EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev_board_info); + /* Probe and load an i2c sub-device. */ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev, struct i2c_adapter *adapter, diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 2e1e3a2..da9c95d 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -130,6 +130,7 @@ int v4l2_chip_match_host(const struct v4l2_dbg_match *match); struct i2c_driver; struct i2c_adapter; struct i2c_client; +struct i2c_board_info; struct i2c_device_id; struct v4l2_device; struct v4l2_subdev; @@ -147,6 +148,11 @@ int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev, struct i2c_adapter *adapter, const char *module_name, const char *client_type, u8 addr); +/* Same as v4l2_i2c_new_subdev, but with oportunity to pass i2c_board_info + to client device */ +struct v4l2_subdev *v4l2_i2c_new_subdev_board_info(struct v4l2_device *v4l2_dev, + struct i2c_adapter *adapter, const char *module_name, + struct i2c_board_info *i); /* Probe and load an i2c module and return an initialized v4l2_subdev struct. Only call request_module if module_name != NULL. The client_type argument is the name of the chip that's on the adapter. */