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