Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: soc_button_array - use platform_device_register_resndata()

The registration of gpio-keys device can be written much shorter
by using the platform_device_register_resndata() helper.

Signed-off-by: Enrico Weigelt <info@metux.net>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Enrico Weigelt and committed by
Dmitry Torokhov
53119e51 cfd8579d

+8 -14
+8 -14
drivers/input/misc/soc_button_array.c
··· 120 120 gpio_keys_pdata->nbuttons = n_buttons; 121 121 gpio_keys_pdata->rep = autorepeat; 122 122 123 - pd = platform_device_alloc("gpio-keys", PLATFORM_DEVID_AUTO); 124 - if (!pd) { 125 - error = -ENOMEM; 123 + pd = platform_device_register_resndata(&pdev->dev, "gpio-keys", 124 + PLATFORM_DEVID_AUTO, NULL, 0, 125 + gpio_keys_pdata, 126 + sizeof(*gpio_keys_pdata)); 127 + error = PTR_ERR_OR_ZERO(pd); 128 + if (error) { 129 + dev_err(&pdev->dev, 130 + "failed registering gpio-keys: %d\n", error); 126 131 goto err_free_mem; 127 132 } 128 133 129 - error = platform_device_add_data(pd, gpio_keys_pdata, 130 - sizeof(*gpio_keys_pdata)); 131 - if (error) 132 - goto err_free_pdev; 133 - 134 - error = platform_device_add(pd); 135 - if (error) 136 - goto err_free_pdev; 137 - 138 134 return pd; 139 135 140 - err_free_pdev: 141 - platform_device_put(pd); 142 136 err_free_mem: 143 137 devm_kfree(&pdev->dev, gpio_keys_pdata); 144 138 return ERR_PTR(error);