Backport memory allocation reworking from Linux 2.6.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2445 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2004-04-17 17:20:01 +00:00
1 parent 8f4ce259b5
commit 239b3d0344
45 files changed
+260 -304

No files matched your search

+5 -8
View File
@@ -86,6 +86,7 @@ SENSORS_INSMOD_8(adm1021, adm1023, max1617, max1617a, thmc10, lm84, gl523sm, mc1
/* Each client has this additional data */
struct adm1021_data {
struct i2c_client client;
int sysctl_id;
enum chips type;
@@ -211,14 +212,12 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access adm1021_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct adm1021_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct adm1021_data), GFP_KERNEL))) {
err = -ENOMEM;
goto error0;
}
data = (struct adm1021_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -321,7 +320,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
error3:
error1:
kfree(new_client);
kfree(data);
error0:
return err;
}
@@ -337,7 +336,6 @@ static void adm1021_init_client(struct i2c_client *client)
static int adm1021_detach_client(struct i2c_client *client)
{
int err;
i2c_deregister_entry(((struct adm1021_data *) (client->data))->
@@ -349,10 +347,9 @@ static int adm1021_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -7
View File
@@ -148,6 +148,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
dynamically allocated, at the same time when a new adm1024 client is
allocated. */
struct adm1024_data {
struct i2c_client client;
int sysctl_id;
enum chips type;
@@ -325,14 +326,12 @@ static int adm1024_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access adm1024_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct adm1024_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct adm1024_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct adm1024_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -404,7 +403,7 @@ static int adm1024_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -422,10 +421,9 @@ static int adm1024_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
static int adm1024_read_value(struct i2c_client *client, u8 reg)
+5 -7
View File
@@ -117,6 +117,7 @@ SENSORS_INSMOD_2(adm1025, ne1619);
dynamically allocated, at the same time when a new adm1025 client is
allocated. */
struct adm1025_data {
struct i2c_client client;
int sysctl_id;
enum chips type;
@@ -259,14 +260,12 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access adm1025_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct adm1025_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct adm1025_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct adm1025_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -350,7 +349,7 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -368,10 +367,9 @@ static int adm1025_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
/* Called when we have found a new ADM1025. */
+5 -6
View File
@@ -298,6 +298,7 @@ static int adm1026_scaling[] = { /* .001 Volts */
* allocated, when a new client structure is allocated. */
struct adm1026_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
enum chips type;
@@ -637,14 +638,12 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access adm1026_{read,write}_value. */
if (!(new_client = kmalloc((sizeof(struct i2c_client)) +
sizeof(struct adm1026_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct adm1026_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct adm1026_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -767,7 +766,7 @@ int adm1026_detect(struct i2c_adapter *adapter, int address,
ERROR2:
i2c_detach_client(new_client);
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -786,7 +785,7 @@ int adm1026_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+6 -7
View File
@@ -164,6 +164,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
dynamically allocated, at the same time when a new adm9240 client is
allocated. */
struct adm9240_data {
struct i2c_client client;
int sysctl_id;
enum chips type;
@@ -323,14 +324,13 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access adm9240_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct adm9240_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct adm9240_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct adm9240_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -417,7 +417,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -435,10 +435,9 @@ static int adm9240_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -7
View File
@@ -60,6 +60,7 @@ SENSORS_INSMOD_1(bt869);
/* Each client has this additional data */
struct bt869_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -503,15 +504,12 @@ int bt869_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access bt869_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct bt869_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct bt869_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data =
(struct bt869_data *) (((struct i2c_client *) new_client) + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -567,7 +565,7 @@ int bt869_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -585,7 +583,7 @@ static int bt869_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -74,6 +74,7 @@ MODULE_PARM_DESC(checksum, "Only accept eeproms whose checksum is correct");
/* Each client has this additional data */
struct ddcmon_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -215,14 +216,12 @@ int ddcmon_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access ddcmon_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct ddcmon_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct ddcmon_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct ddcmon_data *) (new_client + 1);
new_client = &data->client;
memset(data->data, 0xff, DDCMON_SIZE);
new_client->addr = address;
new_client->data = data;
@@ -283,7 +282,7 @@ int ddcmon_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -299,7 +298,7 @@ static int ddcmon_detach_client(struct i2c_client *client)
("ddcmon.o: Client deregistration failed, client not detached.\n");
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -80,6 +80,7 @@ SENSORS_INSMOD_1(ds1621);
/* Each client has this additional data */
struct ds1621_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -189,14 +190,12 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access ds1621_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct ds1621_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct ds1621_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct ds1621_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -256,7 +255,7 @@ int ds1621_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -274,7 +273,7 @@ static int ds1621_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -63,6 +63,7 @@ MODULE_PARM_DESC(checksum,
/* Each client has this additional data */
struct eeprom_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -194,14 +195,12 @@ int eeprom_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access eeprom_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct eeprom_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct eeprom_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct eeprom_data *) (new_client + 1);
new_client = &data->client;
memset(data->data, 0xff, EEPROM_SIZE);
new_client->addr = address;
new_client->data = data;
@@ -278,7 +277,7 @@ int eeprom_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -296,7 +295,7 @@ static int eeprom_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -108,6 +108,7 @@ SENSORS_INSMOD_1(fscher);
dynamically allocated, at the same time when a new fscher client is
allocated. */
struct fscher_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -266,14 +267,12 @@ int fscher_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access fscher_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct fscher_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct fscher_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct fscher_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -324,7 +323,7 @@ int fscher_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -340,7 +339,7 @@ static int fscher_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -112,6 +112,7 @@ SENSORS_INSMOD_1(fscpos);
dynamically allocated, at the same time when a new fscpos client is
allocated. */
struct fscpos_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -250,14 +251,12 @@ int fscpos_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access fscpos_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct fscpos_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct fscpos_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct fscpos_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -307,7 +306,7 @@ int fscpos_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -325,7 +324,7 @@ static int fscpos_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -156,6 +156,7 @@ SENSORS_INSMOD_1(fscscy);
dynamically allocated, at the same time when a new fscscy client is
allocated. */
struct fscscy_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -329,14 +330,12 @@ int fscscy_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access fscscy_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct fscscy_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct fscscy_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct fscscy_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -386,7 +385,7 @@ int fscscy_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -404,7 +403,7 @@ static int fscscy_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -111,6 +111,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
/* Each client has this additional data */
struct gl518_data {
struct i2c_client client;
int sysctl_id;
enum chips type;
@@ -278,14 +279,12 @@ static int gl518_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access gl518_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct gl518_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct gl518_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct gl518_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -388,7 +387,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address,
gl518_list[i] = NULL;
ERROR2:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -440,7 +439,7 @@ static int gl518_detach_client(struct i2c_client *client)
wake_up_interruptible(&data->wq);
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -116,6 +116,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
/* Each client has this additional data */
struct gl520_data {
struct i2c_client client;
int sysctl_id;
enum chips type;
@@ -282,14 +283,12 @@ static int gl520_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access gl520_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct gl520_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct gl520_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct gl520_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -354,7 +353,7 @@ static int gl520_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -391,7 +390,7 @@ static int gl520_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -53,6 +53,7 @@ SENSORS_INSMOD_1(icspll);
/* Each client has this additional data */
struct icspll_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
char valid; /* !=0 if following fields are valid */
@@ -133,15 +134,13 @@ int icspll_detect(struct i2c_adapter *adapter, int address,
}
/* Allocate space for a new client structure */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct icspll_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct icspll_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
/* Fill the new client structure with data */
data = (struct icspll_data *) (new_client + 1);
new_data = &data->client;
new_client->data = data;
new_client->id = icspll_id++;
new_client->addr = address;
@@ -178,7 +177,7 @@ int icspll_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR2:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -196,7 +195,7 @@ static int icspll_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -223,6 +223,7 @@ extern inline u8 DIV_TO_REG(long val)
dynamically allocated, at the same time when a new it87 client is
allocated. */
struct it87_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
enum chips type;
@@ -498,14 +499,12 @@ int it87_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access it87_{read,write}_value. */
if (!(new_client = kmalloc((sizeof(struct i2c_client)) +
sizeof(struct it87_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct it87_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct it87_data *) (new_client + 1);
new_client = &data->client;
if (is_isa)
init_MUTEX(&data->lock);
new_client->addr = address;
@@ -594,7 +593,7 @@ int it87_detect(struct i2c_adapter *adapter, int address,
if (is_isa)
release_region(address, IT87_EXTENT);
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -614,7 +613,7 @@ static int it87_detach_client(struct i2c_client *client)
if(i2c_is_isa_client(client))
release_region(client->addr, IT87_EXTENT);
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -45,6 +45,7 @@ SENSORS_INSMOD_1(lm75);
/* Each client has this additional data */
struct lm75_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -128,14 +129,12 @@ int lm75_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access lm75_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct lm75_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct lm75_data), GFP_KERNEL))) {
err = -ENOMEM;
goto error0;
}
data = (struct lm75_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -202,7 +201,7 @@ int lm75_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
error3:
error1:
kfree(new_client);
kfree(data);
error0:
return err;
}
@@ -213,7 +212,7 @@ static int lm75_detach_client(struct i2c_client *client)
i2c_deregister_entry(data->sysctl_id);
i2c_detach_client(client);
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -118,6 +118,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
dynamically allocated, at the same time when a new lm78 client is
allocated. */
struct lm78_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
enum chips type;
@@ -312,14 +313,12 @@ int lm78_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access lm78_{read,write}_value. */
if (!(new_client = kmalloc((sizeof(struct i2c_client)) +
sizeof(struct lm78_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct lm78_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct lm78_data *) (new_client + 1);
new_client = &data->client;
if (is_isa)
init_MUTEX(&data->lock);
new_client->addr = address;
@@ -412,7 +411,7 @@ int lm78_detect(struct i2c_adapter *adapter, int address,
if (is_isa)
release_region(address, LM78_EXTENT);
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -432,7 +431,7 @@ static int lm78_detach_client(struct i2c_client *client)
if(i2c_is_isa_client(client))
release_region(client->addr, LM78_EXTENT);
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -109,6 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp)
#define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1)
struct lm80_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -261,14 +262,12 @@ int lm80_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access lm80_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct lm80_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct lm80_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct lm80_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -330,7 +329,7 @@ int lm80_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -348,7 +347,7 @@ static int lm80_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+9 -8
View File
@@ -142,6 +142,7 @@ static struct i2c_driver lm83_driver = {
struct lm83_data
{
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -244,21 +245,21 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, unsigned
return 0;
}
if (!(new_client = kmalloc(sizeof(struct i2c_client) + sizeof(struct
lm83_data), GFP_KERNEL)))
if (!(data = kmalloc(sizeof(struct lm83_data), GFP_KERNEL)))
{
printk("lm83.o: Out of memory in lm83_detect (new_client).\n");
return -ENOMEM;
}
/*
* The LM83-specific data is placed right after the common I2C
* client data, and is pointed to by the data field from the I2C
* client data.
* The common I2C client data is placed right before the
* LM83-specific data. The LM83-specific data is pointed to by the
* data field from the I2C client data.
*/
new_client = &data->client;
new_client->addr = address;
new_client->data = data = (struct lm83_data *) (new_client + 1);
new_client->data = data;
new_client->adapter = adapter;
new_client->driver = &lm83_driver;
new_client->flags = 0;
@@ -368,7 +369,7 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, unsigned
ERROR2:
i2c_detach_client(new_client);
ERROR1:
kfree(new_client);
kfree(data);
return err;
}
@@ -384,7 +385,7 @@ static int lm83_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -384,6 +384,7 @@ struct lm85_autofan {
};
struct lm85_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
enum chips type;
@@ -738,14 +739,12 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access lm85_{read,write}_value. */
if (!(new_client = kmalloc((sizeof(struct i2c_client)) +
sizeof(struct lm85_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct lm85_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct lm85_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -921,7 +920,7 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
ERROR2:
i2c_detach_client(new_client);
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -940,7 +939,7 @@ int lm85_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -7
View File
@@ -195,6 +195,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
dynamically allocated, at the same time when a new LM87 client is
allocated. */
struct lm87_data {
struct i2c_client client;
int sysctl_id;
enum chips type;
@@ -417,14 +418,12 @@ static int lm87_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access LM87_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct lm87_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct lm87_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct lm87_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -474,7 +473,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -492,10 +491,9 @@ static int lm87_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
static int lm87_read_value(struct i2c_client *client, u8 reg)
+9 -8
View File
@@ -160,6 +160,7 @@ static struct i2c_driver lm90_driver = {
struct lm90_data
{
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -265,21 +266,21 @@ static int lm90_detect(struct i2c_adapter *adapter, int address,
return 0;
}
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct lm90_data), GFP_KERNEL)))
if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL)))
{
printk("lm90.o: Out of memory in lm90_detect (new_client).\n");
return -ENOMEM;
}
/*
* The LM90-specific data is placed right after the common I2C
* client data, and is pointed to by the data field from the I2C
* client data.
* The common I2C client data is placed right before the
* LM90-specific data. The LM90-specific data is pointed to by the
* data field from the I2C client data.
*/
new_client = &data->client;
new_client->addr = address;
new_client->data = data = (struct lm90_data *) (new_client + 1);
new_client->data = data;
new_client->adapter = adapter;
new_client->driver = &lm90_driver;
new_client->flags = 0;
@@ -412,7 +413,7 @@ static int lm90_detect(struct i2c_adapter *adapter, int address,
ERROR2:
i2c_detach_client(new_client);
ERROR1:
kfree(new_client);
kfree(data);
return err;
}
@@ -445,7 +446,7 @@ static int lm90_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+21 -20
View File
@@ -83,6 +83,7 @@ static ctl_table lm92_dir_table[] = {
/* NOTE: all temperatures are degrees centigrade * 16 */
typedef struct {
struct i2c_client client;
int sysctl_id;
unsigned long timestamp;
struct {
@@ -307,10 +308,10 @@ static int lm92_detect (struct i2c_adapter *adapter,int address,unsigned short f
if (!i2c_check_functionality (adapter,I2C_FUNC_SMBUS_BYTE_DATA))
return (-ENODEV);
if ((client = kmalloc (sizeof (struct i2c_client) + sizeof (lm92_t),GFP_KERNEL)) == NULL)
if (!(data = kmalloc(sizeof(lm92_t), GFP_KERNEL)))
return (-ENOMEM);
data = (lm92_t *) (client + 1);
client = &data->client;
client->addr = address;
client->data = data;
client->adapter = adapter;
@@ -319,8 +320,8 @@ static int lm92_detect (struct i2c_adapter *adapter,int address,unsigned short f
strcpy (client->name,lm92_driver.name);
if (down_interruptible (&mutex)) {
kfree (client);
return (-ERESTARTSYS);
result = -ERESTARTSYS;
goto ERROR1;
}
if (kind < 0) {
@@ -330,33 +331,23 @@ static int lm92_detect (struct i2c_adapter *adapter,int address,unsigned short f
|| manufacturer != LM92_MANUFACTURER_ID)) {
/* Is it a MAX6635/MAX6635/MAX6635? */
if (!max6635_check(client)) {
kfree (client);
up (&mutex);
return (-ENODEV);
result = -ENODEV;
goto ERROR2;
}
}
}
if ((result = i2c_attach_client (client))) {
kfree (client);
up (&mutex);
return (result);
goto ERROR2;
}
if ((result = i2c_register_entry (client,client->name,lm92_dir_table)) < 0) {
i2c_detach_client (client);
kfree (client);
up (&mutex);
return (result);
goto ERROR3;
}
data->sysctl_id = result;
if ((result = lm92_init_client (client)) < 0) {
i2c_deregister_entry (data->sysctl_id);
i2c_detach_client (client);
kfree (client);
up (&mutex);
return (result);
goto ERROR4;
}
client->id = id++;
@@ -364,6 +355,16 @@ static int lm92_detect (struct i2c_adapter *adapter,int address,unsigned short f
up (&mutex);
return (0);
ERROR4:
i2c_deregister_entry(data->sysctl_id);
ERROR3:
i2c_detach_client(client);
ERROR2:
up(&mutex);
ERROR1:
kfree(data);
return result;
}
static int lm92_attach_adapter (struct i2c_adapter *adapter)
@@ -394,7 +395,7 @@ static int lm92_detach_client (struct i2c_client *client)
if ((result = i2c_detach_client (client)))
return (result);
kfree (client);
kfree(client->data);
return (0);
}
+5 -6
View File
@@ -68,6 +68,7 @@ SENSORS_INSMOD_1(ltc1710);
/* Each client has this additional data */
struct ltc1710_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -152,14 +153,12 @@ int ltc1710_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access ltc1710_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct ltc1710_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct ltc1710_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct ltc1710_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -212,7 +211,7 @@ int ltc1710_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -231,7 +230,7 @@ static int ltc1710_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
+5 -6
View File
@@ -45,6 +45,7 @@ SENSORS_INSMOD_1(matorb);
/* Each client has this additional data */
struct matorb_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -127,14 +128,12 @@ int matorb_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access matorb_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct matorb_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct matorb_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct matorb_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -174,7 +173,7 @@ int matorb_detect(struct i2c_adapter *adapter, int address,
ERROR4:
i2c_detach_client(new_client);
ERROR3:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -192,7 +191,7 @@ static int matorb_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+9 -8
View File
@@ -128,6 +128,7 @@ static struct i2c_driver max6650_driver = {
struct max6650_data
{
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
char valid; /* zero until following fields are valid */
@@ -219,20 +220,20 @@ static int max6650_detect(struct i2c_adapter *adapter, int address, unsigned
return 0;
}
if (!(new_client = kmalloc(sizeof(struct i2c_client) + sizeof(struct
max6650_data), GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct max6650_data), GFP_KERNEL))) {
printk("max6650.o: Out of memory in max6650_detect (new_client).\n");
return -ENOMEM;
}
/*
* The max6650-specific data is placed right after the common I2C
* client data, and is pointed to by the data field from the I2C
* client data.
* The common I2C client data is placed right before the
* max6650-specific data. The max6650-specific data is pointed to by the
* data field from the I2C client data.
*/
new_client = &data->client;
new_client->addr = address;
new_client->data = data = (struct max6650_data *) (new_client + 1);
new_client->data = data;
new_client->adapter = adapter;
new_client->driver = &max6650_driver;
new_client->flags = 0;
@@ -328,7 +329,7 @@ static int max6650_detect(struct i2c_adapter *adapter, int address, unsigned
ERROR2:
i2c_detach_client(new_client);
ERROR1:
kfree(new_client);
kfree(data);
return err;
}
@@ -348,7 +349,7 @@ static int max6650_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -238,6 +238,7 @@ enum sensor_type { fan, temp, vid, pll, lcd, alarm };
client is allocated. We assume MaxiLife will only be present on the
SMBus and not on the ISA bus. */
struct maxi_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
enum maxi_type type;
@@ -439,15 +440,13 @@ int maxi_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access maxi_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct maxi_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct maxi_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
/* Fill the new client structure with data */
data = (struct maxi_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -629,7 +628,7 @@ int maxi_detect(struct i2c_adapter *adapter, int address,
ERROR4:
i2c_detach_client(new_client);
ERROR2:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -650,7 +649,7 @@ static int maxi_detach_client(struct i2c_client *client)
("maxilife: Client deregistration failed, client not detached.\n");
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+6 -6
View File
@@ -193,6 +193,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
* mtp008 client is allocated.
*/
struct mtp008_data {
struct i2c_client client;
int sysctl_id;
enum chips type;
@@ -402,13 +403,12 @@ int mtp008_detect(struct i2c_adapter *adapter, int address,
* structure, even though we cannot fill it completely yet. But it
* allows us to use mtp008_(read|write)_value().
*/
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct mtp008_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct mtp008_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct mtp008_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -463,7 +463,7 @@ int mtp008_detect(struct i2c_adapter *adapter, int address,
ERROR2:
i2c_detach_client(new_client);
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
@@ -481,7 +481,7 @@ static int mtp008_detach_client(struct i2c_client *client)
"client not detached.\n");
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -109,6 +109,7 @@ static inline void superio_exit(void)
#define ALARM_FROM_REG(val) ((val) & 0x07)
struct pc87360_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
@@ -276,13 +277,11 @@ int pc87360_detect(struct i2c_adapter *adapter, int address,
return -ENODEV;
}
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct pc87360_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) {
return -ENOMEM;
}
data = (struct pc87360_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
init_MUTEX(&data->lock);
new_client->data = data;
@@ -337,7 +336,7 @@ int pc87360_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR1:
release_region(address, PC87360_EXTENT);
kfree(new_client);
kfree(data);
return err;
}
@@ -354,7 +353,7 @@ static int pc87360_detach_client(struct i2c_client *client)
}
release_region(client->addr, PC87360_EXTENT);
kfree(client);
kfree(client->data);
return 0;
}
+5 -7
View File
@@ -48,6 +48,7 @@ SENSORS_INSMOD_1(pca9540);
/* Each client has this additional data */
struct pca9540_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -107,14 +108,12 @@ int pca9540_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct pca9540_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct pca9540_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct pca9540_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -159,7 +158,7 @@ int pca9540_detect(struct i2c_adapter *adapter, int address,
ERROR2:
i2c_detach_client(new_client);
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -176,10 +175,9 @@ static int pca9540_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
static void pca9540_update_client(struct i2c_client *client)
+5 -7
View File
@@ -65,6 +65,7 @@ SENSORS_INSMOD_2(pcf8574, pcf8574a);
/* Each client has this additional data */
struct pcf8574_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -146,14 +147,12 @@ int pcf8574_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct pcf8574_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct pcf8574_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct pcf8574_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -207,7 +206,7 @@ int pcf8574_detect(struct i2c_adapter *adapter, int address,
ERROR2:
i2c_detach_client(new_client);
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -225,10 +224,9 @@ static int pcf8574_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
/* Called when we have found a new PCF8574. */
+5 -6
View File
@@ -70,6 +70,7 @@ SENSORS_INSMOD_1(pcf8591);
struct pcf8591_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -183,14 +184,12 @@ int pcf8591_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct pcf8591_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct pcf8591_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct pcf8591_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -237,7 +236,7 @@ int pcf8591_detect(struct i2c_adapter *adapter, int address,
ERROR4:
i2c_detach_client(new_client);
ERROR3:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -255,7 +254,7 @@ static int pcf8591_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+6 -7
View File
@@ -121,6 +121,7 @@ SENSORS_INSMOD_1(saa1064);
/* Each client has this additional data */
struct saa1064_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -218,14 +219,12 @@ static int saa1064_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access i2c_smbus_read_byte */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct saa1064_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct saa1064_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct saa1064_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -279,8 +278,8 @@ static int saa1064_detect(struct i2c_adapter *adapter, int address,
ERROR4:
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
ERROR1:
kfree(data);
ERROR0:
return err;
}
@@ -299,7 +298,7 @@ int saa1064_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -170,6 +170,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
dynamically allocated, at the time when the new sis5595 client is
allocated. */
struct sis5595_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
@@ -386,13 +387,11 @@ int sis5595_detect(struct i2c_adapter *adapter, int address,
}
}
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct sis5595_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct sis5595_data), GFP_KERNEL))) {
return -ENOMEM;
}
data = (struct sis5595_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
init_MUTEX(&data->lock);
new_client->data = data;
@@ -445,7 +444,7 @@ int sis5595_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
release_region(address, SIS5595_EXTENT);
kfree(new_client);
kfree(data);
return err;
}
@@ -463,7 +462,7 @@ static int sis5595_detach_client(struct i2c_client *client)
}
release_region(client->addr, SIS5595_EXTENT);
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -72,6 +72,7 @@ SENSORS_INSMOD_1(smartbatt);
/* Each client has this additional data */
struct smartbatt_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -243,14 +244,12 @@ int smartbatt_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access smartbatt_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct smartbatt_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct smartbatt_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct smartbatt_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -297,7 +296,7 @@ int smartbatt_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -315,7 +314,7 @@ static int smartbatt_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -105,6 +105,7 @@ struct arp_device {
/* Each client has this additional data */
struct arp_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -190,13 +191,11 @@ int smbusarp_detect(struct i2c_adapter *adapter, int address,
I2C_FUNC_SMBUS_BLOCK_DATA_PEC)))
return(0);
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct arp_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct arp_data), GFP_KERNEL))) {
return(-ENOMEM);
}
data = (struct arp_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -231,7 +230,7 @@ int smbusarp_detect(struct i2c_adapter *adapter, int address,
ERROR4:
i2c_detach_client(new_client);
ERROR1:
kfree(new_client);
kfree(data);
return err;
}
@@ -248,7 +247,7 @@ static int smbusarp_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -121,6 +121,7 @@ static inline u8 MIN_TO_REG(long rpm, int div)
#define PWM_TO_REG(val) SENSORS_LIMIT((((val) * 645) / 1000), 0, 63)
struct smsc47m1_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
@@ -259,13 +260,11 @@ int smsc47m1_detect(struct i2c_adapter *adapter, int address,
superio_exit();
}
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct smsc47m1_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct smsc47m1_data), GFP_KERNEL))) {
return -ENOMEM;
}
data = (struct smsc47m1_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
init_MUTEX(&data->lock);
new_client->data = data;
@@ -298,7 +297,7 @@ int smsc47m1_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
release_region(address, SMSC_EXTENT);
kfree(new_client);
kfree(data);
return err;
}
@@ -316,7 +315,7 @@ static int smsc47m1_detach_client(struct i2c_client *client)
}
release_region(client->addr, SMSC_EXTENT);
kfree(client);
kfree(client->data);
return 0;
}
+5 -8
View File
@@ -73,6 +73,7 @@ SENSORS_INSMOD_1(thmc50);
/* Each client has this additional data */
struct thmc50_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -190,16 +191,12 @@ int thmc50_detect(struct i2c_adapter *adapter, int address,
/* OK. For now, we presume we have a valid client. We now create the
client structure, even though we cannot fill it completely yet.
But it allows us to access thmc50_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct thmc50_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct thmc50_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data =
(struct thmc50_data *) (((struct i2c_client *) new_client) +
1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -262,7 +259,7 @@ int thmc50_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -280,7 +277,7 @@ static int thmc50_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -334,6 +334,7 @@ static inline long TEMP_FROM_REG10(u16 val)
The structure is dynamically allocated, at the same time when a new
via686a client is allocated. */
struct via686a_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
@@ -516,14 +517,12 @@ int via686a_detect(struct i2c_adapter *adapter, int address,
return -ENODEV;
}
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct via686a_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct via686a_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
init_MUTEX(&data->lock);
new_client->data = data;
@@ -562,7 +561,7 @@ int via686a_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
release_region(address, VIA686A_EXTENT);
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -581,7 +580,7 @@ static int via686a_detach_client(struct i2c_client *client)
}
release_region(client->addr, VIA686A_EXTENT);
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -175,6 +175,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
#define FAN_FROM_REG(val,div) ((val)==0?0:(val)==255?0:1310720/((val)*(div)))
struct vt1211_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
@@ -409,13 +410,11 @@ int vt1211_detect(struct i2c_adapter *adapter, int address,
superio_outb(VT1211_ACT_REG, 1);
superio_exit();
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct vt1211_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct vt1211_data), GFP_KERNEL))) {
return -ENOMEM;
}
data = (struct vt1211_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
init_MUTEX(&data->lock);
new_client->data = data;
@@ -448,7 +447,7 @@ int vt1211_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
release_region(address, VT1211_EXTENT);
kfree(new_client);
kfree(data);
return err;
}
@@ -466,7 +465,7 @@ static int vt1211_detach_client(struct i2c_client *client)
}
release_region(client->addr, VT1211_EXTENT);
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -134,6 +134,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
#define FAN_FROM_REG(val,div) ((val)==0?0:(val)==255?0:1310720/((val)*(div)))
struct vt8231_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
@@ -373,14 +374,12 @@ int vt8231_detect(struct i2c_adapter *adapter, int address,
return -ENODEV;
}
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct vt8231_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct vt8231_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct vt8231_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
init_MUTEX(&data->lock);
new_client->data = data;
@@ -418,7 +417,7 @@ int vt8231_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
ERROR3:
release_region(address, VIA686A_EXTENT);
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -437,7 +436,7 @@ static int vt8231_detach_client(struct i2c_client *client)
}
release_region(client->addr, VIA686A_EXTENT);
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -277,6 +277,7 @@ static inline u8 DIV_TO_REG(long val)
data is pointed to by w83627hf_list[NR]->data. The structure itself is
dynamically allocated, at the same time when a new client is allocated. */
struct w83627hf_data {
struct i2c_client client;
struct semaphore lock;
int sysctl_id;
enum chips type;
@@ -660,14 +661,12 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access w83627hf_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct w83627hf_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) {
err = -ENOMEM;
goto ERROR0;
}
data = (struct w83627hf_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
init_MUTEX(&data->lock);
new_client->data = data;
@@ -733,7 +732,7 @@ int w83627hf_detect(struct i2c_adapter *adapter, int address,
ERROR3:
release_region(address, WINB_EXTENT);
ERROR1:
kfree(new_client);
kfree(data);
ERROR0:
return err;
}
@@ -752,7 +751,7 @@ static int w83627hf_detach_client(struct i2c_client *client)
}
release_region(client->addr, WINB_EXTENT);
kfree(client);
kfree(client->data);
return 0;
}
+9 -8
View File
@@ -101,6 +101,7 @@ static struct i2c_driver w83l785ts_driver = {
*/
struct w83l785ts_data {
struct i2c_client client;
int sysctl_id;
struct semaphore update_lock;
@@ -166,21 +167,21 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address,
return 0;
}
if (!(new_client = kmalloc(sizeof(struct i2c_client) + sizeof(struct w83l785ts_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct w83l785ts_data), GFP_KERNEL))) {
printk(KERN_ERR "w83l785ts.o: Out of memory in w83l785ts_detect "
"(new_client).\n");
return -ENOMEM;
}
/*
* The W83L785TS-specific data is placed right after the common I2C
* client data, and is pointed to by the data field from the I2C
* client data.
* The common I2C client data is placed right after the
* W83L785TS-specific. The W83L785TS-specific data is pointed to by the
* data field from the I2C client data.
*/
new_client = &data->client;
new_client->addr = address;
new_client->data = data = (struct w83l785ts_data *) (new_client + 1);
new_client->data = data;
new_client->adapter = adapter;
new_client->driver = &w83l785ts_driver;
new_client->flags = 0;
@@ -279,7 +280,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address,
ERROR2:
i2c_detach_client(new_client);
ERROR1:
kfree(new_client);
kfree(data);
return err;
}
@@ -294,7 +295,7 @@ static int w83l785ts_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;
}
+5 -6
View File
@@ -78,6 +78,7 @@ SENSORS_INSMOD_1(xeontemp);
/* Each client has this additional data */
struct xeontemp_data {
struct i2c_client client;
int sysctl_id;
enum chips type;
@@ -167,14 +168,12 @@ static int xeontemp_detect(struct i2c_adapter *adapter, int address,
client structure, even though we cannot fill it completely yet.
But it allows us to access xeontemp_{read,write}_value. */
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
sizeof(struct xeontemp_data),
GFP_KERNEL))) {
if (!(data = kmalloc(sizeof(struct xeontemp_data), GFP_KERNEL))) {
err = -ENOMEM;
goto error0;
}
data = (struct xeontemp_data *) (new_client + 1);
new_client = &data->client;
new_client->addr = address;
new_client->data = data;
new_client->adapter = adapter;
@@ -226,7 +225,7 @@ static int xeontemp_detect(struct i2c_adapter *adapter, int address,
i2c_detach_client(new_client);
error3:
error1:
kfree(new_client);
kfree(data);
error0:
return err;
}
@@ -253,7 +252,7 @@ static int xeontemp_detach_client(struct i2c_client *client)
return err;
}
kfree(client);
kfree(client->data);
return 0;