Commit 2d7877d7 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: omap-keypad - use driver core to instantiate device attributes

Instead of manually creating driver-specific device attributes
set struct driver->dev_groups pointer to have the driver core
do it.

This also fixes issue with the attribute not being deleted on driver
unbind.
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/Zo9nofWJ1xg9MgKs@google.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent a122a6fd
...@@ -171,6 +171,12 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute ...@@ -171,6 +171,12 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, omap_kp_enable_show, omap_kp_enable_store); static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, omap_kp_enable_show, omap_kp_enable_store);
static struct attribute *omap_kp_attrs[] = {
&dev_attr_enable.attr,
NULL
};
ATTRIBUTE_GROUPS(omap_kp);
static int omap_kp_probe(struct platform_device *pdev) static int omap_kp_probe(struct platform_device *pdev)
{ {
struct omap_kp *omap_kp; struct omap_kp *omap_kp;
...@@ -214,10 +220,6 @@ static int omap_kp_probe(struct platform_device *pdev) ...@@ -214,10 +220,6 @@ static int omap_kp_probe(struct platform_device *pdev)
kp_tasklet.data = (unsigned long) omap_kp; kp_tasklet.data = (unsigned long) omap_kp;
tasklet_enable(&kp_tasklet); tasklet_enable(&kp_tasklet);
ret = device_create_file(&pdev->dev, &dev_attr_enable);
if (ret < 0)
goto err2;
/* setup input device */ /* setup input device */
input_dev->name = "omap-keypad"; input_dev->name = "omap-keypad";
input_dev->phys = "omap-keypad/input0"; input_dev->phys = "omap-keypad/input0";
...@@ -235,12 +237,12 @@ static int omap_kp_probe(struct platform_device *pdev) ...@@ -235,12 +237,12 @@ static int omap_kp_probe(struct platform_device *pdev)
pdata->rows, pdata->cols, pdata->rows, pdata->cols,
omap_kp->keymap, input_dev); omap_kp->keymap, input_dev);
if (ret < 0) if (ret < 0)
goto err3; goto err2;
ret = input_register_device(omap_kp->input); ret = input_register_device(omap_kp->input);
if (ret < 0) { if (ret < 0) {
printk(KERN_ERR "Unable to register omap-keypad input device\n"); printk(KERN_ERR "Unable to register omap-keypad input device\n");
goto err3; goto err2;
} }
if (pdata->dbounce) if (pdata->dbounce)
...@@ -252,17 +254,15 @@ static int omap_kp_probe(struct platform_device *pdev) ...@@ -252,17 +254,15 @@ static int omap_kp_probe(struct platform_device *pdev)
if (omap_kp->irq >= 0) { if (omap_kp->irq >= 0) {
if (request_irq(omap_kp->irq, omap_kp_interrupt, 0, if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
"omap-keypad", omap_kp) < 0) "omap-keypad", omap_kp) < 0)
goto err4; goto err3;
} }
omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
return 0; return 0;
err4: err3:
input_unregister_device(omap_kp->input); input_unregister_device(omap_kp->input);
input_dev = NULL; input_dev = NULL;
err3:
device_remove_file(&pdev->dev, &dev_attr_enable);
err2: err2:
kfree(omap_kp); kfree(omap_kp);
input_free_device(input_dev); input_free_device(input_dev);
...@@ -293,6 +293,7 @@ static struct platform_driver omap_kp_driver = { ...@@ -293,6 +293,7 @@ static struct platform_driver omap_kp_driver = {
.remove_new = omap_kp_remove, .remove_new = omap_kp_remove,
.driver = { .driver = {
.name = "omap-keypad", .name = "omap-keypad",
.dev_groups = omap_kp_groups,
}, },
}; };
module_platform_driver(omap_kp_driver); module_platform_driver(omap_kp_driver);
......
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