Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] PCI hotplug: convert semaphores to mutex

semaphore to mutex conversion.

the conversion was generated via scripts, and the result was validated
automatically via a script as well.

build tested with allyesconfig.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Ingo Molnar and committed by
Greg Kroah-Hartman
6aa4cdd0 c408a379

+143 -137
+2 -1
drivers/pci/hotplug/acpiphp.h
··· 37 37 38 38 #include <linux/acpi.h> 39 39 #include <linux/kobject.h> /* for KOBJ_NAME_LEN */ 40 + #include <linux/mutex.h> 40 41 #include "pci_hotplug.h" 41 42 42 43 #define dbg(format, arg...) \ ··· 119 118 struct acpiphp_bridge *bridge; /* parent */ 120 119 struct list_head funcs; /* one slot may have different 121 120 objects (i.e. for each function) */ 122 - struct semaphore crit_sect; 121 + struct mutex crit_sect; 123 122 124 123 u32 id; /* slot id (serial #) for hotplug core */ 125 124 u8 device; /* pci device# */
+6 -6
drivers/pci/hotplug/acpiphp_glue.c
··· 46 46 #include <linux/kernel.h> 47 47 #include <linux/pci.h> 48 48 #include <linux/smp_lock.h> 49 - #include <asm/semaphore.h> 49 + #include <linux/mutex.h> 50 50 51 51 #include "../pci.h" 52 52 #include "pci_hotplug.h" ··· 188 188 slot->device = device; 189 189 slot->sun = sun; 190 190 INIT_LIST_HEAD(&slot->funcs); 191 - init_MUTEX(&slot->crit_sect); 191 + mutex_init(&slot->crit_sect); 192 192 193 193 slot->next = bridge->slots; 194 194 bridge->slots = slot; ··· 1401 1401 { 1402 1402 int retval; 1403 1403 1404 - down(&slot->crit_sect); 1404 + mutex_lock(&slot->crit_sect); 1405 1405 1406 1406 /* wake up all functions */ 1407 1407 retval = power_on_slot(slot); ··· 1413 1413 retval = enable_device(slot); 1414 1414 1415 1415 err_exit: 1416 - up(&slot->crit_sect); 1416 + mutex_unlock(&slot->crit_sect); 1417 1417 return retval; 1418 1418 } 1419 1419 ··· 1424 1424 { 1425 1425 int retval = 0; 1426 1426 1427 - down(&slot->crit_sect); 1427 + mutex_lock(&slot->crit_sect); 1428 1428 1429 1429 /* unconfigure all functions */ 1430 1430 retval = disable_device(slot); ··· 1437 1437 goto err_exit; 1438 1438 1439 1439 err_exit: 1440 - up(&slot->crit_sect); 1440 + mutex_unlock(&slot->crit_sect); 1441 1441 return retval; 1442 1442 } 1443 1443
+2 -1
drivers/pci/hotplug/cpqphp.h
··· 32 32 #include <linux/interrupt.h> 33 33 #include <asm/io.h> /* for read? and write? functions */ 34 34 #include <linux/delay.h> /* for delays */ 35 + #include <linux/mutex.h> 35 36 36 37 #define MY_NAME "cpqphp" 37 38 ··· 287 286 struct controller { 288 287 struct controller *next; 289 288 u32 ctrl_int_comp; 290 - struct semaphore crit_sect; /* critical section semaphore */ 289 + struct mutex crit_sect; /* critical section mutex */ 291 290 void __iomem *hpc_reg; /* cookie for our pci controller location */ 292 291 struct pci_resource *mem_head; 293 292 struct pci_resource *p_mem_head;
+7 -7
drivers/pci/hotplug/cpqphp_core.c
··· 599 599 hp_slot = func->device - ctrl->slot_device_offset; 600 600 601 601 // Wait for exclusive access to hardware 602 - down(&ctrl->crit_sect); 602 + mutex_lock(&ctrl->crit_sect); 603 603 604 604 if (status == 1) { 605 605 amber_LED_on (ctrl, hp_slot); ··· 607 607 amber_LED_off (ctrl, hp_slot); 608 608 } else { 609 609 // Done with exclusive hardware access 610 - up(&ctrl->crit_sect); 610 + mutex_unlock(&ctrl->crit_sect); 611 611 return(1); 612 612 } 613 613 ··· 617 617 wait_for_ctrl_irq (ctrl); 618 618 619 619 // Done with exclusive hardware access 620 - up(&ctrl->crit_sect); 620 + mutex_unlock(&ctrl->crit_sect); 621 621 622 622 return(0); 623 623 } ··· 1084 1084 dbg("bus device function rev: %d %d %d %d\n", ctrl->bus, 1085 1085 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), ctrl->rev); 1086 1086 1087 - init_MUTEX(&ctrl->crit_sect); 1087 + mutex_init(&ctrl->crit_sect); 1088 1088 init_waitqueue_head(&ctrl->queue); 1089 1089 1090 1090 /* initialize our threads if they haven't already been started up */ ··· 1223 1223 1224 1224 // turn off empty slots here unless command line option "ON" set 1225 1225 // Wait for exclusive access to hardware 1226 - down(&ctrl->crit_sect); 1226 + mutex_lock(&ctrl->crit_sect); 1227 1227 1228 1228 num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F; 1229 1229 ··· 1270 1270 rc = init_SERR(ctrl); 1271 1271 if (rc) { 1272 1272 err("init_SERR failed\n"); 1273 - up(&ctrl->crit_sect); 1273 + mutex_unlock(&ctrl->crit_sect); 1274 1274 goto err_free_irq; 1275 1275 } 1276 1276 1277 1277 // Done with exclusive hardware access 1278 - up(&ctrl->crit_sect); 1278 + mutex_unlock(&ctrl->crit_sect); 1279 1279 1280 1280 cpqhp_create_debugfs_files(ctrl); 1281 1281
+28 -28
drivers/pci/hotplug/cpqphp_ctrl.c
··· 1299 1299 **********************************/ 1300 1300 rc = CARD_FUNCTIONING; 1301 1301 } else { 1302 - down(&ctrl->crit_sect); 1302 + mutex_lock(&ctrl->crit_sect); 1303 1303 1304 1304 /* turn on board without attaching to the bus */ 1305 1305 enable_slot_power (ctrl, hp_slot); ··· 1333 1333 /* Wait for SOBS to be unset */ 1334 1334 wait_for_ctrl_irq (ctrl); 1335 1335 1336 - up(&ctrl->crit_sect); 1336 + mutex_unlock(&ctrl->crit_sect); 1337 1337 1338 1338 if (rc) 1339 1339 return rc; 1340 1340 1341 - down(&ctrl->crit_sect); 1341 + mutex_lock(&ctrl->crit_sect); 1342 1342 1343 1343 slot_enable (ctrl, hp_slot); 1344 1344 green_LED_blink (ctrl, hp_slot); ··· 1350 1350 /* Wait for SOBS to be unset */ 1351 1351 wait_for_ctrl_irq (ctrl); 1352 1352 1353 - up(&ctrl->crit_sect); 1353 + mutex_unlock(&ctrl->crit_sect); 1354 1354 1355 1355 /* Wait for ~1 second because of hot plug spec */ 1356 1356 long_delay(1*HZ); ··· 1375 1375 * called for the "base" bus/dev/func of an 1376 1376 * adapter. */ 1377 1377 1378 - down(&ctrl->crit_sect); 1378 + mutex_lock(&ctrl->crit_sect); 1379 1379 1380 1380 amber_LED_on (ctrl, hp_slot); 1381 1381 green_LED_off (ctrl, hp_slot); ··· 1386 1386 /* Wait for SOBS to be unset */ 1387 1387 wait_for_ctrl_irq (ctrl); 1388 1388 1389 - up(&ctrl->crit_sect); 1389 + mutex_unlock(&ctrl->crit_sect); 1390 1390 1391 1391 if (rc) 1392 1392 return rc; ··· 1410 1410 * called for the "base" bus/dev/func of an 1411 1411 * adapter. */ 1412 1412 1413 - down(&ctrl->crit_sect); 1413 + mutex_lock(&ctrl->crit_sect); 1414 1414 1415 1415 amber_LED_on (ctrl, hp_slot); 1416 1416 green_LED_off (ctrl, hp_slot); ··· 1421 1421 /* Wait for SOBS to be unset */ 1422 1422 wait_for_ctrl_irq (ctrl); 1423 1423 1424 - up(&ctrl->crit_sect); 1424 + mutex_unlock(&ctrl->crit_sect); 1425 1425 1426 1426 return rc; 1427 1427 } 1428 1428 /* Done configuring so turn LED on full time */ 1429 1429 1430 - down(&ctrl->crit_sect); 1430 + mutex_lock(&ctrl->crit_sect); 1431 1431 1432 1432 green_LED_on (ctrl, hp_slot); 1433 1433 ··· 1436 1436 /* Wait for SOBS to be unset */ 1437 1437 wait_for_ctrl_irq (ctrl); 1438 1438 1439 - up(&ctrl->crit_sect); 1439 + mutex_unlock(&ctrl->crit_sect); 1440 1440 rc = 0; 1441 1441 } else { 1442 1442 /* Something is wrong ··· 1445 1445 * in this case it will always be called for the "base" 1446 1446 * bus/dev/func of an adapter. */ 1447 1447 1448 - down(&ctrl->crit_sect); 1448 + mutex_lock(&ctrl->crit_sect); 1449 1449 1450 1450 amber_LED_on (ctrl, hp_slot); 1451 1451 green_LED_off (ctrl, hp_slot); ··· 1456 1456 /* Wait for SOBS to be unset */ 1457 1457 wait_for_ctrl_irq (ctrl); 1458 1458 1459 - up(&ctrl->crit_sect); 1459 + mutex_unlock(&ctrl->crit_sect); 1460 1460 } 1461 1461 1462 1462 } ··· 1488 1488 dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n", 1489 1489 __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot); 1490 1490 1491 - down(&ctrl->crit_sect); 1491 + mutex_lock(&ctrl->crit_sect); 1492 1492 1493 1493 /* turn on board without attaching to the bus */ 1494 1494 enable_slot_power(ctrl, hp_slot); ··· 1522 1522 /* Wait for SOBS to be unset */ 1523 1523 wait_for_ctrl_irq(ctrl); 1524 1524 1525 - up(&ctrl->crit_sect); 1525 + mutex_unlock(&ctrl->crit_sect); 1526 1526 1527 1527 if (rc) 1528 1528 return rc; ··· 1532 1532 /* turn on board and blink green LED */ 1533 1533 1534 1534 dbg("%s: before down\n", __FUNCTION__); 1535 - down(&ctrl->crit_sect); 1535 + mutex_lock(&ctrl->crit_sect); 1536 1536 dbg("%s: after down\n", __FUNCTION__); 1537 1537 1538 1538 dbg("%s: before slot_enable\n", __FUNCTION__); ··· 1553 1553 dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__); 1554 1554 1555 1555 dbg("%s: before up\n", __FUNCTION__); 1556 - up(&ctrl->crit_sect); 1556 + mutex_unlock(&ctrl->crit_sect); 1557 1557 dbg("%s: after up\n", __FUNCTION__); 1558 1558 1559 1559 /* Wait for ~1 second because of hot plug spec */ ··· 1607 1607 cpqhp_resource_sort_and_combine(&(ctrl->bus_head)); 1608 1608 1609 1609 if (rc) { 1610 - down(&ctrl->crit_sect); 1610 + mutex_lock(&ctrl->crit_sect); 1611 1611 1612 1612 amber_LED_on (ctrl, hp_slot); 1613 1613 green_LED_off (ctrl, hp_slot); ··· 1618 1618 /* Wait for SOBS to be unset */ 1619 1619 wait_for_ctrl_irq (ctrl); 1620 1620 1621 - up(&ctrl->crit_sect); 1621 + mutex_unlock(&ctrl->crit_sect); 1622 1622 return rc; 1623 1623 } else { 1624 1624 cpqhp_save_slot_config(ctrl, func); ··· 1640 1640 } 1641 1641 } while (new_slot); 1642 1642 1643 - down(&ctrl->crit_sect); 1643 + mutex_lock(&ctrl->crit_sect); 1644 1644 1645 1645 green_LED_on (ctrl, hp_slot); 1646 1646 ··· 1649 1649 /* Wait for SOBS to be unset */ 1650 1650 wait_for_ctrl_irq (ctrl); 1651 1651 1652 - up(&ctrl->crit_sect); 1652 + mutex_unlock(&ctrl->crit_sect); 1653 1653 } else { 1654 - down(&ctrl->crit_sect); 1654 + mutex_lock(&ctrl->crit_sect); 1655 1655 1656 1656 amber_LED_on (ctrl, hp_slot); 1657 1657 green_LED_off (ctrl, hp_slot); ··· 1662 1662 /* Wait for SOBS to be unset */ 1663 1663 wait_for_ctrl_irq (ctrl); 1664 1664 1665 - up(&ctrl->crit_sect); 1665 + mutex_unlock(&ctrl->crit_sect); 1666 1666 1667 1667 return rc; 1668 1668 } ··· 1721 1721 func->status = 0x01; 1722 1722 func->configured = 0; 1723 1723 1724 - down(&ctrl->crit_sect); 1724 + mutex_lock(&ctrl->crit_sect); 1725 1725 1726 1726 green_LED_off (ctrl, hp_slot); 1727 1727 slot_disable (ctrl, hp_slot); ··· 1736 1736 /* Wait for SOBS to be unset */ 1737 1737 wait_for_ctrl_irq (ctrl); 1738 1738 1739 - up(&ctrl->crit_sect); 1739 + mutex_unlock(&ctrl->crit_sect); 1740 1740 1741 1741 if (!replace_flag && ctrl->add_support) { 1742 1742 while (func) { ··· 1899 1899 dbg("button cancel\n"); 1900 1900 del_timer(&p_slot->task_event); 1901 1901 1902 - down(&ctrl->crit_sect); 1902 + mutex_lock(&ctrl->crit_sect); 1903 1903 1904 1904 if (p_slot->state == BLINKINGOFF_STATE) { 1905 1905 /* slot is on */ ··· 1922 1922 /* Wait for SOBS to be unset */ 1923 1923 wait_for_ctrl_irq (ctrl); 1924 1924 1925 - up(&ctrl->crit_sect); 1925 + mutex_unlock(&ctrl->crit_sect); 1926 1926 } 1927 1927 /*** button Released (No action on press...) */ 1928 1928 else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) { ··· 1937 1937 p_slot->state = BLINKINGON_STATE; 1938 1938 info(msg_button_on, p_slot->number); 1939 1939 } 1940 - down(&ctrl->crit_sect); 1940 + mutex_lock(&ctrl->crit_sect); 1941 1941 1942 1942 dbg("blink green LED and turn off amber\n"); 1943 1943 ··· 1949 1949 /* Wait for SOBS to be unset */ 1950 1950 wait_for_ctrl_irq (ctrl); 1951 1951 1952 - up(&ctrl->crit_sect); 1952 + mutex_unlock(&ctrl->crit_sect); 1953 1953 init_timer(&p_slot->task_event); 1954 1954 p_slot->hp_slot = hp_slot; 1955 1955 p_slot->ctrl = ctrl;
+6 -4
drivers/pci/hotplug/ibmphp_hpc.c
··· 34 34 #include <linux/pci.h> 35 35 #include <linux/smp_lock.h> 36 36 #include <linux/init.h> 37 + #include <linux/mutex.h> 38 + 37 39 #include "ibmphp.h" 38 40 39 41 static int to_debug = FALSE; ··· 103 101 //---------------------------------------------------------------------------- 104 102 static int ibmphp_shutdown; 105 103 static int tid_poll; 106 - static struct semaphore sem_hpcaccess; // lock access to HPC 104 + static struct mutex sem_hpcaccess; // lock access to HPC 107 105 static struct semaphore semOperations; // lock all operations and 108 106 // access to data structures 109 107 static struct semaphore sem_exit; // make sure polling thread goes away ··· 133 131 { 134 132 debug ("%s - Entry\n", __FUNCTION__); 135 133 136 - init_MUTEX (&sem_hpcaccess); 134 + mutex_init(&sem_hpcaccess); 137 135 init_MUTEX (&semOperations); 138 136 init_MUTEX_LOCKED (&sem_exit); 139 137 to_debug = FALSE; ··· 780 778 *---------------------------------------------------------------------*/ 781 779 static void get_hpc_access (void) 782 780 { 783 - down (&sem_hpcaccess); 781 + mutex_lock(&sem_hpcaccess); 784 782 } 785 783 786 784 /*---------------------------------------------------------------------- ··· 788 786 *---------------------------------------------------------------------*/ 789 787 void free_hpc_access (void) 790 788 { 791 - up (&sem_hpcaccess); 789 + mutex_unlock(&sem_hpcaccess); 792 790 } 793 791 794 792 /*----------------------------------------------------------------------
+2 -1
drivers/pci/hotplug/pciehp.h
··· 34 34 #include <linux/delay.h> 35 35 #include <linux/sched.h> /* signal_pending() */ 36 36 #include <linux/pcieport_if.h> 37 + #include <linux/mutex.h> 37 38 #include "pci_hotplug.h" 38 39 39 40 #define MY_NAME "pciehp" ··· 97 96 #define MAX_EVENTS 10 98 97 struct controller { 99 98 struct controller *next; 100 - struct semaphore crit_sect; /* critical section semaphore */ 99 + struct mutex crit_sect; /* critical section mutex */ 101 100 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ 102 101 int num_slots; /* Number of slots on ctlr */ 103 102 int slot_num_inc; /* 1 or -1 */
+3 -3
drivers/pci/hotplug/pciehp_core.c
··· 439 439 } 440 440 441 441 /* Wait for exclusive access to hardware */ 442 - down(&ctrl->crit_sect); 442 + mutex_lock(&ctrl->crit_sect); 443 443 444 444 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ 445 445 ··· 447 447 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ 448 448 if (rc) { 449 449 /* Done with exclusive hardware access */ 450 - up(&ctrl->crit_sect); 450 + mutex_unlock(&ctrl->crit_sect); 451 451 goto err_out_free_ctrl_slot; 452 452 } else 453 453 /* Wait for the command to complete */ ··· 455 455 } 456 456 457 457 /* Done with exclusive hardware access */ 458 - up(&ctrl->crit_sect); 458 + mutex_unlock(&ctrl->crit_sect); 459 459 460 460 return 0; 461 461
+34 -34
drivers/pci/hotplug/pciehp_ctrl.c
··· 229 229 static void set_slot_off(struct controller *ctrl, struct slot * pslot) 230 230 { 231 231 /* Wait for exclusive access to hardware */ 232 - down(&ctrl->crit_sect); 232 + mutex_lock(&ctrl->crit_sect); 233 233 234 234 /* turn off slot, turn on Amber LED, turn off Green LED if supported*/ 235 235 if (POWER_CTRL(ctrl->ctrlcap)) { 236 236 if (pslot->hpc_ops->power_off_slot(pslot)) { 237 237 err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__); 238 - up(&ctrl->crit_sect); 238 + mutex_unlock(&ctrl->crit_sect); 239 239 return; 240 240 } 241 241 wait_for_ctrl_irq (ctrl); ··· 249 249 if (ATTN_LED(ctrl->ctrlcap)) { 250 250 if (pslot->hpc_ops->set_attention_status(pslot, 1)) { 251 251 err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__); 252 - up(&ctrl->crit_sect); 252 + mutex_unlock(&ctrl->crit_sect); 253 253 return; 254 254 } 255 255 wait_for_ctrl_irq (ctrl); 256 256 } 257 257 258 258 /* Done with exclusive hardware access */ 259 - up(&ctrl->crit_sect); 259 + mutex_unlock(&ctrl->crit_sect); 260 260 } 261 261 262 262 /** ··· 279 279 ctrl->slot_device_offset, hp_slot); 280 280 281 281 /* Wait for exclusive access to hardware */ 282 - down(&ctrl->crit_sect); 282 + mutex_lock(&ctrl->crit_sect); 283 283 284 284 if (POWER_CTRL(ctrl->ctrlcap)) { 285 285 /* Power on slot */ 286 286 rc = p_slot->hpc_ops->power_on_slot(p_slot); 287 287 if (rc) { 288 - up(&ctrl->crit_sect); 288 + mutex_unlock(&ctrl->crit_sect); 289 289 return -1; 290 290 } 291 291 ··· 301 301 } 302 302 303 303 /* Done with exclusive hardware access */ 304 - up(&ctrl->crit_sect); 304 + mutex_unlock(&ctrl->crit_sect); 305 305 306 306 /* Wait for ~1 second */ 307 307 wait_for_ctrl_irq (ctrl); ··· 335 335 pci_fixup_device(pci_fixup_final, ctrl->pci_dev); 336 336 if (PWR_LED(ctrl->ctrlcap)) { 337 337 /* Wait for exclusive access to hardware */ 338 - down(&ctrl->crit_sect); 338 + mutex_lock(&ctrl->crit_sect); 339 339 340 340 p_slot->hpc_ops->green_led_on(p_slot); 341 341 ··· 343 343 wait_for_ctrl_irq (ctrl); 344 344 345 345 /* Done with exclusive hardware access */ 346 - up(&ctrl->crit_sect); 346 + mutex_unlock(&ctrl->crit_sect); 347 347 } 348 348 return 0; 349 349 ··· 375 375 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); 376 376 377 377 /* Wait for exclusive access to hardware */ 378 - down(&ctrl->crit_sect); 378 + mutex_lock(&ctrl->crit_sect); 379 379 380 380 if (POWER_CTRL(ctrl->ctrlcap)) { 381 381 /* power off slot */ 382 382 rc = p_slot->hpc_ops->power_off_slot(p_slot); 383 383 if (rc) { 384 384 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); 385 - up(&ctrl->crit_sect); 385 + mutex_unlock(&ctrl->crit_sect); 386 386 return rc; 387 387 } 388 388 /* Wait for the command to complete */ ··· 398 398 } 399 399 400 400 /* Done with exclusive hardware access */ 401 - up(&ctrl->crit_sect); 401 + mutex_unlock(&ctrl->crit_sect); 402 402 403 403 return 0; 404 404 } ··· 445 445 446 446 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { 447 447 /* Wait for exclusive access to hardware */ 448 - down(&p_slot->ctrl->crit_sect); 448 + mutex_lock(&p_slot->ctrl->crit_sect); 449 449 450 450 p_slot->hpc_ops->green_led_off(p_slot); 451 451 ··· 453 453 wait_for_ctrl_irq (p_slot->ctrl); 454 454 455 455 /* Done with exclusive hardware access */ 456 - up(&p_slot->ctrl->crit_sect); 456 + mutex_unlock(&p_slot->ctrl->crit_sect); 457 457 } 458 458 p_slot->state = STATIC_STATE; 459 459 } ··· 495 495 496 496 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { 497 497 /* Wait for exclusive access to hardware */ 498 - down(&p_slot->ctrl->crit_sect); 498 + mutex_lock(&p_slot->ctrl->crit_sect); 499 499 500 500 p_slot->hpc_ops->green_led_off(p_slot); 501 501 ··· 503 503 wait_for_ctrl_irq (p_slot->ctrl); 504 504 505 505 /* Done with exclusive hardware access */ 506 - up(&p_slot->ctrl->crit_sect); 506 + mutex_unlock(&p_slot->ctrl->crit_sect); 507 507 } 508 508 p_slot->state = STATIC_STATE; 509 509 } ··· 616 616 switch (p_slot->state) { 617 617 case BLINKINGOFF_STATE: 618 618 /* Wait for exclusive access to hardware */ 619 - down(&ctrl->crit_sect); 619 + mutex_lock(&ctrl->crit_sect); 620 620 621 621 if (PWR_LED(ctrl->ctrlcap)) { 622 622 p_slot->hpc_ops->green_led_on(p_slot); ··· 630 630 wait_for_ctrl_irq (ctrl); 631 631 } 632 632 /* Done with exclusive hardware access */ 633 - up(&ctrl->crit_sect); 633 + mutex_unlock(&ctrl->crit_sect); 634 634 break; 635 635 case BLINKINGON_STATE: 636 636 /* Wait for exclusive access to hardware */ 637 - down(&ctrl->crit_sect); 637 + mutex_lock(&ctrl->crit_sect); 638 638 639 639 if (PWR_LED(ctrl->ctrlcap)) { 640 640 p_slot->hpc_ops->green_led_off(p_slot); ··· 647 647 wait_for_ctrl_irq (ctrl); 648 648 } 649 649 /* Done with exclusive hardware access */ 650 - up(&ctrl->crit_sect); 650 + mutex_unlock(&ctrl->crit_sect); 651 651 652 652 break; 653 653 default: ··· 676 676 } 677 677 678 678 /* Wait for exclusive access to hardware */ 679 - down(&ctrl->crit_sect); 679 + mutex_lock(&ctrl->crit_sect); 680 680 681 681 /* blink green LED and turn off amber */ 682 682 if (PWR_LED(ctrl->ctrlcap)) { ··· 693 693 } 694 694 695 695 /* Done with exclusive hardware access */ 696 - up(&ctrl->crit_sect); 696 + mutex_unlock(&ctrl->crit_sect); 697 697 698 698 init_timer(&p_slot->task_event); 699 699 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ ··· 708 708 if (POWER_CTRL(ctrl->ctrlcap)) { 709 709 dbg("power fault\n"); 710 710 /* Wait for exclusive access to hardware */ 711 - down(&ctrl->crit_sect); 711 + mutex_lock(&ctrl->crit_sect); 712 712 713 713 if (ATTN_LED(ctrl->ctrlcap)) { 714 714 p_slot->hpc_ops->set_attention_status(p_slot, 1); ··· 721 721 } 722 722 723 723 /* Done with exclusive hardware access */ 724 - up(&ctrl->crit_sect); 724 + mutex_unlock(&ctrl->crit_sect); 725 725 } 726 726 } 727 727 /***********SURPRISE REMOVAL********************/ ··· 756 756 int rc; 757 757 758 758 /* Check to see if (latch closed, card present, power off) */ 759 - down(&p_slot->ctrl->crit_sect); 759 + mutex_lock(&p_slot->ctrl->crit_sect); 760 760 761 761 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 762 762 if (rc || !getstatus) { 763 763 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 764 - up(&p_slot->ctrl->crit_sect); 764 + mutex_unlock(&p_slot->ctrl->crit_sect); 765 765 return 1; 766 766 } 767 767 if (MRL_SENS(p_slot->ctrl->ctrlcap)) { 768 768 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 769 769 if (rc || getstatus) { 770 770 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 771 - up(&p_slot->ctrl->crit_sect); 771 + mutex_unlock(&p_slot->ctrl->crit_sect); 772 772 return 1; 773 773 } 774 774 } ··· 777 777 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 778 778 if (rc || getstatus) { 779 779 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 780 - up(&p_slot->ctrl->crit_sect); 780 + mutex_unlock(&p_slot->ctrl->crit_sect); 781 781 return 1; 782 782 } 783 783 } 784 - up(&p_slot->ctrl->crit_sect); 784 + mutex_unlock(&p_slot->ctrl->crit_sect); 785 785 786 786 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 787 787 ··· 806 806 return 1; 807 807 808 808 /* Check to see if (latch closed, card present, power on) */ 809 - down(&p_slot->ctrl->crit_sect); 809 + mutex_lock(&p_slot->ctrl->crit_sect); 810 810 811 811 if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) { 812 812 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 813 813 if (ret || !getstatus) { 814 814 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 815 - up(&p_slot->ctrl->crit_sect); 815 + mutex_unlock(&p_slot->ctrl->crit_sect); 816 816 return 1; 817 817 } 818 818 } ··· 821 821 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 822 822 if (ret || getstatus) { 823 823 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 824 - up(&p_slot->ctrl->crit_sect); 824 + mutex_unlock(&p_slot->ctrl->crit_sect); 825 825 return 1; 826 826 } 827 827 } ··· 830 830 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 831 831 if (ret || !getstatus) { 832 832 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 833 - up(&p_slot->ctrl->crit_sect); 833 + mutex_unlock(&p_slot->ctrl->crit_sect); 834 834 return 1; 835 835 } 836 836 } 837 837 838 - up(&p_slot->ctrl->crit_sect); 838 + mutex_unlock(&p_slot->ctrl->crit_sect); 839 839 840 840 ret = remove_board(p_slot); 841 841 update_slot_info(p_slot);
+1 -1
drivers/pci/hotplug/pciehp_hpc.c
··· 1334 1334 if (pci_enable_device(pdev)) 1335 1335 goto abort_free_ctlr; 1336 1336 1337 - init_MUTEX(&ctrl->crit_sect); 1337 + mutex_init(&ctrl->crit_sect); 1338 1338 /* setup wait queue */ 1339 1339 init_waitqueue_head(&ctrl->queue); 1340 1340
+2 -1
drivers/pci/hotplug/shpchp.h
··· 33 33 #include <linux/pci.h> 34 34 #include <linux/delay.h> 35 35 #include <linux/sched.h> /* signal_pending(), struct timer_list */ 36 + #include <linux/mutex.h> 36 37 37 38 #include "pci_hotplug.h" 38 39 ··· 80 79 81 80 struct controller { 82 81 struct controller *next; 83 - struct semaphore crit_sect; /* critical section semaphore */ 82 + struct mutex crit_sect; /* critical section mutex */ 84 83 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */ 85 84 int num_slots; /* Number of slots on ctlr */ 86 85 int slot_num_inc; /* 1 or -1 */
+49 -49
drivers/pci/hotplug/shpchp_ctrl.c
··· 242 242 int rc = 0; 243 243 244 244 dbg("%s: change to speed %d\n", __FUNCTION__, speed); 245 - down(&ctrl->crit_sect); 245 + mutex_lock(&ctrl->crit_sect); 246 246 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) { 247 247 err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__); 248 - up(&ctrl->crit_sect); 248 + mutex_unlock(&ctrl->crit_sect); 249 249 return WRONG_BUS_FREQUENCY; 250 250 } 251 251 ··· 253 253 err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", 254 254 __FUNCTION__); 255 255 err("%s: Error code (%d)\n", __FUNCTION__, rc); 256 - up(&ctrl->crit_sect); 256 + mutex_unlock(&ctrl->crit_sect); 257 257 return WRONG_BUS_FREQUENCY; 258 258 } 259 - up(&ctrl->crit_sect); 259 + mutex_unlock(&ctrl->crit_sect); 260 260 return rc; 261 261 } 262 262 ··· 319 319 ctrl->slot_device_offset, hp_slot); 320 320 321 321 /* Wait for exclusive access to hardware */ 322 - down(&ctrl->crit_sect); 322 + mutex_lock(&ctrl->crit_sect); 323 323 324 324 /* Power on slot without connecting to bus */ 325 325 rc = p_slot->hpc_ops->power_on_slot(p_slot); 326 326 if (rc) { 327 327 err("%s: Failed to power on slot\n", __FUNCTION__); 328 328 /* Done with exclusive hardware access */ 329 - up(&ctrl->crit_sect); 329 + mutex_unlock(&ctrl->crit_sect); 330 330 return -1; 331 331 } 332 332 ··· 334 334 if (rc) { 335 335 err("%s: Failed to power on slot, error code(%d)\n", __FUNCTION__, rc); 336 336 /* Done with exclusive hardware access */ 337 - up(&ctrl->crit_sect); 337 + mutex_unlock(&ctrl->crit_sect); 338 338 return -1; 339 339 } 340 340 ··· 345 345 346 346 if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) { 347 347 err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__); 348 - up(&ctrl->crit_sect); 348 + mutex_unlock(&ctrl->crit_sect); 349 349 return WRONG_BUS_FREQUENCY; 350 350 } 351 351 ··· 353 353 err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n", 354 354 __FUNCTION__); 355 355 err("%s: Error code (%d)\n", __FUNCTION__, rc); 356 - up(&ctrl->crit_sect); 356 + mutex_unlock(&ctrl->crit_sect); 357 357 return WRONG_BUS_FREQUENCY; 358 358 } 359 359 /* turn on board, blink green LED, turn off Amber LED */ 360 360 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 361 361 err("%s: Issue of Slot Enable command failed\n", __FUNCTION__); 362 - up(&ctrl->crit_sect); 362 + mutex_unlock(&ctrl->crit_sect); 363 363 return rc; 364 364 } 365 365 366 366 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { 367 367 err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc); 368 - up(&ctrl->crit_sect); 368 + mutex_unlock(&ctrl->crit_sect); 369 369 return rc; 370 370 } 371 371 } ··· 380 380 if (rc || adapter_speed == PCI_SPEED_UNKNOWN) { 381 381 err("%s: Can't get adapter speed or bus mode mismatch\n", __FUNCTION__); 382 382 /* Done with exclusive hardware access */ 383 - up(&ctrl->crit_sect); 383 + mutex_unlock(&ctrl->crit_sect); 384 384 return WRONG_BUS_FREQUENCY; 385 385 } 386 386 ··· 388 388 if (rc || bus_speed == PCI_SPEED_UNKNOWN) { 389 389 err("%s: Can't get bus operation speed\n", __FUNCTION__); 390 390 /* Done with exclusive hardware access */ 391 - up(&ctrl->crit_sect); 391 + mutex_unlock(&ctrl->crit_sect); 392 392 return WRONG_BUS_FREQUENCY; 393 393 } 394 394 ··· 399 399 } 400 400 401 401 /* Done with exclusive hardware access */ 402 - up(&ctrl->crit_sect); 402 + mutex_unlock(&ctrl->crit_sect); 403 403 404 404 if ((rc = p_slot->hpc_ops->get_prog_int(p_slot, &pi))) { 405 405 err("%s: Can't get controller programming interface, set it to 1\n", __FUNCTION__); ··· 481 481 return rc; 482 482 } 483 483 484 - down(&ctrl->crit_sect); 484 + mutex_lock(&ctrl->crit_sect); 485 485 /* turn on board, blink green LED, turn off Amber LED */ 486 486 if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) { 487 487 err("%s: Issue of Slot Enable command failed\n", __FUNCTION__); 488 - up(&ctrl->crit_sect); 488 + mutex_unlock(&ctrl->crit_sect); 489 489 return rc; 490 490 } 491 491 492 492 if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) { 493 493 err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc); 494 - up(&ctrl->crit_sect); 494 + mutex_unlock(&ctrl->crit_sect); 495 495 return rc; 496 496 } 497 497 498 - up(&ctrl->crit_sect); 498 + mutex_unlock(&ctrl->crit_sect); 499 499 500 500 /* Wait for ~1 second */ 501 501 wait_for_ctrl_irq (ctrl); ··· 521 521 p_slot->pwr_save = 1; 522 522 523 523 /* Wait for exclusive access to hardware */ 524 - down(&ctrl->crit_sect); 524 + mutex_lock(&ctrl->crit_sect); 525 525 526 526 p_slot->hpc_ops->green_led_on(p_slot); 527 527 528 528 /* Done with exclusive hardware access */ 529 - up(&ctrl->crit_sect); 529 + mutex_unlock(&ctrl->crit_sect); 530 530 531 531 return 0; 532 532 533 533 err_exit: 534 534 /* Wait for exclusive access to hardware */ 535 - down(&ctrl->crit_sect); 535 + mutex_lock(&ctrl->crit_sect); 536 536 537 537 /* turn off slot, turn on Amber LED, turn off Green LED */ 538 538 rc = p_slot->hpc_ops->slot_disable(p_slot); 539 539 if (rc) { 540 540 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); 541 541 /* Done with exclusive hardware access */ 542 - up(&ctrl->crit_sect); 542 + mutex_unlock(&ctrl->crit_sect); 543 543 return rc; 544 544 } 545 545 ··· 547 547 if (rc) { 548 548 err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc); 549 549 /* Done with exclusive hardware access */ 550 - up(&ctrl->crit_sect); 550 + mutex_unlock(&ctrl->crit_sect); 551 551 return rc; 552 552 } 553 553 554 554 /* Done with exclusive hardware access */ 555 - up(&ctrl->crit_sect); 555 + mutex_unlock(&ctrl->crit_sect); 556 556 557 557 return(rc); 558 558 } ··· 581 581 p_slot->status = 0x01; 582 582 583 583 /* Wait for exclusive access to hardware */ 584 - down(&ctrl->crit_sect); 584 + mutex_lock(&ctrl->crit_sect); 585 585 586 586 /* turn off slot, turn on Amber LED, turn off Green LED */ 587 587 rc = p_slot->hpc_ops->slot_disable(p_slot); 588 588 if (rc) { 589 589 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__); 590 590 /* Done with exclusive hardware access */ 591 - up(&ctrl->crit_sect); 591 + mutex_unlock(&ctrl->crit_sect); 592 592 return rc; 593 593 } 594 594 ··· 596 596 if (rc) { 597 597 err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc); 598 598 /* Done with exclusive hardware access */ 599 - up(&ctrl->crit_sect); 599 + mutex_unlock(&ctrl->crit_sect); 600 600 return rc; 601 601 } 602 602 ··· 604 604 if (rc) { 605 605 err("%s: Issue of Set Attention command failed\n", __FUNCTION__); 606 606 /* Done with exclusive hardware access */ 607 - up(&ctrl->crit_sect); 607 + mutex_unlock(&ctrl->crit_sect); 608 608 return rc; 609 609 } 610 610 611 611 /* Done with exclusive hardware access */ 612 - up(&ctrl->crit_sect); 612 + mutex_unlock(&ctrl->crit_sect); 613 613 614 614 p_slot->pwr_save = 0; 615 615 p_slot->is_a_board = 0; ··· 656 656 657 657 if (shpchp_enable_slot(p_slot)) { 658 658 /* Wait for exclusive access to hardware */ 659 - down(&p_slot->ctrl->crit_sect); 659 + mutex_lock(&p_slot->ctrl->crit_sect); 660 660 661 661 p_slot->hpc_ops->green_led_off(p_slot); 662 662 663 663 /* Done with exclusive hardware access */ 664 - up(&p_slot->ctrl->crit_sect); 664 + mutex_unlock(&p_slot->ctrl->crit_sect); 665 665 } 666 666 p_slot->state = STATIC_STATE; 667 667 } ··· 768 768 switch (p_slot->state) { 769 769 case BLINKINGOFF_STATE: 770 770 /* Wait for exclusive access to hardware */ 771 - down(&ctrl->crit_sect); 771 + mutex_lock(&ctrl->crit_sect); 772 772 773 773 p_slot->hpc_ops->green_led_on(p_slot); 774 774 775 775 p_slot->hpc_ops->set_attention_status(p_slot, 0); 776 776 777 777 /* Done with exclusive hardware access */ 778 - up(&ctrl->crit_sect); 778 + mutex_unlock(&ctrl->crit_sect); 779 779 break; 780 780 case BLINKINGON_STATE: 781 781 /* Wait for exclusive access to hardware */ 782 - down(&ctrl->crit_sect); 782 + mutex_lock(&ctrl->crit_sect); 783 783 784 784 p_slot->hpc_ops->green_led_off(p_slot); 785 785 786 786 p_slot->hpc_ops->set_attention_status(p_slot, 0); 787 787 788 788 /* Done with exclusive hardware access */ 789 - up(&ctrl->crit_sect); 789 + mutex_unlock(&ctrl->crit_sect); 790 790 791 791 break; 792 792 default: ··· 813 813 } 814 814 815 815 /* Wait for exclusive access to hardware */ 816 - down(&ctrl->crit_sect); 816 + mutex_lock(&ctrl->crit_sect); 817 817 818 818 /* blink green LED and turn off amber */ 819 819 p_slot->hpc_ops->green_led_blink(p_slot); ··· 821 821 p_slot->hpc_ops->set_attention_status(p_slot, 0); 822 822 823 823 /* Done with exclusive hardware access */ 824 - up(&ctrl->crit_sect); 824 + mutex_unlock(&ctrl->crit_sect); 825 825 826 826 init_timer(&p_slot->task_event); 827 827 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */ ··· 834 834 /***********POWER FAULT********************/ 835 835 dbg("%s: power fault\n", __FUNCTION__); 836 836 /* Wait for exclusive access to hardware */ 837 - down(&ctrl->crit_sect); 837 + mutex_lock(&ctrl->crit_sect); 838 838 839 839 p_slot->hpc_ops->set_attention_status(p_slot, 1); 840 840 841 841 p_slot->hpc_ops->green_led_off(p_slot); 842 842 843 843 /* Done with exclusive hardware access */ 844 - up(&ctrl->crit_sect); 844 + mutex_unlock(&ctrl->crit_sect); 845 845 } else { 846 846 /* refresh notification */ 847 847 if (p_slot) ··· 865 865 int rc; 866 866 867 867 /* Check to see if (latch closed, card present, power off) */ 868 - down(&p_slot->ctrl->crit_sect); 868 + mutex_lock(&p_slot->ctrl->crit_sect); 869 869 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 870 870 if (rc || !getstatus) { 871 871 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 872 - up(&p_slot->ctrl->crit_sect); 872 + mutex_unlock(&p_slot->ctrl->crit_sect); 873 873 return -ENODEV; 874 874 } 875 875 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 876 876 if (rc || getstatus) { 877 877 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 878 - up(&p_slot->ctrl->crit_sect); 878 + mutex_unlock(&p_slot->ctrl->crit_sect); 879 879 return -ENODEV; 880 880 } 881 881 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 882 882 if (rc || getstatus) { 883 883 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 884 - up(&p_slot->ctrl->crit_sect); 884 + mutex_unlock(&p_slot->ctrl->crit_sect); 885 885 return -ENODEV; 886 886 } 887 - up(&p_slot->ctrl->crit_sect); 887 + mutex_unlock(&p_slot->ctrl->crit_sect); 888 888 889 889 p_slot->is_a_board = 1; 890 890 ··· 925 925 return -ENODEV; 926 926 927 927 /* Check to see if (latch closed, card present, power on) */ 928 - down(&p_slot->ctrl->crit_sect); 928 + mutex_lock(&p_slot->ctrl->crit_sect); 929 929 930 930 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 931 931 if (ret || !getstatus) { 932 932 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 933 - up(&p_slot->ctrl->crit_sect); 933 + mutex_unlock(&p_slot->ctrl->crit_sect); 934 934 return -ENODEV; 935 935 } 936 936 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 937 937 if (ret || getstatus) { 938 938 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 939 - up(&p_slot->ctrl->crit_sect); 939 + mutex_unlock(&p_slot->ctrl->crit_sect); 940 940 return -ENODEV; 941 941 } 942 942 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 943 943 if (ret || !getstatus) { 944 944 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 945 - up(&p_slot->ctrl->crit_sect); 945 + mutex_unlock(&p_slot->ctrl->crit_sect); 946 946 return -ENODEV; 947 947 } 948 - up(&p_slot->ctrl->crit_sect); 948 + mutex_unlock(&p_slot->ctrl->crit_sect); 949 949 950 950 ret = remove_board(p_slot); 951 951 update_slot_info(p_slot);
+1 -1
drivers/pci/hotplug/shpchp_hpc.c
··· 1454 1454 } 1455 1455 dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg); 1456 1456 1457 - init_MUTEX(&ctrl->crit_sect); 1457 + mutex_init(&ctrl->crit_sect); 1458 1458 /* Setup wait queue */ 1459 1459 init_waitqueue_head(&ctrl->queue); 1460 1460