mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2025-12-10 08:44:39 +01:00
gpio-button-hotplug: use devm_kmemdup_array
Eliminates a manual memcpy. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://github.com/openwrt/openwrt/pull/19932 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
parent
5b263f3360
commit
616b0cebe7
1 changed files with 1 additions and 2 deletions
|
|
@ -463,13 +463,12 @@ static int gpio_keys_button_probe(struct platform_device *pdev,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
buttons = devm_kzalloc(dev, pdata->nbuttons * sizeof(struct gpio_keys_button),
|
||||
buttons = devm_kmemdup_array(dev, pdata->buttons, pdata->nbuttons, sizeof(struct gpio_keys_button),
|
||||
GFP_KERNEL);
|
||||
if (!buttons) {
|
||||
dev_err(dev, "no memory for button data\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
memcpy(buttons, pdata->buttons, pdata->nbuttons * sizeof(struct gpio_keys_button));
|
||||
|
||||
bdev = devm_kzalloc(dev, sizeof(struct gpio_keys_button_dev) +
|
||||
pdata->nbuttons * sizeof(struct gpio_keys_button_data),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue