net: convert print_mac to %pM
[safe/jmp/linux-2.6] / drivers / net / wireless / libertas / scan.c
index e72c97a..fcaef38 100644 (file)
@@ -298,7 +298,8 @@ static int lbs_do_scan(struct lbs_private *priv, uint8_t bsstype,
        uint8_t *tlv;   /* pointer into our current, growing TLV storage area */
 
        lbs_deb_enter_args(LBS_DEB_SCAN, "bsstype %d, chanlist[].chan %d, chan_count %d",
-                          bsstype, chan_list[0].channumber, chan_count);
+               bsstype, chan_list ? chan_list[0].channumber : -1,
+               chan_count);
 
        /* create the fixed part for scan command */
        scan_cmd = kzalloc(MAX_SCAN_CFG_ALLOC, GFP_KERNEL);
@@ -358,7 +359,6 @@ int lbs_scan_networks(struct lbs_private *priv, int full_scan)
 #ifdef CONFIG_LIBERTAS_DEBUG
        struct bss_descriptor *iter;
        int i = 0;
-       DECLARE_MAC_BUF(mac);
 #endif
 
        lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", full_scan);
@@ -450,8 +450,8 @@ int lbs_scan_networks(struct lbs_private *priv, int full_scan)
        mutex_lock(&priv->lock);
        lbs_deb_scan("scan table:\n");
        list_for_each_entry(iter, &priv->network_list, list)
-               lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n",
-                            i++, print_mac(mac, iter->bssid), iter->rssi,
+               lbs_deb_scan("%02d: BSSID %pM, RSSI %d, SSID '%s'\n",
+                            i++, iter->bssid, iter->rssi,
                             escape_essid(iter->ssid, iter->ssid_len));
        mutex_unlock(&priv->lock);
 #endif
@@ -511,7 +511,6 @@ static int lbs_process_bss(struct bss_descriptor *bss,
        struct ieeetypes_dsparamset *pDS;
        struct ieeetypes_cfparamset *pCF;
        struct ieeetypes_ibssparamset *pibss;
-       DECLARE_MAC_BUF(mac);
        struct ieeetypes_countryinfoset *pcountryinfo;
        uint8_t *pos, *end, *p;
        uint8_t n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0;
@@ -522,7 +521,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
 
        if (*bytesleft >= sizeof(beaconsize)) {
                /* Extract & convert beacon size from the command buffer */
-               beaconsize = le16_to_cpu(get_unaligned((__le16 *)*pbeaconinfo));
+               beaconsize = get_unaligned_le16(*pbeaconinfo);
                *bytesleft -= sizeof(beaconsize);
                *pbeaconinfo += sizeof(beaconsize);
        }
@@ -543,7 +542,7 @@ static int lbs_process_bss(struct bss_descriptor *bss,
        *bytesleft -= beaconsize;
 
        memcpy(bss->bssid, pos, ETH_ALEN);
-       lbs_deb_scan("process_bss: BSSID %s\n", print_mac(mac, bss->bssid));
+       lbs_deb_scan("process_bss: BSSID %pM\n", bss->bssid);
        pos += ETH_ALEN;
 
        if ((end - pos) < 12) {
@@ -566,11 +565,11 @@ static int lbs_process_bss(struct bss_descriptor *bss,
        pos += 8;
 
        /* beacon interval is 2 bytes long */
-       bss->beaconperiod = le16_to_cpup((void *) pos);
+       bss->beaconperiod = get_unaligned_le16(pos);
        pos += 2;
 
        /* capability information is 2 bytes long */
-       bss->capability = le16_to_cpup((void *) pos);
+       bss->capability = get_unaligned_le16(pos);
        lbs_deb_scan("process_bss: capabilities 0x%04x\n", bss->capability);
        pos += 2;
 
@@ -775,8 +774,9 @@ out:
 #define MAX_CUSTOM_LEN 64
 
 static inline char *lbs_translate_scan(struct lbs_private *priv,
-                                      char *start, char *stop,
-                                      struct bss_descriptor *bss)
+                                           struct iw_request_info *info,
+                                           char *start, char *stop,
+                                           struct bss_descriptor *bss)
 {
        struct chan_freq_power *cfp;
        char *current_val;      /* For rates */
@@ -800,24 +800,24 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
        iwe.cmd = SIOCGIWAP;
        iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
        memcpy(iwe.u.ap_addr.sa_data, &bss->bssid, ETH_ALEN);
-       start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN);
+       start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN);
 
        /* SSID */
        iwe.cmd = SIOCGIWESSID;
        iwe.u.data.flags = 1;
        iwe.u.data.length = min((uint32_t) bss->ssid_len, (uint32_t) IW_ESSID_MAX_SIZE);
-       start = iwe_stream_add_point(start, stop, &iwe, bss->ssid);
+       start = iwe_stream_add_point(info, start, stop, &iwe, bss->ssid);
 
        /* Mode */
        iwe.cmd = SIOCGIWMODE;
        iwe.u.mode = bss->mode;
-       start = iwe_stream_add_event(start, stop, &iwe, IW_EV_UINT_LEN);
+       start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN);
 
        /* Frequency */
        iwe.cmd = SIOCGIWFREQ;
        iwe.u.freq.m = (long)cfp->freq * 100000;
        iwe.u.freq.e = 1;
-       start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN);
+       start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN);
 
        /* Add quality statistics */
        iwe.cmd = IWEVQUAL;
@@ -851,7 +851,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
                nf = priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE;
                iwe.u.qual.level = CAL_RSSI(snr, nf);
        }
-       start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN);
+       start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN);
 
        /* Add encryption capability */
        iwe.cmd = SIOCGIWENCODE;
@@ -861,9 +861,9 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
                iwe.u.data.flags = IW_ENCODE_DISABLED;
        }
        iwe.u.data.length = 0;
-       start = iwe_stream_add_point(start, stop, &iwe, bss->ssid);
+       start = iwe_stream_add_point(info, start, stop, &iwe, bss->ssid);
 
-       current_val = start + IW_EV_LCP_LEN;
+       current_val = start + iwe_stream_lcp_len(info);
 
        iwe.cmd = SIOCGIWRATE;
        iwe.u.bitrate.fixed = 0;
@@ -873,19 +873,19 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
        for (j = 0; bss->rates[j] && (j < sizeof(bss->rates)); j++) {
                /* Bit rate given in 500 kb/s units */
                iwe.u.bitrate.value = bss->rates[j] * 500000;
-               current_val = iwe_stream_add_value(start, current_val,
-                                        stop, &iwe, IW_EV_PARAM_LEN);
+               current_val = iwe_stream_add_value(info, start, current_val,
+                                                  stop, &iwe, IW_EV_PARAM_LEN);
        }
        if ((bss->mode == IW_MODE_ADHOC) && priv->adhoccreate
            && !lbs_ssid_cmp(priv->curbssparams.ssid,
                             priv->curbssparams.ssid_len,
                             bss->ssid, bss->ssid_len)) {
                iwe.u.bitrate.value = 22 * 500000;
-               current_val = iwe_stream_add_value(start, current_val,
+               current_val = iwe_stream_add_value(info, start, current_val,
                                                   stop, &iwe, IW_EV_PARAM_LEN);
        }
        /* Check if we added any event */
-       if((current_val - start) > IW_EV_LCP_LEN)
+       if ((current_val - start) > iwe_stream_lcp_len(info))
                start = current_val;
 
        memset(&iwe, 0, sizeof(iwe));
@@ -894,7 +894,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
                memcpy(buf, bss->wpa_ie, bss->wpa_ie_len);
                iwe.cmd = IWEVGENIE;
                iwe.u.data.length = bss->wpa_ie_len;
-               start = iwe_stream_add_point(start, stop, &iwe, buf);
+               start = iwe_stream_add_point(info, start, stop, &iwe, buf);
        }
 
        memset(&iwe, 0, sizeof(iwe));
@@ -903,7 +903,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
                memcpy(buf, bss->rsn_ie, bss->rsn_ie_len);
                iwe.cmd = IWEVGENIE;
                iwe.u.data.length = bss->rsn_ie_len;
-               start = iwe_stream_add_point(start, stop, &iwe, buf);
+               start = iwe_stream_add_point(info, start, stop, &iwe, buf);
        }
 
        if (bss->mesh) {
@@ -914,7 +914,8 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
                p += snprintf(p, MAX_CUSTOM_LEN, "mesh-type: olpc");
                iwe.u.data.length = p - custom;
                if (iwe.u.data.length)
-                       start = iwe_stream_add_point(start, stop, &iwe, custom);
+                       start = iwe_stream_add_point(info, start, stop,
+                                                    &iwe, custom);
        }
 
 out:
@@ -941,6 +942,11 @@ int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
 
        lbs_deb_enter(LBS_DEB_WEXT);
 
+       if (!priv->radio_on) {
+               ret = -EINVAL;
+               goto out;
+       }
+
        if (!netif_running(dev)) {
                ret = -ENETDOWN;
                goto out;
@@ -1035,7 +1041,7 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
                }
 
                /* Translate to WE format this entry */
-               next_ev = lbs_translate_scan(priv, ev, stop, iter_bss);
+               next_ev = lbs_translate_scan(priv, info, ev, stop, iter_bss);
                if (next_ev == NULL)
                        continue;
                ev = next_ev;
@@ -1143,7 +1149,6 @@ static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy,
                struct bss_descriptor new;
                struct bss_descriptor *found = NULL;
                struct bss_descriptor *oldest = NULL;
-               DECLARE_MAC_BUF(mac);
 
                /* Process the data fields and IEs returned for this BSS */
                memset(&new, 0, sizeof (struct bss_descriptor));
@@ -1182,7 +1187,7 @@ static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy,
                        continue;
                }
 
-               lbs_deb_scan("SCAN_RESP: BSSID %s\n", print_mac(mac, new.bssid));
+               lbs_deb_scan("SCAN_RESP: BSSID %pM\n", new.bssid);
 
                /* Copy the locally created newbssentry to the scan table */
                memcpy(found, &new, offsetof(struct bss_descriptor, list));