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 -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. */