diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-05 14:18:03 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-05 14:18:03 -0700 |
commit | e9563355ac1175dd3440dc2ea5c28b27ed51a283 (patch) | |
tree | 8546d55832714b5d19ba4c7799266918ca04882e /drivers/staging/otus | |
parent | cdd854bc42b5e6c79bbbc40c6600d995ffe6e747 (diff) | |
parent | b12d1995f650e92f26184afd28e6cf40bf64467a (diff) |
Staging: Merge staging-next into Linus's tree
Conflicts:
drivers/staging/Kconfig
drivers/staging/batman-adv/bat_sysfs.c
drivers/staging/batman-adv/device.c
drivers/staging/batman-adv/hard-interface.c
drivers/staging/cx25821/cx25821-audups11.c
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/otus')
-rw-r--r-- | drivers/staging/otus/80211core/ctxrx.c | 2 | ||||
-rw-r--r-- | drivers/staging/otus/TODO | 16 | ||||
-rw-r--r-- | drivers/staging/otus/apdbg.c | 24 | ||||
-rw-r--r-- | drivers/staging/otus/hal/hpani.c | 16 | ||||
-rw-r--r-- | drivers/staging/otus/hal/hpmain.c | 28 | ||||
-rw-r--r-- | drivers/staging/otus/hal/hpreg.c | 17 | ||||
-rw-r--r-- | drivers/staging/otus/ioctl.c | 55 | ||||
-rw-r--r-- | drivers/staging/otus/wrap_sec.c | 2 | ||||
-rw-r--r-- | drivers/staging/otus/wrap_usb.c | 5 | ||||
-rw-r--r-- | drivers/staging/otus/wwrap.c | 968 | ||||
-rw-r--r-- | drivers/staging/otus/zdusb.c | 251 |
11 files changed, 624 insertions, 760 deletions
diff --git a/drivers/staging/otus/80211core/ctxrx.c b/drivers/staging/otus/80211core/ctxrx.c index a127196260e6..135167d23d0f 100644 --- a/drivers/staging/otus/80211core/ctxrx.c +++ b/drivers/staging/otus/80211core/ctxrx.c @@ -3117,7 +3117,7 @@ u16_t zfWlanRxFilter(zdev_t* dev, zbuf_t* buf) index = (src[2]+up) & (ZM_FILTER_TABLE_ROW-1); - /* TBD : filter frame with source address == own MAC adress */ + /* TBD : filter frame with source address == own MAC address */ if ((wd->macAddr[0] == src[0]) && (wd->macAddr[1] == src[1]) && (wd->macAddr[2] == src[2])) { diff --git a/drivers/staging/otus/TODO b/drivers/staging/otus/TODO index 4caf026a4915..6fea974fcc9f 100644 --- a/drivers/staging/otus/TODO +++ b/drivers/staging/otus/TODO @@ -2,15 +2,7 @@ I'm hesitant to add a TODO file here, as the wireless developers would really have people help them out on the "clean" ar9170 driver that can be found at the linux-wireless developer site. -But, if you wish to clean up this driver instead, here's a short list of -things that need to be done to get it into a more mergable shape: - -TODO: - - checkpatch.pl cleanups - - sparse cleanups - - port to in-kernel 80211 stack - - review by the wireless developer community - -Please send any patches to Greg Kroah-Hartman <greg@kroah.com> and -Luis Rodriguez <Luis.Rodriguez@Atheros.com> and the -otus-devel@lists.madwifi-project.org mailing list. +This driver is unmaintained and its only purpose is as a +source of documentation for developers working on ar9170 and carl9170. +Once carl9170 gets 11n support and merged upstream then this driver +can be removed. diff --git a/drivers/staging/otus/apdbg.c b/drivers/staging/otus/apdbg.c index b59028e7e33c..09415a6b93ca 100644 --- a/drivers/staging/otus/apdbg.c +++ b/drivers/staging/otus/apdbg.c @@ -90,28 +90,6 @@ struct zdap_ioctl { #endif -static char hex(char v) -{ - if (isdigit(v)) - return v - '0'; - else if (isxdigit(v)) - return tolower(v) - 'a' + 10; - else - return 0; -} - -static unsigned char asctohex(char *str) -{ - unsigned char value; - - value = hex(*str) & 0x0f; - value = value << 4; - str++; - value |= hex(*str) & 0x0f; - - return value; -} - char *prgname; int set_ioctl(int sock, struct ifreq *req) @@ -180,7 +158,7 @@ int main(int argc, char **argv) if (argc < 3) { fprintf(stderr, "%s: usage is \"%s <ifname> <operation>" "[<address>] [<value>]\"\n", prgname, prgname); - fprintf(stderr, "valid operation : read, write, mem, reg, \n"); + fprintf(stderr, "valid operation : read, write, mem, reg,\n"); fprintf(stderr, " : txd, rxd, rmem, wmem\n"); fprintf(stderr, " : dmat, regt, test\n"); diff --git a/drivers/staging/otus/hal/hpani.c b/drivers/staging/otus/hal/hpani.c index f53e483b394d..9b9420c75d42 100644 --- a/drivers/staging/otus/hal/hpani.c +++ b/drivers/staging/otus/hal/hpani.c @@ -72,7 +72,6 @@ s32_t BEACON_RSSI(zdev_t *dev) void zfHpAniAttach(zdev_t *dev) { -#define N(a) (sizeof(a) / sizeof(a[0])) u32_t i; struct zsHpPriv *HpPriv; @@ -125,7 +124,6 @@ void zfHpAniAttach(zdev_t *dev) HpPriv->stats.ast_nodestats.ns_avgbrssi = ZM_RSSI_DUMMY_MARKER; HpPriv->stats.ast_nodestats.ns_avgrssi = ZM_RSSI_DUMMY_MARKER; HpPriv->stats.ast_nodestats.ns_avgtxrssi = ZM_RSSI_DUMMY_MARKER; -#undef N } /* @@ -133,7 +131,6 @@ void zfHpAniAttach(zdev_t *dev) */ u8_t zfHpAniControl(zdev_t *dev, ZM_HAL_ANI_CMD cmd, int param) { -#define N(a) (sizeof(a)/sizeof(a[0])) typedef s32_t TABLE[]; struct zsHpPriv *HpPriv; struct zsAniState *aniState; @@ -148,9 +145,9 @@ u8_t zfHpAniControl(zdev_t *dev, ZM_HAL_ANI_CMD cmd, int param) { u32_t level = param; - if (level >= N(HpPriv->totalSizeDesired)) { + if (level >= ARRAY_SIZE(HpPriv->totalSizeDesired)) { zm_debug_msg1("level out of range, desired level : ", level); - zm_debug_msg1("max level : ", N(HpPriv->totalSizeDesired)); + zm_debug_msg1("max level : ", ARRAY_SIZE(HpPriv->totalSizeDesired)); return FALSE; } @@ -260,10 +257,10 @@ u8_t zfHpAniControl(zdev_t *dev, ZM_HAL_ANI_CMD cmd, int param) const TABLE firstep = { 0, 4, 8 }; u32_t level = param; - if (level >= N(firstep)) + if (level >= ARRAY_SIZE(firstep)) { zm_debug_msg1("level out of range, desired level : ", level); - zm_debug_msg1("max level : ", N(firstep)); + zm_debug_msg1("max level : ", ARRAY_SIZE(firstep)); return FALSE; } zfDelayWriteInternalReg(dev, AR_PHY_FIND_SIG, @@ -283,10 +280,10 @@ u8_t zfHpAniControl(zdev_t *dev, ZM_HAL_ANI_CMD cmd, int param) const TABLE cycpwrThr1 = { 2, 4, 6, 8, 10, 12, 14, 16 }; u32_t level = param; - if (level >= N(cycpwrThr1)) + if (level >= ARRAY_SIZE(cycpwrThr1)) { zm_debug_msg1("level out of range, desired level : ", level); - zm_debug_msg1("max level : ", N(cycpwrThr1)); + zm_debug_msg1("max level : ", ARRAY_SIZE(cycpwrThr1)); return FALSE; } zfDelayWriteInternalReg(dev, AR_PHY_TIMING5, @@ -335,7 +332,6 @@ u8_t zfHpAniControl(zdev_t *dev, ZM_HAL_ANI_CMD cmd, int param) return FALSE; } return TRUE; -#undef N } void zfHpAniRestart(zdev_t* dev) diff --git a/drivers/staging/otus/hal/hpmain.c b/drivers/staging/otus/hal/hpmain.c index 5f412e020457..6d2d358d5ca9 100644 --- a/drivers/staging/otus/hal/hpmain.c +++ b/drivers/staging/otus/hal/hpmain.c @@ -430,7 +430,7 @@ void zfInitPhy(zdev_t* dev, u32_t frequency, u8_t bw40) * Register setting by mode */ - entries = sizeof(ar5416Modes) / sizeof(*ar5416Modes); + entries = ARRAY_SIZE(ar5416Modes); zm_msg1_scan(ZM_LV_2, "Modes register setting entries=", entries); for (i=0; i<entries; i++) { @@ -496,7 +496,7 @@ void zfInitPhy(zdev_t* dev, u32_t frequency, u8_t bw40) /* * Common Register setting */ - entries = sizeof(ar5416Common) / sizeof(*ar5416Common); + entries = ARRAY_SIZE(ar5416Common); for (i=0; i<entries; i++) { reg_write(ar5416Common[i][0], ar5416Common[i][1]); @@ -506,7 +506,7 @@ void zfInitPhy(zdev_t* dev, u32_t frequency, u8_t bw40) /* * RF Gain setting by freqIndex */ - entries = sizeof(ar5416BB_RfGain) / sizeof(*ar5416BB_RfGain); + entries = ARRAY_SIZE(ar5416BB_RfGain); for (i=0; i<entries; i++) { reg_write(ar5416BB_RfGain[i][0], ar5416BB_RfGain[i][freqIndex]); @@ -963,7 +963,6 @@ u32_t reverse_bits(u32_t chan_sel) /* Bank 0 1 2 3 5 6 7 */ void zfSetRfRegs(zdev_t* dev, u32_t frequency) { - u16_t entries; u16_t freqIndex = 0; u16_t i; @@ -984,33 +983,28 @@ void zfSetRfRegs(zdev_t* dev, u32_t frequency) } #if 1 - entries = sizeof(otusBank) / sizeof(*otusBank); - for (i=0; i<entries; i++) + for (i=0; i<ARRAY_SIZE(otusBank); i++) { reg_write(otusBank[i][0], otusBank[i][freqIndex]); } #else /* Bank0 */ - entries = sizeof(ar5416Bank0) / sizeof(*ar5416Bank0); - for (i=0; i<entries; i++) + for (i=0; i<ARRAY_SIZE(ar5416Bank0); i++) { reg_write(ar5416Bank0[i][0], ar5416Bank0[i][1]); } /* Bank1 */ - entries = sizeof(ar5416Bank1) / sizeof(*ar5416Bank1); - for (i=0; i<entries; i++) + for (i=0; i<ARRAY_SIZE(ar5416Bank1); i++) { reg_write(ar5416Bank1[i][0], ar5416Bank1[i][1]); } /* Bank2 */ - entries = sizeof(ar5416Bank2) / sizeof(*ar5416Bank2); - for (i=0; i<entries; i++) + for (i=0; i<ARRAY_SIZE(ar5416Bank2); i++) { reg_write(ar5416Bank2[i][0], ar5416Bank2[i][1]); } /* Bank3 */ - entries = sizeof(ar5416Bank3) / sizeof(*ar5416Bank3); - for (i=0; i<entries; i++) + for (i=0; i<ARRAY_SIZE(ar5416Bank3); i++) { reg_write(ar5416Bank3[i][0], ar5416Bank3[i][freqIndex]); } @@ -1018,14 +1012,12 @@ void zfSetRfRegs(zdev_t* dev, u32_t frequency) reg_write (0x98b0, 0x00000013); reg_write (0x98e4, 0x00000002); /* Bank6 */ - entries = sizeof(ar5416Bank6) / sizeof(*ar5416Bank6); - for (i=0; i<entries; i++) + for (i=0; i<ARRAY_SIZE(ar5416Bank6); i++) { reg_write(ar5416Bank6[i][0], ar5416Bank6[i][freqIndex]); } /* Bank7 */ - entries = sizeof(ar5416Bank7) / sizeof(*ar5416Bank7); - for (i=0; i<entries; i++) + for (i=0; i<ARRAY_SIZE(ar5416Bank7); i++) { reg_write(ar5416Bank7[i][0], ar5416Bank7[i][1]); } diff --git a/drivers/staging/otus/hal/hpreg.c b/drivers/staging/otus/hal/hpreg.c index da3b77433874..9b04653c1c53 100644 --- a/drivers/staging/otus/hal/hpreg.c +++ b/drivers/staging/otus/hal/hpreg.c @@ -29,9 +29,6 @@ #include "hpreg.h" #include "hpusb.h" -/* used throughout this file... */ -#define N(a) (sizeof(a) / sizeof(a[0])) - #define HAL_MODE_11A_TURBO HAL_MODE_108A #define HAL_MODE_11G_TURBO HAL_MODE_108G @@ -1557,7 +1554,7 @@ u8_t GetWmRD(u16_t regionCode, u16_t channelFlag, REG_DOMAIN *rd) u64_t flags = NO_REQ; REG_DMN_PAIR_MAPPING *regPair = NULL; - for (i = 0, found = 0; (i < N(regDomainPairs)) && (!found); i++) { + for (i = 0, found = 0; (i < ARRAY_SIZE(regDomainPairs)) && (!found); i++) { if (regDomainPairs[i].regDmnEnum == regionCode) { regPair = ®DomainPairs[i]; found = 1; @@ -1581,7 +1578,7 @@ u8_t GetWmRD(u16_t regionCode, u16_t channelFlag, REG_DOMAIN *rd) * unitary reg domain of the pair */ - for (i = 0 ; i < N(regDomains) ; i++) { + for (i = 0 ; i < ARRAY_SIZE(regDomains) ; i++) { if (regDomains[i].regDmnEnum == regDmn) { if (rd != NULL) { zfMemoryCopy((u8_t *)rd, (u8_t *)®Domains[i], @@ -1653,7 +1650,7 @@ void zfHpGetRegulationTable(zdev_t *dev, u16_t regionCode, u16_t c_lo, u16_t c_h zmw_enter_critical_section(dev); - for (cm = modes; cm < &modes[N(modes)]; cm++) { + for (cm = modes; cm < &modes[ARRAY_SIZE(modes)]; cm++) { u16_t c; u64_t *channelBM = NULL; REG_DOMAIN *rd = NULL; @@ -1846,7 +1843,7 @@ void zfHpGetRegulationTablefromCountry(zdev_t *dev, u16_t CountryCode) zmw_declare_for_critical_section(); - for (i = 0; i < N(allCountries); i++) { + for (i = 0; i < ARRAY_SIZE(allCountries); i++) { if (CountryCode == allCountries[i].countryCode) { RegDomain = allCountries[i].regDmnEnum; @@ -1881,7 +1878,7 @@ u8_t zfHpGetRegulationTablefromISO(zdev_t *dev, u8_t *countryInfo, u8_t length) strLen = 3; */ } /* zm_debug_msg_s("Desired iso name = ", isoName); */ - for (i = 0; i < N(allCountries); i++) { + for (i = 0; i < ARRAY_SIZE(allCountries); i++) { /* zm_debug_msg_s("Current iso name = ", allCountries[i].isoName); */ if (zfMemoryIsEqual((u8_t *)allCountries[i].isoName, (u8_t *)&countryInfo[2], length-1)) { /* DbgPrint("Set current iso name = %s\n", allCountries[i].isoName); */ @@ -1937,7 +1934,7 @@ const char *zfHpGetisoNamefromregionCode(zdev_t *dev, u16_t regionCode) { u16_t i; - for (i = 0; i < N(allCountries); i++) { + for (i = 0; i < ARRAY_SIZE(allCountries); i++) { if (allCountries[i].regDmnEnum == regionCode) return allCountries[i].isoName; } @@ -1953,7 +1950,7 @@ u16_t zfHpGetRegionCodeFromIsoName(zdev_t *dev, u8_t *countryIsoName) /* if no matching item, return default */ regionCode = DEF_REGDMN; - for (i = 0; i < N(allCountries); i++) { + for (i = 0; i < ARRAY_SIZE(allCountries); i++) { if (zfMemoryIsEqual((u8_t *)allCountries[i].isoName, countryIsoName, 2)) { regionCode = allCountries[i].regDmnEnum; break; diff --git a/drivers/staging/otus/ioctl.c b/drivers/staging/otus/ioctl.c index a48c8e4a9ea7..dc3066d28845 100644 --- a/drivers/staging/otus/ioctl.c +++ b/drivers/staging/otus/ioctl.c @@ -63,8 +63,7 @@ extern u16_t zfLnxGetVapId(zdev_t *dev); -static const u32_t channel_frequency_11A[] = -{ +static const u32_t channel_frequency_11A[] = { /* Even element for Channel Number, Odd for Frequency */ 36, 5180, 40, 5200, @@ -507,7 +506,7 @@ int usbdrvwext_giwname(struct net_device *dev, { /* struct usbdrv_private *macp = dev->ml_priv; */ - strcpy(wrq->name, "IEEE 802.11-MIMO"); + strcpy(wrq->name, "IEEE 802.11abgn"); return 0; } @@ -1361,7 +1360,7 @@ int usbdrvwext_giwpower(struct net_device *dev, } /*int usbdrvwext_setparam(struct net_device *dev, struct iw_request_info *info, -* void *w, char *extra) +* void *w, char *extra) *{ * struct ieee80211vap *vap = dev->ml_priv; * struct ieee80211com *ic = vap->iv_ic; @@ -2261,10 +2260,10 @@ int usbdrv_wpa_ioctl(struct net_device *dev, struct athr_wlan_param *zdparm) printk(KERN_ERR "wd->ap.wpaLen : % d\n", len); /* DUMP WPA IE */ - for(ii = 0; ii < len;) { + for (ii = 0; ii < len;) { printk(KERN_ERR "0x%02x ", wpaie[ii]); - if((++ii % 16) == 0) + if ((++ii % 16) == 0) printk(KERN_ERR "\n"); } printk(KERN_ERR "\n"); @@ -2309,11 +2308,10 @@ int usbdrv_cenc_ioctl(struct net_device *dev, struct zydas_cenc_param *zdparm) /* Get the AP Id */ apId = zfLnxGetVapId(dev); - if (apId == 0xffff) { + if (apId == 0xffff) apId = 0; - } else { + else apId = apId + 1; - } switch (zdparm->cmd) { case ZM_CMD_CENC_SETCENC: @@ -2334,15 +2332,15 @@ int usbdrv_cenc_ioctl(struct net_device *dev, struct zydas_cenc_param *zdparm) printk(KERN_ERR "Key Index : % d\n", zdparm->u.crypt.keyid); printk(KERN_ERR "Encryption key = "); - for (ii = 0; ii < 16; ii++) { + for (ii = 0; ii < 16; ii++) printk(KERN_ERR "0x%02x ", zdparm->u.crypt.key[ii]); - } + printk(KERN_ERR "\n"); printk(KERN_ERR "MIC key = "); - for(ii = 16; ii < ZM_CENC_KEY_SIZE; ii++) { + for (ii = 16; ii < ZM_CENC_KEY_SIZE; ii++) printk(KERN_ERR "0x%02x ", zdparm->u.crypt.key[ii]); - } + printk(KERN_ERR "\n"); /* Set up key information */ @@ -2424,7 +2422,7 @@ int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) break; case SIOCSIWRTS: err = usbdrv_ioctl_setrts(dev, &wrq->u.rts); - if (! err) + if (!err) changed = 1; break; /* set_auth */ @@ -2582,8 +2580,7 @@ int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ZM_AUTH_MODE_WPA); } else if ((macp->supIe[17] == 0xf) && (macp->supIe[18] == 0xac) && - (macp->supIe[19] == 0x2)) - { + (macp->supIe[19] == 0x2)) { printk(KERN_ERR "wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK\n"); /* wd->sta.authMode = ZM_AUTH_MODE_WPA2PSK; */ @@ -2592,8 +2589,7 @@ int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ZM_AUTH_MODE_WPA2PSK); } else if ((macp->supIe[17] == 0xf) && (macp->supIe[18] == 0xac) && - (macp->supIe[19] == 0x1)) - { + (macp->supIe[19] == 0x1)) { printk(KERN_ERR "wd->sta.authMode = ZM_AUTH_MODE_WPA2\n"); /* wd->sta.authMode = ZM_AUTH_MODE_WPA2; */ @@ -2618,7 +2614,7 @@ int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) zfiWlanSetWepStatus(dev, ZM_ENCRYPTION_AES); } } - //WPA2 or WPA2PSK + /*WPA2 or WPA2PSK*/ if ((macp->supIe[17] == 0xf) || (macp->supIe[18] == 0xac)) { if (macp->supIe[13] == 0x2) { @@ -2656,7 +2652,7 @@ int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) printk(KERN_ERR "****************ZD_PARAM_COUNTERMEASURES : "); - if(arg) { + if (arg) { /* mCounterMeasureState=1; */ printk(KERN_ERR "enable\n"); } else { @@ -2667,20 +2663,18 @@ int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) if (op == ZD_PARAM_DROPUNENCRYPTED) { printk(KERN_ERR "ZD_PARAM_DROPUNENCRYPTED : "); - if(arg) { + if (arg) printk(KERN_ERR "enable\n"); - } else { + else printk(KERN_ERR "disable\n"); - } } if (op == ZD_PARAM_AUTH_ALGS) { printk(KERN_ERR "ZD_PARAM_AUTH_ALGS : "); - if (arg == 0) { + if (arg == 0) printk(KERN_ERR "OPEN_SYSTEM\n"); - } else { + else printk(KERN_ERR "SHARED_KEY\n"); - } } if (op == ZD_PARAM_WPS_FILTER) { printk(KERN_ERR "ZD_PARAM_WPS_FILTER : "); @@ -2705,11 +2699,10 @@ int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /* Get the AP Id */ apId = zfLnxGetVapId(dev); - if (apId == 0xffff) { + if (apId == 0xffff) apId = 0; - } else { + else apId = apId + 1; - } if (copy_from_user(&req_wpaie, ifr->ifr_data, sizeof(struct ieee80211req_wpaie))) { @@ -2721,10 +2714,10 @@ int usbdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) for (j = 0; j < IEEE80211_ADDR_LEN; j++) { if (macp->stawpaie[i].wpa_macaddr[j] != req_wpaie.wpa_macaddr[j]) - break; + break; } if (j == 6) - break; + break; } if (i < ZM_OAL_MAX_STA_SUPPORT) { diff --git a/drivers/staging/otus/wrap_sec.c b/drivers/staging/otus/wrap_sec.c index 0b238e9999bf..1fba7a98d52b 100644 --- a/drivers/staging/otus/wrap_sec.c +++ b/drivers/staging/otus/wrap_sec.c @@ -36,7 +36,7 @@ extern int zfLnxCencSendMsg(struct sock *netlink_sk, u_int8_t *msg, int len); u16_t zfLnxCencAsocNotify(zdev_t *dev, u16_t *macAddr, u8_t *body, u16_t bodySize, u16_t port) { - struct usbdrv_private *macp = (struct usbdrv_private *)dev->priv; + struct usbdrv_private *macp = dev->priv; struct zydas_cenc_sta_info cenc_info; /* struct sock *netlink_sk; */ u8_t ie_len; diff --git a/drivers/staging/otus/wrap_usb.c b/drivers/staging/otus/wrap_usb.c index 93459cadc472..9f04047bf5a6 100644 --- a/drivers/staging/otus/wrap_usb.c +++ b/drivers/staging/otus/wrap_usb.c @@ -104,6 +104,11 @@ u32_t zfwUsbSubmitControl(zdev_t *dev, u8_t req, u16_t value, u16_t index, if (size > 0) { buf = kmalloc(size, GFP_KERNEL); + if (buf == NULL) { + pr_err("zfwUsbSubmitControl() failed, " + "kmalloc() returned NULL\n"); + return 1; + } memcpy(buf, (u8_t *)data, size); } else buf = NULL; diff --git a/drivers/staging/otus/wwrap.c b/drivers/staging/otus/wwrap.c index b02eb42cd796..fcd3da07155b 100644 --- a/drivers/staging/otus/wwrap.c +++ b/drivers/staging/otus/wwrap.c @@ -29,24 +29,24 @@ #include <linux/slab.h> #include <net/iw_handler.h> -extern void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo); -extern void zfCoreRecv(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo); -extern void zfIdlChkRsp(zdev_t* dev, u32_t* rsp, u16_t rspLen); -extern void zfIdlRsp(zdev_t* dev, u32_t *rsp, u16_t rspLen); +extern void zfiRecv80211(zdev_t *dev, zbuf_t *buf, struct zsAdditionInfo *addInfo); +extern void zfCoreRecv(zdev_t *dev, zbuf_t *buf, struct zsAdditionInfo *addInfo); +extern void zfIdlChkRsp(zdev_t *dev, u32_t *rsp, u16_t rspLen); +extern void zfIdlRsp(zdev_t *dev, u32_t *rsp, u16_t rspLen); -//extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER]; +/*extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER];*/ extern struct zsVapStruct vap[ZM_VAP_PORT_NUMBER]; -u32_t zfLnxUsbSubmitTxData(zdev_t* dev); -u32_t zfLnxUsbIn(zdev_t* dev, urb_t *urb, zbuf_t *buf); +u32_t zfLnxUsbSubmitTxData(zdev_t *dev); +u32_t zfLnxUsbIn(zdev_t *dev, urb_t *urb, zbuf_t *buf); u32_t zfLnxSubmitRegInUrb(zdev_t *dev); u32_t zfLnxUsbSubmitBulkUrb(urb_t *urb, struct usb_device *usb, u16_t epnum, u16_t direction, - void *transfer_buffer, int buffer_length, usb_complete_t complete, void *context); + void *transfer_buffer, int buffer_length, usb_complete_t complete, void *context); u32_t zfLnxUsbSubmitIntUrb(urb_t *urb, struct usb_device *usb, u16_t epnum, u16_t direction, - void *transfer_buffer, int buffer_length, usb_complete_t complete, void *context, - u32_t interval); + void *transfer_buffer, int buffer_length, usb_complete_t complete, void *context, + u32_t interval); u16_t zfLnxGetFreeTxUrb(zdev_t *dev) { @@ -56,22 +56,19 @@ u16_t zfLnxGetFreeTxUrb(zdev_t *dev) spin_lock_irqsave(&macp->cs_lock, irqFlag); - //idx = ((macp->TxUrbTail + 1) & (ZM_MAX_TX_URB_NUM - 1)); + /*idx = ((macp->TxUrbTail + 1) & (ZM_MAX_TX_URB_NUM - 1));*/ - //if (idx != macp->TxUrbHead) - if (macp->TxUrbCnt != 0) - { - idx = macp->TxUrbTail; - macp->TxUrbTail = ((macp->TxUrbTail + 1) & (ZM_MAX_TX_URB_NUM - 1)); - macp->TxUrbCnt--; - } - else - { - //printk(KERN_ERR "macp->TxUrbCnt: %d\n", macp->TxUrbCnt); - idx = 0xffff; - } + /*if (idx != macp->TxUrbHead)*/ + if (macp->TxUrbCnt != 0) { + idx = macp->TxUrbTail; + macp->TxUrbTail = ((macp->TxUrbTail + 1) & (ZM_MAX_TX_URB_NUM - 1)); + macp->TxUrbCnt--; + } else { + /*printk(KERN_ERR "macp->TxUrbCnt: %d\n", macp->TxUrbCnt);*/ + idx = 0xffff; + } - spin_unlock_irqrestore(&macp->cs_lock, irqFlag); + spin_unlock_irqrestore(&macp->cs_lock, irqFlag); return idx; } @@ -85,16 +82,13 @@ void zfLnxPutTxUrb(zdev_t *dev) idx = ((macp->TxUrbHead + 1) & (ZM_MAX_TX_URB_NUM - 1)); - //if (idx != macp->TxUrbTail) - if (macp->TxUrbCnt < ZM_MAX_TX_URB_NUM) - { - macp->TxUrbHead = idx; - macp->TxUrbCnt++; - } - else - { - printk("UsbTxUrbQ inconsistent: TxUrbHead: %d, TxUrbTail: %d\n", - macp->TxUrbHead, macp->TxUrbTail); + /*if (idx != macp->TxUrbTail)*/ + if (macp->TxUrbCnt < ZM_MAX_TX_URB_NUM) { + macp->TxUrbHead = idx; + macp->TxUrbCnt++; + } else { + printk("UsbTxUrbQ inconsistent: TxUrbHead: %d, TxUrbTail: %d\n", + macp->TxUrbHead, macp->TxUrbTail); } spin_unlock_irqrestore(&macp->cs_lock, irqFlag); @@ -125,24 +119,20 @@ UsbTxQ_t *zfLnxGetUsbTxBuffer(zdev_t *dev) idx = ((macp->TxBufHead+1) & (ZM_MAX_TX_BUF_NUM - 1)); - //if (idx != macp->TxBufTail) - if (macp->TxBufCnt > 0) - { - //printk("CWY - zfwGetUsbTxBuffer ,macp->TxBufCnt = %d\n", macp->TxBufCnt); - TxQ = (UsbTxQ_t *)&(macp->UsbTxBufQ[macp->TxBufHead]); - macp->TxBufHead = ((macp->TxBufHead+1) & (ZM_MAX_TX_BUF_NUM - 1)); - macp->TxBufCnt--; - } - else - { - if (macp->TxBufHead != macp->TxBufTail) - { - printk(KERN_ERR "zfwGetUsbTxBuf UsbTxBufQ inconsistent: TxBufHead: %d, TxBufTail: %d\n", - macp->TxBufHead, macp->TxBufTail); - } - - spin_unlock_irqrestore(&macp->cs_lock, irqFlag); - return NULL; + /*if (idx != macp->TxBufTail)*/ + if (macp->TxBufCnt > 0) { + /*printk("CWY - zfwGetUsbTxBuffer ,macp->TxBufCnt = %d\n", macp->TxBufCnt);*/ + TxQ = (UsbTxQ_t *)&(macp->UsbTxBufQ[macp->TxBufHead]); + macp->TxBufHead = ((macp->TxBufHead+1) & (ZM_MAX_TX_BUF_NUM - 1)); + macp->TxBufCnt--; + } else { + if (macp->TxBufHead != macp->TxBufTail) { + printk(KERN_ERR "zfwGetUsbTxBuf UsbTxBufQ inconsistent: TxBufHead: %d, TxBufTail: %d\n", + macp->TxBufHead, macp->TxBufTail); + } + + spin_unlock_irqrestore(&macp->cs_lock, irqFlag); + return NULL; } spin_unlock_irqrestore(&macp->cs_lock, irqFlag); @@ -150,8 +140,8 @@ UsbTxQ_t *zfLnxGetUsbTxBuffer(zdev_t *dev) } u16_t zfLnxPutUsbTxBuffer(zdev_t *dev, u8_t *hdr, u16_t hdrlen, - u8_t *snap, u16_t snapLen, u8_t *tail, u16_t tailLen, - zbuf_t *buf, u16_t offset) + u8_t *snap, u16_t snapLen, u8_t *tail, u16_t tailLen, + zbuf_t *buf, u16_t offset) { struct usbdrv_private *macp = dev->ml_priv; u16_t idx; @@ -163,32 +153,29 @@ u16_t zfLnxPutUsbTxBuffer(zdev_t *dev, u8_t *hdr, u16_t hdrlen, idx = ((macp->TxBufTail+1) & (ZM_MAX_TX_BUF_NUM - 1)); /* For Tx debug */ - //zm_assert(macp->TxBufCnt >= 0); // deleted because of always true - - //if (idx != macp->TxBufHead) - if (macp->TxBufCnt < ZM_MAX_TX_BUF_NUM) - { - //printk("CWY - zfwPutUsbTxBuffer ,macp->TxBufCnt = %d\n", macp->TxBufCnt); - TxQ = (UsbTxQ_t *)&(macp->UsbTxBufQ[macp->TxBufTail]); - memcpy(TxQ->hdr, hdr, hdrlen); - TxQ->hdrlen = hdrlen; - memcpy(TxQ->snap, snap, snapLen); - TxQ->snapLen = snapLen; - memcpy(TxQ->tail, tail, tailLen); - TxQ->tailLen = tailLen; - TxQ->buf = buf; - TxQ->offset = offset; - - macp->TxBufTail = ((macp->TxBufTail+1) & (ZM_MAX_TX_BUF_NUM - 1)); - macp->TxBufCnt++; - } - else - { - printk(KERN_ERR "zfLnxPutUsbTxBuffer UsbTxBufQ inconsistent: TxBufHead: %d, TxBufTail: %d, TxBufCnt: %d\n", - macp->TxBufHead, macp->TxBufTail, macp->TxBufCnt); - spin_unlock_irqrestore(&macp->cs_lock, irqFlag); - return 0xffff; - } + /*zm_assert(macp->TxBufCnt >= 0); // deleted because of always true*/ + + /*if (idx != macp->TxBufHead)*/ + if (macp->TxBufCnt < ZM_MAX_TX_BUF_NUM) { + /*printk("CWY - zfwPutUsbTxBuffer ,macp->TxBufCnt = %d\n", macp->TxBufCnt);*/ + TxQ = (UsbTxQ_t *)&(macp->UsbTxBufQ[macp->TxBufTail]); + memcpy(TxQ->hdr, hdr, hdrlen); + TxQ->hdrlen = hdrlen; + memcpy(TxQ->snap, snap, snapLen); + TxQ->snapLen = snapLen; + memcpy(TxQ->tail, tail, tailLen); + TxQ->tailLen = tailLen; + TxQ->buf = buf; + TxQ->offset = offset; + + macp->TxBufTail = ((macp->TxBufTail+1) & (ZM_MAX_TX_BUF_NUM - 1)); + macp->TxBufCnt++; + } else { + printk(KERN_ERR "zfLnxPutUsbTxBuffer UsbTxBufQ inconsistent: TxBufHead: %d, TxBufTail: %d, TxBufCnt: %d\n", + macp->TxBufHead, macp->TxBufTail, macp->TxBufCnt); + spin_unlock_irqrestore(&macp->cs_lock, irqFlag); + return 0xffff; + } spin_unlock_irqrestore(&macp->cs_lock, irqFlag); return 0; @@ -197,28 +184,25 @@ u16_t zfLnxPutUsbTxBuffer(zdev_t *dev, u8_t *hdr, u16_t hdrlen, zbuf_t *zfLnxGetUsbRxBuffer(zdev_t *dev) { struct usbdrv_private *macp = dev->ml_priv; - //u16_t idx; + /*u16_t idx;*/ zbuf_t *buf; unsigned long irqFlag; spin_lock_irqsave(&macp->cs_lock, irqFlag); - //idx = ((macp->RxBufHead+1) & (ZM_MAX_RX_URB_NUM - 1)); - - //if (idx != macp->RxBufTail) - if (macp->RxBufCnt != 0) - { - buf = macp->UsbRxBufQ[macp->RxBufHead]; - macp->RxBufHead = ((macp->RxBufHead+1) & (ZM_MAX_RX_URB_NUM - 1)); - macp->RxBufCnt--; - } - else - { - printk("RxBufQ inconsistent: RxBufHead: %d, RxBufTail: %d\n", - macp->RxBufHead, macp->RxBufTail); - spin_unlock_irqrestore(&macp->cs_lock, irqFlag); - return NULL; - } + /*idx = ((macp->RxBufHead+1) & (ZM_MAX_RX_URB_NUM - 1));*/ + + /*if (idx != macp->RxBufTail)*/ + if (macp->RxBufCnt != 0) { + buf = macp->UsbRxBufQ[macp->RxBufHead]; + macp->RxBufHead = ((macp->RxBufHead+1) & (ZM_MAX_RX_URB_NUM - 1)); + macp->RxBufCnt--; + } else { + printk("RxBufQ inconsistent: RxBufHead: %d, RxBufTail: %d\n", + macp->RxBufHead, macp->RxBufTail); + spin_unlock_irqrestore(&macp->cs_lock, irqFlag); + return NULL; + } spin_unlock_irqrestore(&macp->cs_lock, irqFlag); return buf; @@ -234,61 +218,56 @@ u32_t zfLnxPutUsbRxBuffer(zdev_t *dev, zbuf_t *buf) idx = ((macp->RxBufTail+1) & (ZM_MAX_RX_URB_NUM - 1)); - //if (idx != macp->RxBufHead) - if (macp->RxBufCnt != ZM_MAX_RX_URB_NUM) - { - macp->UsbRxBufQ[macp->RxBufTail] = buf; - macp->RxBufTail = idx; - macp->RxBufCnt++; - } - else - { - printk("RxBufQ inconsistent: RxBufHead: %d, RxBufTail: %d\n", - macp->RxBufHead, macp->RxBufTail); - spin_unlock_irqrestore(&macp->cs_lock, irqFlag); - return 0xffff; - } + /*if (idx != macp->RxBufHead)*/ + if (macp->RxBufCnt != ZM_MAX_RX_URB_NUM) { + macp->UsbRxBufQ[macp->RxBufTail] = buf; + macp->RxBufTail = idx; + macp->RxBufCnt++; + } else { + printk("RxBufQ inconsistent: RxBufHead: %d, RxBufTail: %d\n", + macp->RxBufHead, macp->RxBufTail); + spin_unlock_irqrestore(&macp->cs_lock, irqFlag); + return 0xffff; + } - spin_unlock_irqrestore(&macp->cs_lock, irqFlag); - return 0; + spin_unlock_irqrestore(&macp->cs_lock, irqFlag); + return 0; } void zfLnxUsbDataOut_callback(urb_t *urb) { - zdev_t* dev = urb->context; - //UsbTxQ_t *TxData; + zdev_t *dev = urb->context; + /*UsbTxQ_t *TxData;*/ /* Give the urb back */ zfLnxPutTxUrb(dev); /* Check whether there is any pending buffer needed */ /* to be sent */ - if (zfLnxCheckTxBufferCnt(dev) != 0) - { - //TxData = zfwGetUsbTxBuffer(dev); - - //if (TxData == NULL) - //{ - // printk("Get a NULL buffer from zfwGetUsbTxBuffer\n"); - // return; - //} - //else - //{ - zfLnxUsbSubmitTxData(dev); - //} + if (zfLnxCheckTxBufferCnt(dev) != 0) { + /*TxData = zfwGetUsbTxBuffer(dev); + //if (TxData == NULL) + //{ + // printk("Get a NULL buffer from zfwGetUsbTxBuffer\n"); + // return; + //} + //else + //{ + zfLnxUsbSubmitTxData(dev); + //}*/ } } void zfLnxUsbDataIn_callback(urb_t *urb) { - zdev_t* dev = urb->context; + zdev_t *dev = urb->context; struct usbdrv_private *macp = dev->ml_priv; zbuf_t *buf; zbuf_t *new_buf; int status; #if ZM_USB_STREAM_MODE == 1 - static int remain_len = 0, check_pad = 0, check_len = 0; + static int remain_len, check_pad, check_len; int index = 0; int chk_idx; u16_t pkt_len; @@ -299,47 +278,45 @@ void zfLnxUsbDataIn_callback(urb_t *urb) #endif /* Check status for URB */ - if (urb->status != 0){ - printk("zfLnxUsbDataIn_callback() : status=0x%x\n", urb->status); - if ((urb->status != -ENOENT) && (urb->status != -ECONNRESET) - && (urb->status != -ESHUTDOWN)) - { - if (urb->status == -EPIPE){ - //printk(KERN_ERR "nonzero read bulk status received: -EPIPE"); - status = -1; - } - - if (urb->status == -EPROTO){ - //printk(KERN_ERR "nonzero read bulk status received: -EPROTO"); - status = -1; - } - } - - //printk(KERN_ERR "urb->status: 0x%08x\n", urb->status); - - /* Dequeue skb buffer */ - buf = zfLnxGetUsbRxBuffer(dev); - dev_kfree_skb_any(buf); - #if 0 - /* Enqueue skb buffer */ - zfLnxPutUsbRxBuffer(dev, buf); - - /* Submit a Rx urb */ - zfLnxUsbIn(dev, urb, buf); - #endif - return; - } + if (urb->status != 0) { + printk("zfLnxUsbDataIn_callback() : status=0x%x\n", urb->status); + if ((urb->status != -ENOENT) && (urb->status != -ECONNRESET) + && (urb->status != -ESHUTDOWN)) { + if (urb->status == -EPIPE) { + /*printk(KERN_ERR "nonzero read bulk status received: -EPIPE");*/ + status = -1; + } + + if (urb->status == -EPROTO) { + /*printk(KERN_ERR "nonzero read bulk status received: -EPROTO");*/ + status = -1; + } + } + + /*printk(KERN_ERR "urb->status: 0x%08x\n", urb->status);*/ + + /* Dequeue skb buffer */ + buf = zfLnxGetUsbRxBuffer(dev); + dev_kfree_skb_any(buf); + #if 0 + /* Enqueue skb buffer */ + zfLnxPutUsbRxBuffer(dev, buf); - if (urb->actual_length == 0) - { - printk(KERN_ERR "Get an URB whose length is zero"); - status = -1; + /* Submit a Rx urb */ + zfLnxUsbIn(dev, urb, buf); + #endif + return; + } + + if (urb->actual_length == 0) { + printk(KERN_ERR "Get an URB whose length is zero"); + status = -1; } /* Dequeue skb buffer */ buf = zfLnxGetUsbRxBuffer(dev); - //zfwBufSetSize(dev, buf, urb->actual_length); + /*zfwBufSetSize(dev, buf, urb->actual_length);*/ #ifdef NET_SKBUFF_DATA_USES_OFFSET buf->tail = 0; buf->len = 0; @@ -353,134 +330,122 @@ void zfLnxUsbDataIn_callback(urb_t *urb) skb_put(buf, urb->actual_length); #if ZM_USB_STREAM_MODE == 1 - if (remain_len != 0) - { - zbuf_t *remain_buf = macp->reamin_buf; + if (remain_len != 0) { + zbuf_t *remain_buf = macp->reamin_buf; - index = remain_len; - remain_len -= check_pad; + index = remain_len; + remain_len -= check_pad; - /* Copy data */ - memcpy(&(remain_buf->data[check_len]), buf->data, remain_len); - check_len += remain_len; - remain_len = 0; + /* Copy data */ + memcpy(&(remain_buf->data[check_len]), buf->data, remain_len); + check_len += remain_len; + remain_len = 0; - rxBufPool[rxBufPoolIndex++] = remain_buf; + rxBufPool[rxBufPoolIndex++] = remain_buf; } - while(index < urb->actual_length) - { - pkt_len = buf->data[index] + (buf->data[index+1] << 8); - pkt_tag = buf->data[index+2] + (buf->data[index+3] << 8); - - if (pkt_tag == 0x4e00) - { - int pad_len; - - //printk("Get a packet, index: %d, pkt_len: 0x%04x\n", index, pkt_len); - #if 0 - /* Dump data */ - for (ii = index; ii < pkt_len+4;) - { - printk("%02x ", (buf->data[ii] & 0xff)); - - if ((++ii % 16) == 0) - printk("\n"); - } - - printk("\n"); - #endif - - pad_len = 4 - (pkt_len & 0x3); - - if(pad_len == 4) - pad_len = 0; - - chk_idx = index; - index = index + 4 + pkt_len + pad_len; - - if (index > ZM_MAX_RX_BUFFER_SIZE) - { - remain_len = index - ZM_MAX_RX_BUFFER_SIZE; // - pad_len; - check_len = ZM_MAX_RX_BUFFER_SIZE - chk_idx - 4; - check_pad = pad_len; - - /* Allocate a skb buffer */ - //new_buf = zfwBufAllocate(dev, ZM_MAX_RX_BUFFER_SIZE); - new_buf = dev_alloc_skb(ZM_MAX_RX_BUFFER_SIZE); - - /* Set skb buffer length */ - #ifdef NET_SKBUFF_DATA_USES_OFFSET - new_buf->tail = 0; - new_buf->len = 0; - #else - new_buf->tail = new_buf->data; - new_buf->len = 0; - #endif - - skb_put(new_buf, pkt_len); - - /* Copy the buffer */ - memcpy(new_buf->data, &(buf->data[chk_idx+4]), check_len); - - /* Record the buffer pointer */ - macp->reamin_buf = new_buf; - } - else - { - #ifdef ZM_DONT_COPY_RX_BUFFER - if (rxBufPoolIndex == 0) - { - new_buf = skb_clone(buf, GFP_ATOMIC); - - new_buf->data = &(buf->data[chk_idx+4]); - new_buf->len = pkt_len; - } - else - { - #endif - /* Allocate a skb buffer */ - new_buf = dev_alloc_skb(ZM_MAX_RX_BUFFER_SIZE); - - /* Set skb buffer length */ - #ifdef NET_SKBUFF_DATA_USES_OFFSET - new_buf->tail = 0; - new_buf->len = 0; - #else - new_buf->tail = new_buf->data; - new_buf->len = 0; - #endif - - skb_put(new_buf, pkt_len); - - /* Copy the buffer */ - memcpy(new_buf->data, &(buf->data[chk_idx+4]), pkt_len); - - #ifdef ZM_DONT_COPY_RX_BUFFER - } - #endif - rxBufPool[rxBufPoolIndex++] = new_buf; - } - } - else - { - printk(KERN_ERR "Can't find tag, pkt_len: 0x%04x, tag: 0x%04x\n", pkt_len, pkt_tag); - - /* Free buffer */ - dev_kfree_skb_any(buf); - - /* Allocate a skb buffer */ - new_buf = dev_alloc_skb(ZM_MAX_RX_BUFFER_SIZE); - - /* Enqueue skb buffer */ - zfLnxPutUsbRxBuffer(dev, new_buf); - - /* Submit a Rx urb */ - zfLnxUsbIn(dev, urb, new_buf); - - return; - } - } + while (index < urb->actual_length) { + pkt_len = buf->data[index] + (buf->data[index+1] << 8); + pkt_tag = buf->data[index+2] + (buf->data[index+3] << 8); + + if (pkt_tag == 0x4e00) { + int pad_len; + + /*printk("Get a packet, index: %d, pkt_len: 0x%04x\n", index, pkt_len);*/ + #if 0 + /* Dump data */ + for (ii = index; ii < pkt_len+4;) { + printk("%02x ", (buf->data[ii] & 0xff)); + + if ((++ii % 16) == 0) + printk("\n"); + } + + printk("\n"); + #endif + + pad_len = 4 - (pkt_len & 0x3); + + if (pad_len == 4) + pad_len = 0; + + chk_idx = index; + index = index + 4 + pkt_len + pad_len; + + if (index > ZM_MAX_RX_BUFFER_SIZE) { + remain_len = index - ZM_MAX_RX_BUFFER_SIZE; /* - pad_len;*/ + check_len = ZM_MAX_RX_BUFFER_SIZE - chk_idx - 4; + check_pad = pad_len; + + /* Allocate a skb buffer */ + /*new_buf = zfwBufAllocate(dev, ZM_MAX_RX_BUFFER_SIZE);*/ + new_buf = dev_alloc_skb(ZM_MAX_RX_BUFFER_SIZE); + + /* Set skb buffer length */ + #ifdef NET_SKBUFF_DATA_USES_OFFSET + new_buf->tail = 0; + new_buf->len = 0; + #else + new_buf->tail = new_buf->data; + new_buf->len = 0; + #endif + + skb_put(new_buf, pkt_len); + + /* Copy the buffer */ + memcpy(new_buf->data, &(buf->data[chk_idx+4]), check_len); + + /* Record the buffer pointer */ + macp->reamin_buf = new_buf; + } else { + #ifdef ZM_DONT_COPY_RX_BUFFER + if (rxBufPoolIndex == 0) { + new_buf = skb_clone(buf, GFP_ATOMIC); + + new_buf->data = &(buf->data[chk_idx+4]); + new_buf->len = pkt_len; + } else { + #endif + /* Allocate a skb buffer */ + new_buf = dev_alloc_skb(ZM_MAX_RX_BUFFER_SIZE); + + /* Set skb buffer length */ + #ifdef NET_SKBUFF_DATA_USES_OFFSET + new_buf->tail = 0; + new_buf->len = 0; + #else + new_buf->tail = new_buf->data; + new_buf->len = 0; + #endif + + skb_put(new_buf, pkt_len); + + /* Copy the buffer */ + memcpy(new_buf->data, &(buf->data[chk_idx+4]), pkt_len); + + #ifdef ZM_DONT_COPY_RX_BUFFER + } + #endif + rxBufPool[rxBufPoolIndex++] = new_buf; + } + } else { + printk(KERN_ERR "Can't find tag, pkt_len: 0x%04x, tag: 0x%04x\n", pkt_len, pkt_tag); + + /* Free buffer */ + dev_kfree_skb_any(buf); + + /* Allocate a skb buffer */ + new_buf = dev_alloc_skb(ZM_MAX_RX_BUFFER_SIZE); + + /* Enqueue skb buffer */ + zfLnxPutUsbRxBuffer(dev, new_buf); + + /* Submit a Rx urb */ + zfLnxUsbIn(dev, urb, new_buf); + + return; + } + } /* Free buffer */ dev_kfree_skb_any(buf); @@ -496,9 +461,8 @@ void zfLnxUsbDataIn_callback(urb_t *urb) zfLnxUsbIn(dev, urb, new_buf); #if ZM_USB_STREAM_MODE == 1 - for(ii = 0; ii < rxBufPoolIndex; ii++) - { - macp->usbCbFunctions.zfcbUsbRecv(dev, rxBufPool[ii]); + for (ii = 0; ii < rxBufPoolIndex; ii++) { + macp->usbCbFunctions.zfcbUsbRecv(dev, rxBufPool[ii]); } #else /* pass data to upper layer */ @@ -508,51 +472,48 @@ void zfLnxUsbDataIn_callback(urb_t *urb) void zfLnxUsbRegOut_callback(urb_t *urb) { - //dev_t* dev = urb->context; + /*dev_t* dev = urb->context;*/ - //printk(KERN_ERR "zfwUsbRegOut_callback\n"); + /*printk(KERN_ERR "zfwUsbRegOut_callback\n");*/ } void zfLnxUsbRegIn_callback(urb_t *urb) { - zdev_t* dev = urb->context; + zdev_t *dev = urb->context; u32_t rsp[64/4]; int status; struct usbdrv_private *macp = dev->ml_priv; /* Check status for URB */ - if (urb->status != 0){ - printk("zfLnxUsbRegIn_callback() : status=0x%x\n", urb->status); - if ((urb->status != -ENOENT) && (urb->status != -ECONNRESET) - && (urb->status != -ESHUTDOWN)) - { - if (urb->status == -EPIPE){ - //printk(KERN_ERR "nonzero read bulk status received: -EPIPE"); - status = -1; - } - - if (urb->status == -EPROTO){ - //printk(KERN_ERR "nonzero read bulk status received: -EPROTO"); - status = -1; - } - } - - //printk(KERN_ERR "urb->status: 0x%08x\n", urb->status); - return; - } + if (urb->status != 0) { + printk("zfLnxUsbRegIn_callback() : status=0x%x\n", urb->status); + if ((urb->status != -ENOENT) && (urb->status != -ECONNRESET) && (urb->status != -ESHUTDOWN)) { + if (urb->status == -EPIPE) { + /*printk(KERN_ERR "nonzero read bulk status received: -EPIPE");*/ + status = -1; + } + + if (urb->status == -EPROTO) { + /*printk(KERN_ERR "nonzero read bulk status received: -EPROTO");*/ + status = -1; + } + } + + /*printk(KERN_ERR "urb->status: 0x%08x\n", urb->status);*/ + return; + } - if (urb->actual_length == 0) - { - printk(KERN_ERR "Get an URB whose length is zero"); - status = -1; + if (urb->actual_length == 0) { + printk(KERN_ERR "Get an URB whose length is zero"); + status = -1; } /* Copy data into respone buffer */ memcpy(rsp, macp->regUsbReadBuf, urb->actual_length); /* Notify to upper layer */ - //zfIdlChkRsp(dev, rsp, (u16_t)urb->actual_length); - //zfiUsbRegIn(dev, rsp, (u16_t)urb->actual_length); + /*zfIdlChkRsp(dev, rsp, (u16_t)urb->actual_length);*/ + /*zfiUsbRegIn(dev, rsp, (u16_t)urb->actual_length);*/ macp->usbCbFunctions.zfcbUsbRegIn(dev, rsp, (u16_t)urb->actual_length); /* Issue another USB IN URB */ @@ -564,22 +525,22 @@ u32_t zfLnxSubmitRegInUrb(zdev_t *dev) u32_t ret; struct usbdrv_private *macp = dev->ml_priv; - /* Submit a rx urb */ + /* Submit a rx urb //ret = zfLnxUsbSubmitBulkUrb(macp->RegInUrb, macp->udev, // USB_REG_IN_PIPE, USB_DIR_IN, macp->regUsbReadBuf, // ZM_USB_REG_MAX_BUF_SIZE, zfLnxUsbRegIn_callback, dev); //CWYang(-) //if (ret != 0) - // printk("zfwUsbSubmitBulkUrb fail, status: 0x%08x\n", (int)ret); + // printk("zfwUsbSubmitBulkUrb fail, status: 0x%08x\n", (int)ret);*/ ret = zfLnxUsbSubmitIntUrb(macp->RegInUrb, macp->udev, - USB_REG_IN_PIPE, USB_DIR_IN, macp->regUsbReadBuf, - ZM_USB_REG_MAX_BUF_SIZE, zfLnxUsbRegIn_callback, dev, 1); + USB_REG_IN_PIPE, USB_DIR_IN, macp->regUsbReadBuf, + ZM_USB_REG_MAX_BUF_SIZE, zfLnxUsbRegIn_callback, dev, 1); return ret; } -u32_t zfLnxUsbSubmitTxData(zdev_t* dev) +u32_t zfLnxUsbSubmitTxData(zdev_t *dev) { u32_t i; u32_t ret; @@ -600,39 +561,33 @@ u32_t zfLnxUsbSubmitTxData(zdev_t* dev) freeTxUrb = zfLnxGetFreeTxUrb(dev); /* If there is no any free Tx Urb */ - if (freeTxUrb == 0xffff) - { - //printk(KERN_ERR "Can't get free Tx Urb\n"); - //printk("CWY - Can't get free Tx Urb\n"); - return 0xffff; + if (freeTxUrb == 0xffff) { + /*printk(KERN_ERR "Can't get free Tx Urb\n"); + //printk("CWY - Can't get free Tx Urb\n");*/ + return 0xffff; } #if ZM_USB_TX_STREAM_MODE == 1 usbTxAggCnt = zfLnxCheckTxBufferCnt(dev); - if (usbTxAggCnt >= ZM_MAX_TX_AGGREGATE_NUM) - { - usbTxAggCnt = ZM_MAX_TX_AGGREGATE_NUM; - } - else - { - usbTxAggCnt = 1; + if (usbTxAggCnt >= ZM_MAX_TX_AGGREGATE_NUM) { + usbTxAggCnt = ZM_MAX_TX_AGGREGATE_NUM; + } else { + usbTxAggCnt = 1; } - //printk("usbTxAggCnt: %d\n", usbTxAggCnt); + /*printk("usbTxAggCnt: %d\n", usbTxAggCnt);*/ #endif #if ZM_USB_TX_STREAM_MODE == 1 - for(ii = 0; ii < usbTxAggCnt; ii++) - { + for (ii = 0; ii < usbTxAggCnt; ii++) { #endif /* Dequeue the packet from UsbTxBufQ */ TxData = zfLnxGetUsbTxBuffer(dev); - if (TxData == NULL) - { - /* Give the urb back */ - zfLnxPutTxUrb(dev); - return 0xffff; + if (TxData == NULL) { + /* Give the urb back */ + zfLnxPutTxUrb(dev); + return 0xffff; } /* Point to the freeTxUrb buffer */ @@ -644,114 +599,103 @@ u32_t zfLnxUsbSubmitTxData(zdev_t* dev) /* Add the packet length and tag information */ *pUsbTxHdr++ = TxData->hdrlen + TxData->snapLen + - (TxData->buf->len - TxData->offset) + TxData->tailLen; + (TxData->buf->len - TxData->offset) + TxData->tailLen; *pUsbTxHdr++ = 0x697e; puTxBuf += 4; -#endif // #ifdef ZM_USB_TX_STREAM_MODE +#endif /* #ifdef ZM_USB_TX_STREAM_MODE*/ /* Copy WLAN header and packet buffer into USB buffer */ - for(i = 0; i < TxData->hdrlen; i++) - { - *puTxBuf++ = TxData->hdr[i]; + for (i = 0; i < TxData->hdrlen; i++) { + *puTxBuf++ = TxData->hdr[i]; } /* Copy SNAP header */ - for(i = 0; i < TxData->snapLen; i++) - { - *puTxBuf++ = TxData->snap[i]; + for (i = 0; i < TxData->snapLen; i++) { + *puTxBuf++ = TxData->snap[i]; } /* Copy packet buffer */ - for(i = 0; i < TxData->buf->len - TxData->offset; i++) - { - //*puTxBuf++ = zmw_rx_buf_readb(dev, TxData->buf, i); - *puTxBuf++ = *(u8_t*)((u8_t*)TxData->buf->data+i+TxData->offset); + for (i = 0; i < TxData->buf->len - TxData->offset; i++) { + /*puTxBuf++ = zmw_rx_buf_readb(dev, TxData->buf, i);*/ + *puTxBuf++ = *(u8_t *)((u8_t *)TxData->buf->data+i+TxData->offset); } /* Copy tail */ - for(i = 0; i < TxData->tailLen; i++) - { - *puTxBuf++ = TxData->tail[i]; + for (i = 0; i < TxData->tailLen; i++) { + *puTxBuf++ = TxData->tail[i]; } len = TxData->hdrlen+TxData->snapLen+TxData->buf->len+TxData->tailLen-TxData->offset; #if 0 - if (TxData->hdrlen != 0) - { - puTxBuf = macp->txUsbBuf[freeTxUrb]; - for (i = 0; i < len; i++) - { - printk("%02x ", puTxBuf[i]); - if (i % 16 == 15) - printk("\n"); - } - printk("\n"); - } + if (TxData->hdrlen != 0) { + puTxBuf = macp->txUsbBuf[freeTxUrb]; + for (i = 0; i < len; i++) { + printk("%02x ", puTxBuf[i]); + if (i % 16 == 15) + printk("\n"); + } + printk("\n"); + } #endif #if 0 /* For debug purpose */ - if(TxData->hdr[9] & 0x40) - { - int i; - u16_t ctrlLen = TxData->hdr[0] + (TxData->hdr[1] << 8); - - if (ctrlLen != len + 4) - { - /* Dump control setting */ - for(i = 0; i < 8; i++) - { - printk(KERN_ERR "0x%02x ", TxData->hdr[i]); - } - printk(KERN_ERR "\n"); - - printk(KERN_ERR "ctrLen: %d, hdrLen: %d, snapLen: %d\n", ctrlLen, TxData->hdrlen, TxData->snapLen); - printk(KERN_ERR "bufLen: %d, tailLen: %d, len: %d\n", TxData->buf->len, TxData->tailLen, len); - } + if (TxData->hdr[9] & 0x40) { + int i; + u16_t ctrlLen = TxData->hdr[0] + (TxData->hdr[1] << 8); + + if (ctrlLen != len + 4) { + /* Dump control setting */ + for (i = 0; i < 8; i++) { + printk(KERN_ERR "0x%02x ", TxData->hdr[i]); + } + printk(KERN_ERR "\n"); + + printk(KERN_ERR "ctrLen: %d, hdrLen: %d, snapLen: %d\n", ctrlLen, TxData->hdrlen, TxData->snapLen); + printk(KERN_ERR "bufLen: %d, tailLen: %d, len: %d\n", TxData->buf->len, TxData->tailLen, len); + } } #endif #if ZM_USB_TX_STREAM_MODE == 1 - // Add the Length and Tag + /* Add the Length and Tag*/ len += 4; - //printk("%d packet, length: %d\n", ii+1, len); + /*printk("%d packet, length: %d\n", ii+1, len);*/ - if (ii < (ZM_MAX_TX_AGGREGATE_NUM-1)) - { - /* Pad the buffer to firmware descriptor boundary */ - offset += (((len-1) / 4) + 1) * 4; + if (ii < (ZM_MAX_TX_AGGREGATE_NUM-1)) { + /* Pad the buffer to firmware descriptor boundary */ + offset += (((len-1) / 4) + 1) * 4; } - if (ii == (ZM_MAX_TX_AGGREGATE_NUM-1)) - { - len += offset; + if (ii == (ZM_MAX_TX_AGGREGATE_NUM-1)) { + len += offset; } TxQPool[ii] = TxData; - //DbgPrint("%d packet, offset: %d\n", ii+1, pUsbTxTransfer->offset); + /*DbgPrint("%d packet, offset: %d\n", ii+1, pUsbTxTransfer->offset);*/ /* free packet */ - //zfBufFree(dev, txData->buf); + /*zfBufFree(dev, txData->buf);*/ } #endif - //printk("CWY - call zfwUsbSubmitBulkUrb(), len = 0x%d\n", len); + /*printk("CWY - call zfwUsbSubmitBulkUrb(), len = 0x%d\n", len);*/ /* Submit a tx urb */ ret = zfLnxUsbSubmitBulkUrb(macp->WlanTxDataUrb[freeTxUrb], macp->udev, - USB_WLAN_TX_PIPE, USB_DIR_OUT, macp->txUsbBuf[freeTxUrb], - len, zfLnxUsbDataOut_callback, dev); - //CWYang(-) + USB_WLAN_TX_PIPE, USB_DIR_OUT, macp->txUsbBuf[freeTxUrb], + len, zfLnxUsbDataOut_callback, dev); + /*CWYang(-) //if (ret != 0) - // printk("zfwUsbSubmitBulkUrb fail, status: 0x%08x\n", (int)ret); + // printk("zfwUsbSubmitBulkUrb fail, status: 0x%08x\n", (int)ret);*/ /* free packet */ - //dev_kfree_skb_any(TxData->buf); + /*dev_kfree_skb_any(TxData->buf);*/ #if ZM_USB_TX_STREAM_MODE == 1 - for(ii = 0; ii < usbTxAggCnt; ii++) - macp->usbCbFunctions.zfcbUsbOutComplete(dev, TxQPool[ii]->buf, 1, TxQPool[ii]->hdr); + for (ii = 0; ii < usbTxAggCnt; ii++) + macp->usbCbFunctions.zfcbUsbOutComplete(dev, TxQPool[ii]->buf, 1, TxQPool[ii]->hdr); #else macp->usbCbFunctions.zfcbUsbOutComplete(dev, TxData->buf, 1, TxData->hdr); #endif @@ -761,23 +705,23 @@ u32_t zfLnxUsbSubmitTxData(zdev_t* dev) -u32_t zfLnxUsbIn(zdev_t* dev, urb_t *urb, zbuf_t *buf) +u32_t zfLnxUsbIn(zdev_t *dev, urb_t *urb, zbuf_t *buf) { u32_t ret; struct usbdrv_private *macp = dev->ml_priv; /* Submit a rx urb */ ret = zfLnxUsbSubmitBulkUrb(urb, macp->udev, USB_WLAN_RX_PIPE, - USB_DIR_IN, buf->data, ZM_MAX_RX_BUFFER_SIZE, - zfLnxUsbDataIn_callback, dev); - //CWYang(-) + USB_DIR_IN, buf->data, ZM_MAX_RX_BUFFER_SIZE, + zfLnxUsbDataIn_callback, dev); + /*CWYang(-) //if (ret != 0) - // printk("zfwUsbSubmitBulkUrb fail, status: 0x%08x\n", (int)ret); + // printk("zfwUsbSubmitBulkUrb fail, status: 0x%08x\n", (int)ret);*/ return ret; } -u32_t zfLnxUsbWriteReg(zdev_t* dev, u32_t* cmd, u16_t cmdLen) +u32_t zfLnxUsbWriteReg(zdev_t *dev, u32_t *cmd, u16_t cmdLen) { struct usbdrv_private *macp = dev->ml_priv; u32_t ret; @@ -785,7 +729,7 @@ u32_t zfLnxUsbWriteReg(zdev_t* dev, u32_t* cmd, u16_t cmdLen) #ifdef ZM_CONFIG_BIG_ENDIAN int ii = 0; - for(ii=0; ii<(cmdLen>>2); ii++) + for (ii = 0; ii < (cmdLen>>2); ii++) cmd[ii] = cpu_to_le32(cmd[ii]); #endif @@ -794,39 +738,38 @@ u32_t zfLnxUsbWriteReg(zdev_t* dev, u32_t* cmd, u16_t cmdLen) /* Issue an USB Out transfer */ /* Submit a tx urb */ ret = zfLnxUsbSubmitIntUrb(macp->RegOutUrb, macp->udev, - USB_REG_OUT_PIPE, USB_DIR_OUT, macp->regUsbWriteBuf, - cmdLen, zfLnxUsbRegOut_callback, dev, 1); + USB_REG_OUT_PIPE, USB_DIR_OUT, macp->regUsbWriteBuf, + cmdLen, zfLnxUsbRegOut_callback, dev, 1); return ret; } -u32_t zfLnxUsbOut(zdev_t* dev, u8_t *hdr, u16_t hdrlen, u8_t *snap, u16_t snapLen, - u8_t *tail, u16_t tailLen, zbuf_t *buf, u16_t offset) +u32_t zfLnxUsbOut(zdev_t *dev, u8_t *hdr, u16_t hdrlen, u8_t *snap, u16_t snapLen, + u8_t *tail, u16_t tailLen, zbuf_t *buf, u16_t offset) { u32_t ret; struct usbdrv_private *macp = dev->ml_priv; /* Check length of tail buffer */ - //zm_assert((tailLen <= 16)); + /*zm_assert((tailLen <= 16));*/ /* Enqueue the packet into UsbTxBufQ */ - if (zfLnxPutUsbTxBuffer(dev, hdr, hdrlen, snap, snapLen, tail, tailLen, buf, offset) == 0xffff) - { - /* free packet */ - //printk("CWY - zfwPutUsbTxBuffer Error, free packet\n"); - //dev_kfree_skb_any(buf); - macp->usbCbFunctions.zfcbUsbOutComplete(dev, buf, 0, hdr); - return 0xffff; - } + if (zfLnxPutUsbTxBuffer(dev, hdr, hdrlen, snap, snapLen, tail, tailLen, buf, offset) == 0xffff) { + /* free packet */ + /*printk("CWY - zfwPutUsbTxBuffer Error, free packet\n"); + //dev_kfree_skb_any(buf);*/ + macp->usbCbFunctions.zfcbUsbOutComplete(dev, buf, 0, hdr); + return 0xffff; + } - //return 0; - //printk("CWY - call zfwUsbSubmitTxData()\n"); + /*return 0; + //printk("CWY - call zfwUsbSubmitTxData()\n");*/ ret = zfLnxUsbSubmitTxData(dev); return ret; } -void zfLnxInitUsbTxQ(zdev_t* dev) +void zfLnxInitUsbTxQ(zdev_t *dev) { struct usbdrv_private *macp = dev->ml_priv; @@ -842,7 +785,7 @@ void zfLnxInitUsbTxQ(zdev_t* dev) macp->TxUrbCnt = ZM_MAX_TX_URB_NUM; } -void zfLnxInitUsbRxQ(zdev_t* dev) +void zfLnxInitUsbRxQ(zdev_t *dev) { u16_t i; zbuf_t *buf; @@ -853,76 +796,65 @@ void zfLnxInitUsbRxQ(zdev_t* dev) macp->RxBufHead = 0; - for (i = 0; i < ZM_MAX_RX_URB_NUM; i++) - { - //buf = zfwBufAllocate(dev, ZM_MAX_RX_BUFFER_SIZE); - buf = dev_alloc_skb(ZM_MAX_RX_BUFFER_SIZE); - macp->UsbRxBufQ[i] = buf; - } + for (i = 0; i < ZM_MAX_RX_URB_NUM; i++) { + /*buf = zfwBufAllocate(dev, ZM_MAX_RX_BUFFER_SIZE);*/ + buf = dev_alloc_skb(ZM_MAX_RX_BUFFER_SIZE); + macp->UsbRxBufQ[i] = buf; + } - //macp->RxBufTail = ZM_MAX_RX_URB_NUM - 1; + /*macp->RxBufTail = ZM_MAX_RX_URB_NUM - 1;*/ macp->RxBufTail = 0; /* Submit all Rx urbs */ - for (i = 0; i < ZM_MAX_RX_URB_NUM; i++) - { - zfLnxPutUsbRxBuffer(dev, macp->UsbRxBufQ[i]); - zfLnxUsbIn(dev, macp->WlanRxDataUrb[i], macp->UsbRxBufQ[i]); - } + for (i = 0; i < ZM_MAX_RX_URB_NUM; i++) { + zfLnxPutUsbRxBuffer(dev, macp->UsbRxBufQ[i]); + zfLnxUsbIn(dev, macp->WlanRxDataUrb[i], macp->UsbRxBufQ[i]); + } } u32_t zfLnxUsbSubmitBulkUrb(urb_t *urb, struct usb_device *usb, u16_t epnum, u16_t direction, - void *transfer_buffer, int buffer_length, usb_complete_t complete, void *context) + void *transfer_buffer, int buffer_length, usb_complete_t complete, void *context) { u32_t ret; - if(direction == USB_DIR_OUT) - { - usb_fill_bulk_urb(urb, usb, usb_sndbulkpipe(usb, epnum), - transfer_buffer, buffer_length, complete, context); + if (direction == USB_DIR_OUT) { + usb_fill_bulk_urb(urb, usb, usb_sndbulkpipe(usb, epnum), + transfer_buffer, buffer_length, complete, context); - urb->transfer_flags |= URB_ZERO_PACKET; - } - else - { - usb_fill_bulk_urb(urb, usb, usb_rcvbulkpipe(usb, epnum), - transfer_buffer, buffer_length, complete, context); + urb->transfer_flags |= URB_ZERO_PACKET; + } else { + usb_fill_bulk_urb(urb, usb, usb_rcvbulkpipe(usb, epnum), + transfer_buffer, buffer_length, complete, context); } - if (epnum == 4) - { - if (urb->hcpriv) - { - //printk("CWY - urb->hcpriv set by unknown reason, reset it\n"); - //urb->hcpriv = 0; - } - } + if (epnum == 4) { + if (urb->hcpriv) { + /*printk("CWY - urb->hcpriv set by unknown reason, reset it\n"); + //urb->hcpriv = 0;*/ + } + } ret = usb_submit_urb(urb, GFP_ATOMIC); - if ((epnum == 4) & (ret != 0)) - { - //printk("CWY - ret = %x\n", ret); + if ((epnum == 4) & (ret != 0)) { + /*printk("CWY - ret = %x\n", ret);*/ } return ret; } u32_t zfLnxUsbSubmitIntUrb(urb_t *urb, struct usb_device *usb, u16_t epnum, u16_t direction, - void *transfer_buffer, int buffer_length, usb_complete_t complete, void *context, - u32_t interval) + void *transfer_buffer, int buffer_length, usb_complete_t complete, void *context, + u32_t interval) { u32_t ret; - if(direction == USB_DIR_OUT) - { - usb_fill_int_urb(urb, usb, usb_sndbulkpipe(usb, epnum), - transfer_buffer, buffer_length, complete, context, interval); - } - else - { - usb_fill_int_urb(urb, usb, usb_rcvbulkpipe(usb, epnum), - transfer_buffer, buffer_length, complete, context, interval); + if (direction == USB_DIR_OUT) { + usb_fill_int_urb(urb, usb, usb_sndbulkpipe(usb, epnum), + transfer_buffer, buffer_length, complete, context, interval); + } else { + usb_fill_int_urb(urb, usb, usb_rcvbulkpipe(usb, epnum), + transfer_buffer, buffer_length, complete, context, interval); } ret = usb_submit_urb(urb, GFP_ATOMIC); @@ -946,51 +878,48 @@ int zfLnxCencSendMsg(struct sock *netlink_sk, u_int8_t *msg, int len) size = NLMSG_SPACE(len); skb = alloc_skb(size, GFP_ATOMIC); - if(skb == NULL) - { + if (skb == NULL) { printk("dev_alloc_skb failure \n"); goto out; } old_tail = skb->tail; - /*填写数据报相关信息*/ + /* */ nlh = NLMSG_PUT(skb, 0, 0, WAI_K_MSG, size-sizeof(*nlh)); pos = NLMSG_DATA(nlh); - /*传输到用户空间的数据*/ + /* */ memcpy(pos, msg, len); - /*计算经过字节对其后的数据实际长度*/ + /* */ nlh->nlmsg_len = skb->tail - old_tail; NETLINK_CB(skb).dst_group = COMMTYPE_GROUP; netlink_broadcast(netlink_sk, skb, 0, COMMTYPE_GROUP, GFP_ATOMIC); ret = 0; out: return ret; -nlmsg_failure: /*NLMSG_PUT 失败,则撤销套接字缓存*/ +nlmsg_failure: /* */ kfree_skb(skb); goto out; #undef COMMTYPE_GROUP #undef WAI_K_MSG } -#endif //ZM_ENABLE_CENC +#endif /*ZM_ENABLE_CENC*/ /* Simply return 0xffff if VAP function is not supported */ -u16_t zfLnxGetVapId(zdev_t* dev) +u16_t zfLnxGetVapId(zdev_t *dev) { u16_t i; - for (i=0; i<ZM_VAP_PORT_NUMBER; i++) - { - if (vap[i].dev == dev) - { - return i; - } - } - return 0xffff; + for (i = 0; i < ZM_VAP_PORT_NUMBER; i++) { + if (vap[i].dev == dev) { + return i; + } + } + return 0xffff; } -u32_t zfwReadReg(zdev_t* dev, u32_t offset) +u32_t zfwReadReg(zdev_t *dev, u32_t offset) { return 0; } @@ -1012,25 +941,23 @@ u32_t smp_kevent_Lock = 0; void kevent(struct work_struct *work) { struct usbdrv_private *macp = - container_of(work, struct usbdrv_private, kevent); - zdev_t *dev = macp->device; + container_of(work, struct usbdrv_private, kevent); + zdev_t *dev = macp->device; - if (test_and_set_bit(0, (void *)&smp_kevent_Lock)) - { - //schedule_work(&macp->kevent); - return; + if (test_and_set_bit(0, (void *)&smp_kevent_Lock)) { + /*schedule_work(&macp->kevent);*/ + return; } down(&macp->ioctl_sem); - if (test_and_clear_bit(KEVENT_WATCHDOG, &macp->kevent_flags)) - { + if (test_and_clear_bit(KEVENT_WATCHDOG, &macp->kevent_flags)) { extern u16_t zfHpStartRecv(zdev_t *dev); - //zfiHwWatchDogReinit(dev); - printk(("\n ************ Hw watchDog occur!! ************** \n")); - zfiWlanSuspend(dev); - zfiWlanResume(dev,0); - zfHpStartRecv(dev); + /*zfiHwWatchDogReinit(dev);*/ + printk(("\n ************ Hw watchDog occur!! ************** \n")); + zfiWlanSuspend(dev); + zfiWlanResume(dev , 0); + zfHpStartRecv(dev); } clear_bit(0, (void *)&smp_kevent_Lock); @@ -1083,41 +1010,38 @@ void zfLnxSignalThread(zdev_t *dev, int flag) { struct usbdrv_private *macp = dev->ml_priv; - if (macp == NULL) - { - printk("macp is NULL\n"); - return; + if (macp == NULL) { + printk("macp is NULL\n"); + return; } - if (0 && macp->kevent_ready != 1) - { - printk("Kevent not ready\n"); - return; + if (0 && macp->kevent_ready != 1) { + printk("Kevent not ready\n"); + return; } set_bit(flag, &macp->kevent_flags); - if (!schedule_work(&macp->kevent)) - { - //Fails is Normal - //printk(KERN_ERR "schedule_task failed, flag = %x\n", flag); - } + if (!schedule_work(&macp->kevent)) { + /*Fails is Normal + //printk(KERN_ERR "schedule_task failed, flag = %x\n", flag);*/ + } } /* Notify wrapper todo redownload firmware and reinit procedure when */ /* hardware watchdog occur : zfiHwWatchDogReinit() */ -void zfLnxWatchDogNotify(zdev_t* dev) +void zfLnxWatchDogNotify(zdev_t *dev) { zfLnxSignalThread(dev, KEVENT_WATCHDOG); } /* Query Durantion of Active Scan */ -void zfwGetActiveScanDur(zdev_t* dev, u8_t* Dur) +void zfwGetActiveScanDur(zdev_t *dev, u8_t *Dur) { - *Dur = 30; // default 30 ms + *Dur = 30; /* default 30 ms*/ } -void zfwGetShowZeroLengthSSID(zdev_t* dev, u8_t* Dur) +void zfwGetShowZeroLengthSSID(zdev_t *dev, u8_t *Dur) { *Dur = 0; } diff --git a/drivers/staging/otus/zdusb.c b/drivers/staging/otus/zdusb.c index 2c799a250294..4014b7472454 100644 --- a/drivers/staging/otus/zdusb.c +++ b/drivers/staging/otus/zdusb.c @@ -48,7 +48,7 @@ static const char driver_name[] = "Otus"; /* table of devices that work with this driver */ static const struct usb_device_id zd1221_ids[] = { { USB_DEVICE(VENDOR_ATHR, PRODUCT_AR9170) }, - { USB_DEVICE(VENDOR_DLINK, PRODUCT_DWA160A) }, + { USB_DEVICE(VENDOR_DLINK, PRODUCT_DWA160A) }, { USB_DEVICE(VENDOR_NETGEAR, PRODUCT_WNDA3100) }, { USB_DEVICE(VENDOR_NETGEAR, PRODUCT_WN111v2) }, { } /* Terminating entry */ @@ -60,9 +60,9 @@ extern u8_t zfLnxInitSetup(struct net_device *dev, struct usbdrv_private *macp); extern int usbdrv_close(struct net_device *dev); extern u8_t zfLnxClearStructs(struct net_device *dev); extern int zfWdsClose(struct net_device *dev); -extern int zfUnregisterWdsDev(struct net_device* parentDev, u16_t wdsId); +extern int zfUnregisterWdsDev(struct net_device *parentDev, u16_t wdsId); extern int zfLnxVapClose(struct net_device *dev); -extern int zfLnxUnregisterVapDev(struct net_device* parentDev, u16_t vapId); +extern int zfLnxUnregisterVapDev(struct net_device *parentDev, u16_t vapId); /* WDS */ extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER]; @@ -73,148 +73,135 @@ extern struct zsVapStruct vap[ZM_VAP_PORT_NUMBER]; static int zfLnxProbe(struct usb_interface *interface, const struct usb_device_id *id) { - struct usb_device *dev = interface_to_usbdev(interface); - - struct net_device *net = NULL; - struct usbdrv_private *macp = NULL; - int vendor_id, product_id; - int result = 0; - - usb_get_dev(dev); - - vendor_id = dev->descriptor.idVendor; - product_id = dev->descriptor.idProduct; - -#ifdef HMAC_DEBUG - printk(KERN_NOTICE "vendor_id = %04x\n", vendor_id); - printk(KERN_NOTICE "product_id = %04x\n", product_id); - - if (dev->speed == USB_SPEED_HIGH) - printk(KERN_NOTICE "USB 2.0 Host\n"); - else - printk(KERN_NOTICE "USB 1.1 Host\n"); -#endif - - macp = kzalloc(sizeof(struct usbdrv_private), GFP_KERNEL); - if (!macp) - { - printk(KERN_ERR "out of memory allocating device structure\n"); - result = -ENOMEM; - goto fail; - } - - net = alloc_etherdev(0); - - if (net == NULL) - { - printk(KERN_ERR "zfLnxProbe: Not able to alloc etherdev struct\n"); - result = -ENOMEM; - goto fail1; - } - - strcpy(net->name, "ath%d"); - - net->ml_priv = macp; //kernel 2.6 - macp->udev = dev; - macp->device = net; - - /* set up the endpoint information */ - /* check out the endpoints */ - macp->interface = interface; - - //init_waitqueue_head(&macp->regSet_wait); - //init_waitqueue_head(&macp->iorwRsp_wait); - //init_waitqueue_head(&macp->term_wait); - - if (!zfLnxAllocAllUrbs(macp)) - { - result = -ENOMEM; - goto fail2; - } - - if (!zfLnxInitSetup(net, macp)) - { - result = -EIO; - goto fail3; - } - else - { - usb_set_intfdata(interface, macp); - SET_NETDEV_DEV(net, &interface->dev); - - if (register_netdev(net) != 0) - { - usb_set_intfdata(interface, NULL); - goto fail3; - } - } - - netif_carrier_off(net); - goto done; - + struct usb_device *dev = interface_to_usbdev(interface); + + struct net_device *net = NULL; + struct usbdrv_private *macp = NULL; + int vendor_id, product_id; + int result = 0; + + usb_get_dev(dev); + + vendor_id = dev->descriptor.idVendor; + product_id = dev->descriptor.idProduct; + + #ifdef HMAC_DEBUG + printk(KERN_NOTICE "vendor_id = %04x\n", vendor_id); + printk(KERN_NOTICE "product_id = %04x\n", product_id); + + if (dev->speed == USB_SPEED_HIGH) + printk(KERN_NOTICE "USB 2.0 Host\n"); + else + printk(KERN_NOTICE "USB 1.1 Host\n"); + #endif + + macp = kzalloc(sizeof(struct usbdrv_private), GFP_KERNEL); + if (!macp) { + printk(KERN_ERR "out of memory allocating device structure\n"); + result = -ENOMEM; + goto fail; + } + + net = alloc_etherdev(0); + + if (net == NULL) { + printk(KERN_ERR "zfLnxProbe: Not able to alloc etherdev struct\n"); + result = -ENOMEM; + goto fail1; + } + + strcpy(net->name, "ath%d"); + + net->ml_priv = macp; /* kernel 2.6 */ + macp->udev = dev; + macp->device = net; + + /* set up the endpoint information */ + /* check out the endpoints */ + macp->interface = interface; + + /* init_waitqueue_head(&macp->regSet_wait); */ + /* init_waitqueue_head(&macp->iorwRsp_wait); */ + /* init_waitqueue_head(&macp->term_wait); */ + + if (!zfLnxAllocAllUrbs(macp)) { + result = -ENOMEM; + goto fail2; + } + + if (!zfLnxInitSetup(net, macp)) { + result = -EIO; + goto fail3; + } else { + usb_set_intfdata(interface, macp); + SET_NETDEV_DEV(net, &interface->dev); + + if (register_netdev(net) != 0) { + usb_set_intfdata(interface, NULL); + goto fail3; + } + } + + netif_carrier_off(net); + goto done; fail3: - zfLnxFreeAllUrbs(macp); + zfLnxFreeAllUrbs(macp); fail2: - free_netdev(net); //kernel 2.6 + free_netdev(net); /* kernel 2.6 */ fail1: - kfree(macp); - + kfree(macp); fail: - usb_put_dev(dev); - macp = NULL; - + usb_put_dev(dev); + macp = NULL; done: - return result; + return result; } static void zfLnxDisconnect(struct usb_interface *interface) { - struct usbdrv_private *macp = (struct usbdrv_private *) usb_get_intfdata(interface); - - printk(KERN_DEBUG "zfLnxDisconnect\n"); - - if (!macp) - { - printk(KERN_ERR "unregistering non-existant device\n"); - return; - } - - if (macp->driver_isolated) - { - if (macp->device->flags & IFF_UP) - usbdrv_close(macp->device); - } - -#if 0 - /* Close WDS */ - //zfWdsClose(wds[0].dev); - /* Unregister WDS */ - //zfUnregisterWdsDev(macp->device, 0); - - /* Close VAP */ - zfLnxVapClose(vap[0].dev); - /* Unregister VAP */ - zfLnxUnregisterVapDev(macp->device, 0); -#endif + struct usbdrv_private *macp = (struct usbdrv_private *) usb_get_intfdata(interface); + + printk(KERN_DEBUG "zfLnxDisconnect\n"); + + if (!macp) { + printk(KERN_ERR "unregistering non-existant device\n"); + return; + } + + if (macp->driver_isolated) + if (macp->device->flags & IFF_UP) + usbdrv_close(macp->device); + + #if 0 + /* Close WDS */ + /* zfWdsClose(wds[0].dev); */ + /* Unregister WDS */ + /* zfUnregisterWdsDev(macp->device, 0); */ + + /* Close VAP */ + zfLnxVapClose(vap[0].dev); + /* Unregister VAP */ + zfLnxUnregisterVapDev(macp->device, 0); + #endif - zfLnxClearStructs(macp->device); + zfLnxClearStructs(macp->device); - unregister_netdev(macp->device); + unregister_netdev(macp->device); - usb_put_dev(interface_to_usbdev(interface)); + usb_put_dev(interface_to_usbdev(interface)); - //printk(KERN_ERR "3. zfLnxUnlinkAllUrbs\n"); - //zfLnxUnlinkAllUrbs(macp); + /* printk(KERN_ERR "3. zfLnxUnlinkAllUrbs\n"); */ + /* zfLnxUnlinkAllUrbs(macp); */ - /* Free network interface */ - free_netdev(macp->device); + /* Free network interface */ + free_netdev(macp->device); - zfLnxFreeAllUrbs(macp); - //zfLnxClearStructs(macp->device); - kfree(macp); - macp = NULL; + zfLnxFreeAllUrbs(macp); + /* zfLnxClearStructs(macp->device); */ + kfree(macp); + macp = NULL; - usb_set_intfdata(interface, NULL); + usb_set_intfdata(interface, NULL); } static struct usb_driver zd1221_driver = { @@ -226,13 +213,13 @@ static struct usb_driver zd1221_driver = { int __init zfLnxIinit(void) { - printk(KERN_NOTICE "%s - version %s\n", DRIVER_NAME, VERSIONID); - return usb_register(&zd1221_driver); + printk(KERN_NOTICE "%s - version %s\n", DRIVER_NAME, VERSIONID); + return usb_register(&zd1221_driver); } void __exit zfLnxExit(void) { - usb_deregister(&zd1221_driver); + usb_deregister(&zd1221_driver); } module_init(zfLnxIinit); |