Commit b56a1471 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Petr Vandrovec

[PATCH] i2c: remove the data field from struct i2c_client

It's no longer needed, as the struct device should be used instead.

Created i2c_get_clientdata() and i2c_set_clientdata() to access the data.
parent 329e2f3a
...@@ -223,8 +223,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, ...@@ -223,8 +223,8 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
} }
data = (struct adm1021_data *) (new_client + 1); data = (struct adm1021_data *) (new_client + 1);
i2c_set_clientdata(new_client, data);
new_client->addr = address; new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter; new_client->adapter = adapter;
new_client->driver = &adm1021_driver; new_client->driver = &adm1021_driver;
new_client->flags = 0; new_client->flags = 0;
...@@ -354,8 +354,7 @@ static int adm1021_detach_client(struct i2c_client *client) ...@@ -354,8 +354,7 @@ static int adm1021_detach_client(struct i2c_client *client)
int err; int err;
i2c_deregister_entry(((struct adm1021_data *) (client->data))-> i2c_deregister_entry(((struct adm1021_data *) (i2c_get_clientdata(client)))->sysctl_id);
sysctl_id);
if ((err = i2c_detach_client(client))) { if ((err = i2c_detach_client(client))) {
printk printk
...@@ -384,7 +383,7 @@ static int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value) ...@@ -384,7 +383,7 @@ static int adm1021_write_value(struct i2c_client *client, u8 reg, u16 value)
static void adm1021_update_client(struct i2c_client *client) static void adm1021_update_client(struct i2c_client *client)
{ {
struct adm1021_data *data = client->data; struct adm1021_data *data = i2c_get_clientdata(client);
down(&data->update_lock); down(&data->update_lock);
...@@ -435,7 +434,7 @@ static void adm1021_update_client(struct i2c_client *client) ...@@ -435,7 +434,7 @@ static void adm1021_update_client(struct i2c_client *client)
static void adm1021_temp(struct i2c_client *client, int operation, static void adm1021_temp(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results) int ctl_name, int *nrels_mag, long *results)
{ {
struct adm1021_data *data = client->data; struct adm1021_data *data = i2c_get_clientdata(client);
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
*nrels_mag = 0; *nrels_mag = 0;
...@@ -462,7 +461,7 @@ static void adm1021_temp(struct i2c_client *client, int operation, ...@@ -462,7 +461,7 @@ static void adm1021_temp(struct i2c_client *client, int operation,
static void adm1021_remote_temp(struct i2c_client *client, int operation, static void adm1021_remote_temp(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results) int ctl_name, int *nrels_mag, long *results)
{ {
struct adm1021_data *data = client->data; struct adm1021_data *data = i2c_get_clientdata(client);
int prec = 0; int prec = 0;
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
...@@ -535,7 +534,7 @@ static void adm1021_remote_temp(struct i2c_client *client, int operation, ...@@ -535,7 +534,7 @@ static void adm1021_remote_temp(struct i2c_client *client, int operation,
static void adm1021_die_code(struct i2c_client *client, int operation, static void adm1021_die_code(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results) int ctl_name, int *nrels_mag, long *results)
{ {
struct adm1021_data *data = client->data; struct adm1021_data *data = i2c_get_clientdata(client);
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
*nrels_mag = 0; *nrels_mag = 0;
...@@ -551,7 +550,7 @@ static void adm1021_die_code(struct i2c_client *client, int operation, ...@@ -551,7 +550,7 @@ static void adm1021_die_code(struct i2c_client *client, int operation,
static void adm1021_alarms(struct i2c_client *client, int operation, static void adm1021_alarms(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results) int ctl_name, int *nrels_mag, long *results)
{ {
struct adm1021_data *data = client->data; struct adm1021_data *data = i2c_get_clientdata(client);
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
*nrels_mag = 0; *nrels_mag = 0;
else if (operation == SENSORS_PROC_REAL_READ) { else if (operation == SENSORS_PROC_REAL_READ) {
......
...@@ -142,8 +142,8 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, ...@@ -142,8 +142,8 @@ static int lm75_detect(struct i2c_adapter *adapter, int address,
} }
data = (struct lm75_data *) (new_client + 1); data = (struct lm75_data *) (new_client + 1);
i2c_set_clientdata(new_client, data);
new_client->addr = address; new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter; new_client->adapter = adapter;
new_client->driver = &lm75_driver; new_client->driver = &lm75_driver;
new_client->flags = 0; new_client->flags = 0;
...@@ -215,7 +215,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, ...@@ -215,7 +215,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address,
static int lm75_detach_client(struct i2c_client *client) static int lm75_detach_client(struct i2c_client *client)
{ {
struct lm75_data *data = client->data; struct lm75_data *data = i2c_get_clientdata(client);
i2c_deregister_entry(data->sysctl_id); i2c_deregister_entry(data->sysctl_id);
i2c_detach_client(client); i2c_detach_client(client);
...@@ -263,7 +263,7 @@ static void lm75_init_client(struct i2c_client *client) ...@@ -263,7 +263,7 @@ static void lm75_init_client(struct i2c_client *client)
static void lm75_update_client(struct i2c_client *client) static void lm75_update_client(struct i2c_client *client)
{ {
struct lm75_data *data = client->data; struct lm75_data *data = i2c_get_clientdata(client);
down(&data->update_lock); down(&data->update_lock);
...@@ -286,7 +286,7 @@ static void lm75_update_client(struct i2c_client *client) ...@@ -286,7 +286,7 @@ static void lm75_update_client(struct i2c_client *client)
static void lm75_temp(struct i2c_client *client, int operation, int ctl_name, static void lm75_temp(struct i2c_client *client, int operation, int ctl_name,
int *nrels_mag, long *results) int *nrels_mag, long *results)
{ {
struct lm75_data *data = client->data; struct lm75_data *data = i2c_get_clientdata(client);
if (operation == SENSORS_PROC_REAL_INFO) if (operation == SENSORS_PROC_REAL_INFO)
*nrels_mag = 1; *nrels_mag = 1;
else if (operation == SENSORS_PROC_REAL_READ) { else if (operation == SENSORS_PROC_REAL_READ) {
......
...@@ -167,13 +167,22 @@ struct i2c_client { ...@@ -167,13 +167,22 @@ struct i2c_client {
alignment considerations */ alignment considerations */
struct i2c_adapter *adapter; /* the adapter we sit on */ struct i2c_adapter *adapter; /* the adapter we sit on */
struct i2c_driver *driver; /* and our access routines */ struct i2c_driver *driver; /* and our access routines */
void *data; /* for the clients */
int usage_count; /* How many accesses currently */ int usage_count; /* How many accesses currently */
/* to the client */ /* to the client */
struct device dev; /* the device structure */ struct device dev; /* the device structure */
}; };
#define to_i2c_client(d) container_of(d, struct i2c_client, dev) #define to_i2c_client(d) container_of(d, struct i2c_client, dev)
static inline void *i2c_get_clientdata (struct i2c_client *dev)
{
return dev_get_drvdata (&dev->dev);
}
static inline void i2c_set_clientdata (struct i2c_client *dev, void *data)
{
return dev_set_drvdata (&dev->dev, data);
}
/* /*
* The following structs are for those who like to implement new bus drivers: * The following structs are for those who like to implement new bus drivers:
* i2c_algorithm is the interface to a class of hardware solutions which can * i2c_algorithm is the interface to a class of hardware solutions which can
......
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