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

staging: r8712u: Most return-values changed from -1 to proper errno macros.

The ioctl handlers were frequently returning -1 upon failure. Most of
these have now been changed to proper errno macros.
The few remaining ones have been left untouched because either the
handler is not called (and so cannot be tested), or the function never
fails (and so cannot be system-tested), or requires new code to
distinguish its failures.

Signed-off-by: Ali Bahar <ali@internetDog.org>
Cc: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Ali Bahar and committed by
Greg Kroah-Hartman
2192e606 5d3da4a2

+24 -25
+22 -22
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
··· 530 530 memcpy(buf, pie , ielen); 531 531 pos = buf; 532 532 if (ielen < RSN_HEADER_LEN) { 533 - ret = -1; 533 + ret = -EINVAL; 534 534 goto exit; 535 535 } 536 536 if (r8712_parse_wpa_ie(buf, ielen, &group_cipher, ··· 740 740 pcur_bss->Configuration.DSConfig-1] * 100000; 741 741 wrqu->freq.e = 1; 742 742 wrqu->freq.i = pcur_bss->Configuration.DSConfig; 743 - } else 744 - return -1; 743 + } else { 744 + return -ENOLINK; 745 + } 745 746 return 0; 746 747 } 747 748 ··· 773 772 r8712_setopmode_cmd(padapter, networkType); 774 773 else 775 774 r8712_setopmode_cmd(padapter, Ndis802_11AutoUnknown); 776 - if (!r8712_set_802_11_infrastructure_mode(padapter, networkType)) 777 - return -1; 775 + 776 + r8712_set_802_11_infrastructure_mode(padapter, networkType); 778 777 return 0; 779 778 } 780 779 ··· 1091 1090 enum NDIS_802_11_AUTHENTICATION_MODE authmode; 1092 1091 1093 1092 if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) 1094 - return -1; 1093 + return -EBUSY; 1095 1094 if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) 1096 1095 return ret; 1097 1096 if (temp->sa_family != ARPHRD_ETHER) ··· 1108 1107 pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); 1109 1108 dst_bssid = pnetwork->network.MacAddress; 1110 1109 if (!memcmp(dst_bssid, temp->sa_data, ETH_ALEN)) { 1111 - if (r8712_set_802_11_infrastructure_mode(padapter, 1112 - pnetwork->network.InfrastructureMode) == false) 1113 - ret = -1; 1110 + r8712_set_802_11_infrastructure_mode(padapter, 1111 + pnetwork->network.InfrastructureMode); 1114 1112 break; 1115 1113 } 1116 1114 } 1117 1115 spin_unlock_irqrestore(&queue->lock, irqL); 1118 1116 if (!ret) { 1119 1117 if (!r8712_set_802_11_authentication_mode(padapter, authmode)) 1120 - ret = -1; 1118 + ret = -ENOMEM; 1121 1119 else { 1122 1120 if (!r8712_set_802_11_bssid(padapter, temp->sa_data)) 1123 1121 ret = -1; ··· 1191 1191 return -1; 1192 1192 } 1193 1193 if (padapter->bup == false) 1194 - return -1; 1194 + return -ENETDOWN; 1195 1195 if (padapter->hw_init_completed == false) 1196 1196 return -1; 1197 1197 if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) || ··· 1294 1294 u32 len; 1295 1295 1296 1296 if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) 1297 - return -1; 1297 + return -EBUSY; 1298 1298 if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) 1299 1299 return 0; 1300 1300 if (wrqu->essid.length > IW_ESSID_MAX_SIZE) ··· 1330 1330 continue; 1331 1331 } 1332 1332 1333 - if (!r8712_set_802_11_infrastructure_mode( 1333 + r8712_set_802_11_infrastructure_mode( 1334 1334 padapter, 1335 - pnetwork->network.InfrastructureMode)) 1336 - return -1; 1335 + pnetwork->network.InfrastructureMode); 1337 1336 break; 1338 1337 } 1339 1338 } ··· 1356 1357 wrqu->essid.length = len; 1357 1358 memcpy(extra, pcur_bss->Ssid.Ssid, len); 1358 1359 wrqu->essid.flags = 1; 1359 - } else 1360 - ret = -1; 1360 + } else { 1361 + ret = -ENOLINK; 1362 + } 1361 1363 return ret; 1362 1364 } 1363 1365 ··· 1430 1430 datarates[i] = 0xff; 1431 1431 } 1432 1432 if (r8712_setdatarate_cmd(padapter, datarates) != _SUCCESS) 1433 - ret = -1; 1433 + ret = -ENOMEM; 1434 1434 return ret; 1435 1435 } 1436 1436 ··· 1492 1492 wrqu->bitrate.value = max_rate * 500000; 1493 1493 } 1494 1494 } else 1495 - return -1; 1495 + return -ENOLINK; 1496 1496 return 0; 1497 1497 } 1498 1498 ··· 1822 1822 param_len = sizeof(struct ieee_param) + pext->key_len; 1823 1823 param = (struct ieee_param *)_malloc(param_len); 1824 1824 if (param == NULL) 1825 - return -1; 1825 + return -ENOMEM; 1826 1826 memset(param, 0, param_len); 1827 1827 param->cmd = IEEE_CMD_SET_ENCRYPTION; 1828 1828 memset(param->sta_addr, 0xff, ETH_ALEN); ··· 1840 1840 alg_name = "CCMP"; 1841 1841 break; 1842 1842 default: 1843 - return -1; 1843 + return -EINVAL; 1844 1844 } 1845 1845 strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); 1846 1846 if (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) ··· 1906 1906 struct iw_request_info *a, 1907 1907 union iwreq_data *wrqu, char *b) 1908 1908 { 1909 - return -1; 1909 + return -ENOSYS; 1910 1910 } 1911 1911 1912 1912 static int r8711_drvext_hdl(struct net_device *dev,
+1 -2
drivers/staging/rtl8712/rtl871x_ioctl_set.c
··· 243 243 spin_unlock_irqrestore(&pmlmepriv->lock, irqL); 244 244 } 245 245 246 - u8 r8712_set_802_11_infrastructure_mode(struct _adapter *padapter, 246 + void r8712_set_802_11_infrastructure_mode(struct _adapter *padapter, 247 247 enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype) 248 248 { 249 249 unsigned long irqL; ··· 290 290 } 291 291 spin_unlock_irqrestore(&pmlmepriv->lock, irqL); 292 292 } 293 - return true; 294 293 } 295 294 296 295 u8 r8712_set_802_11_disassociate(struct _adapter *padapter)
+1 -1
drivers/staging/rtl8712/rtl871x_ioctl_set.h
··· 47 47 48 48 u8 r8712_set_802_11_bssid_list_scan(struct _adapter *padapter); 49 49 50 - u8 r8712_set_802_11_infrastructure_mode(struct _adapter *padapter, 50 + void r8712_set_802_11_infrastructure_mode(struct _adapter *padapter, 51 51 enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype); 52 52 53 53 void r8712_set_802_11_ssid(struct _adapter *padapter,