# Re: \[PATCH 8/12\] neo1973: button input device driver

- From: Dmitry Torokhov \<dmitry.torokhov@gmail.com\>
- Date: 2008-01-03 17:05:04 
- List: linux-input
- Page: https://ratatoskr.run/linux-input/2008/01/8909321
- Thread: https://ratatoskr.run/linux-input/2007/12/8909308/t.md

```text
Hi Harald,

Sorry for the slow response.

On Dec 18, 2007 6:08 AM, Harald Welte [ref] wrote:
> +
> +       input_dev->name = "Neo1973 Buttons";
> +       input_dev->phys = "neo1973kbd/input0";
> +       input_dev->id.bustype = BUS_HOST;
> +       input_dev->id.vendor = 0x0001;
> +       input_dev->id.product = 0x0001;
> +       input_dev->id.version = 0x0100;
> +       input_dev->cdev.dev = &pdev->dev;

Please use input_dev->dev.parent instead of cdev as it is going away.

> +       input_dev->private = neo1973kbd;

Please use input_set_drvdata() instead of accessing private directly.

> +out_aux:
> +       input_unregister_device(neo1973kbd->input);

Add neo1973kbd->input = NULL here, otherwise we'll end up doing
input_free_device after input_unregister_device which is no good
(unregister will free the device if it is the last reference).

> +out_register:
> +       input_free_device(neo1973kbd->input);
> +       platform_set_drvdata(pdev, NULL);
> +       kfree(neo1973kbd);
> +
> +       return -ENODEV;
> +}
> +
> +static int neo1973kbd_remove(struct platform_device *pdev)
> +{
> +       struct neo1973kbd *neo1973kbd = platform_get_drvdata(pdev);
> +
> +       free_irq(s3c2410_gpio_getirq(pdev->resource[2].start), neo1973kbd);
> +       free_irq(s3c2410_gpio_getirq(pdev->resource[1].start), neo1973kbd);
> +       free_irq(s3c2410_gpio_getirq(pdev->resource[0].start), neo1973kbd);
> +
> +       input_unregister_device(neo1973kbd->input);
> +       input_free_device(neo1973kbd->input);

Same here, input_free_device() is harmful here.

-- 
Dmitry
```
