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>
This commit is contained in:
parent
3ce24d8d93
commit
8a89efd18a
@ -4,6 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
extern spinlock_t pnp_lock;
|
extern spinlock_t pnp_lock;
|
||||||
|
extern struct device_attribute pnp_interface_attrs[];
|
||||||
void *pnp_alloc(long size);
|
void *pnp_alloc(long size);
|
||||||
|
|
||||||
int pnp_register_protocol(struct pnp_protocol *protocol);
|
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);
|
|||||||
|
|
||||||
int pnp_add_device(struct pnp_dev *dev);
|
int pnp_add_device(struct pnp_dev *dev);
|
||||||
struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
|
struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id);
|
||||||
int pnp_interface_attach_device(struct pnp_dev *dev);
|
|
||||||
|
|
||||||
int pnp_add_card(struct pnp_card *card);
|
int pnp_add_card(struct pnp_card *card);
|
||||||
void pnp_remove_card(struct pnp_card *card);
|
void pnp_remove_card(struct pnp_card *card);
|
||||||
|
@ -159,21 +159,13 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid
|
|||||||
|
|
||||||
int __pnp_add_device(struct pnp_dev *dev)
|
int __pnp_add_device(struct pnp_dev *dev)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
pnp_fixup_device(dev);
|
pnp_fixup_device(dev);
|
||||||
dev->status = PNP_READY;
|
dev->status = PNP_READY;
|
||||||
spin_lock(&pnp_lock);
|
spin_lock(&pnp_lock);
|
||||||
list_add_tail(&dev->global_list, &pnp_global);
|
list_add_tail(&dev->global_list, &pnp_global);
|
||||||
list_add_tail(&dev->protocol_list, &dev->protocol->devices);
|
list_add_tail(&dev->protocol_list, &dev->protocol->devices);
|
||||||
spin_unlock(&pnp_lock);
|
spin_unlock(&pnp_lock);
|
||||||
|
return device_register(&dev->dev);
|
||||||
ret = device_register(&dev->dev);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
pnp_interface_attach_device(dev);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -206,6 +206,7 @@ struct bus_type pnp_bus_type = {
|
|||||||
.remove = pnp_device_remove,
|
.remove = pnp_device_remove,
|
||||||
.suspend = pnp_bus_suspend,
|
.suspend = pnp_bus_suspend,
|
||||||
.resume = pnp_bus_resume,
|
.resume = pnp_bus_resume,
|
||||||
|
.dev_attrs = pnp_interface_attrs,
|
||||||
};
|
};
|
||||||
|
|
||||||
int pnp_register_driver(struct pnp_driver *drv)
|
int pnp_register_driver(struct pnp_driver *drv)
|
||||||
|
@ -243,8 +243,6 @@ static ssize_t pnp_show_options(struct device *dmdev,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL);
|
|
||||||
|
|
||||||
static ssize_t pnp_show_current_resources(struct device *dmdev,
|
static ssize_t pnp_show_current_resources(struct device *dmdev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
@ -420,9 +418,6 @@ done:
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR,
|
|
||||||
pnp_show_current_resources, pnp_set_current_resources);
|
|
||||||
|
|
||||||
static ssize_t pnp_show_current_ids(struct device *dmdev,
|
static ssize_t pnp_show_current_ids(struct device *dmdev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
@ -437,27 +432,11 @@ static ssize_t pnp_show_current_ids(struct device *dmdev,
|
|||||||
return (str - buf);
|
return (str - buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL);
|
struct device_attribute pnp_interface_attrs[] = {
|
||||||
|
__ATTR(resources, S_IRUGO | S_IWUSR,
|
||||||
int pnp_interface_attach_device(struct pnp_dev *dev)
|
pnp_show_current_resources,
|
||||||
{
|
pnp_set_current_resources),
|
||||||
int rc = device_create_file(&dev->dev, &dev_attr_options);
|
__ATTR(options, S_IRUGO, pnp_show_options, NULL),
|
||||||
|
__ATTR(id, S_IRUGO, pnp_show_current_ids, NULL),
|
||||||
if (rc)
|
__ATTR_NULL,
|
||||||
goto err;
|
};
|
||||||
rc = device_create_file(&dev->dev, &dev_attr_resources);
|
|
||||||
if (rc)
|
|
||||||
goto err_opt;
|
|
||||||
rc = device_create_file(&dev->dev, &dev_attr_id);
|
|
||||||
if (rc)
|
|
||||||
goto err_res;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
err_res:
|
|
||||||
device_remove_file(&dev->dev, &dev_attr_resources);
|
|
||||||
err_opt:
|
|
||||||
device_remove_file(&dev->dev, &dev_attr_options);
|
|
||||||
err:
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user