aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-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