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

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 <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/Zo9nofWJ1xg9MgKs@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+11 -10
+11 -10
drivers/input/keyboard/omap-keypad.c
··· 171 171 172 172 static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, omap_kp_enable_show, omap_kp_enable_store); 173 173 174 + static struct attribute *omap_kp_attrs[] = { 175 + &dev_attr_enable.attr, 176 + NULL 177 + }; 178 + ATTRIBUTE_GROUPS(omap_kp); 179 + 174 180 static int omap_kp_probe(struct platform_device *pdev) 175 181 { 176 182 struct omap_kp *omap_kp; ··· 220 214 kp_tasklet.data = (unsigned long) omap_kp; 221 215 tasklet_enable(&kp_tasklet); 222 216 223 - ret = device_create_file(&pdev->dev, &dev_attr_enable); 224 - if (ret < 0) 225 - goto err2; 226 - 227 217 /* setup input device */ 228 218 input_dev->name = "omap-keypad"; 229 219 input_dev->phys = "omap-keypad/input0"; ··· 237 235 pdata->rows, pdata->cols, 238 236 omap_kp->keymap, input_dev); 239 237 if (ret < 0) 240 - goto err3; 238 + goto err2; 241 239 242 240 ret = input_register_device(omap_kp->input); 243 241 if (ret < 0) { 244 242 printk(KERN_ERR "Unable to register omap-keypad input device\n"); 245 - goto err3; 243 + goto err2; 246 244 } 247 245 248 246 if (pdata->dbounce) ··· 254 252 if (omap_kp->irq >= 0) { 255 253 if (request_irq(omap_kp->irq, omap_kp_interrupt, 0, 256 254 "omap-keypad", omap_kp) < 0) 257 - goto err4; 255 + goto err3; 258 256 } 259 257 omap_writew(0, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); 260 258 261 259 return 0; 262 260 263 - err4: 261 + err3: 264 262 input_unregister_device(omap_kp->input); 265 263 input_dev = NULL; 266 - err3: 267 - device_remove_file(&pdev->dev, &dev_attr_enable); 268 264 err2: 269 265 kfree(omap_kp); 270 266 input_free_device(input_dev); ··· 293 293 .remove_new = omap_kp_remove, 294 294 .driver = { 295 295 .name = "omap-keypad", 296 + .dev_groups = omap_kp_groups, 296 297 }, 297 298 }; 298 299 module_platform_driver(omap_kp_driver);