Skip to content

Commit 8a89efd

Browse files
Drew Moseleygregkh
authored andcommitted
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>
1 parent 3ce24d8 commit 8a89efd

4 files changed

Lines changed: 11 additions & 39 deletions

File tree

‎drivers/pnp/base.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
extern spinlock_t pnp_lock;
7+
extern struct device_attribute pnp_interface_attrs[];
78
void *pnp_alloc(long size);
89

910
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);
1617

1718
int pnp_add_device(struct pnp_dev *dev);
1819
struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
19-
int pnp_interface_attach_device(struct pnp_dev *dev);
2020

2121
int pnp_add_card(struct pnp_card *card);
2222
void pnp_remove_card(struct pnp_card *card);

‎drivers/pnp/core.c‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,21 +159,13 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid
159159

160160
int __pnp_add_device(struct pnp_dev *dev)
161161
{
162-
int ret;
163-
164162
pnp_fixup_device(dev);
165163
dev->status = PNP_READY;
166164
spin_lock(&pnp_lock);
167165
list_add_tail(&dev->global_list, &pnp_global);
168166
list_add_tail(&dev->protocol_list, &dev->protocol->devices);
169167
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);
177169
}
178170

179171
/*

‎drivers/pnp/driver.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ struct bus_type pnp_bus_type = {
206206
.remove = pnp_device_remove,
207207
.suspend = pnp_bus_suspend,
208208
.resume = pnp_bus_resume,
209+
.dev_attrs = pnp_interface_attrs,
209210
};
210211

211212
int pnp_register_driver(struct pnp_driver *drv)

‎drivers/pnp/interface.c‎

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ static ssize_t pnp_show_options(struct device *dmdev,
243243
return ret;
244244
}
245245

246-
static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL);
247-
248246
static ssize_t pnp_show_current_resources(struct device *dmdev,
249247
struct device_attribute *attr,
250248
char *buf)
@@ -420,9 +418,6 @@ static ssize_t pnp_set_current_resources(struct device *dmdev,
420418
return count;
421419
}
422420

423-
static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR,
424-
pnp_show_current_resources, pnp_set_current_resources);
425-
426421
static ssize_t pnp_show_current_ids(struct device *dmdev,
427422
struct device_attribute *attr, char *buf)
428423
{
@@ -437,27 +432,11 @@ static ssize_t pnp_show_current_ids(struct device *dmdev,
437432
return (str - buf);
438433
}
439434

440-
static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL);
441-
442-
int pnp_interface_attach_device(struct pnp_dev *dev)
443-
{
444-
int rc = device_create_file(&dev->dev, &dev_attr_options);
445-
446-
if (rc)
447-
goto err;
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-
}
435+
struct device_attribute pnp_interface_attrs[] = {
436+
__ATTR(resources, S_IRUGO | S_IWUSR,
437+
pnp_show_current_resources,
438+
pnp_set_current_resources),
439+
__ATTR(options, S_IRUGO, pnp_show_options, NULL),
440+
__ATTR(id, S_IRUGO, pnp_show_current_ids, NULL),
441+
__ATTR_NULL,
442+
};

0 commit comments

Comments
 (0)