aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firewire/fw-device.c')
-rw-r--r--drivers/firewire/fw-device.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 71976571c807..7503b8d9abe5 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -550,6 +550,7 @@ static int shutdown_unit(struct device *device, void *data)
550 return 0; 550 return 0;
551} 551}
552 552
553static DECLARE_RWSEM(idr_rwsem);
553static DEFINE_IDR(fw_device_idr); 554static DEFINE_IDR(fw_device_idr);
554int fw_cdev_major; 555int fw_cdev_major;
555 556
@@ -557,9 +558,9 @@ struct fw_device *fw_device_from_devt(dev_t devt)
557{ 558{
558 struct fw_device *device; 559 struct fw_device *device;
559 560
560 down_read(&fw_bus_type.subsys.rwsem); 561 down_read(&idr_rwsem);
561 device = idr_find(&fw_device_idr, MINOR(devt)); 562 device = idr_find(&fw_device_idr, MINOR(devt));
562 up_read(&fw_bus_type.subsys.rwsem); 563 up_read(&idr_rwsem);
563 564
564 return device; 565 return device;
565} 566}
@@ -570,9 +571,9 @@ static void fw_device_shutdown(struct work_struct *work)
570 container_of(work, struct fw_device, work.work); 571 container_of(work, struct fw_device, work.work);
571 int minor = MINOR(device->device.devt); 572 int minor = MINOR(device->device.devt);
572 573
573 down_write(&fw_bus_type.subsys.rwsem); 574 down_write(&idr_rwsem);
574 idr_remove(&fw_device_idr, minor); 575 idr_remove(&fw_device_idr, minor);
575 up_write(&fw_bus_type.subsys.rwsem); 576 up_write(&idr_rwsem);
576 577
577 fw_device_cdev_remove(device); 578 fw_device_cdev_remove(device);
578 device_for_each_child(&device->device, NULL, shutdown_unit); 579 device_for_each_child(&device->device, NULL, shutdown_unit);
@@ -621,10 +622,10 @@ static void fw_device_init(struct work_struct *work)
621 } 622 }
622 623
623 err = -ENOMEM; 624 err = -ENOMEM;
624 down_write(&fw_bus_type.subsys.rwsem); 625 down_write(&idr_rwsem);
625 if (idr_pre_get(&fw_device_idr, GFP_KERNEL)) 626 if (idr_pre_get(&fw_device_idr, GFP_KERNEL))
626 err = idr_get_new(&fw_device_idr, device, &minor); 627 err = idr_get_new(&fw_device_idr, device, &minor);
627 up_write(&fw_bus_type.subsys.rwsem); 628 up_write(&idr_rwsem);
628 if (err < 0) 629 if (err < 0)
629 goto error; 630 goto error;
630 631
@@ -670,9 +671,9 @@ static void fw_device_init(struct work_struct *work)
670 return; 671 return;
671 672
672 error_with_cdev: 673 error_with_cdev:
673 down_write(&fw_bus_type.subsys.rwsem); 674 down_write(&idr_rwsem);
674 idr_remove(&fw_device_idr, minor); 675 idr_remove(&fw_device_idr, minor);
675 up_write(&fw_bus_type.subsys.rwsem); 676 up_write(&idr_rwsem);
676 error: 677 error:
677 put_device(&device->device); 678 put_device(&device->device);
678} 679}