Commit 175cc9b7 authored by Michał Kępień's avatar Michał Kępień Committed by Darren Hart

platform/x86: intel-hid: use devm_input_allocate_device() for HID events input device

intel_hid_input_setup() is only called from the platform driver's .probe
callback.  Use the devm variant of input_allocate_device() for
allocating memory for the HID events input device in order to simplify
two error paths and get rid of intel_hid_input_destroy().
Signed-off-by: default avatarMichał Kępień <kernel@kempniu.pl>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-and-tested-by: default avatarAlex Hung <alex.hung@canonical.com>
parent 99a75e7b
...@@ -144,28 +144,20 @@ static int intel_hid_input_setup(struct platform_device *device) ...@@ -144,28 +144,20 @@ static int intel_hid_input_setup(struct platform_device *device)
struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); struct intel_hid_priv *priv = dev_get_drvdata(&device->dev);
int ret; int ret;
priv->input_dev = input_allocate_device(); priv->input_dev = devm_input_allocate_device(&device->dev);
if (!priv->input_dev) if (!priv->input_dev)
return -ENOMEM; return -ENOMEM;
ret = sparse_keymap_setup(priv->input_dev, intel_hid_keymap, NULL); ret = sparse_keymap_setup(priv->input_dev, intel_hid_keymap, NULL);
if (ret) if (ret)
goto err_free_device; return ret;
priv->input_dev->dev.parent = &device->dev; priv->input_dev->dev.parent = &device->dev;
priv->input_dev->name = "Intel HID events"; priv->input_dev->name = "Intel HID events";
priv->input_dev->id.bustype = BUS_HOST; priv->input_dev->id.bustype = BUS_HOST;
set_bit(KEY_RFKILL, priv->input_dev->keybit); set_bit(KEY_RFKILL, priv->input_dev->keybit);
ret = input_register_device(priv->input_dev); return input_register_device(priv->input_dev);
if (ret)
goto err_free_device;
return 0;
err_free_device:
input_free_device(priv->input_dev);
return ret;
} }
static int intel_button_array_input_setup(struct platform_device *device) static int intel_button_array_input_setup(struct platform_device *device)
...@@ -189,13 +181,6 @@ static int intel_button_array_input_setup(struct platform_device *device) ...@@ -189,13 +181,6 @@ static int intel_button_array_input_setup(struct platform_device *device)
return input_register_device(priv->array); return input_register_device(priv->array);
} }
static void intel_hid_input_destroy(struct platform_device *device)
{
struct intel_hid_priv *priv = dev_get_drvdata(&device->dev);
input_unregister_device(priv->input_dev);
}
static void notify_handler(acpi_handle handle, u32 event, void *context) static void notify_handler(acpi_handle handle, u32 event, void *context)
{ {
struct platform_device *device = context; struct platform_device *device = context;
...@@ -270,10 +255,8 @@ static int intel_hid_probe(struct platform_device *device) ...@@ -270,10 +255,8 @@ static int intel_hid_probe(struct platform_device *device)
ACPI_DEVICE_NOTIFY, ACPI_DEVICE_NOTIFY,
notify_handler, notify_handler,
device); device);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status))
err = -EBUSY; return -EBUSY;
goto err_remove_input;
}
err = intel_hid_set_enable(&device->dev, true); err = intel_hid_set_enable(&device->dev, true);
if (err) if (err)
...@@ -294,9 +277,6 @@ static int intel_hid_probe(struct platform_device *device) ...@@ -294,9 +277,6 @@ static int intel_hid_probe(struct platform_device *device)
err_remove_notify: err_remove_notify:
acpi_remove_notify_handler(handle, ACPI_DEVICE_NOTIFY, notify_handler); acpi_remove_notify_handler(handle, ACPI_DEVICE_NOTIFY, notify_handler);
err_remove_input:
intel_hid_input_destroy(device);
return err; return err;
} }
...@@ -305,7 +285,6 @@ static int intel_hid_remove(struct platform_device *device) ...@@ -305,7 +285,6 @@ static int intel_hid_remove(struct platform_device *device)
acpi_handle handle = ACPI_HANDLE(&device->dev); acpi_handle handle = ACPI_HANDLE(&device->dev);
acpi_remove_notify_handler(handle, ACPI_DEVICE_NOTIFY, notify_handler); acpi_remove_notify_handler(handle, ACPI_DEVICE_NOTIFY, notify_handler);
intel_hid_input_destroy(device);
intel_hid_set_enable(&device->dev, false); intel_hid_set_enable(&device->dev, false);
intel_button_array_enable(&device->dev, false); intel_button_array_enable(&device->dev, false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment