aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ehea
diff options
context:
space:
mode:
authorSebastien Dugue <sebastien.dugue@bull.net>2008-09-11 09:34:40 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-09-24 18:58:55 -0400
commit2eefbd63d0c85daa1317636474c226e236beba81 (patch)
tree2c108c03a261dbc38b77954e96365c2070005d66 /drivers/net/ehea
parentd100ba33f8d2c4dbb53b05f5ac49c39a0dd9dd76 (diff)
ehea: fix mutex and spinlock use
Looks like to me that the ehea_fw_handles.lock mutex and the ehea_bcmc_regs.lock spinlock are taken much longer than necessary and could as well be pushed inside the functions that need them (ehea_update_firmware_handles() and ehea_update_bcmc_registrations()) rather than at each callsite. Signed-off-by: Sebastien Dugue <sebastien.dugue@bull.net> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/ehea')
-rw-r--r--drivers/net/ehea/ehea_main.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index b70c5314f537..c765ec609462 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -219,9 +219,11 @@ static void ehea_update_firmware_handles(void)
219 } 219 }
220 220
221out_update: 221out_update:
222 mutex_lock(&ehea_fw_handles.lock);
222 kfree(ehea_fw_handles.arr); 223 kfree(ehea_fw_handles.arr);
223 ehea_fw_handles.arr = arr; 224 ehea_fw_handles.arr = arr;
224 ehea_fw_handles.num_entries = i; 225 ehea_fw_handles.num_entries = i;
226 mutex_unlock(&ehea_fw_handles.lock);
225} 227}
226 228
227static void ehea_update_bcmc_registrations(void) 229static void ehea_update_bcmc_registrations(void)
@@ -293,9 +295,11 @@ static void ehea_update_bcmc_registrations(void)
293 } 295 }
294 296
295out_update: 297out_update:
298 spin_lock(&ehea_bcmc_regs.lock);
296 kfree(ehea_bcmc_regs.arr); 299 kfree(ehea_bcmc_regs.arr);
297 ehea_bcmc_regs.arr = arr; 300 ehea_bcmc_regs.arr = arr;
298 ehea_bcmc_regs.num_entries = i; 301 ehea_bcmc_regs.num_entries = i;
302 spin_unlock(&ehea_bcmc_regs.lock);
299} 303}
300 304
301static struct net_device_stats *ehea_get_stats(struct net_device *dev) 305static struct net_device_stats *ehea_get_stats(struct net_device *dev)
@@ -1770,8 +1774,6 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
1770 1774
1771 memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); 1775 memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len);
1772 1776
1773 spin_lock(&ehea_bcmc_regs.lock);
1774
1775 /* Deregister old MAC in pHYP */ 1777 /* Deregister old MAC in pHYP */
1776 if (port->state == EHEA_PORT_UP) { 1778 if (port->state == EHEA_PORT_UP) {
1777 ret = ehea_broadcast_reg_helper(port, H_DEREG_BCMC); 1779 ret = ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
@@ -1792,7 +1794,6 @@ static int ehea_set_mac_addr(struct net_device *dev, void *sa)
1792 1794
1793out_upregs: 1795out_upregs:
1794 ehea_update_bcmc_registrations(); 1796 ehea_update_bcmc_registrations();
1795 spin_unlock(&ehea_bcmc_regs.lock);
1796out_free: 1797out_free:
1797 kfree(cb0); 1798 kfree(cb0);
1798out: 1799out:
@@ -1954,8 +1955,6 @@ static void ehea_set_multicast_list(struct net_device *dev)
1954 } 1955 }
1955 ehea_promiscuous(dev, 0); 1956 ehea_promiscuous(dev, 0);
1956 1957
1957 spin_lock(&ehea_bcmc_regs.lock);
1958
1959 if (dev->flags & IFF_ALLMULTI) { 1958 if (dev->flags & IFF_ALLMULTI) {
1960 ehea_allmulti(dev, 1); 1959 ehea_allmulti(dev, 1);
1961 goto out; 1960 goto out;
@@ -1985,7 +1984,6 @@ static void ehea_set_multicast_list(struct net_device *dev)
1985 } 1984 }
1986out: 1985out:
1987 ehea_update_bcmc_registrations(); 1986 ehea_update_bcmc_registrations();
1988 spin_unlock(&ehea_bcmc_regs.lock);
1989 return; 1987 return;
1990} 1988}
1991 1989
@@ -2466,8 +2464,6 @@ static int ehea_up(struct net_device *dev)
2466 if (port->state == EHEA_PORT_UP) 2464 if (port->state == EHEA_PORT_UP)
2467 return 0; 2465 return 0;
2468 2466
2469 mutex_lock(&ehea_fw_handles.lock);
2470
2471 ret = ehea_port_res_setup(port, port->num_def_qps, 2467 ret = ehea_port_res_setup(port, port->num_def_qps,
2472 port->num_add_tx_qps); 2468 port->num_add_tx_qps);
2473 if (ret) { 2469 if (ret) {
@@ -2504,8 +2500,6 @@ static int ehea_up(struct net_device *dev)
2504 } 2500 }
2505 } 2501 }
2506 2502
2507 spin_lock(&ehea_bcmc_regs.lock);
2508
2509 ret = ehea_broadcast_reg_helper(port, H_REG_BCMC); 2503 ret = ehea_broadcast_reg_helper(port, H_REG_BCMC);
2510 if (ret) { 2504 if (ret) {
2511 ret = -EIO; 2505 ret = -EIO;
@@ -2527,10 +2521,8 @@ out:
2527 ehea_info("Failed starting %s. ret=%i", dev->name, ret); 2521 ehea_info("Failed starting %s. ret=%i", dev->name, ret);
2528 2522
2529 ehea_update_bcmc_registrations(); 2523 ehea_update_bcmc_registrations();
2530 spin_unlock(&ehea_bcmc_regs.lock);
2531 2524
2532 ehea_update_firmware_handles(); 2525 ehea_update_firmware_handles();
2533 mutex_unlock(&ehea_fw_handles.lock);
2534 2526
2535 return ret; 2527 return ret;
2536} 2528}
@@ -2580,9 +2572,6 @@ static int ehea_down(struct net_device *dev)
2580 if (port->state == EHEA_PORT_DOWN) 2572 if (port->state == EHEA_PORT_DOWN)
2581 return 0; 2573 return 0;
2582 2574
2583 mutex_lock(&ehea_fw_handles.lock);
2584
2585 spin_lock(&ehea_bcmc_regs.lock);
2586 ehea_drop_multicast_list(dev); 2575 ehea_drop_multicast_list(dev);
2587 ehea_broadcast_reg_helper(port, H_DEREG_BCMC); 2576 ehea_broadcast_reg_helper(port, H_DEREG_BCMC);
2588 2577
@@ -2591,7 +2580,6 @@ static int ehea_down(struct net_device *dev)
2591 port->state = EHEA_PORT_DOWN; 2580 port->state = EHEA_PORT_DOWN;
2592 2581
2593 ehea_update_bcmc_registrations(); 2582 ehea_update_bcmc_registrations();
2594 spin_unlock(&ehea_bcmc_regs.lock);
2595 2583
2596 ret = ehea_clean_all_portres(port); 2584 ret = ehea_clean_all_portres(port);
2597 if (ret) 2585 if (ret)
@@ -2599,7 +2587,6 @@ static int ehea_down(struct net_device *dev)
2599 dev->name, ret); 2587 dev->name, ret);
2600 2588
2601 ehea_update_firmware_handles(); 2589 ehea_update_firmware_handles();
2602 mutex_unlock(&ehea_fw_handles.lock);
2603 2590
2604 return ret; 2591 return ret;
2605} 2592}
@@ -3378,7 +3365,6 @@ static int __devinit ehea_probe_adapter(struct of_device *dev,
3378 ehea_error("Invalid ibmebus device probed"); 3365 ehea_error("Invalid ibmebus device probed");
3379 return -EINVAL; 3366 return -EINVAL;
3380 } 3367 }
3381 mutex_lock(&ehea_fw_handles.lock);
3382 3368
3383 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL); 3369 adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
3384 if (!adapter) { 3370 if (!adapter) {
@@ -3462,7 +3448,6 @@ out_free_ad:
3462 3448
3463out: 3449out:
3464 ehea_update_firmware_handles(); 3450 ehea_update_firmware_handles();
3465 mutex_unlock(&ehea_fw_handles.lock);
3466 return ret; 3451 return ret;
3467} 3452}
3468 3453
@@ -3481,8 +3466,6 @@ static int __devexit ehea_remove(struct of_device *dev)
3481 3466
3482 flush_scheduled_work(); 3467 flush_scheduled_work();
3483 3468
3484 mutex_lock(&ehea_fw_handles.lock);
3485
3486 ibmebus_free_irq(adapter->neq->attr.ist1, adapter); 3469 ibmebus_free_irq(adapter->neq->attr.ist1, adapter);
3487 tasklet_kill(&adapter->neq_tasklet); 3470 tasklet_kill(&adapter->neq_tasklet);
3488 3471
@@ -3492,7 +3475,6 @@ static int __devexit ehea_remove(struct of_device *dev)
3492 kfree(adapter); 3475 kfree(adapter);
3493 3476
3494 ehea_update_firmware_handles(); 3477 ehea_update_firmware_handles();
3495 mutex_unlock(&ehea_fw_handles.lock);
3496 3478
3497 return 0; 3479 return 0;
3498} 3480}