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

[PATCH] drivers/net: fix-up schedule_timeout() usage

Use schedule_timeout_interruptible() instead of
set_current_state()/schedule_timeout() to reduce kernel size.

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>

authored by

Nishanth Aravamudan and committed by
Jeff Garzik
3173c890 343c686c

+53 -92
+1 -2
drivers/net/8139cp.c
··· 1029 1029 if (!(cpr8(Cmd) & CmdReset)) 1030 1030 return; 1031 1031 1032 - set_current_state(TASK_UNINTERRUPTIBLE); 1033 - schedule_timeout(10); 1032 + schedule_timeout_uninterruptible(10); 1034 1033 } 1035 1034 1036 1035 printk(KERN_ERR "%s: hardware reset timeout\n", cp->dev->name);
+16 -32
drivers/net/hp100.c
··· 2517 2517 do { 2518 2518 if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) 2519 2519 break; 2520 - if (!in_interrupt()) { 2521 - set_current_state(TASK_INTERRUPTIBLE); 2522 - schedule_timeout(1); 2523 - } 2520 + if (!in_interrupt()) 2521 + schedule_timeout_interruptible(1); 2524 2522 } while (time_after(time, jiffies)); 2525 2523 2526 2524 if (time_after_eq(jiffies, time)) /* no signal->no logout */ ··· 2534 2536 do { 2535 2537 if (!(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST)) 2536 2538 break; 2537 - if (!in_interrupt()) { 2538 - set_current_state(TASK_INTERRUPTIBLE); 2539 - schedule_timeout(1); 2540 - } 2539 + if (!in_interrupt()) 2540 + schedule_timeout_interruptible(1); 2541 2541 } while (time_after(time, jiffies)); 2542 2542 2543 2543 #ifdef HP100_DEBUG ··· 2573 2577 do { 2574 2578 if (!(hp100_inb(MAC_CFG_4) & HP100_MAC_SEL_ST)) 2575 2579 break; 2576 - if (!in_interrupt()) { 2577 - set_current_state(TASK_INTERRUPTIBLE); 2578 - schedule_timeout(1); 2579 - } 2580 + if (!in_interrupt()) 2581 + schedule_timeout_interruptible(1); 2580 2582 } while (time_after(time, jiffies)); 2581 2583 2582 2584 hp100_orb(HP100_AUTO_MODE, MAC_CFG_3); /* Autosel back on */ ··· 2585 2591 do { 2586 2592 if ((hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) == 0) 2587 2593 break; 2588 - if (!in_interrupt()) { 2589 - set_current_state(TASK_INTERRUPTIBLE); 2590 - schedule_timeout(1); 2591 - } 2594 + if (!in_interrupt()) 2595 + schedule_timeout_interruptible(1); 2592 2596 } while (time_after(time, jiffies)); 2593 2597 2594 2598 if (time_before_eq(time, jiffies)) { ··· 2598 2606 2599 2607 time = jiffies + (2 * HZ); /* This seems to take a while.... */ 2600 2608 do { 2601 - if (!in_interrupt()) { 2602 - set_current_state(TASK_INTERRUPTIBLE); 2603 - schedule_timeout(1); 2604 - } 2609 + if (!in_interrupt()) 2610 + schedule_timeout_interruptible(1); 2605 2611 } while (time_after(time, jiffies)); 2606 2612 2607 2613 return 0; ··· 2649 2659 do { 2650 2660 if (~(hp100_inb(VG_LAN_CFG_1) & HP100_LINK_UP_ST)) 2651 2661 break; 2652 - if (!in_interrupt()) { 2653 - set_current_state(TASK_INTERRUPTIBLE); 2654 - schedule_timeout(1); 2655 - } 2662 + if (!in_interrupt()) 2663 + schedule_timeout_interruptible(1); 2656 2664 } while (time_after(time, jiffies)); 2657 2665 2658 2666 /* Start an addressed training and optionally request promiscuous port */ ··· 2685 2697 do { 2686 2698 if (hp100_inb(VG_LAN_CFG_1) & HP100_LINK_CABLE_ST) 2687 2699 break; 2688 - if (!in_interrupt()) { 2689 - set_current_state(TASK_INTERRUPTIBLE); 2690 - schedule_timeout(1); 2691 - } 2700 + if (!in_interrupt()) 2701 + schedule_timeout_interruptible(1); 2692 2702 } while (time_before(jiffies, time)); 2693 2703 2694 2704 if (time_after_eq(jiffies, time)) { ··· 2709 2723 #endif 2710 2724 break; 2711 2725 } 2712 - if (!in_interrupt()) { 2713 - set_current_state(TASK_INTERRUPTIBLE); 2714 - schedule_timeout(1); 2715 - } 2726 + if (!in_interrupt()) 2727 + schedule_timeout_interruptible(1); 2716 2728 } while (time_after(time, jiffies)); 2717 2729 } 2718 2730
+3 -4
drivers/net/irda/stir4200.c
··· 678 678 return; 679 679 680 680 ticks = us / (1000000 / HZ); 681 - if (ticks > 0) { 682 - current->state = TASK_INTERRUPTIBLE; 683 - schedule_timeout(1 + ticks); 684 - } else 681 + if (ticks > 0) 682 + schedule_timeout_interruptible(1 + ticks); 683 + else 685 684 udelay(us); 686 685 } 687 686
+3 -4
drivers/net/ixgb/ixgb_ethtool.c
··· 645 645 646 646 mod_timer(&adapter->blink_timer, jiffies); 647 647 648 - set_current_state(TASK_INTERRUPTIBLE); 649 - if(data) 650 - schedule_timeout(data * HZ); 648 + if (data) 649 + schedule_timeout_interruptible(data * HZ); 651 650 else 652 - schedule_timeout(MAX_SCHEDULE_TIMEOUT); 651 + schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT); 653 652 654 653 del_timer_sync(&adapter->blink_timer); 655 654 ixgb_led_off(&adapter->hw);
+1 -2
drivers/net/ns83820.c
··· 1632 1632 timed_out = 1; 1633 1633 break; 1634 1634 } 1635 - set_current_state(TASK_UNINTERRUPTIBLE); 1636 - schedule_timeout(1); 1635 + schedule_timeout_uninterruptible(1); 1637 1636 } 1638 1637 1639 1638 if (status & fail)
+4 -5
drivers/net/tokenring/ibmtr.c
··· 318 318 if (dev->base_addr) { 319 319 outb(0,dev->base_addr+ADAPTRESET); 320 320 321 - schedule_timeout(TR_RST_TIME); /* wait 50ms */ 321 + schedule_timeout_uninterruptible(TR_RST_TIME); /* wait 50ms */ 322 322 323 323 outb(0,dev->base_addr+ADAPTRESETREL); 324 324 } ··· 859 859 writeb(~INT_ENABLE, ti->mmio + ACA_OFFSET + ACA_RESET + ISRP_EVEN); 860 860 outb(0, PIOaddr + ADAPTRESET); 861 861 862 - current->state=TASK_UNINTERRUPTIBLE; 863 - schedule_timeout(TR_RST_TIME); /* wait 50ms */ 862 + schedule_timeout_uninterruptible(TR_RST_TIME); /* wait 50ms */ 864 863 865 864 outb(0, PIOaddr + ADAPTRESETREL); 866 865 #ifdef ENABLE_PAGING ··· 907 908 DPRINTK("Adapter is up and running\n"); 908 909 return 0; 909 910 } 910 - current->state=TASK_INTERRUPTIBLE; 911 - i=schedule_timeout(TR_RETRY_INTERVAL); /* wait 30 seconds */ 911 + i=schedule_timeout_interruptible(TR_RETRY_INTERVAL); 912 + /* wait 30 seconds */ 912 913 if(i!=0) break; /*prob. a signal, like the i>24*HZ case above */ 913 914 } 914 915 outb(0, dev->base_addr + ADAPTRESET);/* kill pending interrupts*/
+1 -1
drivers/net/tokenring/olympic.c
··· 1101 1101 1102 1102 while(olympic_priv->srb_queued) { 1103 1103 1104 - t = schedule_timeout(60*HZ); 1104 + t = schedule_timeout_interruptible(60*HZ); 1105 1105 1106 1106 if(signal_pending(current)) { 1107 1107 printk(KERN_WARNING "%s: SRB timed out.\n",dev->name);
+1 -2
drivers/net/tokenring/tms380tr.c
··· 1243 1243 1244 1244 tmp = jiffies + time/(1000000/HZ); 1245 1245 do { 1246 - current->state = TASK_INTERRUPTIBLE; 1247 - tmp = schedule_timeout(tmp); 1246 + tmp = schedule_timeout_interruptible(tmp); 1248 1247 } while(time_after(tmp, jiffies)); 1249 1248 #else 1250 1249 udelay(time);
+3 -4
drivers/net/typhoon.c
··· 419 419 TYPHOON_STATUS_WAITING_FOR_HOST) 420 420 goto out; 421 421 422 - if(wait_type == WaitSleep) { 423 - set_current_state(TASK_UNINTERRUPTIBLE); 424 - schedule_timeout(1); 425 - } else 422 + if(wait_type == WaitSleep) 423 + schedule_timeout_uninterruptible(1); 424 + else 426 425 udelay(TYPHOON_UDELAY); 427 426 } 428 427
+2 -4
drivers/net/wan/cosa.c
··· 1617 1617 return r; 1618 1618 } 1619 1619 /* sleep if not ready to read */ 1620 - set_current_state(TASK_INTERRUPTIBLE); 1621 - schedule_timeout(1); 1620 + schedule_timeout_interruptible(1); 1622 1621 } 1623 1622 printk(KERN_INFO "cosa: timeout in get_wait_data (status 0x%x)\n", 1624 1623 cosa_getstatus(cosa)); ··· 1643 1644 } 1644 1645 #if 0 1645 1646 /* sleep if not ready to read */ 1646 - current->state = TASK_INTERRUPTIBLE; 1647 - schedule_timeout(1); 1647 + schedule_timeout_interruptible(1); 1648 1648 #endif 1649 1649 } 1650 1650 printk(KERN_INFO "cosa%d: timeout in put_wait_data (status 0x%x)\n",
+3 -6
drivers/net/wan/dscc4.c
··· 542 542 msg, i); 543 543 goto done; 544 544 } 545 - set_current_state(TASK_UNINTERRUPTIBLE); 546 - schedule_timeout(10); 545 + schedule_timeout_uninterruptible(10); 547 546 rmb(); 548 547 } while (++i > 0); 549 548 printk(KERN_ERR "%s: %s timeout\n", dev->name, msg); ··· 587 588 (dpriv->iqtx[cur] & Xpr)) 588 589 break; 589 590 smp_rmb(); 590 - set_current_state(TASK_UNINTERRUPTIBLE); 591 - schedule_timeout(10); 591 + schedule_timeout_uninterruptible(10); 592 592 } while (++i > 0); 593 593 594 594 return (i >= 0 ) ? i : -EAGAIN; ··· 1033 1035 /* Flush posted writes */ 1034 1036 readl(ioaddr + GSTAR); 1035 1037 1036 - set_current_state(TASK_UNINTERRUPTIBLE); 1037 - schedule_timeout(10); 1038 + schedule_timeout_uninterruptible(10); 1038 1039 1039 1040 for (i = 0; i < 16; i++) 1040 1041 pci_write_config_dword(pdev, i << 2, dscc4_pci_config_store[i]);
+1 -2
drivers/net/wan/farsync.c
··· 980 980 /* Wait for any previous command to complete */ 981 981 while (mbval > NAK) { 982 982 spin_unlock_irqrestore(&card->card_lock, flags); 983 - set_current_state(TASK_UNINTERRUPTIBLE); 984 - schedule_timeout(1); 983 + schedule_timeout_uninterruptible(1); 985 984 spin_lock_irqsave(&card->card_lock, flags); 986 985 987 986 if (++safety > 2000) {
+6 -11
drivers/net/wireless/ipw2100.c
··· 800 800 * doesn't seem to have as many firmware restart cycles... 801 801 * 802 802 * As a test, we're sticking in a 1/100s delay here */ 803 - set_current_state(TASK_UNINTERRUPTIBLE); 804 - schedule_timeout(HZ / 100); 803 + schedule_timeout_uninterruptible(msecs_to_jiffies(10)); 805 804 806 805 return 0; 807 806 ··· 1255 1256 IPW_DEBUG_FW("Waiting for f/w initialization to complete...\n"); 1256 1257 i = 5000; 1257 1258 do { 1258 - set_current_state(TASK_UNINTERRUPTIBLE); 1259 - schedule_timeout(40 * HZ / 1000); 1259 + schedule_timeout_uninterruptible(msecs_to_jiffies(40)); 1260 1260 /* Todo... wait for sync command ... */ 1261 1261 1262 1262 read_register(priv->net_dev, IPW_REG_INTA, &inta); ··· 1409 1411 (val2 & IPW2100_COMMAND_PHY_OFF)) 1410 1412 return 0; 1411 1413 1412 - set_current_state(TASK_UNINTERRUPTIBLE); 1413 - schedule_timeout(HW_PHY_OFF_LOOP_DELAY); 1414 + schedule_timeout_uninterruptible(HW_PHY_OFF_LOOP_DELAY); 1414 1415 } 1415 1416 1416 1417 return -EIO; ··· 1463 1466 1464 1467 static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv) 1465 1468 { 1466 - #define HW_POWER_DOWN_DELAY (HZ / 10) 1469 + #define HW_POWER_DOWN_DELAY (msecs_to_jiffies(100)) 1467 1470 1468 1471 struct host_command cmd = { 1469 1472 .host_command = HOST_PRE_POWER_DOWN, ··· 1517 1520 printk(KERN_WARNING DRV_NAME ": " 1518 1521 "%s: Power down command failed: Error %d\n", 1519 1522 priv->net_dev->name, err); 1520 - else { 1521 - set_current_state(TASK_UNINTERRUPTIBLE); 1522 - schedule_timeout(HW_POWER_DOWN_DELAY); 1523 - } 1523 + else 1524 + schedule_timeout_uninterruptible(HW_POWER_DOWN_DELAY); 1524 1525 } 1525 1526 1526 1527 priv->status &= ~STATUS_ENABLED;
+2 -4
drivers/net/wireless/prism54/islpci_dev.c
··· 439 439 wmb(); 440 440 441 441 /* wait a while for the device to reset */ 442 - set_current_state(TASK_UNINTERRUPTIBLE); 443 - schedule_timeout(50*HZ/1000); 442 + schedule_timeout_uninterruptible(msecs_to_jiffies(50)); 444 443 445 444 return 0; 446 445 } ··· 490 491 /* The software reset acknowledge needs about 220 msec here. 491 492 * Be conservative and wait for up to one second. */ 492 493 493 - set_current_state(TASK_UNINTERRUPTIBLE); 494 - remaining = schedule_timeout(HZ); 494 + remaining = schedule_timeout_uninterruptible(HZ); 495 495 496 496 if(remaining > 0) { 497 497 result = 0;
+2 -3
drivers/net/wireless/prism54/islpci_mgt.c
··· 455 455 struct islpci_mgmtframe **recvframe) 456 456 { 457 457 islpci_private *priv = netdev_priv(ndev); 458 - const long wait_cycle_jiffies = (ISL38XX_WAIT_CYCLE * 10 * HZ) / 1000; 458 + const long wait_cycle_jiffies = msecs_to_jiffies(ISL38XX_WAIT_CYCLE * 10); 459 459 long timeout_left = ISL38XX_MAX_WAIT_CYCLES * wait_cycle_jiffies; 460 460 int err; 461 461 DEFINE_WAIT(wait); ··· 475 475 int timeleft; 476 476 struct islpci_mgmtframe *frame; 477 477 478 - set_current_state(TASK_UNINTERRUPTIBLE); 479 - timeleft = schedule_timeout(wait_cycle_jiffies); 478 + timeleft = schedule_timeout_uninterruptible(wait_cycle_jiffies); 480 479 frame = xchg(&priv->mgmt_received, NULL); 481 480 if (frame) { 482 481 if (frame->header->oid == oid) {
+2 -2
include/linux/ibmtr.h
··· 7 7 /* ported to the Alpha architecture 02/20/96 (just used the HZ macro) */ 8 8 9 9 #define TR_RETRY_INTERVAL (30*HZ) /* 500 on PC = 5 s */ 10 - #define TR_RST_TIME (HZ/20) /* 5 on PC = 50 ms */ 11 - #define TR_BUSY_INTERVAL (HZ/5) /* 5 on PC = 200 ms */ 10 + #define TR_RST_TIME (msecs_to_jiffies(50)) /* 5 on PC = 50 ms */ 11 + #define TR_BUSY_INTERVAL (msecs_to_jiffies(200)) /* 5 on PC = 200 ms */ 12 12 #define TR_SPIN_INTERVAL (3*HZ) /* 3 seconds before init timeout */ 13 13 14 14 #define TR_ISA 1
+2 -4
include/linux/netdevice.h
··· 852 852 853 853 static inline void netif_poll_disable(struct net_device *dev) 854 854 { 855 - while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) { 855 + while (test_and_set_bit(__LINK_STATE_RX_SCHED, &dev->state)) 856 856 /* No hurry. */ 857 - current->state = TASK_INTERRUPTIBLE; 858 - schedule_timeout(1); 859 - } 857 + schedule_timeout_interruptible(1); 860 858 } 861 859 862 860 static inline void netif_poll_enable(struct net_device *dev)