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

PNP: create device attributes via default device attributes

This creates the attributes before the uevent is sent.

Signed-off-by: Drew Moseley <dmoseley@mvista.com>
Acked-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Drew Moseley and committed by
Greg Kroah-Hartman
8a89efd1 3ce24d8d

+11 -39
+1 -1
drivers/pnp/base.h
··· 4 4 */ 5 5 6 6 extern spinlock_t pnp_lock; 7 + extern struct device_attribute pnp_interface_attrs[]; 7 8 void *pnp_alloc(long size); 8 9 9 10 int pnp_register_protocol(struct pnp_protocol *protocol); ··· 17 16 18 17 int pnp_add_device(struct pnp_dev *dev); 19 18 struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); 20 - int pnp_interface_attach_device(struct pnp_dev *dev); 21 19 22 20 int pnp_add_card(struct pnp_card *card); 23 21 void pnp_remove_card(struct pnp_card *card);
+1 -9
drivers/pnp/core.c
··· 159 159 160 160 int __pnp_add_device(struct pnp_dev *dev) 161 161 { 162 - int ret; 163 - 164 162 pnp_fixup_device(dev); 165 163 dev->status = PNP_READY; 166 164 spin_lock(&pnp_lock); 167 165 list_add_tail(&dev->global_list, &pnp_global); 168 166 list_add_tail(&dev->protocol_list, &dev->protocol->devices); 169 167 spin_unlock(&pnp_lock); 170 - 171 - ret = device_register(&dev->dev); 172 - if (ret) 173 - return ret; 174 - 175 - pnp_interface_attach_device(dev); 176 - return 0; 168 + return device_register(&dev->dev); 177 169 } 178 170 179 171 /*
+1
drivers/pnp/driver.c
··· 206 206 .remove = pnp_device_remove, 207 207 .suspend = pnp_bus_suspend, 208 208 .resume = pnp_bus_resume, 209 + .dev_attrs = pnp_interface_attrs, 209 210 }; 210 211 211 212 int pnp_register_driver(struct pnp_driver *drv)
+8 -29
drivers/pnp/interface.c
··· 243 243 return ret; 244 244 } 245 245 246 - static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL); 247 - 248 246 static ssize_t pnp_show_current_resources(struct device *dmdev, 249 247 struct device_attribute *attr, 250 248 char *buf) ··· 418 420 return count; 419 421 } 420 422 421 - static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR, 422 - pnp_show_current_resources, pnp_set_current_resources); 423 - 424 423 static ssize_t pnp_show_current_ids(struct device *dmdev, 425 424 struct device_attribute *attr, char *buf) 426 425 { ··· 432 437 return (str - buf); 433 438 } 434 439 435 - static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL); 436 - 437 - int pnp_interface_attach_device(struct pnp_dev *dev) 438 - { 439 - int rc = device_create_file(&dev->dev, &dev_attr_options); 440 - 441 - if (rc) 442 - goto err; 443 - rc = device_create_file(&dev->dev, &dev_attr_resources); 444 - if (rc) 445 - goto err_opt; 446 - rc = device_create_file(&dev->dev, &dev_attr_id); 447 - if (rc) 448 - goto err_res; 449 - 450 - return 0; 451 - 452 - err_res: 453 - device_remove_file(&dev->dev, &dev_attr_resources); 454 - err_opt: 455 - device_remove_file(&dev->dev, &dev_attr_options); 456 - err: 457 - return rc; 458 - } 440 + struct device_attribute pnp_interface_attrs[] = { 441 + __ATTR(resources, S_IRUGO | S_IWUSR, 442 + pnp_show_current_resources, 443 + pnp_set_current_resources), 444 + __ATTR(options, S_IRUGO, pnp_show_options, NULL), 445 + __ATTR(id, S_IRUGO, pnp_show_current_ids, NULL), 446 + __ATTR_NULL, 447 + };