Commit d2653e92 authored by Jean Delvare's avatar Jean Delvare Committed by Jean Delvare
Browse files

i2c: Add support for device alias names


Based on earlier work by Jon Smirl and Jochen Friedrich.

This patch allows new-style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). At this
point, the old i2c driver binding scheme (driver_name/type) is still
supported.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Cc: Jochen Friedrich <jochen@scram.de>
Cc: Jon Smirl <jonsmirl@gmail.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
parent ee56d977
...@@ -25,7 +25,7 @@ struct v4l2_i2c_driver_data { ...@@ -25,7 +25,7 @@ struct v4l2_i2c_driver_data {
const char * const name; const char * const name;
int driverid; int driverid;
int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
int (*probe)(struct i2c_client *client); int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
int (*remove)(struct i2c_client *client); int (*remove)(struct i2c_client *client);
int (*suspend)(struct i2c_client *client, pm_message_t state); int (*suspend)(struct i2c_client *client, pm_message_t state);
int (*resume)(struct i2c_client *client); int (*resume)(struct i2c_client *client);
......
...@@ -30,7 +30,7 @@ struct v4l2_i2c_driver_data { ...@@ -30,7 +30,7 @@ struct v4l2_i2c_driver_data {
const char * const name; const char * const name;
int driverid; int driverid;
int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
int (*probe)(struct i2c_client *client); int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
int (*remove)(struct i2c_client *client); int (*remove)(struct i2c_client *client);
int (*suspend)(struct i2c_client *client, pm_message_t state); int (*suspend)(struct i2c_client *client, pm_message_t state);
int (*resume)(struct i2c_client *client); int (*resume)(struct i2c_client *client);
......
...@@ -576,6 +576,15 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id, ...@@ -576,6 +576,15 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id,
return 1; return 1;
} }
/* Looks like: i2c:S */
static int do_i2c_entry(const char *filename, struct i2c_device_id *id,
char *alias)
{
sprintf(alias, I2C_MODULE_PREFIX "%s", id->name);
return 1;
}
/* Ignore any prefix, eg. v850 prepends _ */ /* Ignore any prefix, eg. v850 prepends _ */
static inline int sym_is(const char *symbol, const char *name) static inline int sym_is(const char *symbol, const char *name)
{ {
...@@ -704,6 +713,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, ...@@ -704,6 +713,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
do_table(symval, sym->st_size, do_table(symval, sym->st_size,
sizeof(struct virtio_device_id), "virtio", sizeof(struct virtio_device_id), "virtio",
do_virtio_entry, mod); do_virtio_entry, mod);
else if (sym_is(symname, "__mod_i2c_device_table"))
do_table(symval, sym->st_size,
sizeof(struct i2c_device_id), "i2c",
do_i2c_entry, mod);
free(zeros); free(zeros);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment