Commit bfc7ee20 authored by Jeff Garzik's avatar Jeff Garzik Committed by Linus Torvalds

[PATCH] PNP: handle sysfs errors

Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
Cc: Adam Belay <ambx1@neo.rr.com>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 3889b26b
...@@ -164,9 +164,17 @@ static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL); ...@@ -164,9 +164,17 @@ static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL);
static int pnp_interface_attach_card(struct pnp_card *card) static int pnp_interface_attach_card(struct pnp_card *card)
{ {
device_create_file(&card->dev,&dev_attr_name); int rc = device_create_file(&card->dev,&dev_attr_name);
device_create_file(&card->dev,&dev_attr_card_id); if (rc) return rc;
rc = device_create_file(&card->dev,&dev_attr_card_id);
if (rc) goto err_name;
return 0; return 0;
err_name:
device_remove_file(&card->dev,&dev_attr_name);
return rc;
} }
/** /**
...@@ -306,16 +314,20 @@ struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char ...@@ -306,16 +314,20 @@ struct pnp_dev * pnp_request_card_device(struct pnp_card_link *clink, const char
down_write(&dev->dev.bus->subsys.rwsem); down_write(&dev->dev.bus->subsys.rwsem);
dev->card_link = clink; dev->card_link = clink;
dev->dev.driver = &drv->link.driver; dev->dev.driver = &drv->link.driver;
if (pnp_bus_type.probe(&dev->dev)) { if (pnp_bus_type.probe(&dev->dev))
goto err_out;
if (device_bind_driver(&dev->dev))
goto err_out;
up_write(&dev->dev.bus->subsys.rwsem);
return dev;
err_out:
dev->dev.driver = NULL; dev->dev.driver = NULL;
dev->card_link = NULL; dev->card_link = NULL;
up_write(&dev->dev.bus->subsys.rwsem); up_write(&dev->dev.bus->subsys.rwsem);
return NULL; return NULL;
}
device_bind_driver(&dev->dev);
up_write(&dev->dev.bus->subsys.rwsem);
return dev;
} }
/** /**
......
...@@ -461,8 +461,19 @@ static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL); ...@@ -461,8 +461,19 @@ static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL);
int pnp_interface_attach_device(struct pnp_dev *dev) int pnp_interface_attach_device(struct pnp_dev *dev)
{ {
device_create_file(&dev->dev,&dev_attr_options); int rc = device_create_file(&dev->dev,&dev_attr_options);
device_create_file(&dev->dev,&dev_attr_resources); if (rc) goto err;
device_create_file(&dev->dev,&dev_attr_id); 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; 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;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment