diff options
author | Drew Moseley <dmoseley@mvista.com> | 2008-09-27 19:31:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-10-16 12:24:51 -0400 |
commit | 8a89efd18aa15bb832778baa4e6eee3857ecada4 (patch) | |
tree | 91b4fe321aecd787d995543bc49e894a3c123628 /drivers | |
parent | 3ce24d8d93f8f9617841d0c8416174da7ee1b042 (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pnp/base.h | 2 | ||||
-rw-r--r-- | drivers/pnp/core.c | 10 | ||||
-rw-r--r-- | drivers/pnp/driver.c | 1 | ||||
-rw-r--r-- | drivers/pnp/interface.c | 37 |
4 files changed, 11 insertions, 39 deletions
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index 9fd7bb9b7dce..3532984a9cab 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h | |||
@@ -4,6 +4,7 @@ | |||
4 | */ | 4 | */ |
5 | 5 | ||
6 | extern spinlock_t pnp_lock; | 6 | extern spinlock_t pnp_lock; |
7 | extern struct device_attribute pnp_interface_attrs[]; | ||
7 | void *pnp_alloc(long size); | 8 | void *pnp_alloc(long size); |
8 | 9 | ||
9 | int pnp_register_protocol(struct pnp_protocol *protocol); | 10 | int pnp_register_protocol(struct pnp_protocol *protocol); |
@@ -16,7 +17,6 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid); | |||
16 | 17 | ||
17 | int pnp_add_device(struct pnp_dev *dev); | 18 | int pnp_add_device(struct pnp_dev *dev); |
18 | struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); | 19 | struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); |
19 | int pnp_interface_attach_device(struct pnp_dev *dev); | ||
20 | 20 | ||
21 | int pnp_add_card(struct pnp_card *card); | 21 | int pnp_add_card(struct pnp_card *card); |
22 | void pnp_remove_card(struct pnp_card *card); | 22 | void pnp_remove_card(struct pnp_card *card); |
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index a411582bcd72..7d65da821229 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c | |||
@@ -159,21 +159,13 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid | |||
159 | 159 | ||
160 | int __pnp_add_device(struct pnp_dev *dev) | 160 | int __pnp_add_device(struct pnp_dev *dev) |
161 | { | 161 | { |
162 | int ret; | ||
163 | |||
164 | pnp_fixup_device(dev); | 162 | pnp_fixup_device(dev); |
165 | dev->status = PNP_READY; | 163 | dev->status = PNP_READY; |
166 | spin_lock(&pnp_lock); | 164 | spin_lock(&pnp_lock); |
167 | list_add_tail(&dev->global_list, &pnp_global); | 165 | list_add_tail(&dev->global_list, &pnp_global); |
168 | list_add_tail(&dev->protocol_list, &dev->protocol->devices); | 166 | list_add_tail(&dev->protocol_list, &dev->protocol->devices); |
169 | spin_unlock(&pnp_lock); | 167 | spin_unlock(&pnp_lock); |
170 | 168 | return device_register(&dev->dev); | |
171 | ret = device_register(&dev->dev); | ||
172 | if (ret) | ||
173 | return ret; | ||
174 | |||
175 | pnp_interface_attach_device(dev); | ||
176 | return 0; | ||
177 | } | 169 | } |
178 | 170 | ||
179 | /* | 171 | /* |
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c index d3f869ee1d92..e3f7e89c4dfb 100644 --- a/drivers/pnp/driver.c +++ b/drivers/pnp/driver.c | |||
@@ -206,6 +206,7 @@ struct bus_type pnp_bus_type = { | |||
206 | .remove = pnp_device_remove, | 206 | .remove = pnp_device_remove, |
207 | .suspend = pnp_bus_suspend, | 207 | .suspend = pnp_bus_suspend, |
208 | .resume = pnp_bus_resume, | 208 | .resume = pnp_bus_resume, |
209 | .dev_attrs = pnp_interface_attrs, | ||
209 | }; | 210 | }; |
210 | 211 | ||
211 | int pnp_register_driver(struct pnp_driver *drv) | 212 | int pnp_register_driver(struct pnp_driver *drv) |
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index a876ecf7028c..478a4a739c00 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c | |||
@@ -243,8 +243,6 @@ static ssize_t pnp_show_options(struct device *dmdev, | |||
243 | return ret; | 243 | return ret; |
244 | } | 244 | } |
245 | 245 | ||
246 | static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL); | ||
247 | |||
248 | static ssize_t pnp_show_current_resources(struct device *dmdev, | 246 | static ssize_t pnp_show_current_resources(struct device *dmdev, |
249 | struct device_attribute *attr, | 247 | struct device_attribute *attr, |
250 | char *buf) | 248 | char *buf) |
@@ -420,9 +418,6 @@ done: | |||
420 | return count; | 418 | return count; |
421 | } | 419 | } |
422 | 420 | ||
423 | static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR, | ||
424 | pnp_show_current_resources, pnp_set_current_resources); | ||
425 | |||
426 | static ssize_t pnp_show_current_ids(struct device *dmdev, | 421 | static ssize_t pnp_show_current_ids(struct device *dmdev, |
427 | struct device_attribute *attr, char *buf) | 422 | struct device_attribute *attr, char *buf) |
428 | { | 423 | { |
@@ -437,27 +432,11 @@ static ssize_t pnp_show_current_ids(struct device *dmdev, | |||
437 | return (str - buf); | 432 | return (str - buf); |
438 | } | 433 | } |
439 | 434 | ||
440 | static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL); | 435 | struct device_attribute pnp_interface_attrs[] = { |
441 | 436 | __ATTR(resources, S_IRUGO | S_IWUSR, | |
442 | int pnp_interface_attach_device(struct pnp_dev *dev) | 437 | pnp_show_current_resources, |
443 | { | 438 | pnp_set_current_resources), |
444 | int rc = device_create_file(&dev->dev, &dev_attr_options); | 439 | __ATTR(options, S_IRUGO, pnp_show_options, NULL), |
445 | 440 | __ATTR(id, S_IRUGO, pnp_show_current_ids, NULL), | |
446 | if (rc) | 441 | __ATTR_NULL, |
447 | goto err; | 442 | }; |
448 | rc = device_create_file(&dev->dev, &dev_attr_resources); | ||
449 | if (rc) | ||
450 | goto err_opt; | ||
451 | rc = device_create_file(&dev->dev, &dev_attr_id); | ||
452 | if (rc) | ||
453 | goto err_res; | ||
454 | |||
455 | return 0; | ||
456 | |||
457 | err_res: | ||
458 | device_remove_file(&dev->dev, &dev_attr_resources); | ||
459 | err_opt: | ||
460 | device_remove_file(&dev->dev, &dev_attr_options); | ||
461 | err: | ||
462 | return rc; | ||
463 | } | ||