mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-29 21:08:19 +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
@@ -193,6 +193,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
|
||||
* mtp008 client is allocated.
|
||||
*/
|
||||
struct mtp008_data {
|
||||
struct i2c_client client;
|
||||
int sysctl_id;
|
||||
enum chips type;
|
||||
|
||||
@@ -402,13 +403,12 @@ int mtp008_detect(struct i2c_adapter *adapter, int address,
|
||||
* structure, even though we cannot fill it completely yet. But it
|
||||
* allows us to use mtp008_(read|write)_value().
|
||||
*/
|
||||
if (!(new_client = kmalloc(sizeof(struct i2c_client) +
|
||||
sizeof(struct mtp008_data),
|
||||
GFP_KERNEL))) {
|
||||
if (!(data = kmalloc(sizeof(struct mtp008_data), GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
data = (struct mtp008_data *) (new_client + 1);
|
||||
|
||||
new_client = &data->client;
|
||||
new_client->addr = address;
|
||||
new_client->data = data;
|
||||
new_client->adapter = adapter;
|
||||
@@ -463,7 +463,7 @@ int mtp008_detect(struct i2c_adapter *adapter, int address,
|
||||
ERROR2:
|
||||
i2c_detach_client(new_client);
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
kfree(data);
|
||||
|
||||
ERROR0:
|
||||
return err;
|
||||
@@ -481,7 +481,7 @@ static int mtp008_detach_client(struct i2c_client *client)
|
||||
"client not detached.\n");
|
||||
return err;
|
||||
}
|
||||
kfree(client);
|
||||
kfree(client->data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user