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

[PATCH] ipw2100: semaphore to mutexes conversion

semaphore to mutexes conversion.

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

build-tested.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Ingo Molnar and committed by
John W. Linville
752e377b cae16295

+62 -61
+60 -59
drivers/net/wireless/ipw2100.c
··· 194 194 #endif 195 195 196 196 #include <linux/moduleparam.h> 197 + #include <linux/mutex.h> 197 198 module_param(debug, int, 0444); 198 199 module_param(mode, int, 0444); 199 200 module_param(channel, int, 0444); ··· 1419 1418 if (priv->status & STATUS_ENABLED) 1420 1419 return 0; 1421 1420 1422 - down(&priv->adapter_sem); 1421 + mutex_lock(&priv->adapter_mutex); 1423 1422 1424 1423 if (rf_kill_active(priv)) { 1425 1424 IPW_DEBUG_HC("Command aborted due to RF kill active.\n"); ··· 1445 1444 } 1446 1445 1447 1446 fail_up: 1448 - up(&priv->adapter_sem); 1447 + mutex_unlock(&priv->adapter_mutex); 1449 1448 return err; 1450 1449 } 1451 1450 ··· 1577 1576 cancel_delayed_work(&priv->hang_check); 1578 1577 } 1579 1578 1580 - down(&priv->adapter_sem); 1579 + mutex_lock(&priv->adapter_mutex); 1581 1580 1582 1581 err = ipw2100_hw_send_command(priv, &cmd); 1583 1582 if (err) { ··· 1596 1595 IPW_DEBUG_INFO("TODO: implement scan state machine\n"); 1597 1596 1598 1597 fail_up: 1599 - up(&priv->adapter_sem); 1598 + mutex_unlock(&priv->adapter_mutex); 1600 1599 return err; 1601 1600 } 1602 1601 ··· 1889 1888 priv->status |= STATUS_RESET_PENDING; 1890 1889 spin_unlock_irqrestore(&priv->low_lock, flags); 1891 1890 1892 - down(&priv->action_sem); 1891 + mutex_lock(&priv->action_mutex); 1893 1892 /* stop timed checks so that they don't interfere with reset */ 1894 1893 priv->stop_hang_check = 1; 1895 1894 cancel_delayed_work(&priv->hang_check); ··· 1899 1898 wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL); 1900 1899 1901 1900 ipw2100_up(priv, 0); 1902 - up(&priv->action_sem); 1901 + mutex_unlock(&priv->action_mutex); 1903 1902 1904 1903 } 1905 1904 ··· 4213 4212 IPW_DEBUG_RF_KILL("Manual SW RF Kill set to: RADIO %s\n", 4214 4213 disable_radio ? "OFF" : "ON"); 4215 4214 4216 - down(&priv->action_sem); 4215 + mutex_lock(&priv->action_mutex); 4217 4216 4218 4217 if (disable_radio) { 4219 4218 priv->status |= STATUS_RF_KILL_SW; ··· 4231 4230 schedule_reset(priv); 4232 4231 } 4233 4232 4234 - up(&priv->action_sem); 4233 + mutex_unlock(&priv->action_mutex); 4235 4234 return 1; 4236 4235 } 4237 4236 ··· 5535 5534 struct ipw2100_priv *priv = ieee80211_priv(dev); 5536 5535 int i, force_update = 0; 5537 5536 5538 - down(&priv->action_sem); 5537 + mutex_lock(&priv->action_mutex); 5539 5538 if (!(priv->status & STATUS_INITIALIZED)) 5540 5539 goto done; 5541 5540 ··· 5608 5607 if (!(priv->status & (STATUS_ASSOCIATED | STATUS_ASSOCIATING))) 5609 5608 ipw2100_configure_security(priv, 0); 5610 5609 done: 5611 - up(&priv->action_sem); 5610 + mutex_unlock(&priv->action_mutex); 5612 5611 } 5613 5612 5614 5613 static int ipw2100_adapter_setup(struct ipw2100_priv *priv) ··· 5732 5731 if (!is_valid_ether_addr(addr->sa_data)) 5733 5732 return -EADDRNOTAVAIL; 5734 5733 5735 - down(&priv->action_sem); 5734 + mutex_lock(&priv->action_mutex); 5736 5735 5737 5736 priv->config |= CFG_CUSTOM_MAC; 5738 5737 memcpy(priv->mac_addr, addr->sa_data, ETH_ALEN); ··· 5742 5741 goto done; 5743 5742 5744 5743 priv->reset_backoff = 0; 5745 - up(&priv->action_sem); 5744 + mutex_unlock(&priv->action_mutex); 5746 5745 ipw2100_reset_adapter(priv); 5747 5746 return 0; 5748 5747 5749 5748 done: 5750 - up(&priv->action_sem); 5749 + mutex_unlock(&priv->action_mutex); 5751 5750 return err; 5752 5751 } 5753 5752 ··· 6090 6089 strcpy(priv->nick, "ipw2100"); 6091 6090 6092 6091 spin_lock_init(&priv->low_lock); 6093 - sema_init(&priv->action_sem, 1); 6094 - sema_init(&priv->adapter_sem, 1); 6092 + mutex_init(&priv->action_mutex); 6093 + mutex_init(&priv->adapter_mutex); 6095 6094 6096 6095 init_waitqueue_head(&priv->wait_command_queue); 6097 6096 ··· 6256 6255 * member to call a function that then just turns and calls ipw2100_up. 6257 6256 * net_dev->init is called after name allocation but before the 6258 6257 * notifier chain is called */ 6259 - down(&priv->action_sem); 6258 + mutex_lock(&priv->action_mutex); 6260 6259 err = register_netdev(dev); 6261 6260 if (err) { 6262 6261 printk(KERN_WARNING DRV_NAME ··· 6292 6291 6293 6292 priv->status |= STATUS_INITIALIZED; 6294 6293 6295 - up(&priv->action_sem); 6294 + mutex_unlock(&priv->action_mutex); 6296 6295 6297 6296 return 0; 6298 6297 6299 6298 fail_unlock: 6300 - up(&priv->action_sem); 6299 + mutex_unlock(&priv->action_mutex); 6301 6300 6302 6301 fail: 6303 6302 if (dev) { ··· 6337 6336 struct net_device *dev; 6338 6337 6339 6338 if (priv) { 6340 - down(&priv->action_sem); 6339 + mutex_lock(&priv->action_mutex); 6341 6340 6342 6341 priv->status &= ~STATUS_INITIALIZED; 6343 6342 ··· 6352 6351 /* Take down the hardware */ 6353 6352 ipw2100_down(priv); 6354 6353 6355 - /* Release the semaphore so that the network subsystem can 6354 + /* Release the mutex so that the network subsystem can 6356 6355 * complete any needed calls into the driver... */ 6357 - up(&priv->action_sem); 6356 + mutex_unlock(&priv->action_mutex); 6358 6357 6359 6358 /* Unregister the device first - this results in close() 6360 6359 * being called if the device is open. If we free storage ··· 6393 6392 6394 6393 IPW_DEBUG_INFO("%s: Going into suspend...\n", dev->name); 6395 6394 6396 - down(&priv->action_sem); 6395 + mutex_lock(&priv->action_mutex); 6397 6396 if (priv->status & STATUS_INITIALIZED) { 6398 6397 /* Take down the device; powers it off, etc. */ 6399 6398 ipw2100_down(priv); ··· 6406 6405 pci_disable_device(pci_dev); 6407 6406 pci_set_power_state(pci_dev, PCI_D3hot); 6408 6407 6409 - up(&priv->action_sem); 6408 + mutex_unlock(&priv->action_mutex); 6410 6409 6411 6410 return 0; 6412 6411 } ··· 6420 6419 if (IPW2100_PM_DISABLED) 6421 6420 return 0; 6422 6421 6423 - down(&priv->action_sem); 6422 + mutex_lock(&priv->action_mutex); 6424 6423 6425 6424 IPW_DEBUG_INFO("%s: Coming out of suspend...\n", dev->name); 6426 6425 ··· 6446 6445 if (!(priv->status & STATUS_RF_KILL_SW)) 6447 6446 ipw2100_up(priv, 0); 6448 6447 6449 - up(&priv->action_sem); 6448 + mutex_unlock(&priv->action_mutex); 6450 6449 6451 6450 return 0; 6452 6451 } ··· 6610 6609 if (priv->ieee->iw_mode == IW_MODE_INFRA) 6611 6610 return -EOPNOTSUPP; 6612 6611 6613 - down(&priv->action_sem); 6612 + mutex_lock(&priv->action_mutex); 6614 6613 if (!(priv->status & STATUS_INITIALIZED)) { 6615 6614 err = -EIO; 6616 6615 goto done; ··· 6641 6640 } 6642 6641 6643 6642 done: 6644 - up(&priv->action_sem); 6643 + mutex_unlock(&priv->action_mutex); 6645 6644 return err; 6646 6645 } 6647 6646 ··· 6682 6681 if (wrqu->mode == priv->ieee->iw_mode) 6683 6682 return 0; 6684 6683 6685 - down(&priv->action_sem); 6684 + mutex_lock(&priv->action_mutex); 6686 6685 if (!(priv->status & STATUS_INITIALIZED)) { 6687 6686 err = -EIO; 6688 6687 goto done; ··· 6705 6704 } 6706 6705 6707 6706 done: 6708 - up(&priv->action_sem); 6707 + mutex_unlock(&priv->action_mutex); 6709 6708 return err; 6710 6709 } 6711 6710 ··· 6887 6886 if (wrqu->ap_addr.sa_family != ARPHRD_ETHER) 6888 6887 return -EINVAL; 6889 6888 6890 - down(&priv->action_sem); 6889 + mutex_lock(&priv->action_mutex); 6891 6890 if (!(priv->status & STATUS_INITIALIZED)) { 6892 6891 err = -EIO; 6893 6892 goto done; ··· 6916 6915 wrqu->ap_addr.sa_data[5] & 0xff); 6917 6916 6918 6917 done: 6919 - up(&priv->action_sem); 6918 + mutex_unlock(&priv->action_mutex); 6920 6919 return err; 6921 6920 } 6922 6921 ··· 6952 6951 int length = 0; 6953 6952 int err = 0; 6954 6953 6955 - down(&priv->action_sem); 6954 + mutex_lock(&priv->action_mutex); 6956 6955 if (!(priv->status & STATUS_INITIALIZED)) { 6957 6956 err = -EIO; 6958 6957 goto done; ··· 6989 6988 err = ipw2100_set_essid(priv, essid, length, 0); 6990 6989 6991 6990 done: 6992 - up(&priv->action_sem); 6991 + mutex_unlock(&priv->action_mutex); 6993 6992 return err; 6994 6993 } 6995 6994 ··· 7070 7069 u32 rate; 7071 7070 int err = 0; 7072 7071 7073 - down(&priv->action_sem); 7072 + mutex_lock(&priv->action_mutex); 7074 7073 if (!(priv->status & STATUS_INITIALIZED)) { 7075 7074 err = -EIO; 7076 7075 goto done; ··· 7097 7096 7098 7097 IPW_DEBUG_WX("SET Rate -> %04X \n", rate); 7099 7098 done: 7100 - up(&priv->action_sem); 7099 + mutex_unlock(&priv->action_mutex); 7101 7100 return err; 7102 7101 } 7103 7102 ··· 7117 7116 return 0; 7118 7117 } 7119 7118 7120 - down(&priv->action_sem); 7119 + mutex_lock(&priv->action_mutex); 7121 7120 if (!(priv->status & STATUS_INITIALIZED)) { 7122 7121 err = -EIO; 7123 7122 goto done; ··· 7149 7148 IPW_DEBUG_WX("GET Rate -> %d \n", wrqu->bitrate.value); 7150 7149 7151 7150 done: 7152 - up(&priv->action_sem); 7151 + mutex_unlock(&priv->action_mutex); 7153 7152 return err; 7154 7153 } 7155 7154 ··· 7164 7163 if (wrqu->rts.fixed == 0) 7165 7164 return -EINVAL; 7166 7165 7167 - down(&priv->action_sem); 7166 + mutex_lock(&priv->action_mutex); 7168 7167 if (!(priv->status & STATUS_INITIALIZED)) { 7169 7168 err = -EIO; 7170 7169 goto done; ··· 7184 7183 7185 7184 IPW_DEBUG_WX("SET RTS Threshold -> 0x%08X \n", value); 7186 7185 done: 7187 - up(&priv->action_sem); 7186 + mutex_unlock(&priv->action_mutex); 7188 7187 return err; 7189 7188 } 7190 7189 ··· 7235 7234 value = wrqu->txpower.value; 7236 7235 } 7237 7236 7238 - down(&priv->action_sem); 7237 + mutex_lock(&priv->action_mutex); 7239 7238 if (!(priv->status & STATUS_INITIALIZED)) { 7240 7239 err = -EIO; 7241 7240 goto done; ··· 7246 7245 IPW_DEBUG_WX("SET TX Power -> %d \n", value); 7247 7246 7248 7247 done: 7249 - up(&priv->action_sem); 7248 + mutex_unlock(&priv->action_mutex); 7250 7249 return err; 7251 7250 } 7252 7251 ··· 7338 7337 if (!(wrqu->retry.flags & IW_RETRY_LIMIT)) 7339 7338 return 0; 7340 7339 7341 - down(&priv->action_sem); 7340 + mutex_lock(&priv->action_mutex); 7342 7341 if (!(priv->status & STATUS_INITIALIZED)) { 7343 7342 err = -EIO; 7344 7343 goto done; ··· 7365 7364 IPW_DEBUG_WX("SET Both Retry Limits -> %d \n", wrqu->retry.value); 7366 7365 7367 7366 done: 7368 - up(&priv->action_sem); 7367 + mutex_unlock(&priv->action_mutex); 7369 7368 return err; 7370 7369 } 7371 7370 ··· 7408 7407 struct ipw2100_priv *priv = ieee80211_priv(dev); 7409 7408 int err = 0; 7410 7409 7411 - down(&priv->action_sem); 7410 + mutex_lock(&priv->action_mutex); 7412 7411 if (!(priv->status & STATUS_INITIALIZED)) { 7413 7412 err = -EIO; 7414 7413 goto done; ··· 7423 7422 } 7424 7423 7425 7424 done: 7426 - up(&priv->action_sem); 7425 + mutex_unlock(&priv->action_mutex); 7427 7426 return err; 7428 7427 } 7429 7428 ··· 7473 7472 struct ipw2100_priv *priv = ieee80211_priv(dev); 7474 7473 int err = 0; 7475 7474 7476 - down(&priv->action_sem); 7475 + mutex_lock(&priv->action_mutex); 7477 7476 if (!(priv->status & STATUS_INITIALIZED)) { 7478 7477 err = -EIO; 7479 7478 goto done; ··· 7506 7505 IPW_DEBUG_WX("SET Power Management Mode -> 0x%02X\n", priv->power_mode); 7507 7506 7508 7507 done: 7509 - up(&priv->action_sem); 7508 + mutex_unlock(&priv->action_mutex); 7510 7509 return err; 7511 7510 7512 7511 } ··· 7810 7809 int enable = (parms[0] > 0); 7811 7810 int err = 0; 7812 7811 7813 - down(&priv->action_sem); 7812 + mutex_lock(&priv->action_mutex); 7814 7813 if (!(priv->status & STATUS_INITIALIZED)) { 7815 7814 err = -EIO; 7816 7815 goto done; ··· 7828 7827 err = ipw2100_switch_mode(priv, priv->last_mode); 7829 7828 } 7830 7829 done: 7831 - up(&priv->action_sem); 7830 + mutex_unlock(&priv->action_mutex); 7832 7831 return err; 7833 7832 } 7834 7833 ··· 7851 7850 struct ipw2100_priv *priv = ieee80211_priv(dev); 7852 7851 int err = 0, mode = *(int *)extra; 7853 7852 7854 - down(&priv->action_sem); 7853 + mutex_lock(&priv->action_mutex); 7855 7854 if (!(priv->status & STATUS_INITIALIZED)) { 7856 7855 err = -EIO; 7857 7856 goto done; ··· 7863 7862 if (priv->power_mode != mode) 7864 7863 err = ipw2100_set_power_mode(priv, mode); 7865 7864 done: 7866 - up(&priv->action_sem); 7865 + mutex_unlock(&priv->action_mutex); 7867 7866 return err; 7868 7867 } 7869 7868 ··· 7915 7914 struct ipw2100_priv *priv = ieee80211_priv(dev); 7916 7915 int err, mode = *(int *)extra; 7917 7916 7918 - down(&priv->action_sem); 7917 + mutex_lock(&priv->action_mutex); 7919 7918 if (!(priv->status & STATUS_INITIALIZED)) { 7920 7919 err = -EIO; 7921 7920 goto done; ··· 7933 7932 err = ipw2100_system_config(priv, 0); 7934 7933 7935 7934 done: 7936 - up(&priv->action_sem); 7935 + mutex_unlock(&priv->action_mutex); 7937 7936 return err; 7938 7937 } 7939 7938 ··· 7963 7962 struct ipw2100_priv *priv = ieee80211_priv(dev); 7964 7963 int err, mode = *(int *)extra; 7965 7964 7966 - down(&priv->action_sem); 7965 + mutex_lock(&priv->action_mutex); 7967 7966 if (!(priv->status & STATUS_INITIALIZED)) { 7968 7967 err = -EIO; 7969 7968 goto done; ··· 7980 7979 err = 0; 7981 7980 7982 7981 done: 7983 - up(&priv->action_sem); 7982 + mutex_unlock(&priv->action_mutex); 7984 7983 return err; 7985 7984 } 7986 7985 ··· 8285 8284 if (priv->status & STATUS_STOPPING) 8286 8285 return; 8287 8286 8288 - down(&priv->action_sem); 8287 + mutex_lock(&priv->action_mutex); 8289 8288 8290 8289 IPW_DEBUG_WX("enter\n"); 8291 8290 8292 - up(&priv->action_sem); 8291 + mutex_unlock(&priv->action_mutex); 8293 8292 8294 8293 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 8295 8294 ··· 8312 8311 8313 8312 if (!(priv->status & STATUS_ASSOCIATED)) { 8314 8313 IPW_DEBUG_WX("Configuring ESSID\n"); 8315 - down(&priv->action_sem); 8314 + mutex_lock(&priv->action_mutex); 8316 8315 /* This is a disassociation event, so kick the firmware to 8317 8316 * look for another AP */ 8318 8317 if (priv->config & CFG_STATIC_ESSID) ··· 8320 8319 0); 8321 8320 else 8322 8321 ipw2100_set_essid(priv, NULL, 0, 0); 8323 - up(&priv->action_sem); 8322 + mutex_unlock(&priv->action_mutex); 8324 8323 } 8325 8324 8326 8325 wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
+2 -2
drivers/net/wireless/ipw2100.h
··· 594 594 int inta_other; 595 595 596 596 spinlock_t low_lock; 597 - struct semaphore action_sem; 598 - struct semaphore adapter_sem; 597 + struct mutex action_mutex; 598 + struct mutex adapter_mutex; 599 599 600 600 wait_queue_head_t wait_command_queue; 601 601 };