aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l2-common.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-09-12 07:32:50 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:01:16 -0500
commit8ffbc6559493c64d6194c92d856196fdaeb8a5fb (patch)
treeb279073efa70f56cf6f0614a6a96374464e492ec /drivers/media/video/v4l2-common.c
parent5ef4730d1bfe5be71ce54d927c510ad5da968854 (diff)
V4L/DVB (6451): v4l2: add support for bus-based I2C drivers
Two new headers were added: one for I2C drivers that are only used by V4L2 drivers converted to the new bus-based I2C API, and one that can be used by both converted and unconverted drivers (at the expense of some additional overhead). To support the legacy I2C API a helper function was added to v4l2-common.c. These headers take care of all the 'boilerplate' code that all V4L2 I2C drivers have in common and will automatically support the bus-based I2C API introduced in kernel 2.6.22. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/v4l2-common.c')
-rw-r--r--drivers/media/video/v4l2-common.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index a4d68d3ba5e4..32607a612b18 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -1013,6 +1013,35 @@ int v4l2_chip_match_host(u32 match_type, u32 match_chip)
1013 1013
1014/* ----------------------------------------------------------------- */ 1014/* ----------------------------------------------------------------- */
1015 1015
1016/* Helper function for I2C legacy drivers */
1017
1018int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
1019 const char *name, int (*probe)(struct i2c_client *))
1020{
1021 struct i2c_client *client;
1022 int err;
1023
1024 client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
1025 if (client == 0)
1026 return -ENOMEM;
1027
1028 client->addr = address;
1029 client->adapter = adapter;
1030 client->driver = driver;
1031 snprintf(client->name, sizeof(client->name) - 1, name);
1032
1033 err = probe(client);
1034 if (err == 0) {
1035 i2c_attach_client(client);
1036 }
1037 else {
1038 kfree(client);
1039 }
1040 return err;
1041}
1042
1043/* ----------------------------------------------------------------- */
1044
1016EXPORT_SYMBOL(v4l2_norm_to_name); 1045EXPORT_SYMBOL(v4l2_norm_to_name);
1017EXPORT_SYMBOL(v4l2_video_std_construct); 1046EXPORT_SYMBOL(v4l2_video_std_construct);
1018 1047
@@ -1038,6 +1067,8 @@ EXPORT_SYMBOL(v4l2_chip_match_i2c_client);
1038EXPORT_SYMBOL(v4l2_chip_ident_i2c_client); 1067EXPORT_SYMBOL(v4l2_chip_ident_i2c_client);
1039EXPORT_SYMBOL(v4l2_chip_match_host); 1068EXPORT_SYMBOL(v4l2_chip_match_host);
1040 1069
1070EXPORT_SYMBOL(v4l2_i2c_attach);
1071
1041/* 1072/*
1042 * Local variables: 1073 * Local variables:
1043 * c-basic-offset: 8 1074 * c-basic-offset: 8