mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-24 20:21:43 +00:00
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:
1 parent
8f4ce259b5
commit
239b3d0344
45 files changed
+260
-304
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user