mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
HID: i2c-hid: Use devm to allocate i2c_hid struct
Use devm here to save some lines and prepare for bulk regulator usage in this driver. Otherwise, when we devm bulk get regulators we'll free the containing i2c_hid structure and try to put regulator pointers from freed memory. Cc: Benjamin Tissoires <[email protected]> Cc: Hans de Goede <[email protected]> Cc: Andy Shevchenko <[email protected]> Cc: Dmitry Torokhov <[email protected]> Cc: Doug Anderson <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Acked-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
This commit is contained in:
parent
fdea70d26a
commit
d6f8389411
1 changed files with 3 additions and 6 deletions
|
|
@ -1002,18 +1002,18 @@ static int i2c_hid_probe(struct i2c_client *client,
|
|||
return client->irq;
|
||||
}
|
||||
|
||||
ihid = kzalloc(sizeof(struct i2c_hid), GFP_KERNEL);
|
||||
ihid = devm_kzalloc(&client->dev, sizeof(*ihid), GFP_KERNEL);
|
||||
if (!ihid)
|
||||
return -ENOMEM;
|
||||
|
||||
if (client->dev.of_node) {
|
||||
ret = i2c_hid_of_probe(client, &ihid->pdata);
|
||||
if (ret)
|
||||
goto err;
|
||||
return ret;
|
||||
} else if (!platform_data) {
|
||||
ret = i2c_hid_acpi_pdata(client, &ihid->pdata);
|
||||
if (ret)
|
||||
goto err;
|
||||
return ret;
|
||||
} else {
|
||||
ihid->pdata = *platform_data;
|
||||
}
|
||||
|
|
@ -1126,7 +1126,6 @@ err_regulator:
|
|||
|
||||
err:
|
||||
i2c_hid_free_buffers(ihid);
|
||||
kfree(ihid);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1150,8 +1149,6 @@ static int i2c_hid_remove(struct i2c_client *client)
|
|||
|
||||
regulator_disable(ihid->pdata.supply);
|
||||
|
||||
kfree(ihid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue