Commit 86919833 authored by Ladislav Michl's avatar Ladislav Michl Committed by Greg Kroah-Hartman

[PATCH] I2C: ds1337: search by bus number

Chip is searched by bus number rather than its own proprietary id.
Signed-off-by: default avatarLadislav Michl <ladis@linux-mips.org>
Signed-off-by: default avatarJames Chapman <jchapman@katalix.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 00588243
...@@ -69,13 +69,11 @@ static struct i2c_driver ds1337_driver = { ...@@ -69,13 +69,11 @@ static struct i2c_driver ds1337_driver = {
struct ds1337_data { struct ds1337_data {
struct i2c_client client; struct i2c_client client;
struct list_head list; struct list_head list;
int id;
}; };
/* /*
* Internal variables * Internal variables
*/ */
static int ds1337_id;
static LIST_HEAD(ds1337_clients); static LIST_HEAD(ds1337_clients);
static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value) static inline int ds1337_read(struct i2c_client *client, u8 reg, u8 *value)
...@@ -213,7 +211,7 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd, ...@@ -213,7 +211,7 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd,
* Public API for access to specific device. Useful for low-level * Public API for access to specific device. Useful for low-level
* RTC access from kernel code. * RTC access from kernel code.
*/ */
int ds1337_do_command(int id, int cmd, void *arg) int ds1337_do_command(int bus, int cmd, void *arg)
{ {
struct list_head *walk; struct list_head *walk;
struct list_head *tmp; struct list_head *tmp;
...@@ -221,7 +219,7 @@ int ds1337_do_command(int id, int cmd, void *arg) ...@@ -221,7 +219,7 @@ int ds1337_do_command(int id, int cmd, void *arg)
list_for_each_safe(walk, tmp, &ds1337_clients) { list_for_each_safe(walk, tmp, &ds1337_clients) {
data = list_entry(walk, struct ds1337_data, list); data = list_entry(walk, struct ds1337_data, list);
if (data->id == id) if (data->client.adapter->nr == bus)
return ds1337_command(&data->client, cmd, arg); return ds1337_command(&data->client, cmd, arg);
} }
...@@ -331,7 +329,6 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -331,7 +329,6 @@ static int ds1337_detect(struct i2c_adapter *adapter, int address, int kind)
ds1337_init_client(new_client); ds1337_init_client(new_client);
/* Add client to local list */ /* Add client to local list */
data->id = ds1337_id++;
list_add(&data->list, &ds1337_clients); list_add(&data->list, &ds1337_clients);
return 0; return 0;
......
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