mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-26 20:38:20 +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
+5
-6
@@ -223,6 +223,7 @@ extern inline u8 DIV_TO_REG(long val)
|
||||
dynamically allocated, at the same time when a new it87 client is
|
||||
allocated. */
|
||||
struct it87_data {
|
||||
struct i2c_client client;
|
||||
struct semaphore lock;
|
||||
int sysctl_id;
|
||||
enum chips type;
|
||||
@@ -498,14 +499,12 @@ int it87_detect(struct i2c_adapter *adapter, int address,
|
||||
client structure, even though we cannot fill it completely yet.
|
||||
But it allows us to access it87_{read,write}_value. */
|
||||
|
||||
if (!(new_client = kmalloc((sizeof(struct i2c_client)) +
|
||||
sizeof(struct it87_data),
|
||||
GFP_KERNEL))) {
|
||||
if (!(data = kmalloc(sizeof(struct it87_data), GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto ERROR0;
|
||||
}
|
||||
|
||||
data = (struct it87_data *) (new_client + 1);
|
||||
new_client = &data->client;
|
||||
if (is_isa)
|
||||
init_MUTEX(&data->lock);
|
||||
new_client->addr = address;
|
||||
@@ -594,7 +593,7 @@ int it87_detect(struct i2c_adapter *adapter, int address,
|
||||
if (is_isa)
|
||||
release_region(address, IT87_EXTENT);
|
||||
ERROR1:
|
||||
kfree(new_client);
|
||||
kfree(data);
|
||||
ERROR0:
|
||||
return err;
|
||||
}
|
||||
@@ -614,7 +613,7 @@ static int it87_detach_client(struct i2c_client *client)
|
||||
|
||||
if(i2c_is_isa_client(client))
|
||||
release_region(client->addr, IT87_EXTENT);
|
||||
kfree(client);
|
||||
kfree(client->data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user