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

+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;
}