aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-12-06 23:35:33 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-07 11:39:31 -0500
commitbfc7ee207078e8ca51264355805e6f56b485be4b (patch)
treefe06871e1a6e83ed13b50aa2cef827a6f10b0ade /drivers/pnp
parent3889b26bebd3e3cf5a3b95da683bab2f6462133d (diff)
[PATCH] PNP: handle sysfs errors
Signed-off-by: Jeff Garzik <jeff@garzik.org> Cc: Adam Belay <ambx1@neo.rr.com> Cc: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/pnp')
-rw-r--r--drivers/pnp/card.c30
-rw-r--r--drivers/pnp/interface.c17
2 files changed, 35 insertions, 12 deletions
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 227600cd6360..91c047a7e635 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -164,9 +164,17 @@ static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL);
164 164
165static int pnp_interface_attach_card(struct pnp_card *card) 165static int pnp_interface_attach_card(struct pnp_card *card)
166{ 166{
167 device_create_file(&card->dev,&dev_attr_name); 167 int rc = device_create_file(&card->dev,&dev_attr_name);
168 device_create_file(&card->dev,&dev_attr_card_id); 168 if (rc) return rc;
169
170 rc = device_create_file(&card->dev,&dev_attr_card_id);
171 if (rc) goto err_name;
172
169 return 0; 173 return 0;
174
175err_name:
176 device_remove_file(&card->dev,&dev_attr_name);
177 return rc;
170} 178}
171 179
172/** 180/**
@@ -306,16 +314,20 @@ found:
306 down_write(&dev->dev.bus->subsys.rwsem); 314 down_write(&dev->dev.bus->subsys.rwsem);
307 dev->card_link = clink; 315 dev->card_link = clink;
308 dev->dev.driver = &drv->link.driver; 316 dev->dev.driver = &drv->link.driver;
309 if (pnp_bus_type.probe(&dev->dev)) { 317 if (pnp_bus_type.probe(&dev->dev))
310 dev->dev.driver = NULL; 318 goto err_out;
311 dev->card_link = NULL; 319 if (device_bind_driver(&dev->dev))
312 up_write(&dev->dev.bus->subsys.rwsem); 320 goto err_out;
313 return NULL; 321
314 }
315 device_bind_driver(&dev->dev);
316 up_write(&dev->dev.bus->subsys.rwsem); 322 up_write(&dev->dev.bus->subsys.rwsem);
317 323
318 return dev; 324 return dev;
325
326err_out:
327 dev->dev.driver = NULL;
328 dev->card_link = NULL;
329 up_write(&dev->dev.bus->subsys.rwsem);
330 return NULL;
319} 331}
320 332
321/** 333/**
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index 9d8b415eca79..ac9fcd499f3f 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -461,8 +461,19 @@ static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL);
461 461
462int pnp_interface_attach_device(struct pnp_dev *dev) 462int pnp_interface_attach_device(struct pnp_dev *dev)
463{ 463{
464 device_create_file(&dev->dev,&dev_attr_options); 464 int rc = device_create_file(&dev->dev,&dev_attr_options);
465 device_create_file(&dev->dev,&dev_attr_resources); 465 if (rc) goto err;
466 device_create_file(&dev->dev,&dev_attr_id); 466 rc = device_create_file(&dev->dev,&dev_attr_resources);
467 if (rc) goto err_opt;
468 rc = device_create_file(&dev->dev,&dev_attr_id);
469 if (rc) goto err_res;
470
467 return 0; 471 return 0;
472
473err_res:
474 device_remove_file(&dev->dev,&dev_attr_resources);
475err_opt:
476 device_remove_file(&dev->dev,&dev_attr_options);
477err:
478 return rc;
468} 479}