X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=drivers%2Fstaging%2Fvt6656%2Fmain_usb.c;h=2fcaf70aa4654c1b76b5352dafc9c1c036c4f676;hb=8611a29ab967bc197494db19d31994d1b5a26fdc;hp=a8e1adbc9592daea1e114c147f6c2116477680db;hpb=50da56706b989b99edb20f9c03172df193240c78;p=linux-2.6-block.git diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index a8e1adbc9592..2fcaf70aa465 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -26,7 +26,7 @@ * * Functions: * - * vntwusb_found1 - module initial (insmod) driver entry + * vt6656_probe - module initial (insmod) driver entry * device_remove1 - module remove entry * device_open - allocate dma/descripter resource & initial mac/bbp function * device_xmit - asynchrous data tx function @@ -222,15 +222,11 @@ DEVICE_PARAM(b80211hEnable, "802.11h mode"); // Static vars definitions // - - -static struct usb_device_id vntwusb_table[] = { +static struct usb_device_id vt6656_table[] __devinitdata = { {USB_DEVICE(VNT_USB_VENDOR_ID, VNT_USB_PRODUCT_ID)}, {} }; - - // Frequency list (map channels to frequencies) /* static const long frequency_list[] = { @@ -250,15 +246,17 @@ static const long frequency_list[] = { static const struct iw_handler_def iwctl_handler_def; */ +/*--------------------- Static Functions --------------------------*/ +static int vt6656_probe(struct usb_interface *intf, + const struct usb_device_id *id); +static void vt6656_disconnect(struct usb_interface *intf); -/*--------------------- Static Functions --------------------------*/ -static int vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id); -static void vntwusb_disconnect(struct usb_interface *intf); #ifdef CONFIG_PM /* Minimal support for suspend and resume */ -static int vntwusb_suspend(struct usb_interface *intf, pm_message_t message); -static int vntwusb_resume(struct usb_interface *intf); -#endif +static int vt6656_suspend(struct usb_interface *intf, pm_message_t message); +static int vt6656_resume(struct usb_interface *intf); +#endif /* CONFIG_PM */ + static struct net_device_stats *device_get_stats(struct net_device *dev); static int device_open(struct net_device *dev); static int device_xmit(struct sk_buff *skb, struct net_device *dev); @@ -297,14 +295,13 @@ static void usb_device_reset(PSDevice pDevice); static void device_set_options(PSDevice pDevice) { - BYTE abyBroadcastAddr[U_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - BYTE abySNAP_RFC1042[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; - BYTE abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; - + BYTE abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + BYTE abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; + u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; - memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, U_ETHER_ADDR_LEN); - memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, U_ETHER_ADDR_LEN); - memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, U_ETHER_ADDR_LEN); + memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN); + memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN); + memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN); pDevice->cbTD = TX_DESC_DEF0; pDevice->cbRD = RX_DESC_DEF0; @@ -334,8 +331,8 @@ device_set_options(PSDevice pDevice) { } -static VOID device_init_diversity_timer(PSDevice pDevice) { - +static void device_init_diversity_timer(PSDevice pDevice) +{ init_timer(&pDevice->TimerSQ3Tmax1); pDevice->TimerSQ3Tmax1.data = (ULONG)pDevice; pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack; @@ -361,9 +358,9 @@ static VOID device_init_diversity_timer(PSDevice pDevice) { static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) { - BYTE abyBroadcastAddr[U_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - BYTE abySNAP_RFC1042[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; - BYTE abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; + u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; + u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; BYTE byAntenna; UINT ii; CMD_CARD_INIT sInitCmd; @@ -377,10 +374,12 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", InitType, pDevice->byPacketType); spin_lock_irq(&pDevice->lock); - if (InitType == DEVICE_INIT_COLD) { - memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, U_ETHER_ADDR_LEN); - memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, U_ETHER_ADDR_LEN); - memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, U_ETHER_ADDR_LEN); + if (InitType == DEVICE_INIT_COLD) { + memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN); + memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN); + memcpy(pDevice->abySNAP_Bridgetunnel, + abySNAP_Bridgetunnel, + ETH_ALEN); if ( !FIRMWAREbCheckVersion(pDevice) ) { if (FIRMWAREbDownload(pDevice) == TRUE) { @@ -605,7 +604,9 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) // get Permanent network address memcpy(pDevice->abyPermanentNetAddr,&(sInitRsp.byNetAddr[0]),6); - memcpy(pDevice->abyCurrentNetAddr, pDevice->abyPermanentNetAddr, U_ETHER_ADDR_LEN); + memcpy(pDevice->abyCurrentNetAddr, + pDevice->abyPermanentNetAddr, + ETH_ALEN); // if exist SW network address, use SW network address. @@ -712,7 +713,8 @@ static BOOL device_release_WPADEV(PSDevice pDevice) } #ifdef CONFIG_PM /* Minimal support for suspend and resume */ -static int vntwusb_suspend(struct usb_interface *intf, pm_message_t message) + +static int vt6656_suspend(struct usb_interface *intf, pm_message_t message) { PSDevice pDevice = usb_get_intfdata(intf); struct net_device *dev = pDevice->dev; @@ -727,7 +729,7 @@ if(dev != NULL) { return 0; } -static int vntwusb_resume(struct usb_interface *intf) +static int vt6656_resume(struct usb_interface *intf) { PSDevice pDevice = usb_get_intfdata(intf); struct net_device *dev = pDevice->dev; @@ -742,8 +744,8 @@ static int vntwusb_resume(struct usb_interface *intf) } return 0; } -#endif +#endif /* CONFIG_PM */ static const struct net_device_ops device_netdev_ops = { .ndo_open = device_open, @@ -755,10 +757,10 @@ static const struct net_device_ops device_netdev_ops = { }; -static int -vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id) +static int __devinit +vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) { - BYTE fake_mac[U_ETHER_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01};//fake MAC address + u8 fake_mac[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; struct usb_device *udev = interface_to_usbdev(intf); int rc = 0; struct net_device *netdev = NULL; @@ -789,7 +791,7 @@ vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id) spin_lock_init(&pDevice->lock); pDevice->tx_80211 = device_dma0_tx_80211; - pDevice->sMgmtObj.pAdapter = (PVOID)pDevice; + pDevice->sMgmtObj.pAdapter = (void *)pDevice; netdev->netdev_ops = &device_netdev_ops; @@ -799,7 +801,7 @@ vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id) //2007-0821-01by MikeLiu usb_set_intfdata(intf, pDevice); SET_NETDEV_DEV(netdev, &intf->dev); - memcpy(pDevice->dev->dev_addr, fake_mac, U_ETHER_ADDR_LEN); //use fake mac address + memcpy(pDevice->dev->dev_addr, fake_mac, ETH_ALEN); rc = register_netdev(netdev); if (rc != 0) { printk(KERN_ERR DEVICE_NAME " Failed to register netdev\n"); @@ -841,7 +843,8 @@ err_nomem: } -static VOID device_free_tx_bufs(PSDevice pDevice) { +static void device_free_tx_bufs(PSDevice pDevice) +{ PUSB_SEND_CONTEXT pTxContext; int ii; @@ -860,7 +863,8 @@ static VOID device_free_tx_bufs(PSDevice pDevice) { } -static VOID device_free_rx_bufs(PSDevice pDevice) { +static void device_free_rx_bufs(PSDevice pDevice) +{ PRCB pRCB; int ii; @@ -892,8 +896,8 @@ static void usb_device_reset(PSDevice pDevice) return ; } -static VOID device_free_int_bufs(PSDevice pDevice) { - +static void device_free_int_bufs(PSDevice pDevice) +{ if (pDevice->intBuf.pDataBuf != NULL) kfree(pDevice->intBuf.pDataBuf); return; @@ -915,7 +919,7 @@ static BOOL device_alloc_bufs(PSDevice pDevice) { goto free_tx; } pDevice->apTD[ii] = pTxContext; - pTxContext->pDevice = (PVOID) pDevice; + pTxContext->pDevice = (void *) pDevice; //allocate URBs pTxContext->pUrb = usb_alloc_urb(0, GFP_ATOMIC); if (pTxContext->pUrb == NULL) { @@ -944,7 +948,7 @@ static BOOL device_alloc_bufs(PSDevice pDevice) { for (ii = 0; ii < pDevice->cbRD; ii++) { pDevice->apRCB[ii] = pRCB; - pRCB->pDevice = (PVOID) pDevice; + pRCB->pDevice = (void *) pDevice; //allocate URBs pRCB->pUrb = usb_alloc_urb(0, GFP_ATOMIC); @@ -1102,8 +1106,8 @@ static int device_open(struct net_device *dev) { // Init for Key Management KeyvInitTable(pDevice,&pDevice->sKey); - memcpy(pDevice->sMgmtObj.abyMACAddr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN); - memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN); + memcpy(pDevice->sMgmtObj.abyMACAddr, pDevice->abyCurrentNetAddr, ETH_ALEN); + memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, ETH_ALEN); pDevice->bStopTx0Pkt = FALSE; pDevice->bStopDataPkt = FALSE; pDevice->bRoaming = FALSE; //DavidWang @@ -1285,8 +1289,7 @@ device_release_WPADEV(pDevice); } -static void vntwusb_disconnect(struct usb_interface *intf) - +static void __devexit vt6656_disconnect(struct usb_interface *intf) { PSDevice pDevice = usb_get_intfdata(intf); @@ -1434,7 +1437,8 @@ static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source) source+=strlen(buf1); //find target string start point - if((start_p = kstrstr(source,buf1))==NULL) + start_p = kstrstr(source,buf1); + if (start_p == NULL) return FALSE; //check if current config line is marked by "#" ?? @@ -1446,7 +1450,8 @@ for(ii=1;;ii++) { } //find target string end point - if((end_p = kstrstr(start_p,"\n"))==NULL) { //cann't find "\n",but don't care + end_p = kstrstr(start_p,"\n"); + if (end_p == NULL) { //can't find "\n",but don't care end_p=start_p+strlen(start_p); //no include "\n" } @@ -1455,7 +1460,8 @@ for(ii=1;;ii++) { buf2[end_p-start_p]='\0'; //find value - if((start_p = kstrstr(buf2,"="))==NULL) + start_p = kstrstr(buf2,"="); + if (start_p == NULL) return FALSE; memset(buf1,0,100); strcpy(buf1,start_p+1); @@ -1548,7 +1554,8 @@ static int Read_config_file(PSDevice pDevice) { pDevice->config_file.eAuthenMode = -1; pDevice->config_file.eEncryptionStatus = -1; - if((buffer=Config_FileOperation(pDevice)) ==NULL) { + buffer = Config_FileOperation(pDevice); + if (buffer == NULL) { result =-1; return result; } @@ -2064,7 +2071,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { rc = 0; } - rc = hostap_ioctl(pDevice, &wrq->u.data); + rc = vt6656_hostap_ioctl(pDevice, &wrq->u.data); break; case IOCTL_CMD_WPA: @@ -2153,35 +2160,29 @@ static int ethtool_ioctl(struct net_device *dev, void *useraddr) /*------------------------------------------------------------------*/ +MODULE_DEVICE_TABLE(usb, vt6656_table); -MODULE_DEVICE_TABLE(usb, vntwusb_table); - - -static struct usb_driver vntwusb_driver = { - .name = DEVICE_NAME, - .probe = vntwusb_found1, - .disconnect = vntwusb_disconnect, - .id_table = vntwusb_table, - -//2008-0920-01by MikeLiu -//for supporting S3 & S4 function +static struct usb_driver vt6656_driver = { + .name = DEVICE_NAME, + .probe = vt6656_probe, + .disconnect = vt6656_disconnect, + .id_table = vt6656_table, #ifdef CONFIG_PM - .suspend = vntwusb_suspend, - .resume = vntwusb_resume, -#endif + .suspend = vt6656_suspend, + .resume = vt6656_resume, +#endif /* CONFIG_PM */ }; -static int __init vntwusb_init_module(void) +static int __init vt6656_init_module(void) { printk(KERN_NOTICE DEVICE_FULL_DRV_NAM " " DEVICE_VERSION); - return usb_register(&vntwusb_driver); + return usb_register(&vt6656_driver); } -static void __exit vntwusb_cleanup_module(void) +static void __exit vt6656_cleanup_module(void) { - usb_deregister(&vntwusb_driver); + usb_deregister(&vt6656_driver); } -module_init(vntwusb_init_module); -module_exit(vntwusb_cleanup_module); - +module_init(vt6656_init_module); +module_exit(vt6656_cleanup_module);