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.c90
1 files changed, 44 insertions, 46 deletions
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 7e05e994c1bb..7276a0d5520f 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -155,27 +155,6 @@ struct bus_type fw_bus_type = {
155}; 155};
156EXPORT_SYMBOL(fw_bus_type); 156EXPORT_SYMBOL(fw_bus_type);
157 157
158static void fw_device_release(struct device *dev)
159{
160 struct fw_device *device = fw_device(dev);
161 struct fw_card *card = device->card;
162 unsigned long flags;
163
164 /*
165 * Take the card lock so we don't set this to NULL while a
166 * FW_NODE_UPDATED callback is being handled or while the
167 * bus manager work looks at this node.
168 */
169 spin_lock_irqsave(&card->lock, flags);
170 device->node->data = NULL;
171 spin_unlock_irqrestore(&card->lock, flags);
172
173 fw_node_put(device->node);
174 kfree(device->config_rom);
175 kfree(device);
176 fw_card_put(card);
177}
178
179int fw_device_enable_phys_dma(struct fw_device *device) 158int fw_device_enable_phys_dma(struct fw_device *device)
180{ 159{
181 int generation = device->generation; 160 int generation = device->generation;
@@ -679,11 +658,53 @@ static void fw_device_shutdown(struct work_struct *work)
679 fw_device_put(device); 658 fw_device_put(device);
680} 659}
681 660
661static void fw_device_release(struct device *dev)
662{
663 struct fw_device *device = fw_device(dev);
664 struct fw_card *card = device->card;
665 unsigned long flags;
666
667 /*
668 * Take the card lock so we don't set this to NULL while a
669 * FW_NODE_UPDATED callback is being handled or while the
670 * bus manager work looks at this node.
671 */
672 spin_lock_irqsave(&card->lock, flags);
673 device->node->data = NULL;
674 spin_unlock_irqrestore(&card->lock, flags);
675
676 fw_node_put(device->node);
677 kfree(device->config_rom);
678 kfree(device);
679 fw_card_put(card);
680}
681
682static struct device_type fw_device_type = { 682static struct device_type fw_device_type = {
683 .release = fw_device_release, 683 .release = fw_device_release,
684}; 684};
685 685
686static void fw_device_update(struct work_struct *work); 686static int update_unit(struct device *dev, void *data)
687{
688 struct fw_unit *unit = fw_unit(dev);
689 struct fw_driver *driver = (struct fw_driver *)dev->driver;
690
691 if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) {
692 down(&dev->sem);
693 driver->update(unit);
694 up(&dev->sem);
695 }
696
697 return 0;
698}
699
700static void fw_device_update(struct work_struct *work)
701{
702 struct fw_device *device =
703 container_of(work, struct fw_device, work.work);
704
705 fw_device_cdev_update(device);
706 device_for_each_child(&device->device, NULL, update_unit);
707}
687 708
688/* 709/*
689 * If a device was pending for deletion because its node went away but its 710 * If a device was pending for deletion because its node went away but its
@@ -851,29 +872,6 @@ static void fw_device_init(struct work_struct *work)
851 put_device(&device->device); /* our reference */ 872 put_device(&device->device); /* our reference */
852} 873}
853 874
854static int update_unit(struct device *dev, void *data)
855{
856 struct fw_unit *unit = fw_unit(dev);
857 struct fw_driver *driver = (struct fw_driver *)dev->driver;
858
859 if (is_fw_unit(dev) && driver != NULL && driver->update != NULL) {
860 down(&dev->sem);
861 driver->update(unit);
862 up(&dev->sem);
863 }
864
865 return 0;
866}
867
868static void fw_device_update(struct work_struct *work)
869{
870 struct fw_device *device =
871 container_of(work, struct fw_device, work.work);
872
873 fw_device_cdev_update(device);
874 device_for_each_child(&device->device, NULL, update_unit);
875}
876
877enum { 875enum {
878 REREAD_BIB_ERROR, 876 REREAD_BIB_ERROR,
879 REREAD_BIB_GONE, 877 REREAD_BIB_GONE,