beceem: remove indirection to Adapter structure
Allocate Adapter structure as part of network device. Signed-off-by: Stephen Hemminber <shemminger@vyatta.com>
This commit is contained in:
parent
2515ab628f
commit
e614e28eac
|
@ -623,6 +623,7 @@ struct _MINI_ADAPTER
|
||||||
};
|
};
|
||||||
typedef struct _MINI_ADAPTER MINI_ADAPTER, *PMINI_ADAPTER;
|
typedef struct _MINI_ADAPTER MINI_ADAPTER, *PMINI_ADAPTER;
|
||||||
|
|
||||||
|
#define GET_BCM_ADAPTER(net_dev) netdev_priv(net_dev)
|
||||||
|
|
||||||
typedef struct _DEVICE_EXTENSION
|
typedef struct _DEVICE_EXTENSION
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
|
|
||||||
#define DRV_NAME "beceem"
|
|
||||||
#define DRV_VERSION "5.2.7.3P1"
|
|
||||||
#define DRV_DESCRIPTION "Beceem Communications Inc. WiMAX driver"
|
|
||||||
#define DRV_COPYRIGHT "Copyright 2010. Beceem Communications Inc"
|
|
||||||
|
|
||||||
|
|
||||||
struct net_device *gblpnetdev;
|
struct net_device *gblpnetdev;
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
/* proto-type of lower function */
|
/* proto-type of lower function */
|
||||||
|
@ -123,29 +117,15 @@ static const struct ethtool_ops bcm_ethtool_ops = {
|
||||||
|
|
||||||
int register_networkdev(PMINI_ADAPTER Adapter)
|
int register_networkdev(PMINI_ADAPTER Adapter)
|
||||||
{
|
{
|
||||||
struct net_device *net;
|
struct net_device *net = Adapter->dev;
|
||||||
PMINI_ADAPTER *temp;
|
|
||||||
PS_INTERFACE_ADAPTER psIntfAdapter = Adapter->pvInterfaceAdapter;
|
|
||||||
struct usb_interface *uintf = psIntfAdapter->interface;
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
net = alloc_etherdev(sizeof(PMINI_ADAPTER));
|
|
||||||
if(!net) {
|
|
||||||
pr_notice("bcmnet: no memory for device\n");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
Adapter->dev = net; /* FIXME - only allows one adapter! */
|
|
||||||
temp = netdev_priv(net);
|
|
||||||
*temp = Adapter;
|
|
||||||
|
|
||||||
net->netdev_ops = &bcmNetDevOps;
|
net->netdev_ops = &bcmNetDevOps;
|
||||||
net->ethtool_ops = &bcm_ethtool_ops;
|
net->ethtool_ops = &bcm_ethtool_ops;
|
||||||
net->mtu = MTU_SIZE; /* 1400 Bytes */
|
net->mtu = MTU_SIZE; /* 1400 Bytes */
|
||||||
net->tx_queue_len = TX_QLEN;
|
net->tx_queue_len = TX_QLEN;
|
||||||
netif_carrier_off(net);
|
netif_carrier_off(net);
|
||||||
|
|
||||||
SET_NETDEV_DEV(net, &uintf->dev);
|
|
||||||
SET_NETDEV_DEVTYPE(net, &wimax_type);
|
SET_NETDEV_DEVTYPE(net, &wimax_type);
|
||||||
|
|
||||||
/* Read the MAC Address from EEPROM */
|
/* Read the MAC Address from EEPROM */
|
||||||
|
|
|
@ -182,30 +182,27 @@ static struct usb_class_driver usbbcm_class = {
|
||||||
static int
|
static int
|
||||||
usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
||||||
{
|
{
|
||||||
int retval =0 ;
|
struct usb_device *udev = interface_to_usbdev (intf);
|
||||||
PMINI_ADAPTER psAdapter = NULL;
|
int retval;
|
||||||
PS_INTERFACE_ADAPTER psIntfAdapter = NULL;
|
PMINI_ADAPTER psAdapter;
|
||||||
struct usb_device *udev = NULL;
|
PS_INTERFACE_ADAPTER psIntfAdapter;
|
||||||
|
struct net_device *ndev;
|
||||||
|
|
||||||
// BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "Usbbcm probe!!");
|
ndev = alloc_etherdev(sizeof(MINI_ADAPTER));
|
||||||
if((intf == NULL) || (id == NULL))
|
if(ndev == NULL) {
|
||||||
{
|
dev_err(&udev->dev, DRV_NAME ": no memory for device\n");
|
||||||
// BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "intf or id is NULL");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate Adapter structure */
|
|
||||||
if((psAdapter = kzalloc(sizeof(MINI_ADAPTER), GFP_KERNEL)) == NULL)
|
|
||||||
{
|
|
||||||
BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory");
|
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SET_NETDEV_DEV(ndev, &intf->dev);
|
||||||
|
|
||||||
|
psAdapter = netdev_priv(ndev);
|
||||||
|
psAdapter->dev = ndev;
|
||||||
|
|
||||||
/* Init default driver debug state */
|
/* Init default driver debug state */
|
||||||
|
|
||||||
psAdapter->stDebugState.debug_level = debug_level;
|
psAdapter->stDebugState.debug_level = debug_level;
|
||||||
psAdapter->stDebugState.type = DBG_TYPE_INITEXIT;
|
psAdapter->stDebugState.type = DBG_TYPE_INITEXIT;
|
||||||
memset (psAdapter->stDebugState.subtype, 0, sizeof (psAdapter->stDebugState.subtype));
|
|
||||||
|
|
||||||
/* Technically, one can start using BCM_DEBUG_PRINT after this point.
|
/* Technically, one can start using BCM_DEBUG_PRINT after this point.
|
||||||
* However, realize that by default the Type/Subtype bitmaps are all zero now;
|
* However, realize that by default the Type/Subtype bitmaps are all zero now;
|
||||||
|
@ -224,22 +221,21 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
||||||
retval = InitAdapter(psAdapter);
|
retval = InitAdapter(psAdapter);
|
||||||
if(retval)
|
if(retval)
|
||||||
{
|
{
|
||||||
BCM_DEBUG_PRINT (psAdapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "InitAdapter Failed\n");
|
dev_err(&udev->dev, DRV_NAME ": InitAdapter Failed\n");
|
||||||
AdapterFree(psAdapter);
|
AdapterFree(psAdapter);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate interface adapter structure */
|
/* Allocate interface adapter structure */
|
||||||
if((psAdapter->pvInterfaceAdapter =
|
psIntfAdapter = kzalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL);
|
||||||
kmalloc(sizeof(S_INTERFACE_ADAPTER), GFP_KERNEL)) == NULL)
|
if (psIntfAdapter == NULL)
|
||||||
{
|
{
|
||||||
BCM_DEBUG_PRINT(psAdapter,DBG_TYPE_PRINTK, 0, 0, "Out of memory");
|
dev_err(&udev->dev, DRV_NAME ": no memory for Interface adapter\n");
|
||||||
AdapterFree (psAdapter);
|
AdapterFree (psAdapter);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
memset(psAdapter->pvInterfaceAdapter, 0, sizeof(S_INTERFACE_ADAPTER));
|
|
||||||
|
|
||||||
psIntfAdapter = InterfaceAdapterGet(psAdapter);
|
psAdapter->pvInterfaceAdapter = psIntfAdapter;
|
||||||
psIntfAdapter->psAdapter = psAdapter;
|
psIntfAdapter->psAdapter = psAdapter;
|
||||||
|
|
||||||
/* Store usb interface in Interface Adapter */
|
/* Store usb interface in Interface Adapter */
|
||||||
|
@ -276,7 +272,6 @@ usbbcm_device_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
udev = interface_to_usbdev (intf);
|
|
||||||
/* Check whether the USB-Device Supports remote Wake-Up */
|
/* Check whether the USB-Device Supports remote Wake-Up */
|
||||||
if(USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes)
|
if(USB_CONFIG_ATT_WAKEUP & udev->actconfig->desc.bmAttributes)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,16 +1,5 @@
|
||||||
#include "headers.h"
|
#include "headers.h"
|
||||||
|
|
||||||
|
|
||||||
PS_INTERFACE_ADAPTER
|
|
||||||
InterfaceAdapterGet(PMINI_ADAPTER psAdapter)
|
|
||||||
{
|
|
||||||
if(psAdapter == NULL)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return (PS_INTERFACE_ADAPTER)(psAdapter->pvInterfaceAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
INT
|
INT
|
||||||
InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter,
|
InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter,
|
||||||
UINT addr,
|
UINT addr,
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
#ifndef __INTERFACE_MISC_H
|
#ifndef __INTERFACE_MISC_H
|
||||||
#define __INTERFACE_MISC_H
|
#define __INTERFACE_MISC_H
|
||||||
|
|
||||||
PS_INTERFACE_ADAPTER
|
|
||||||
InterfaceAdapterGet(PMINI_ADAPTER psAdapter);
|
|
||||||
|
|
||||||
INT
|
INT
|
||||||
InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter,
|
InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter,
|
||||||
UINT addr,
|
UINT addr,
|
||||||
|
|
|
@ -354,7 +354,6 @@ enum eAbortPattern {
|
||||||
ABORT_IDLE_SYNCDOWN = 3
|
ABORT_IDLE_SYNCDOWN = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GET_BCM_ADAPTER(net_dev) (net_dev ? netdev_priv(net_dev) : NULL)
|
|
||||||
|
|
||||||
/* Offsets used by driver in skb cb variable */
|
/* Offsets used by driver in skb cb variable */
|
||||||
#define SKB_CB_CLASSIFICATION_OFFSET 0
|
#define SKB_CB_CLASSIFICATION_OFFSET 0
|
||||||
|
|
|
@ -108,7 +108,7 @@ InitAdapter(PMINI_ADAPTER psAdapter)
|
||||||
|
|
||||||
VOID AdapterFree(PMINI_ADAPTER Adapter)
|
VOID AdapterFree(PMINI_ADAPTER Adapter)
|
||||||
{
|
{
|
||||||
INT count = 0;
|
int count;
|
||||||
|
|
||||||
beceem_protocol_reset(Adapter);
|
beceem_protocol_reset(Adapter);
|
||||||
|
|
||||||
|
@ -116,41 +116,40 @@ VOID AdapterFree(PMINI_ADAPTER Adapter)
|
||||||
|
|
||||||
if(Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler))
|
if(Adapter->control_packet_handler && !IS_ERR(Adapter->control_packet_handler))
|
||||||
kthread_stop (Adapter->control_packet_handler);
|
kthread_stop (Adapter->control_packet_handler);
|
||||||
|
|
||||||
if(Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread))
|
if(Adapter->transmit_packet_thread && !IS_ERR(Adapter->transmit_packet_thread))
|
||||||
kthread_stop (Adapter->transmit_packet_thread);
|
kthread_stop (Adapter->transmit_packet_thread);
|
||||||
wake_up(&Adapter->process_read_wait_queue);
|
|
||||||
|
wake_up(&Adapter->process_read_wait_queue);
|
||||||
|
|
||||||
if(Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY))
|
if(Adapter->LEDInfo.led_thread_running & (BCM_LED_THREAD_RUNNING_ACTIVELY | BCM_LED_THREAD_RUNNING_INACTIVELY))
|
||||||
kthread_stop (Adapter->LEDInfo.led_cntrl_threadid);
|
kthread_stop (Adapter->LEDInfo.led_cntrl_threadid);
|
||||||
|
|
||||||
bcm_unregister_networkdev(Adapter);
|
bcm_unregister_networkdev(Adapter);
|
||||||
|
|
||||||
|
/* FIXME: use proper wait_event and refcounting */
|
||||||
while(atomic_read(&Adapter->ApplicationRunning))
|
while(atomic_read(&Adapter->ApplicationRunning))
|
||||||
{
|
{
|
||||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n",atomic_read(&Adapter->ApplicationRunning));
|
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "Waiting for Application to close.. %d\n",atomic_read(&Adapter->ApplicationRunning));
|
||||||
msleep(100);
|
msleep(100);
|
||||||
}
|
}
|
||||||
unregister_control_device_interface(Adapter);
|
unregister_control_device_interface(Adapter);
|
||||||
if(Adapter->dev && !IS_ERR(Adapter->dev))
|
|
||||||
free_netdev(Adapter->dev);
|
kfree(Adapter->pstargetparams);
|
||||||
if(Adapter->pstargetparams != NULL)
|
|
||||||
{
|
|
||||||
kfree(Adapter->pstargetparams);
|
|
||||||
}
|
|
||||||
for (count =0;count < MAX_CNTRL_PKTS;count++)
|
for (count =0;count < MAX_CNTRL_PKTS;count++)
|
||||||
{
|
kfree(Adapter->txctlpacket[count]);
|
||||||
if(Adapter->txctlpacket[count])
|
|
||||||
kfree(Adapter->txctlpacket[count]);
|
|
||||||
}
|
|
||||||
FreeAdapterDsxBuffer(Adapter);
|
FreeAdapterDsxBuffer(Adapter);
|
||||||
|
|
||||||
if(Adapter->pvInterfaceAdapter)
|
kfree(Adapter->pvInterfaceAdapter);
|
||||||
kfree(Adapter->pvInterfaceAdapter);
|
|
||||||
|
|
||||||
//Free the PHS Interface
|
//Free the PHS Interface
|
||||||
PhsCleanup(&Adapter->stBCMPhsContext);
|
PhsCleanup(&Adapter->stBCMPhsContext);
|
||||||
|
|
||||||
BcmDeAllocFlashCSStructure(Adapter);
|
BcmDeAllocFlashCSStructure(Adapter);
|
||||||
|
|
||||||
kfree(Adapter);
|
free_netdev(Adapter->dev);
|
||||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, MP_INIT, DBG_LVL_ALL, "<========\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,5 +74,11 @@
|
||||||
#include "InterfaceIdleMode.h"
|
#include "InterfaceIdleMode.h"
|
||||||
#include "InterfaceInit.h"
|
#include "InterfaceInit.h"
|
||||||
|
|
||||||
|
#define DRV_NAME "beceem"
|
||||||
|
#define DEV_NAME "tarang"
|
||||||
|
#define DRV_DESCRIPTION "Beceem Communications Inc. WiMAX driver"
|
||||||
|
#define DRV_COPYRIGHT "Copyright 2010. Beceem Communications Inc"
|
||||||
|
#define DRV_VERSION VER_FILEVERSION_STR
|
||||||
|
#define PFX DRV_NAME " "
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue