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