V4L/DVB (11374): v4l2-common: add v4l2_i2c_new_probed_subdev_addr
[safe/jmp/linux-2.6] / drivers / media / video / v4l2-common.c
index b097825..270833b 100644 (file)
@@ -739,33 +739,8 @@ EXPORT_SYMBOL(v4l2_chip_ident_i2c_client);
 
 /* ----------------------------------------------------------------- */
 
-/* Helper function for I2C legacy drivers */
+/* I2C Helper functions */
 
-int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
-               const char *name,
-               int (*probe)(struct i2c_client *, const struct i2c_device_id *))
-{
-       struct i2c_client *client;
-       int err;
-
-       client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
-       if (!client)
-               return -ENOMEM;
-
-       client->addr = address;
-       client->adapter = adapter;
-       client->driver = driver;
-       strlcpy(client->name, name, sizeof(client->name));
-
-       err = probe(client, NULL);
-       if (err == 0) {
-               i2c_attach_client(client);
-       } else {
-               kfree(client);
-       }
-       return err != -ENOMEM ? 0 : err;
-}
-EXPORT_SYMBOL(v4l2_i2c_attach);
 
 void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client,
                const struct v4l2_subdev_ops *ops)
@@ -797,10 +772,10 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
        struct i2c_board_info info;
 
        BUG_ON(!dev);
-#ifdef MODULE
+
        if (module_name)
                request_module(module_name);
-#endif
+
        /* Setup the i2c board info with the device type and
           the device address. */
        memset(&info, 0, sizeof(info));
@@ -850,10 +825,10 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
        struct i2c_board_info info;
 
        BUG_ON(!dev);
-#ifdef MODULE
+
        if (module_name)
                request_module(module_name);
-#endif
+
        /* Setup the i2c board info with the device type and
           the device address. */
        memset(&info, 0, sizeof(info));
@@ -889,6 +864,17 @@ error:
 }
 EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev);
 
+struct v4l2_subdev *v4l2_i2c_new_probed_subdev_addr(struct v4l2_device *v4l2_dev,
+               struct i2c_adapter *adapter,
+               const char *module_name, const char *client_type, u8 addr)
+{
+       unsigned short addrs[2] = { addr, I2C_CLIENT_END };
+
+       return v4l2_i2c_new_probed_subdev(v4l2_dev, adapter,
+                       module_name, client_type, addrs);
+}
+EXPORT_SYMBOL_GPL(v4l2_i2c_new_probed_subdev_addr);
+
 /* Return i2c client address of v4l2_subdev. */
 unsigned short v4l2_i2c_subdev_addr(struct v4l2_subdev *sd)
 {