Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
firewire: core: fix sleep in atomic context due to driver core change

+20 -16
+7 -6
drivers/firewire/fw-card.c
··· 209 209 unsigned long flags; 210 210 int root_id, new_root_id, irm_id, gap_count, generation, grace, rcode; 211 211 bool do_reset = false; 212 + bool root_device_is_running; 213 + bool root_device_is_cmc; 212 214 __be32 lock_data[2]; 213 215 214 216 spin_lock_irqsave(&card->lock, flags); ··· 226 224 227 225 generation = card->generation; 228 226 root_device = root_node->data; 229 - if (root_device) 230 - fw_device_get(root_device); 227 + root_device_is_running = root_device && 228 + atomic_read(&root_device->state) == FW_DEVICE_RUNNING; 229 + root_device_is_cmc = root_device && root_device->cmc; 231 230 root_id = root_node->node_id; 232 231 grace = time_after(jiffies, card->reset_jiffies + DIV_ROUND_UP(HZ, 10)); 233 232 ··· 311 308 * config rom. In either case, pick another root. 312 309 */ 313 310 new_root_id = local_node->node_id; 314 - } else if (atomic_read(&root_device->state) != FW_DEVICE_RUNNING) { 311 + } else if (!root_device_is_running) { 315 312 /* 316 313 * If we haven't probed this device yet, bail out now 317 314 * and let's try again once that's done. 318 315 */ 319 316 spin_unlock_irqrestore(&card->lock, flags); 320 317 goto out; 321 - } else if (root_device->cmc) { 318 + } else if (root_device_is_cmc) { 322 319 /* 323 320 * FIXME: I suppose we should set the cmstr bit in the 324 321 * STATE_CLEAR register of this node, as described in ··· 365 362 fw_core_initiate_bus_reset(card, 1); 366 363 } 367 364 out: 368 - if (root_device) 369 - fw_device_put(root_device); 370 365 fw_node_put(root_node); 371 366 fw_node_put(local_node); 372 367 out_put_card:
+13 -10
drivers/firewire/fw-device.c
··· 159 159 160 160 /* 161 161 * Take the card lock so we don't set this to NULL while a 162 - * FW_NODE_UPDATED callback is being handled. 162 + * FW_NODE_UPDATED callback is being handled or while the 163 + * bus manager work looks at this node. 163 164 */ 164 165 spin_lock_irqsave(&card->lock, flags); 165 166 device->node->data = NULL; ··· 696 695 return; 697 696 } 698 697 699 - err = -ENOMEM; 698 + device_initialize(&device->device); 700 699 701 700 fw_device_get(device); 702 701 down_write(&fw_device_rwsem); 703 - if (idr_pre_get(&fw_device_idr, GFP_KERNEL)) 704 - err = idr_get_new(&fw_device_idr, device, &minor); 702 + err = idr_pre_get(&fw_device_idr, GFP_KERNEL) ? 703 + idr_get_new(&fw_device_idr, device, &minor) : 704 + -ENOMEM; 705 705 up_write(&fw_device_rwsem); 706 706 707 707 if (err < 0) ··· 913 911 914 912 /* 915 913 * Do minimal intialization of the device here, the 916 - * rest will happen in fw_device_init(). We need the 917 - * card and node so we can read the config rom and we 918 - * need to do device_initialize() now so 919 - * device_for_each_child() in FW_NODE_UPDATED is 920 - * doesn't freak out. 914 + * rest will happen in fw_device_init(). 915 + * 916 + * Attention: A lot of things, even fw_device_get(), 917 + * cannot be done before fw_device_init() finished! 918 + * You can basically just check device->state and 919 + * schedule work until then, but only while holding 920 + * card->lock. 921 921 */ 922 - device_initialize(&device->device); 923 922 atomic_set(&device->state, FW_DEVICE_INITIALIZING); 924 923 device->card = fw_card_get(card); 925 924 device->node = fw_node_get(node);