From 4ea4f7a0d3d7a9961bf77f0860df8dd4a213b8a3 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 1 Nov 2010 14:06:24 -0400 Subject: [PATCH] beceem: change startup messages Change the regsister/unregister routines to generate better messages, and control arrival of new frames when USB device is unplugged. Signed-off-by: Stephen Hemminger --- drivers/staging/bcm/Bcmnet.c | 54 +++++++++++++++++++---------- drivers/staging/bcm/InterfaceInit.c | 32 ++++++++--------- drivers/staging/bcm/Misc.c | 2 +- drivers/staging/bcm/Prototypes.h | 1 + drivers/staging/bcm/nvm.c | 32 +++-------------- 5 files changed, 57 insertions(+), 64 deletions(-) diff --git a/drivers/staging/bcm/Bcmnet.c b/drivers/staging/bcm/Bcmnet.c index eb224a9dafab..a6ce2396c791 100644 --- a/drivers/staging/bcm/Bcmnet.c +++ b/drivers/staging/bcm/Bcmnet.c @@ -1,14 +1,5 @@ #include "headers.h" -static int debug = -1; -module_param(debug, uint, 0600); -MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); - -static const u32 default_msg = - NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK - | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR - | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN; - struct net_device *gblpnetdev; static INT bcm_open(struct net_device *dev) @@ -194,6 +185,10 @@ static const struct ethtool_ops bcm_ethtool_ops = { int register_networkdev(PMINI_ADAPTER Adapter) { struct net_device *net = Adapter->dev; + PS_INTERFACE_ADAPTER IntfAdapter = Adapter->pvInterfaceAdapter; + struct usb_interface *udev = IntfAdapter->interface; + struct usb_device *xdev = IntfAdapter->udev; + int result; net->netdev_ops = &bcmNetDevOps; @@ -201,22 +196,43 @@ int register_networkdev(PMINI_ADAPTER Adapter) net->mtu = MTU_SIZE; /* 1400 Bytes */ net->tx_queue_len = TX_QLEN; net->flags |= IFF_NOARP; - Adapter->msg_enable = netif_msg_init(debug, default_msg); netif_carrier_off(net); SET_NETDEV_DEVTYPE(net, &wimax_type); /* Read the MAC Address from EEPROM */ - ReadMacAddressFromNVM(Adapter); - - result = register_netdev(net); - if (result == 0) - gblpnetdev = Adapter->dev = net; - else { - Adapter->dev = NULL; - free_netdev(net); + result = ReadMacAddressFromNVM(Adapter); + if (result != STATUS_SUCCESS) { + dev_err(&udev->dev, + PFX "Error in Reading the mac Address: %d", result); + return -EIO; } - return result; + result = register_netdev(net); + if (result) + return result; + + gblpnetdev = Adapter->dev; + + if (netif_msg_probe(Adapter)) + dev_info(&udev->dev, PFX "%s: register usb-%s-%s %pM\n", + net->name, xdev->bus->bus_name, xdev->devpath, + net->dev_addr); + + return 0; +} + +void unregister_networkdev(PMINI_ADAPTER Adapter) +{ + struct net_device *net = Adapter->dev; + PS_INTERFACE_ADAPTER IntfAdapter = Adapter->pvInterfaceAdapter; + struct usb_interface *udev = IntfAdapter->interface; + struct usb_device *xdev = IntfAdapter->udev; + + if (netif_msg_probe(Adapter)) + dev_info(&udev->dev, PFX "%s: unregister usb-%s%s\n", + net->name, xdev->bus->bus_name, xdev->devpath); + + unregister_netdev(Adapter->dev); } diff --git a/drivers/staging/bcm/InterfaceInit.c b/drivers/staging/bcm/InterfaceInit.c index a64092e940cc..8a26a3ef5bd3 100644 --- a/drivers/staging/bcm/InterfaceInit.c +++ b/drivers/staging/bcm/InterfaceInit.c @@ -11,6 +11,15 @@ static struct usb_device_id InterfaceUsbtable[] = { }; MODULE_DEVICE_TABLE(usb, InterfaceUsbtable); +static int debug = -1; +module_param(debug, uint, 0600); +MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); + +static const u32 default_msg = + NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK + | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR + | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN; + static INT InterfaceAdapterInit(PS_INTERFACE_ADAPTER Adapter); static VOID InterfaceAdapterFree(PS_INTERFACE_ADAPTER psIntfAdapter) @@ -158,6 +167,7 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) psAdapter = netdev_priv(ndev); psAdapter->dev = ndev; + psAdapter->msg_enable = netif_msg_init(debug, default_msg); /* Init default driver debug state */ @@ -269,32 +279,22 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id) static void usbbcm_disconnect (struct usb_interface *intf) { - PS_INTERFACE_ADAPTER psIntfAdapter = NULL; - PMINI_ADAPTER psAdapter = NULL; - struct usb_device *udev = NULL; - PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(gblpnetdev); + PS_INTERFACE_ADAPTER psIntfAdapter = usb_get_intfdata(intf); + PMINI_ADAPTER psAdapter; + struct usb_device *udev = interface_to_usbdev (intf); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usb disconnected"); - if(intf == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf pointer is NULL"); - return; - } - psIntfAdapter = usb_get_intfdata(intf); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "psIntfAdapter 0x%p",psIntfAdapter); if(psIntfAdapter == NULL) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InterfaceAdapter pointer is NULL"); return; - } + psAdapter = psIntfAdapter->psAdapter; + netif_device_detach(psAdapter->dev); + if(psAdapter->bDoSuspend) intf->needs_remote_wakeup = 0; psAdapter->device_removed = TRUE ; usb_set_intfdata(intf, NULL); InterfaceAdapterFree(psIntfAdapter); - udev = interface_to_usbdev (intf); usb_put_dev(udev); } diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index c1d73a70f9e4..82d9f86821ca 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -132,7 +132,7 @@ VOID AdapterFree(PMINI_ADAPTER Adapter) if(Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY)) kthread_stop (Adapter->LEDInfo.led_cntrl_threadid); - unregister_netdev(Adapter->dev); + unregister_networkdev(Adapter); /* FIXME: use proper wait_event and refcounting */ while(atomic_read(&Adapter->ApplicationRunning)) diff --git a/drivers/staging/bcm/Prototypes.h b/drivers/staging/bcm/Prototypes.h index ba0444e70577..b80b806c90a3 100644 --- a/drivers/staging/bcm/Prototypes.h +++ b/drivers/staging/bcm/Prototypes.h @@ -52,6 +52,7 @@ INT SendControlPacket(PMINI_ADAPTER Adapter, /**dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Modem MAC Addr :"); - BCM_DEBUG_PRINT_BUFFER(Adapter,DBG_TYPE_PRINTK, 0, DBG_LVL_ALL,&Adapter->dev->dev_addr[0],MAC_ADDRESS_SIZE); - for(i=0;idev->dev_addr[i] == 0x00) - AllZeroMac++; - if(Adapter->dev->dev_addr[i] == 0xFF) - AllFFMac++; - - } - //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "\n"); - if(AllZeroMac == MAC_ADDRESS_SIZE) - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Warning :: MAC Address has all 00's"); - if(AllFFMac == MAC_ADDRESS_SIZE) - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, NVM_RW, DBG_LVL_ALL,"Warning :: MAC Address has all FF's"); + if(Status == STATUS_SUCCESS) + memcpy(Adapter->dev->dev_addr, puMacAddr, MAC_ADDRESS_SIZE); return Status; - } //-----------------------------------------------------------------------------