diff options
Diffstat (limited to 'drivers/staging/wlan-ng')
-rw-r--r-- | drivers/staging/wlan-ng/hfa384x_usb.c | 154 | ||||
-rw-r--r-- | drivers/staging/wlan-ng/p80211conv.c | 5 | ||||
-rw-r--r-- | drivers/staging/wlan-ng/p80211req.c | 5 | ||||
-rw-r--r-- | drivers/staging/wlan-ng/p80211wext.c | 399 | ||||
-rw-r--r-- | drivers/staging/wlan-ng/prism2fw.c | 36 | ||||
-rw-r--r-- | drivers/staging/wlan-ng/prism2sta.c | 71 | ||||
-rw-r--r-- | drivers/staging/wlan-ng/prism2usb.c | 65 |
7 files changed, 365 insertions, 370 deletions
diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 5df56f0238d6..a41db5dc8c7c 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -62,9 +62,9 @@ * * hfa384x_drvr_xxxconfig An example of the drvr level abstraction. These * functions are wrappers for the RID get/set -* sequence. They call copy_[to|from]_bap() and -* cmd_access(). These functions operate on the -* RIDs and buffers without validation. The caller +* sequence. They call copy_[to|from]_bap() and +* cmd_access(). These functions operate on the +* RIDs and buffers without validation. The caller * is responsible for that. * * API wrapper functions: @@ -144,7 +144,6 @@ enum cmd_mode { DOWAIT = 0, DOASYNC }; -typedef enum cmd_mode CMD_MODE; #define THROTTLE_JIFFIES (HZ/8) #define URB_ASYNC_UNLINK 0 @@ -206,12 +205,11 @@ static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx); struct usbctlx_completor { int (*complete) (struct usbctlx_completor *); }; -typedef struct usbctlx_completor usbctlx_completor_t; static int hfa384x_usbctlx_complete_sync(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx, - usbctlx_completor_t *completor); + struct usbctlx_completor *completor); static int unlocked_usbctlx_cancel_async(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx); @@ -232,13 +230,13 @@ usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp, /* Low level req/resp CTLX formatters and submitters */ static int hfa384x_docmd(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, hfa384x_metacmd_t *cmd, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data); static int hfa384x_dorrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -246,7 +244,7 @@ hfa384x_dorrid(hfa384x_t *hw, static int hfa384x_dowrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -254,7 +252,7 @@ hfa384x_dowrid(hfa384x_t *hw, static int hfa384x_dormem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -263,7 +261,7 @@ hfa384x_dormem(hfa384x_t *hw, static int hfa384x_dowmem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -351,7 +349,8 @@ static int submit_rx_urb(hfa384x_t *hw, gfp_t memflags) hw->rx_urb_skb = skb; result = -ENOLINK; - if (!hw->wlandev->hwremoved && !test_bit(WORK_RX_HALT, &hw->usb_flags)) { + if (!hw->wlandev->hwremoved && + !test_bit(WORK_RX_HALT, &hw->usb_flags)) { result = SUBMIT_URB(&hw->rx_urb, memflags); /* Check whether we need to reset the RX pipe */ @@ -451,7 +450,7 @@ static void hfa384x_usb_defer(struct work_struct *data) if (test_bit(WORK_RX_HALT, &hw->usb_flags)) { int ret; - usb_kill_urb(&hw->rx_urb); /* Cannot be holding spinlock! */ + usb_kill_urb(&hw->rx_urb); /* Cannot be holding spinlock! */ ret = usb_clear_halt(hw->usb, hw->endp_in); if (ret != 0) { @@ -668,26 +667,26 @@ usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp, * when processing a CTLX that returns a hfa384x_cmdresult_t structure. ----------------------------------------------------------------*/ struct usbctlx_cmd_completor { - usbctlx_completor_t head; + struct usbctlx_completor head; const hfa384x_usb_cmdresp_t *cmdresp; hfa384x_cmdresult_t *result; }; -typedef struct usbctlx_cmd_completor usbctlx_cmd_completor_t; -static int usbctlx_cmd_completor_fn(usbctlx_completor_t *head) +static inline int usbctlx_cmd_completor_fn(struct usbctlx_completor *head) { - usbctlx_cmd_completor_t *complete = (usbctlx_cmd_completor_t *) head; + struct usbctlx_cmd_completor *complete; + + complete = (struct usbctlx_cmd_completor *) head; return usbctlx_get_status(complete->cmdresp, complete->result); } -static inline usbctlx_completor_t *init_cmd_completor(usbctlx_cmd_completor_t * - completor, - const - hfa384x_usb_cmdresp_t * - cmdresp, - hfa384x_cmdresult_t * - result) +static inline struct usbctlx_completor *init_cmd_completor( + struct usbctlx_cmd_completor + *completor, + const hfa384x_usb_cmdresp_t + *cmdresp, + hfa384x_cmdresult_t *result) { completor->head.complete = usbctlx_cmd_completor_fn; completor->cmdresp = cmdresp; @@ -701,19 +700,19 @@ static inline usbctlx_completor_t *init_cmd_completor(usbctlx_cmd_completor_t * * when processing a CTLX that reads a RID. ----------------------------------------------------------------*/ struct usbctlx_rrid_completor { - usbctlx_completor_t head; + struct usbctlx_completor head; const hfa384x_usb_rridresp_t *rridresp; void *riddata; unsigned int riddatalen; }; -typedef struct usbctlx_rrid_completor usbctlx_rrid_completor_t; -static int usbctlx_rrid_completor_fn(usbctlx_completor_t *head) +static int usbctlx_rrid_completor_fn(struct usbctlx_completor *head) { - usbctlx_rrid_completor_t *complete = (usbctlx_rrid_completor_t *) head; + struct usbctlx_rrid_completor *complete; hfa384x_rridresult_t rridresult; + complete = (struct usbctlx_rrid_completor *) head; usbctlx_get_rridresult(complete->rridresp, &rridresult); /* Validate the length, note body len calculation in bytes */ @@ -729,12 +728,13 @@ static int usbctlx_rrid_completor_fn(usbctlx_completor_t *head) return 0; } -static inline usbctlx_completor_t *init_rrid_completor(usbctlx_rrid_completor_t - *completor, - const - hfa384x_usb_rridresp_t * - rridresp, void *riddata, - unsigned int riddatalen) +static inline struct usbctlx_completor *init_rrid_completor( + struct usbctlx_rrid_completor + *completor, + const hfa384x_usb_rridresp_t + *rridresp, + void *riddata, + unsigned int riddatalen) { completor->head.complete = usbctlx_rrid_completor_fn; completor->rridresp = rridresp; @@ -747,14 +747,14 @@ static inline usbctlx_completor_t *init_rrid_completor(usbctlx_rrid_completor_t * Completor object: * Interprets the results of a synchronous RID-write ----------------------------------------------------------------*/ -typedef usbctlx_cmd_completor_t usbctlx_wrid_completor_t; +typedef struct usbctlx_cmd_completor usbctlx_wrid_completor_t; #define init_wrid_completor init_cmd_completor /*---------------------------------------------------------------- * Completor object: * Interprets the results of a synchronous memory-write ----------------------------------------------------------------*/ -typedef usbctlx_cmd_completor_t usbctlx_wmem_completor_t; +typedef struct usbctlx_cmd_completor usbctlx_wmem_completor_t; #define init_wmem_completor init_cmd_completor /*---------------------------------------------------------------- @@ -762,7 +762,7 @@ typedef usbctlx_cmd_completor_t usbctlx_wmem_completor_t; * Interprets the results of a synchronous memory-read ----------------------------------------------------------------*/ struct usbctlx_rmem_completor { - usbctlx_completor_t head; + struct usbctlx_completor head; const hfa384x_usb_rmemresp_t *rmemresp; void *data; @@ -770,7 +770,7 @@ struct usbctlx_rmem_completor { }; typedef struct usbctlx_rmem_completor usbctlx_rmem_completor_t; -static int usbctlx_rmem_completor_fn(usbctlx_completor_t *head) +static int usbctlx_rmem_completor_fn(struct usbctlx_completor *head) { usbctlx_rmem_completor_t *complete = (usbctlx_rmem_completor_t *) head; @@ -779,11 +779,13 @@ static int usbctlx_rmem_completor_fn(usbctlx_completor_t *head) return 0; } -static inline usbctlx_completor_t *init_rmem_completor(usbctlx_rmem_completor_t - *completor, - hfa384x_usb_rmemresp_t - *rmemresp, void *data, - unsigned int len) +static inline struct usbctlx_completor *init_rmem_completor( + usbctlx_rmem_completor_t + *completor, + hfa384x_usb_rmemresp_t + *rmemresp, + void *data, + unsigned int len) { completor->head.complete = usbctlx_rmem_completor_fn; completor->rmemresp = rmemresp; @@ -1226,7 +1228,7 @@ int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis) * * Arguments: * hw device structure -* ctlx CTLX ptr +* ctlx CTLX ptr * completor functor object to decide what to * do with the CTLX's result. * @@ -1244,7 +1246,7 @@ int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis) ----------------------------------------------------------------*/ static int hfa384x_usbctlx_complete_sync(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx, - usbctlx_completor_t *completor) + struct usbctlx_completor *completor) { unsigned long flags; int result; @@ -1359,7 +1361,7 @@ cleanup: ----------------------------------------------------------------*/ static int hfa384x_docmd(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, hfa384x_metacmd_t *cmd, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data) { @@ -1394,7 +1396,7 @@ hfa384x_docmd(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_cmd_completor_t completor; + struct usbctlx_cmd_completor completor; result = hfa384x_usbctlx_complete_sync(hw, ctlx, @@ -1448,7 +1450,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dorrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -1481,7 +1483,7 @@ hfa384x_dorrid(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_rrid_completor_t completor; + struct usbctlx_rrid_completor completor; result = hfa384x_usbctlx_complete_sync(hw, ctlx, @@ -1506,7 +1508,7 @@ done: * * Arguments: * hw device structure -* CMD_MODE DOWAIT or DOASYNC +* enum cmd_mode DOWAIT or DOASYNC * rid RID code * riddata Data portion of RID formatted for MAC * riddatalen Length of the data portion in bytes @@ -1529,7 +1531,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dowrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -1616,7 +1618,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dormem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -1707,7 +1709,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dowmem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -2075,12 +2077,9 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) (j * HFA384x_USB_RWMEM_MAXLEN); writepage = HFA384x_ADDR_CMD_MKPAGE(dlbufaddr + - (j * - HFA384x_USB_RWMEM_MAXLEN)); - writeoffset = - HFA384x_ADDR_CMD_MKOFF(dlbufaddr + - (j * - HFA384x_USB_RWMEM_MAXLEN)); + (j * HFA384x_USB_RWMEM_MAXLEN)); + writeoffset = HFA384x_ADDR_CMD_MKOFF(dlbufaddr + + (j * HFA384x_USB_RWMEM_MAXLEN)); writelen = burnlen - (j * HFA384x_USB_RWMEM_MAXLEN); writelen = writelen > HFA384x_USB_RWMEM_MAXLEN ? @@ -2133,7 +2132,7 @@ exit_proc: * 0 success * >0 f/w reported error - f/w status code * <0 driver reported error -* -ENODATA length mismatch between argument and retrieved +* -ENODATA length mismatch between argument and retrieved * record. * * Side effects: @@ -2451,7 +2450,9 @@ int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len) currpage = HFA384x_ADDR_CMD_MKPAGE(pdaloc[i].cardaddr); curroffset = HFA384x_ADDR_CMD_MKOFF(pdaloc[i].cardaddr); - result = hfa384x_dormem_wait(hw, currpage, curroffset, buf, len); /* units of bytes */ + /* units of bytes */ + result = hfa384x_dormem_wait(hw, currpage, curroffset, buf, + len); if (result) { printk(KERN_WARNING @@ -2611,20 +2612,18 @@ int hfa384x_drvr_start(hfa384x_t *hw) if (result1 != 0) { if (result2 != 0) { printk(KERN_ERR - "cmd_initialize() failed on two attempts, results %d and %d\n", - result1, result2); + "cmd_initialize() failed on two attempts, results %d and %d\n", + result1, result2); usb_kill_urb(&hw->rx_urb); goto done; } else { pr_debug("First cmd_initialize() failed (result %d),\n", result1); - pr_debug - ("but second attempt succeeded. All should be ok\n"); + pr_debug("but second attempt succeeded. All should be ok\n"); } } else if (result2 != 0) { - printk(KERN_WARNING - "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n", - result2); + printk(KERN_WARNING "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n", + result2); printk(KERN_WARNING "Most likely the card will be functional\n"); goto done; @@ -3382,8 +3381,7 @@ retry: * our request has been acknowledged. Odd, * but our OUT URB is still alive... */ - pr_debug - ("Causality violation: please reboot Universe, or email linux-wlan-devel@lists.linux-wlan.com\n"); + pr_debug("Causality violation: please reboot Universe\n"); ctlx->state = CTLX_RESP_COMPLETE; break; @@ -3442,7 +3440,7 @@ static void hfa384x_usbin_txcompl(wlandevice_t *wlandev, { u16 status; - status = le16_to_cpu(usbin->type); /* yeah I know it says type... */ + status = le16_to_cpu(usbin->type); /* yeah I know it says type... */ /* Was there an error? */ if (HFA384x_TXSTATUS_ISERROR(status)) @@ -3583,7 +3581,7 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, struct sk_buff *skb; hfa384x_t *hw = wlandev->priv; - /* Don't forget the status, time, and data_len fields are in host order */ + /* Remember the status, time, and data_len fields are in host order */ /* Figure out how big the frame is */ fc = le16_to_cpu(rxdesc->frame_control); hdrlen = p80211_headerlen(fc); @@ -3632,7 +3630,8 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, caphdr->encoding = htonl(1); /* cck */ } - /* Copy the 802.11 header to the skb (ctl frames may be less than a full header) */ + /* Copy the 802.11 header to the skb + (ctl frames may be less than a full header) */ datap = skb_put(skb, hdrlen); memcpy(datap, &(rxdesc->frame_control), hdrlen); @@ -3644,7 +3643,8 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, /* check for unencrypted stuff if WEP bit set. */ if (*(datap - hdrlen + 1) & 0x40) /* wep set */ if ((*(datap) == 0xaa) && (*(datap + 1) == 0xaa)) - *(datap - hdrlen + 1) &= 0xbf; /* clear wep; it's the 802.2 header! */ + /* clear wep; it's the 802.2 header! */ + *(datap - hdrlen + 1) &= 0xbf; } if (hw->sniff_fcs) { @@ -3846,9 +3846,9 @@ retry: default: /* This is NOT a valid CTLX "success" state! */ printk(KERN_ERR - "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n", - le16_to_cpu(ctlx->outbuf.type), - ctlxstr(ctlx->state), urb->status); + "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n", + le16_to_cpu(ctlx->outbuf.type), + ctlxstr(ctlx->state), urb->status); break; } /* switch */ } else { diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index a1605fbc8092..059e15055b74 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -208,7 +208,7 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC); foo = wep_encrypt(wlandev, skb->data, p80211_wep->data, skb->len, - (wlandev->hostwep &HOSTWEP_DEFAULTKEY_MASK), + (wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK), p80211_wep->iv, p80211_wep->icv); if (foo) { printk(KERN_WARNING @@ -601,7 +601,7 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb) } /* Allocate the rxmeta */ - rxmeta = kmalloc(sizeof(p80211_rxmeta_t), GFP_ATOMIC); + rxmeta = kzalloc(sizeof(p80211_rxmeta_t), GFP_ATOMIC); if (rxmeta == NULL) { printk(KERN_ERR "%s: Failed to allocate rxmeta.\n", @@ -611,7 +611,6 @@ int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb) } /* Initialize the rxmeta */ - memset(rxmeta, 0, sizeof(p80211_rxmeta_t)); rxmeta->wlandev = wlandev; rxmeta->hosttime = jiffies; diff --git a/drivers/staging/wlan-ng/p80211req.c b/drivers/staging/wlan-ng/p80211req.c index e1e7bf1bf27c..207f080cfc9e 100644 --- a/drivers/staging/wlan-ng/p80211req.c +++ b/drivers/staging/wlan-ng/p80211req.c @@ -107,7 +107,8 @@ int p80211req_dorequest(wlandevice_t *wlandev, u8 *msgbuf) } /* Check Permissions */ - if (!capable(CAP_NET_ADMIN) && (msg->msgcode != DIDmsg_dot11req_mibget)) { + if (!capable(CAP_NET_ADMIN) && + (msg->msgcode != DIDmsg_dot11req_mibget)) { printk(KERN_ERR "%s: only dot11req_mibget allowed for non-root.\n", wlandev->name); @@ -128,7 +129,7 @@ int p80211req_dorequest(wlandevice_t *wlandev, u8 *msgbuf) wlandev->mlmerequest(wlandev, msg); clear_bit(1, &(wlandev->request_pending)); - return result; /* if result==0, msg->status still may contain an err */ + return result; /* if result==0, msg->status still may contain an err */ } /*---------------------------------------------------------------- diff --git a/drivers/staging/wlan-ng/p80211wext.c b/drivers/staging/wlan-ng/p80211wext.c index 83f1d6cd7991..387194d4a6eb 100644 --- a/drivers/staging/wlan-ng/p80211wext.c +++ b/drivers/staging/wlan-ng/p80211wext.c @@ -49,7 +49,6 @@ #include <linux/uaccess.h> #include <asm/byteorder.h> #include <linux/if_ether.h> -#include <linux/bitops.h> #include "p80211types.h" #include "p80211hdr.h" @@ -74,7 +73,7 @@ static u8 p80211_mhz_to_channel(u16 mhz) if (mhz >= 5000) return (mhz - 5000) / 5; - if (mhz == 2482) + if (mhz == 2484) return 14; if (mhz >= 2407) @@ -126,18 +125,38 @@ static int qual_as_percent(int snr) return 100; } -static int p80211wext_dorequest(wlandevice_t *wlandev, u32 did, u32 data) +static int p80211wext_setmib(wlandevice_t *wlandev, u32 did, u32 data) { p80211msg_dot11req_mibset_t msg; - p80211item_uint32_t mibitem; + p80211item_uint32_t *mibitem = + (p80211item_uint32_t *)&msg.mibattribute.data; int result; msg.msgcode = DIDmsg_dot11req_mibset; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = did; - mibitem.data = data; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); + memset(mibitem, 0, sizeof(*mibitem)); + mibitem->did = did; + mibitem->data = data; + result = p80211req_dorequest(wlandev, (u8 *) &msg); + + return result; +} + +/* + * get a 32 bit mib value + */ +static int p80211wext_getmib(wlandevice_t *wlandev, u32 did, u32 *data) +{ + p80211msg_dot11req_mibset_t msg; + p80211item_uint32_t *mibitem = + (p80211item_uint32_t *)&msg.mibattribute.data; + int result; + + msg.msgcode = DIDmsg_dot11req_mibget; + memset(mibitem, 0, sizeof(*mibitem)); + mibitem->did = did; result = p80211req_dorequest(wlandev, (u8 *) &msg); + if (!result) + *data = mibitem->data; return result; } @@ -263,32 +282,26 @@ static int p80211wext_giwfreq(netdevice_t *dev, struct iw_freq *freq, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; + unsigned int value; - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_getmib(wlandev, + DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - if (mibitem.data > NUM_CHANNELS) { + if (value > NUM_CHANNELS) { err = -EFAULT; goto exit; } /* convert into frequency instead of a channel */ freq->e = 1; - freq->m = p80211_channel_to_mhz(mibitem.data, 0) * 100000; + freq->m = p80211_channel_to_mhz(value, 0) * 100000; exit: return err; @@ -299,28 +312,23 @@ static int p80211wext_siwfreq(netdevice_t *dev, struct iw_freq *freq, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; + unsigned int value; if (!wlan_wext_write) { - err = (-EOPNOTSUPP); + err = -EOPNOTSUPP; goto exit; } - msg.msgcode = DIDmsg_dot11req_mibset; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel; - mibitem.status = P80211ENUM_msgitem_status_data_ok; - if ((freq->e == 0) && (freq->m <= 1000)) - mibitem.data = freq->m; + value = freq->m; else - mibitem.data = p80211_mhz_to_channel(freq->m); + value = p80211_mhz_to_channel(freq->m); - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + result = p80211wext_setmib(wlandev, + DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel, + value); if (result) { err = -EFAULT; @@ -360,13 +368,11 @@ static int p80211wext_siwmode(netdevice_t *dev, __u32 *mode, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; if (!wlan_wext_write) { - err = (-EOPNOTSUPP); + err = -EOPNOTSUPP; goto exit; } @@ -397,16 +403,11 @@ static int p80211wext_siwmode(netdevice_t *dev, } /* Set Operation mode to the PORT TYPE RID */ - msg.msgcode = DIDmsg_dot11req_mibset; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_p2_p2Static_p2CnfPortType; - mibitem.data = (*mode == IW_MODE_ADHOC) ? 0 : 1; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_setmib(wlandev, + DIDmib_p2_p2Static_p2CnfPortType, + (*mode == IW_MODE_ADHOC) ? 0 : 1); if (result) err = -EFAULT; - exit: return err; } @@ -563,9 +564,9 @@ static int p80211wext_siwencode(netdevice_t *dev, /* Set current key number only if no keys are given */ if (erq->flags & IW_ENCODE_NOKEY) { result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, - i); + p80211wext_setmib(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, + i); if (result) { err = -EFAULT; @@ -587,7 +588,6 @@ static int p80211wext_siwencode(netdevice_t *dev, -------------------------------------------------------------*/ if (erq->length > 0) { - /* copy the key from the driver cache as the keys are read-only MIBs */ wlandev->wep_keylens[i] = erq->length; memcpy(wlandev->wep_keys[i], key, erq->length); @@ -637,12 +637,12 @@ static int p80211wext_siwencode(netdevice_t *dev, /* Check the PrivacyInvoked flag */ if (erq->flags & IW_ENCODE_DISABLED) { result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_false); } else { result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_true); } @@ -661,12 +661,12 @@ static int p80211wext_siwencode(netdevice_t *dev, */ if (erq->flags & IW_ENCODE_RESTRICTED) { result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_true); } else if (erq->flags & IW_ENCODE_OPEN) { result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_false); } @@ -768,24 +768,16 @@ static int p80211wext_giwrate(netdevice_t *dev, struct iw_param *rrq, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; + unsigned int value; - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_p2_p2MAC_p2CurrentTxRate; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_getmib(wlandev, DIDmib_p2_p2MAC_p2CurrentTxRate, &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - rrq->fixed = 0; /* can it change? */ rrq->disabled = 0; rrq->value = 0; @@ -795,7 +787,7 @@ static int p80211wext_giwrate(netdevice_t *dev, #define HFA384x_RATEBIT_5dot5 ((u16)4) #define HFA384x_RATEBIT_11 ((u16)8) - switch (mibitem.data) { + switch (value) { case HFA384x_RATEBIT_1: rrq->value = 1000000; break; @@ -820,25 +812,19 @@ static int p80211wext_giwrts(netdevice_t *dev, struct iw_param *rts, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; + unsigned int value; - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_getmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - rts->value = mibitem.data; + rts->value = value; rts->disabled = (rts->value == 2347); rts->fixed = 1; @@ -851,27 +837,23 @@ static int p80211wext_siwrts(netdevice_t *dev, struct iw_param *rts, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; + unsigned int value; if (!wlan_wext_write) { - err = (-EOPNOTSUPP); + err = -EOPNOTSUPP; goto exit; } - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold; if (rts->disabled) - mibitem.data = 2347; + value = 2347; else - mibitem.data = rts->value; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + value = rts->value; + result = p80211wext_setmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold, + value); if (result) { err = -EFAULT; goto exit; @@ -886,26 +868,19 @@ static int p80211wext_giwfrag(netdevice_t *dev, struct iw_param *frag, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; + unsigned int value; - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_getmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - frag->value = mibitem.data; + frag->value = value; frag->disabled = (frag->value == 2346); frag->fixed = 1; @@ -918,28 +893,23 @@ static int p80211wext_siwfrag(netdevice_t *dev, struct iw_param *frag, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; + int value; if (!wlan_wext_write) { err = (-EOPNOTSUPP); goto exit; } - msg.msgcode = DIDmsg_dot11req_mibset; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold; - if (frag->disabled) - mibitem.data = 2346; + value = 2346; else - mibitem.data = frag->value; + value = frag->value; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + result = p80211wext_setmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold, + value); if (result) { err = -EFAULT; @@ -963,56 +933,40 @@ static int p80211wext_giwretry(netdevice_t *dev, struct iw_param *rrq, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; u16 shortretry, longretry, lifetime; + unsigned int value; - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_getmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - shortretry = mibitem.data; - - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + shortretry = value; + result = p80211wext_getmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - longretry = mibitem.data; - - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + longretry = value; + result = p80211wext_getmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - lifetime = mibitem.data; + lifetime = value; rrq->disabled = 0; @@ -1045,8 +999,7 @@ static int p80211wext_siwretry(netdevice_t *dev, p80211msg_dot11req_mibset_t msg; int result; int err = 0; - - memset(&mibitem, 0, sizeof(mibitem)); + unsigned int value; if (!wlan_wext_write) { err = (-EOPNOTSUPP); @@ -1061,26 +1014,20 @@ static int p80211wext_siwretry(netdevice_t *dev, msg.msgcode = DIDmsg_dot11req_mibset; if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime; - mibitem.data = rrq->value /= 1024; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + value = rrq->value /= 1024; + result = p80211wext_setmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime, + value); if (result) { err = -EFAULT; goto exit; } } else { if (rrq->flags & IW_RETRY_LONG) { - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit; - mibitem.data = rrq->value; - - memcpy(&msg.mibattribute.data, &mibitem, - sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + result = p80211wext_setmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit, + rrq->value); if (result) { err = -EFAULT; @@ -1089,13 +1036,9 @@ static int p80211wext_siwretry(netdevice_t *dev, } if (rrq->flags & IW_RETRY_SHORT) { - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit; - mibitem.data = rrq->value; - - memcpy(&msg.mibattribute.data, &mibitem, - sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + result = p80211wext_setmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit, + rrq->value); if (result) { err = -EFAULT; @@ -1118,22 +1061,20 @@ static int p80211wext_siwtxpow(netdevice_t *dev, p80211msg_dot11req_mibset_t msg; int result; int err = 0; + unsigned int value; if (!wlan_wext_write) { err = (-EOPNOTSUPP); goto exit; } - msg.msgcode = DIDmsg_dot11req_mibset; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = - DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel; if (rrq->fixed == 0) - mibitem.data = 30; + value = 30; else - mibitem.data = rrq->value; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + value = rrq->value; + result = p80211wext_setmib(wlandev, + DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel, + value); if (result) { err = -EFAULT; @@ -1149,33 +1090,25 @@ static int p80211wext_giwtxpow(netdevice_t *dev, struct iw_param *rrq, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; + unsigned int value; - msg.msgcode = DIDmsg_dot11req_mibget; - - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = - DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + result = p80211wext_getmib(wlandev, + DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - /* XXX handle OFF by setting disabled = 1; */ rrq->flags = 0; /* IW_TXPOW_DBM; */ rrq->disabled = 0; rrq->fixed = 0; - rrq->value = mibitem.data; + rrq->value = value; exit: return err; @@ -1480,7 +1413,7 @@ static int p80211wext_set_encodeext(struct net_device *dev, } pr_debug("setting default key (%d)\n", idx); result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, idx); if (result) @@ -1600,12 +1533,12 @@ static int p80211_wext_set_iwauth(struct net_device *dev, pr_debug("drop_unencrypted %d\n", param->value); if (param->value) result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_true); else result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_false); break; @@ -1614,12 +1547,12 @@ static int p80211_wext_set_iwauth(struct net_device *dev, pr_debug("privacy invoked %d\n", param->value); if (param->value) result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_true); else result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_false); @@ -1681,64 +1614,50 @@ static int p80211_wext_get_iwauth(struct net_device *dev, return result; } +#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] + static iw_handler p80211wext_handlers[] = { - (iw_handler) p80211wext_siwcommit, /* SIOCSIWCOMMIT */ - (iw_handler) p80211wext_giwname, /* SIOCGIWNAME */ - (iw_handler) NULL, /* SIOCSIWNWID */ - (iw_handler) NULL, /* SIOCGIWNWID */ - (iw_handler) p80211wext_siwfreq, /* SIOCSIWFREQ */ - (iw_handler) p80211wext_giwfreq, /* SIOCGIWFREQ */ - (iw_handler) p80211wext_siwmode, /* SIOCSIWMODE */ - (iw_handler) p80211wext_giwmode, /* SIOCGIWMODE */ - (iw_handler) NULL, /* SIOCSIWSENS */ - (iw_handler) NULL, /* SIOCGIWSENS */ - (iw_handler) NULL, /* not used *//* SIOCSIWRANGE */ - (iw_handler) p80211wext_giwrange, /* SIOCGIWRANGE */ - (iw_handler) NULL, /* not used *//* SIOCSIWPRIV */ - (iw_handler) NULL, /* kernel code *//* SIOCGIWPRIV */ - (iw_handler) NULL, /* not used *//* SIOCSIWSTATS */ - (iw_handler) NULL, /* kernel code *//* SIOCGIWSTATS */ - (iw_handler) p80211wext_siwspy, /* SIOCSIWSPY */ - (iw_handler) p80211wext_giwspy, /* SIOCGIWSPY */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWAP */ - (iw_handler) p80211wext_giwap, /* SIOCGIWAP */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCGIWAPLIST */ - (iw_handler) p80211wext_siwscan, /* SIOCSIWSCAN */ - (iw_handler) p80211wext_giwscan, /* SIOCGIWSCAN */ - (iw_handler) p80211wext_siwessid, /* SIOCSIWESSID */ - (iw_handler) p80211wext_giwessid, /* SIOCGIWESSID */ - (iw_handler) NULL, /* SIOCSIWNICKN */ - (iw_handler) p80211wext_giwessid, /* SIOCGIWNICKN */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWRATE */ - (iw_handler) p80211wext_giwrate, /* SIOCGIWRATE */ - (iw_handler) p80211wext_siwrts, /* SIOCSIWRTS */ - (iw_handler) p80211wext_giwrts, /* SIOCGIWRTS */ - (iw_handler) p80211wext_siwfrag, /* SIOCSIWFRAG */ - (iw_handler) p80211wext_giwfrag, /* SIOCGIWFRAG */ - (iw_handler) p80211wext_siwtxpow, /* SIOCSIWTXPOW */ - (iw_handler) p80211wext_giwtxpow, /* SIOCGIWTXPOW */ - (iw_handler) p80211wext_siwretry, /* SIOCSIWRETRY */ - (iw_handler) p80211wext_giwretry, /* SIOCGIWRETRY */ - (iw_handler) p80211wext_siwencode, /* SIOCSIWENCODE */ - (iw_handler) p80211wext_giwencode, /* SIOCGIWENCODE */ - (iw_handler) NULL, /* SIOCSIWPOWER */ - (iw_handler) NULL, /* SIOCGIWPOWER */ + IW_IOCTL(SIOCSIWCOMMIT) = (iw_handler) p80211wext_siwcommit, + IW_IOCTL(SIOCGIWNAME) = (iw_handler) p80211wext_giwname, +/* SIOCSIWNWID,SIOCGIWNWID */ + IW_IOCTL(SIOCSIWFREQ) = (iw_handler) p80211wext_siwfreq, + IW_IOCTL(SIOCGIWFREQ) = (iw_handler) p80211wext_giwfreq, + IW_IOCTL(SIOCSIWMODE) = (iw_handler) p80211wext_siwmode, + IW_IOCTL(SIOCGIWMODE) = (iw_handler) p80211wext_giwmode, +/* SIOCSIWSENS,SIOCGIWSENS,SIOCSIWRANGE */ + IW_IOCTL(SIOCGIWRANGE) = (iw_handler) p80211wext_giwrange, +/* SIOCSIWPRIV,SIOCGIWPRIV,SIOCSIWSTATS,SIOCGIWSTATS */ + IW_IOCTL(SIOCSIWSPY) = (iw_handler) p80211wext_siwspy, + IW_IOCTL(SIOCGIWSPY) = (iw_handler) p80211wext_giwspy, +/* SIOCSIWAP */ + IW_IOCTL(SIOCGIWAP) = (iw_handler) p80211wext_giwap, +/* SIOCGIWAPLIST */ + IW_IOCTL(SIOCSIWSCAN) = (iw_handler) p80211wext_siwscan, + IW_IOCTL(SIOCGIWSCAN) = (iw_handler) p80211wext_giwscan, + IW_IOCTL(SIOCSIWESSID) = (iw_handler) p80211wext_siwessid, + IW_IOCTL(SIOCGIWESSID) = (iw_handler) p80211wext_giwessid, +/* SIOCSIWNICKN */ + IW_IOCTL(SIOCGIWNICKN) = (iw_handler) p80211wext_giwessid, +/* SIOCSIWRATE */ + IW_IOCTL(SIOCGIWRATE) = (iw_handler) p80211wext_giwrate, + IW_IOCTL(SIOCSIWRTS) = (iw_handler) p80211wext_siwrts, + IW_IOCTL(SIOCGIWRTS) = (iw_handler) p80211wext_giwrts, + IW_IOCTL(SIOCSIWFRAG) = (iw_handler) p80211wext_siwfrag, + IW_IOCTL(SIOCGIWFRAG) = (iw_handler) p80211wext_giwfrag, + IW_IOCTL(SIOCSIWTXPOW) = (iw_handler) p80211wext_siwtxpow, + IW_IOCTL(SIOCGIWTXPOW) = (iw_handler) p80211wext_giwtxpow, + IW_IOCTL(SIOCSIWRETRY) = (iw_handler) p80211wext_siwretry, + IW_IOCTL(SIOCGIWRETRY) = (iw_handler) p80211wext_giwretry, + IW_IOCTL(SIOCSIWENCODE) = (iw_handler) p80211wext_siwencode, + IW_IOCTL(SIOCGIWENCODE) = (iw_handler) p80211wext_giwencode, +/* SIOCSIWPOWER,SIOCGIWPOWER */ /* WPA operations */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWGENIE set generic IE */ - (iw_handler) NULL, /* SIOCGIWGENIE get generic IE */ - (iw_handler) p80211_wext_set_iwauth, /* SIOCSIWAUTH set authentication mode params */ - (iw_handler) p80211_wext_get_iwauth, /* SIOCGIWAUTH get authentication mode params */ - - (iw_handler) p80211wext_set_encodeext, /* SIOCSIWENCODEEXT set encoding token & mode */ - (iw_handler) p80211wext_get_encodeext, /* SIOCGIWENCODEEXT get encoding token & mode */ - (iw_handler) NULL, /* SIOCSIWPMKSA PMKSA cache operation */ +/* SIOCSIWGENIE,SIOCGIWGENIE generic IE */ + IW_IOCTL(SIOCSIWAUTH) = (iw_handler) p80211_wext_set_iwauth, /*set authentication mode params */ + IW_IOCTL(SIOCGIWAUTH) = (iw_handler) p80211_wext_get_iwauth, /*get authentication mode params */ + IW_IOCTL(SIOCSIWENCODEEXT) = (iw_handler) p80211wext_set_encodeext, /*set encoding token & mode */ + IW_IOCTL(SIOCGIWENCODEEXT) = (iw_handler) p80211wext_get_encodeext, /*get encoding token & mode */ +/* SIOCSIWPMKSA PMKSA cache operation */ }; struct iw_handler_def p80211wext_handler_def = { diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index d383ea85c9bc..d20c8797bcc7 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -160,21 +160,30 @@ hfa384x_caplevel_t priid; /*================================================================*/ /* Local Function Declarations */ -int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev); -int read_fwfile(const struct ihex_binrec *rfptr); -int mkimage(imgchunk_t *clist, unsigned int *ccnt); -int read_cardpda(pda_t *pda, wlandevice_t *wlandev); -int mkpdrlist(pda_t *pda); -int plugimage(imgchunk_t *fchunk, unsigned int nfchunks, +static int prism2_fwapply(const struct ihex_binrec *rfptr, +wlandevice_t *wlandev); + +static int read_fwfile(const struct ihex_binrec *rfptr); + +static int mkimage(imgchunk_t *clist, unsigned int *ccnt); + +static int read_cardpda(pda_t *pda, wlandevice_t *wlandev); + +static int mkpdrlist(pda_t *pda); + +static int plugimage(imgchunk_t *fchunk, unsigned int nfchunks, s3plugrec_t *s3plug, unsigned int ns3plug, pda_t * pda); -int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, + +static int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, s3crcrec_t *s3crc, unsigned int ns3crc); -int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, + +static int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk, unsigned int nfchunks); -void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks); -void free_srecs(void); +static void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks); + +static void free_srecs(void); -int validate_identity(void); +static int validate_identity(void); /*================================================================*/ /* Function Definitions */ @@ -255,7 +264,7 @@ int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev) /* clear the pda and add an initial END record */ memset(&pda, 0, sizeof(pda)); pda.rec[0] = (hfa384x_pdrec_t *) pda.buf; - pda.rec[0]->len = cpu_to_le16(2); /* len in words *//* len in words */ + pda.rec[0]->len = cpu_to_le16(2); /* len in words */ pda.rec[0]->code = cpu_to_le16(HFA384x_PDR_END_OF_PDA); pda.nrec = 1; @@ -527,13 +536,12 @@ int mkimage(imgchunk_t *clist, unsigned int *ccnt) /* Allocate buffer space for chunks */ for (i = 0; i < *ccnt; i++) { - clist[i].data = kmalloc(clist[i].len, GFP_KERNEL); + clist[i].data = kzalloc(clist[i].len, GFP_KERNEL); if (clist[i].data == NULL) { printk(KERN_ERR "failed to allocate image space, exitting.\n"); return 1; } - memset(clist[i].data, 0, clist[i].len); pr_debug("chunk[%d]: addr=0x%06x len=%d\n", i, clist[i].addr, clist[i].len); } diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c index 31ac8da39c81..6cd09352f893 100644 --- a/drivers/staging/wlan-ng/prism2sta.c +++ b/drivers/staging/wlan-ng/prism2sta.c @@ -426,7 +426,7 @@ static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg) * msgp ptr to msg buffer * * Returns: -* A p80211 message resultcode value. +* A p80211 message resultcode value. * * Side effects: * @@ -458,7 +458,7 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) "hfa384x_drvr_start() failed," "result=%d\n", (int)result); result = - P80211ENUM_resultcode_implementation_failure; + P80211ENUM_resultcode_implementation_failure; wlandev->msdstate = WLAN_MSD_HWPRESENT; break; } @@ -503,7 +503,7 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) "hfa384x_drvr_start() failed," "result=%d\n", (int)result); result = - P80211ENUM_resultcode_implementation_failure; + P80211ENUM_resultcode_implementation_failure; wlandev->msdstate = WLAN_MSD_HWPRESENT; break; } @@ -514,7 +514,7 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) "prism2sta_getcardinfo() failed," "result=%d\n", (int)result); result = - P80211ENUM_resultcode_implementation_failure; + P80211ENUM_resultcode_implementation_failure; hfa384x_drvr_stop(hw); wlandev->msdstate = WLAN_MSD_HWPRESENT; break; @@ -525,7 +525,7 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate) "prism2sta_globalsetup() failed," "result=%d\n", (int)result); result = - P80211ENUM_resultcode_implementation_failure; + P80211ENUM_resultcode_implementation_failure; hfa384x_drvr_stop(hw); wlandev->msdstate = WLAN_MSD_HWPRESENT; break; @@ -1178,8 +1178,8 @@ static void prism2sta_inf_chinforesults(wlandevice_t *wlandev, chinforesult->active = le16_to_cpu(inf->info.chinforesult.result[n]. active); - pr_debug - ("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n", + pr_debug + ("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf %d\n", channel + 1, chinforesult-> active & HFA384x_CHINFORESULT_BSSACTIVE ? "signal" @@ -1246,7 +1246,9 @@ void prism2sta_processing_defer(struct work_struct *data) netif_carrier_on(wlandev->netdev); - /* If we are joining a specific AP, set our state and reset retries */ + /* If we are joining a specific AP, set our + * state and reset retries + */ if (hw->join_ap == 1) hw->join_ap = 2; hw->join_retries = 60; @@ -1261,9 +1263,9 @@ void prism2sta_processing_defer(struct work_struct *data) /* Collect the BSSID, and set state to allow tx */ result = hfa384x_drvr_getconfig(hw, - HFA384x_RID_CURRENTBSSID, - wlandev->bssid, - WLAN_BSSID_LEN); + HFA384x_RID_CURRENTBSSID, + wlandev->bssid, + WLAN_BSSID_LEN); if (result) { pr_debug ("getconfig(0x%02x) failed, result = %d\n", @@ -1286,8 +1288,8 @@ void prism2sta_processing_defer(struct work_struct *data) /* Collect the port status */ result = hfa384x_drvr_getconfig16(hw, - HFA384x_RID_PORTSTATUS, - &portstatus); + HFA384x_RID_PORTSTATUS, + &portstatus); if (result) { pr_debug ("getconfig(0x%02x) failed, result = %d\n", @@ -1322,7 +1324,7 @@ void prism2sta_processing_defer(struct work_struct *data) &joinreq, HFA384x_RID_JOINREQUEST_LEN); printk(KERN_INFO - "linkstatus=DISCONNECTED (re-submitting join)\n"); + "linkstatus=DISCONNECTED (re-submitting join)\n"); } else { if (wlandev->netdev->type == ARPHRD_ETHER) printk(KERN_INFO @@ -1509,14 +1511,15 @@ static void prism2sta_inf_assocstatus(wlandevice_t *wlandev, rec.reason = le16_to_cpu(rec.reason); /* - ** Find the address in the list of authenticated stations. If it wasn't - ** found, then this address has not been previously authenticated and - ** something weird has happened if this is anything other than an - ** "authentication failed" message. If the address was found, then - ** set the "associated" flag for that station, based on whether the - ** station is associating or losing its association. Something weird - ** has also happened if we find the address in the list of authenticated - ** stations but we are getting an "authentication failed" message. + ** Find the address in the list of authenticated stations. + ** If it wasn't found, then this address has not been previously + ** authenticated and something weird has happened if this is + ** anything other than an "authentication failed" message. + ** If the address was found, then set the "associated" flag for + ** that station, based on whether the station is associating or + ** losing its association. Something weird has also happened + ** if we find the address in the list of authenticated stations + ** but we are getting an "authentication failed" message. */ for (i = 0; i < hw->authlist.cnt; i++) @@ -1526,7 +1529,7 @@ static void prism2sta_inf_assocstatus(wlandevice_t *wlandev, if (i >= hw->authlist.cnt) { if (rec.assocstatus != HFA384x_ASSOCSTATUS_AUTHFAIL) printk(KERN_WARNING - "assocstatus info frame received for non-authenticated station.\n"); + "assocstatus info frame received for non-authenticated station.\n"); } else { hw->authlist.assoc[i] = (rec.assocstatus == HFA384x_ASSOCSTATUS_STAASSOC || @@ -1534,7 +1537,7 @@ static void prism2sta_inf_assocstatus(wlandevice_t *wlandev, if (rec.assocstatus == HFA384x_ASSOCSTATUS_AUTHFAIL) printk(KERN_WARNING - "authfail assocstatus info frame received for authenticated station.\n"); +"authfail assocstatus info frame received for authenticated station.\n"); } return; @@ -1681,12 +1684,12 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev, } /* - ** If the authentication is okay, then add the MAC address to the list - ** of authenticated stations. Don't add the address if it is already in - ** the list. (802.11b does not seem to disallow a station from issuing - ** an authentication request when the station is already authenticated. - ** Does this sort of thing ever happen? We might as well do the check - ** just in case.) + ** If the authentication is okay, then add the MAC address to the + ** list of authenticated stations. Don't add the address if it + ** is already in the list. (802.11b does not seem to disallow + ** a station from issuing an authentication request when the + ** station is already authenticated. Does this sort of thing + ** ever happen? We might as well do the check just in case.) */ added = 0; @@ -1931,7 +1934,7 @@ void prism2sta_ev_alloc(wlandevice_t *wlandev) * the created wlandevice_t structure. * * Side effects: -* also allocates the priv/hw structures. +* also allocates the priv/hw structures. * * Call context: * process thread @@ -1995,9 +1998,9 @@ void prism2sta_commsqual_defer(struct work_struct *data) /* It only makes sense to poll these in non-IBSS */ if (wlandev->macmode != WLAN_MACMODE_IBSS_STA) { - result = hfa384x_drvr_getconfig(hw, HFA384x_RID_DBMCOMMSQUALITY, - &hw->qual, - HFA384x_RID_DBMCOMMSQUALITY_LEN); + result = hfa384x_drvr_getconfig( + hw, HFA384x_RID_DBMCOMMSQUALITY, + &hw->qual, HFA384x_RID_DBMCOMMSQUALITY_LEN); if (result) { printk(KERN_ERR "error fetching commsqual\n"); diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c index 501d27f74c7d..f5cff751db2f 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -285,11 +285,76 @@ exit: usb_set_intfdata(interface, NULL); } +#ifdef CONFIG_PM +static int prism2sta_suspend(struct usb_interface *interface, + pm_message_t message) +{ + hfa384x_t *hw = NULL; + wlandevice_t *wlandev; + wlandev = (wlandevice_t *) usb_get_intfdata(interface); + if (!wlandev) + return -ENODEV; + + hw = wlandev->priv; + if (!hw) + return -ENODEV; + + prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable); + + usb_kill_urb(&hw->rx_urb); + usb_kill_urb(&hw->tx_urb); + usb_kill_urb(&hw->ctlx_urb); + + return 0; +} + +static int prism2sta_resume(struct usb_interface *interface) +{ + int result = 0; + hfa384x_t *hw = NULL; + wlandevice_t *wlandev; + wlandev = (wlandevice_t *) usb_get_intfdata(interface); + if (!wlandev) + return -ENODEV; + + hw = wlandev->priv; + if (!hw) + return -ENODEV; + + /* Do a chip-level reset on the MAC */ + if (prism2_doreset) { + result = hfa384x_corereset(hw, + prism2_reset_holdtime, + prism2_reset_settletime, 0); + if (result != 0) { + unregister_wlandev(wlandev); + hfa384x_destroy(hw); + printk(KERN_ERR + "%s: hfa384x_corereset() failed.\n", dev_info); + kfree(wlandev); + kfree(hw); + wlandev = NULL; + return -ENODEV; + } + } + + prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable); + + return 0; +} +#else +#define prism2sta_suspend NULL +#define prism2sta_resume NULL +#endif /* CONFIG_PM */ + static struct usb_driver prism2_usb_driver = { .name = "prism2_usb", .probe = prism2sta_probe_usb, .disconnect = prism2sta_disconnect_usb, .id_table = usb_prism_tbl, + .suspend = prism2sta_suspend, + .resume = prism2sta_resume, + .reset_resume = prism2sta_resume, /* fops, minor? */ }; |