Skip to content

Commit 2d7877d

Browse files
committed
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: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent a122a6f commit 2d7877d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

drivers/input/keyboard/omap-keypad.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ static ssize_t omap_kp_enable_store(struct device *dev, struct device_attribute
171171

172172
static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, omap_kp_enable_show, omap_kp_enable_store);
173173

174+
static struct attribute *omap_kp_attrs[] = {
175+
&dev_attr_enable.attr,
176+
NULL
177+
};
178+
ATTRIBUTE_GROUPS(omap_kp);
179+
174180
static int omap_kp_probe(struct platform_device *pdev)
175181
{
176182
struct omap_kp *omap_kp;
@@ -214,10 +220,6 @@ static int omap_kp_probe(struct platform_device *pdev)
214220
kp_tasklet.data = (unsigned long) omap_kp;
215221
tasklet_enable(&kp_tasklet);
216222

217-
ret = device_create_file(&pdev->dev, &dev_attr_enable);
218-
if (ret < 0)
219-
goto err2;
220-
221223
/* setup input device */
222224
input_dev->name = "omap-keypad";
223225
input_dev->phys = "omap-keypad/input0";
@@ -235,12 +237,12 @@ static int omap_kp_probe(struct platform_device *pdev)
235237
pdata->rows, pdata->cols,
236238
omap_kp->keymap, input_dev);
237239
if (ret < 0)
238-
goto err3;
240+
goto err2;
239241

240242
ret = input_register_device(omap_kp->input);
241243
if (ret < 0) {
242244
printk(KERN_ERR "Unable to register omap-keypad input device\n");
243-
goto err3;
245+
goto err2;
244246
}
245247

246248
if (pdata->dbounce)
@@ -252,17 +254,15 @@ static int omap_kp_probe(struct platform_device *pdev)
252254
if (omap_kp->irq >= 0) {
253255
if (request_irq(omap_kp->irq, omap_kp_interrupt, 0,
254256
"omap-keypad", omap_kp) < 0)
255-
goto err4;
257+
goto err3;
256258
}
257259
omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT);
258260

259261
return 0;
260262

261-
err4:
263+
err3:
262264
input_unregister_device(omap_kp->input);
263265
input_dev = NULL;
264-
err3:
265-
device_remove_file(&pdev->dev, &dev_attr_enable);
266266
err2:
267267
kfree(omap_kp);
268268
input_free_device(input_dev);
@@ -293,6 +293,7 @@ static struct platform_driver omap_kp_driver = {
293293
.remove_new = omap_kp_remove,
294294
.driver = {
295295
.name = "omap-keypad",
296+
.dev_groups = omap_kp_groups,
296297
},
297298
};
298299
module_platform_driver(omap_kp_driver);

0 commit comments

Comments
 (0)