staging: rtl8188eu:Remove rtw_zmalloc(), wrapper for kzalloc()
[deliverable/linux.git] / drivers / staging / rtl8188eu / os_dep / ioctl_linux.c
index 8ddeaac29cbcf2fd5ce8b1ab17dfa49f5a9bc7e9..284a28ecca3b4c69e4481adffa3d37eb4cd607a8 100644 (file)
@@ -632,7 +632,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
        }
 
        if (ielen) {
-               buf = rtw_zmalloc(ielen);
+               buf = kzalloc(ielen, GFP_KERNEL);
                if (buf == NULL) {
                        ret =  -ENOMEM;
                        goto exit;
@@ -1111,10 +1111,7 @@ static int rtw_wx_set_wap(struct net_device *dev,
        phead = get_list_head(queue);
        pmlmepriv->pscanned = phead->next;
 
-       while (1) {
-               if ((rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) == true)
-                       break;
-
+       while (phead != pmlmepriv->pscanned) {
                pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list);
 
                pmlmepriv->pscanned = pmlmepriv->pscanned->next;
@@ -1402,10 +1399,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a,
        phead = get_list_head(queue);
        plist = phead->next;
 
-       while (1) {
-               if (rtw_end_of_queue_search(phead, plist))
-                       break;
-
+       while (phead != plist) {
                if ((stop - ev) < SCAN_ITEM_SIZE) {
                        ret = -E2BIG;
                        break;
@@ -1490,14 +1484,7 @@ static int rtw_wx_set_essid(struct net_device *dev,
               phead = get_list_head(queue);
              pmlmepriv->pscanned = phead->next;
 
-               while (1) {
-                       if (rtw_end_of_queue_search(phead, pmlmepriv->pscanned) == true) {
-                               RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_warning_,
-                                        ("rtw_wx_set_essid: scan_q is empty, set ssid to check if scanning again!\n"));
-
-                               break;
-                       }
-
+               while (phead != pmlmepriv->pscanned) {
                        pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list);
 
                        pmlmepriv->pscanned = pmlmepriv->pscanned->next;
@@ -2563,10 +2550,7 @@ static int rtw_get_ap_info(struct net_device *dev,
        phead = get_list_head(queue);
        plist = phead->next;
 
-       while (1) {
-               if (rtw_end_of_queue_search(phead, plist) == true)
-                       break;
-
+       while (phead != plist) {
                pnetwork = container_of(plist, struct wlan_network, list);
 
                if (hwaddr_aton_i(data, bssid)) {
@@ -3066,10 +3050,7 @@ static int rtw_p2p_get_wps_configmethod(struct net_device *dev,
        phead = get_list_head(queue);
        plist = phead->next;
 
-       while (1) {
-               if (rtw_end_of_queue_search(phead, plist) == true)
-                       break;
-
+       while (phead != plist) {
                pnetwork = container_of(plist, struct wlan_network, list);
                if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
                        u8 *wpsie;
@@ -3136,10 +3117,7 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev,
        phead = get_list_head(queue);
        plist = phead->next;
 
-       while (1) {
-               if (rtw_end_of_queue_search(phead, plist) == true)
-                       break;
-
+       while (phead != plist) {
                pnetwork = container_of(plist, struct wlan_network, list);
                if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
                        /*      Commented by Albert 2011/05/18 */
@@ -3220,10 +3198,7 @@ static int rtw_p2p_get_device_type(struct net_device *dev,
        phead = get_list_head(queue);
        plist = phead->next;
 
-       while (1) {
-               if (rtw_end_of_queue_search(phead, plist) == true)
-                       break;
-
+       while (phead != plist) {
                pnetwork = container_of(plist, struct wlan_network, list);
                if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
                        u8 *wpsie;
@@ -3299,10 +3274,7 @@ static int rtw_p2p_get_device_name(struct net_device *dev,
        phead = get_list_head(queue);
        plist = phead->next;
 
-       while (1) {
-               if (rtw_end_of_queue_search(phead, plist) == true)
-                       break;
-
+       while (phead != plist) {
                pnetwork = container_of(plist, struct wlan_network, list);
                if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
                        u8 *wpsie;
@@ -3370,10 +3342,7 @@ static int rtw_p2p_get_invitation_procedure(struct net_device *dev,
        phead = get_list_head(queue);
        plist = phead->next;
 
-       while (1) {
-               if (rtw_end_of_queue_search(phead, plist) == true)
-                       break;
-
+       while (phead != plist) {
                pnetwork = container_of(plist, struct wlan_network, list);
                if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
                        /*      Commented by Albert 20121226 */
@@ -3452,10 +3421,7 @@ static int rtw_p2p_connect(struct net_device *dev,
        phead = get_list_head(queue);
        plist = phead->next;
 
-       while (1) {
-               if (rtw_end_of_queue_search(phead, plist) == true)
-                       break;
-
+       while (phead != plist) {
                pnetwork = container_of(plist, struct wlan_network, list);
                if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) {
                        uintPeerChannel = pnetwork->network.Configuration.DSConfig;
@@ -3547,10 +3513,7 @@ static int rtw_p2p_invite_req(struct net_device *dev,
        phead = get_list_head(queue);
        plist = phead->next;
 
-       while (1) {
-               if (rtw_end_of_queue_search(phead, plist) == true)
-                       break;
-
+       while (phead != plist) {
                pnetwork = container_of(plist, struct wlan_network, list);
 
                /*      Commented by Albert 2011/05/18 */
@@ -3697,9 +3660,7 @@ static int rtw_p2p_prov_disc(struct net_device *dev,
        phead = get_list_head(queue);
        plist = phead->next;
 
-       while (1) {
-               if (rtw_end_of_queue_search(phead, plist) == true)
-                       break;
+       while (phead != plist) {
 
                if (uintPeerChannel != 0)
                        break;
@@ -4402,7 +4363,7 @@ static int rtw_dbg_port(struct net_device *dev,
                                        phead = &(pstapriv->sta_hash[i]);
                                        plist = phead->next;
 
-                                       while ((rtw_end_of_queue_search(phead, plist)) == false) {
+                                       while (phead != plist) {
                                                psta = container_of(plist, struct sta_info, hash_list);
 
                                                plist = plist->next;
@@ -4760,13 +4721,13 @@ static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta)
        struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
        u8 res = _SUCCESS;
 
-       ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj));
+       ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL);
        if (ph2c == NULL) {
                res = _FAIL;
                goto exit;
        }
 
-       psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm));
+       psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL);
        if (psetstakey_para == NULL) {
                kfree(ph2c);
                res = _FAIL;
@@ -4798,12 +4759,12 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid)
 
        DBG_88E("%s\n", __func__);
 
-       pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct      cmd_obj));
+       pcmd = kzalloc(sizeof(struct    cmd_obj), GFP_KERNEL);
        if (pcmd == NULL) {
                res = _FAIL;
                goto exit;
        }
-       psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm));
+       psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL);
        if (psetkeyparm == NULL) {
                kfree(pcmd);
                res = _FAIL;
@@ -4840,7 +4801,7 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid)
        pcmd->rsp = NULL;
        pcmd->rspsz = 0;
 
-       _rtw_init_listhead(&pcmd->list);
+       INIT_LIST_HEAD(&pcmd->list);
 
        res = rtw_enqueue_cmd(pcmdpriv, pcmd);
 
@@ -5215,7 +5176,7 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param)
        psta = rtw_get_stainfo(pstapriv, param->sta_addr);
        if (psta) {
                spin_lock_bh(&pstapriv->asoc_list_lock);
-               if (!rtw_is_list_empty(&psta->asoc_list)) {
+               if (!list_empty(&psta->asoc_list)) {
                        rtw_list_delete(&psta->asoc_list);
                        pstapriv->asoc_list_cnt--;
                        updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING);
@@ -5711,12 +5672,12 @@ static int rtw_mp_efuse_get(struct net_device *dev,
        pEfuseHal = &haldata->EfuseHal;
 
        err = 0;
-       data = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN);
+       data = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL);
        if (data == NULL) {
                err = -ENOMEM;
                goto exit;
        }
-       rawdata = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN);
+       rawdata = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL);
        if (rawdata == NULL) {
                err = -ENOMEM;
                goto exit;
@@ -5955,7 +5916,7 @@ static int rtw_mp_efuse_set(struct net_device *dev,
        haldata = GET_HAL_DATA(padapter);
        pEfuseHal = &haldata->EfuseHal;
        err = 0;
-       setdata = _rtw_zmalloc(1024);
+       setdata = kzalloc(1024, GFP_KERNEL);
        if (setdata == NULL) {
                err = -ENOMEM;
                goto exit;
@@ -6629,9 +6590,10 @@ static int rtw_mp_rate(struct net_device *dev,
                        struct iw_request_info *info,
                        struct iw_point *wrqu, char *extra)
 {
-       u32 rate = MPT_RATE_1M;
+       unsigned long rate = MPT_RATE_1M;
        char    *input = kmalloc(wrqu->length, GFP_KERNEL);
        struct adapter *padapter = rtw_netdev_priv(dev);
+       int status;
 
        if (!input)
                return -ENOMEM;
@@ -6639,8 +6601,12 @@ static int rtw_mp_rate(struct net_device *dev,
                kfree(input);
                return -EFAULT;
        }
-       rate = rtw_atoi(input);
-       sprintf(extra, "Set data rate to %d", rate);
+
+       status = kstrtoul(input, 0, &rate);
+       if (status)
+               return status;
+
+       sprintf(extra, "Set data rate to %lu", rate);
        kfree(input);
        if (rate <= 0x7f)
                rate = wifirate2_ratetbl_inx((u8)rate);
@@ -6662,8 +6628,9 @@ static int rtw_mp_channel(struct net_device *dev,
                        struct iw_point *wrqu, char *extra)
 {
        struct adapter *padapter = rtw_netdev_priv(dev);
-       char    *input = kmalloc(wrqu->length, GFP_KERNEL);
-       u32     channel = 1;
+       char *input = kmalloc(wrqu->length, GFP_KERNEL);
+       unsigned long channel = 1;
+       int status;
 
        if (!input)
                return -ENOMEM;
@@ -6671,8 +6638,12 @@ static int rtw_mp_channel(struct net_device *dev,
                kfree(input);
                return -EFAULT;
        }
-       channel = rtw_atoi(input);
-       sprintf(extra, "Change channel %d to channel %d", padapter->mppriv.channel, channel);
+
+       status = kstrtoul(input, 0, &channel);
+       if (status)
+               return status;
+
+       sprintf(extra, "Change channel %d to channel %lu", padapter->mppriv.channel, channel);
 
        padapter->mppriv.channel = channel;
        Hal_SetChannel(padapter);
@@ -7467,7 +7438,7 @@ static int rtw_test(
        DBG_88E("+%s\n", __func__);
        len = wrqu->data.length;
 
-       pbuf = (u8 *)rtw_zmalloc(len);
+       pbuf = kzalloc(len, GFP_KERNEL);
        if (pbuf == NULL) {
                DBG_88E("%s: no memory!\n", __func__);
                return -ENOMEM;
@@ -7812,7 +7783,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
        memcpy(&wdata, wrq_data, sizeof(wdata));
 
        input_len = wdata.data.length;
-       input = rtw_zmalloc(input_len);
+       input = kzalloc(input_len, GFP_KERNEL);
        if (NULL == input)
                return -ENOMEM;
        if (copy_from_user(input, wdata.data.pointer, input_len)) {
@@ -7879,7 +7850,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
                k = j;
        }
 
-       buffer = rtw_zmalloc(4096);
+       buffer = kzalloc(4096, GFP_KERNEL);
        if (NULL == buffer) {
                err = -ENOMEM;
                goto exit;
@@ -8028,7 +7999,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
                else
                        n = wdata.data.length;
 
-               output = rtw_zmalloc(4096);
+               output = kzalloc(4096, GFP_KERNEL);
                if (NULL == output) {
                        err =  -ENOMEM;
                        goto exit;
This page took 0.029549 seconds and 5 git commands to generate.