summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/v4l2-common.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2007-10-30 01:08:11 -0200
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-10-30 01:08:11 -0200
commit47c9bdaf6e07f0a4b5ccaec663d41aec4bf62e63 (patch)
tree40c30a3a55122a33867122d2e2937ceb20af95ff /linux/drivers/media/video/v4l2-common.c
parentee189d9d96dcebde4ec27edbda3f1582949ca8a4 (diff)
parentdb7fcfc5c5821ff5568dd32c567e0c42488c503f (diff)
downloadmediapointer-dvb-s2-47c9bdaf6e07f0a4b5ccaec663d41aec4bf62e63.tar.gz
mediapointer-dvb-s2-47c9bdaf6e07f0a4b5ccaec663d41aec4bf62e63.tar.bz2
merge: http://linuxtv.org/hg/~dougsland/v4l-dvb
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers/media/video/v4l2-common.c')
-rw-r--r--linux/drivers/media/video/v4l2-common.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/linux/drivers/media/video/v4l2-common.c b/linux/drivers/media/video/v4l2-common.c
index 476b5ea5a..a1d751c8a 100644
--- a/linux/drivers/media/video/v4l2-common.c
+++ b/linux/drivers/media/video/v4l2-common.c
@@ -1625,6 +1625,40 @@ int v4l2_chip_match_host(u32 match_type, u32 match_chip)
/* ----------------------------------------------------------------- */
+/* Helper function for I2C legacy drivers */
+
+int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
+ const char *name, int (*probe)(struct i2c_client *))
+{
+ struct i2c_client *client;
+ int err;
+
+ client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
+ if (client == 0)
+ return -ENOMEM;
+
+ client->addr = address;
+ client->adapter = adapter;
+ client->driver = driver;
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
+ client->flags = I2C_CLIENT_ALLOW_USE;
+#endif
+ strlcpy(client->name, name, sizeof(client->name));
+
+ err = probe(client);
+ if (err == 0) {
+ i2c_attach_client(client);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ MOD_INC_USE_COUNT;
+#endif
+ } else {
+ kfree(client);
+ }
+ return err != -ENOMEM ? 0 : err;
+}
+
+/* ----------------------------------------------------------------- */
+
EXPORT_SYMBOL(v4l2_norm_to_name);
EXPORT_SYMBOL(v4l2_video_std_construct);
@@ -1650,6 +1684,8 @@ EXPORT_SYMBOL(v4l2_chip_match_i2c_client);
EXPORT_SYMBOL(v4l2_chip_ident_i2c_client);
EXPORT_SYMBOL(v4l2_chip_match_host);
+EXPORT_SYMBOL(v4l2_i2c_attach);
+
/*
* Local variables:
* c-basic-offset: 8