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
...@@ -125,7 +125,8 @@ static int tlv320aic23b_command(struct i2c_client *client, ...@@ -125,7 +125,8 @@ static int tlv320aic23b_command(struct i2c_client *client,
* concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
*/ */
static int tlv320aic23b_probe(struct i2c_client *client) static int tlv320aic23b_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct tlv320aic23b_state *state; struct tlv320aic23b_state *state;
......
...@@ -1073,7 +1073,8 @@ static void tuner_lookup(struct i2c_adapter *adap, ...@@ -1073,7 +1073,8 @@ static void tuner_lookup(struct i2c_adapter *adap,
/* During client attach, set_type is called by adapter's attach_inform callback. /* During client attach, set_type is called by adapter's attach_inform callback.
set_type must then be completed by tuner_probe. set_type must then be completed by tuner_probe.
*/ */
static int tuner_probe(struct i2c_client *client) static int tuner_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct tuner *t; struct tuner *t;
struct tuner *radio; struct tuner *radio;
......
...@@ -1461,7 +1461,7 @@ static struct CHIPDESC chiplist[] = { ...@@ -1461,7 +1461,7 @@ static struct CHIPDESC chiplist[] = {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* i2c registration */ /* i2c registration */
static int chip_probe(struct i2c_client *client) static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id)
{ {
struct CHIPSTATE *chip; struct CHIPSTATE *chip;
struct CHIPDESC *desc; struct CHIPDESC *desc;
......
...@@ -195,7 +195,8 @@ static int upd64031a_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -195,7 +195,8 @@ static int upd64031a_command(struct i2c_client *client, unsigned cmd, void *arg)
/* i2c implementation */ /* i2c implementation */
static int upd64031a_probe(struct i2c_client *client) static int upd64031a_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct upd64031a_state *state; struct upd64031a_state *state;
int i; int i;
......
...@@ -172,7 +172,8 @@ static int upd64083_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -172,7 +172,8 @@ static int upd64083_command(struct i2c_client *client, unsigned cmd, void *arg)
/* i2c implementation */ /* i2c implementation */
static int upd64083_probe(struct i2c_client *client) static int upd64083_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct upd64083_state *state; struct upd64083_state *state;
int i; int i;
......
...@@ -710,7 +710,8 @@ EXPORT_SYMBOL(v4l2_chip_ident_i2c_client); ...@@ -710,7 +710,8 @@ EXPORT_SYMBOL(v4l2_chip_ident_i2c_client);
/* Helper function for I2C legacy drivers */ /* Helper function for I2C legacy drivers */
int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver, int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
const char *name, int (*probe)(struct i2c_client *)) const char *name,
int (*probe)(struct i2c_client *, const struct i2c_device_id *))
{ {
struct i2c_client *client; struct i2c_client *client;
int err; int err;
...@@ -724,7 +725,7 @@ int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver ...@@ -724,7 +725,7 @@ int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver
client->driver = driver; client->driver = driver;
strlcpy(client->name, name, sizeof(client->name)); strlcpy(client->name, name, sizeof(client->name));
err = probe(client); err = probe(client, NULL);
if (err == 0) { if (err == 0) {
i2c_attach_client(client); i2c_attach_client(client);
} else { } else {
......
...@@ -121,7 +121,8 @@ static int vp27smpx_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -121,7 +121,8 @@ static int vp27smpx_command(struct i2c_client *client, unsigned cmd, void *arg)
* concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
*/ */
static int vp27smpx_probe(struct i2c_client *client) static int vp27smpx_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct vp27smpx_state *state; struct vp27smpx_state *state;
......
...@@ -261,7 +261,8 @@ static int wm8739_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -261,7 +261,8 @@ static int wm8739_command(struct i2c_client *client, unsigned cmd, void *arg)
/* i2c implementation */ /* i2c implementation */
static int wm8739_probe(struct i2c_client *client) static int wm8739_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct wm8739_state *state; struct wm8739_state *state;
......
...@@ -159,7 +159,8 @@ static int wm8775_command(struct i2c_client *client, unsigned cmd, void *arg) ...@@ -159,7 +159,8 @@ static int wm8775_command(struct i2c_client *client, unsigned cmd, void *arg)
* concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1'
*/ */
static int wm8775_probe(struct i2c_client *client) static int wm8775_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct wm8775_state *state; struct wm8775_state *state;
......
...@@ -326,7 +326,8 @@ static struct bin_attribute nvram = { ...@@ -326,7 +326,8 @@ static struct bin_attribute nvram = {
static struct i2c_driver ds1307_driver; static struct i2c_driver ds1307_driver;
static int __devinit ds1307_probe(struct i2c_client *client) static int __devinit ds1307_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct ds1307 *ds1307; struct ds1307 *ds1307;
int err = -ENODEV; int err = -ENODEV;
......
...@@ -355,7 +355,8 @@ static const struct rtc_class_ops ds1374_rtc_ops = { ...@@ -355,7 +355,8 @@ static const struct rtc_class_ops ds1374_rtc_ops = {
.ioctl = ds1374_ioctl, .ioctl = ds1374_ioctl,
}; };
static int ds1374_probe(struct i2c_client *client) static int ds1374_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct ds1374 *ds1374; struct ds1374 *ds1374;
int ret; int ret;
......
...@@ -490,7 +490,7 @@ isl1208_sysfs_unregister(struct device *dev) ...@@ -490,7 +490,7 @@ isl1208_sysfs_unregister(struct device *dev)
} }
static int static int
isl1208_probe(struct i2c_client *client) isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
{ {
int rc = 0; int rc = 0;
struct rtc_device *rtc; struct rtc_device *rtc;
......
...@@ -756,7 +756,8 @@ static struct notifier_block wdt_notifier = { ...@@ -756,7 +756,8 @@ static struct notifier_block wdt_notifier = {
* *
***************************************************************************** *****************************************************************************
*/ */
static int m41t80_probe(struct i2c_client *client) static int m41t80_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
int i, rc = 0; int i, rc = 0;
struct rtc_device *rtc = NULL; struct rtc_device *rtc = NULL;
......
...@@ -246,7 +246,8 @@ static const struct rtc_class_ops pcf8563_rtc_ops = { ...@@ -246,7 +246,8 @@ static const struct rtc_class_ops pcf8563_rtc_ops = {
.set_time = pcf8563_rtc_set_time, .set_time = pcf8563_rtc_set_time,
}; };
static int pcf8563_probe(struct i2c_client *client) static int pcf8563_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct pcf8563 *pcf8563; struct pcf8563 *pcf8563;
......
...@@ -494,7 +494,8 @@ static void rs5c_sysfs_unregister(struct device *dev) ...@@ -494,7 +494,8 @@ static void rs5c_sysfs_unregister(struct device *dev)
static struct i2c_driver rs5c372_driver; static struct i2c_driver rs5c372_driver;
static int rs5c372_probe(struct i2c_client *client) static int rs5c372_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
int err = 0; int err = 0;
struct rs5c372 *rs5c372; struct rs5c372 *rs5c372;
......
...@@ -195,7 +195,8 @@ static const struct rtc_class_ops s35390a_rtc_ops = { ...@@ -195,7 +195,8 @@ static const struct rtc_class_ops s35390a_rtc_ops = {
static struct i2c_driver s35390a_driver; static struct i2c_driver s35390a_driver;
static int s35390a_probe(struct i2c_client *client) static int s35390a_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
int err; int err;
unsigned int i; unsigned int i;
......
...@@ -494,7 +494,8 @@ static void x1205_sysfs_unregister(struct device *dev) ...@@ -494,7 +494,8 @@ static void x1205_sysfs_unregister(struct device *dev)
} }
static int x1205_probe(struct i2c_client *client) static int x1205_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
int err = 0; int err = 0;
unsigned char sr; unsigned char sr;
......
...@@ -126,7 +126,7 @@ struct i2c_driver { ...@@ -126,7 +126,7 @@ struct i2c_driver {
* With the driver model, device enumeration is NEVER done by drivers; * With the driver model, device enumeration is NEVER done by drivers;
* it's done by infrastructure. (NEW STYLE DRIVERS ONLY) * it's done by infrastructure. (NEW STYLE DRIVERS ONLY)
*/ */
int (*probe)(struct i2c_client *); int (*probe)(struct i2c_client *, const struct i2c_device_id *);
int (*remove)(struct i2c_client *); int (*remove)(struct i2c_client *);
/* driver model interfaces that don't relate to enumeration */ /* driver model interfaces that don't relate to enumeration */
...@@ -140,11 +140,10 @@ struct i2c_driver { ...@@ -140,11 +140,10 @@ struct i2c_driver {
int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
struct device_driver driver; struct device_driver driver;
const struct i2c_device_id *id_table;
}; };
#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) #define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
#define I2C_NAME_SIZE 20
/** /**
* struct i2c_client - represent an I2C slave device * struct i2c_client - represent an I2C slave device
* @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address; * @flags: I2C_CLIENT_TEN indicates the device uses a ten bit chip address;
......
...@@ -368,4 +368,15 @@ struct virtio_device_id { ...@@ -368,4 +368,15 @@ struct virtio_device_id {
}; };
#define VIRTIO_DEV_ANY_ID 0xffffffff #define VIRTIO_DEV_ANY_ID 0xffffffff
/* i2c */
#define I2C_NAME_SIZE 20
#define I2C_MODULE_PREFIX "i2c:"
struct i2c_device_id {
char name[I2C_NAME_SIZE];
kernel_ulong_t driver_data; /* Data private to the driver */
};
#endif /* LINUX_MOD_DEVICETABLE_H */ #endif /* LINUX_MOD_DEVICETABLE_H */
...@@ -107,9 +107,11 @@ int v4l2_chip_match_host(u32 id_type, u32 chip_id); ...@@ -107,9 +107,11 @@ int v4l2_chip_match_host(u32 id_type, u32 chip_id);
struct i2c_driver; struct i2c_driver;
struct i2c_adapter; struct i2c_adapter;
struct i2c_client; struct i2c_client;
struct i2c_device_id;
int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver, int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
const char *name, int (*probe)(struct i2c_client *)); const char *name,
int (*probe)(struct i2c_client *, const struct i2c_device_id *));
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
......
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