aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/enclosure.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/enclosure.c')
-rw-r--r--drivers/misc/enclosure.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/misc/enclosure.c b/drivers/misc/enclosure.c
index 789d12128c24..850706a5e553 100644
--- a/drivers/misc/enclosure.c
+++ b/drivers/misc/enclosure.c
@@ -332,19 +332,25 @@ EXPORT_SYMBOL_GPL(enclosure_add_device);
332 * Returns zero on success or an error. 332 * Returns zero on success or an error.
333 * 333 *
334 */ 334 */
335int enclosure_remove_device(struct enclosure_device *edev, int component) 335int enclosure_remove_device(struct enclosure_device *edev, struct device *dev)
336{ 336{
337 struct enclosure_component *cdev; 337 struct enclosure_component *cdev;
338 int i;
338 339
339 if (!edev || component >= edev->components) 340 if (!edev || !dev)
340 return -EINVAL; 341 return -EINVAL;
341 342
342 cdev = &edev->component[component]; 343 for (i = 0; i < edev->components; i++) {
343 344 cdev = &edev->component[i];
344 device_del(&cdev->cdev); 345 if (cdev->dev == dev) {
345 put_device(cdev->dev); 346 enclosure_remove_links(cdev);
346 cdev->dev = NULL; 347 device_del(&cdev->cdev);
347 return device_add(&cdev->cdev); 348 put_device(dev);
349 cdev->dev = NULL;
350 return device_add(&cdev->cdev);
351 }
352 }
353 return -ENODEV;
348} 354}
349EXPORT_SYMBOL_GPL(enclosure_remove_device); 355EXPORT_SYMBOL_GPL(enclosure_remove_device);
350 356