Commit 0ad008fc authored by Stephen Hemminger's avatar Stephen Hemminger

beceem: cleanup network device setup

Change how network device is setup:
* set pointer to device object so sysfs has eth0/device symlink
* set network device type
* eliminate all the compatiablity with older kernels.
Signed-off-by: default avatarStephen Hemminger <shemminger@vyatta.com>
parent 92bc6058
...@@ -11,8 +11,8 @@ struct net_device *gblpnetdev; ...@@ -11,8 +11,8 @@ struct net_device *gblpnetdev;
static INT bcm_open(struct net_device *dev) static INT bcm_open(struct net_device *dev)
{ {
PMINI_ADAPTER Adapter = NULL ; //(PMINI_ADAPTER)dev->priv; PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
Adapter = GET_BCM_ADAPTER(dev);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "======>"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "======>");
if(Adapter->fw_download_done==FALSE) if(Adapter->fw_download_done==FALSE)
return -EINVAL; return -EINVAL;
...@@ -30,8 +30,8 @@ static INT bcm_open(struct net_device *dev) ...@@ -30,8 +30,8 @@ static INT bcm_open(struct net_device *dev)
static INT bcm_close(struct net_device *dev) static INT bcm_close(struct net_device *dev)
{ {
PMINI_ADAPTER Adapter = NULL ;//gpadapter ; PMINI_ADAPTER Adapter = GET_BCM_ADAPTER(dev);
Adapter = GET_BCM_ADAPTER(dev);
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=====>"); BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "=====>");
Adapter->if_up=0; Adapter->if_up=0;
if(!netif_queue_stopped(dev)) { if(!netif_queue_stopped(dev)) {
...@@ -60,12 +60,12 @@ static struct net_device_stats *bcm_get_stats(struct net_device *dev) ...@@ -60,12 +60,12 @@ static struct net_device_stats *bcm_get_stats(struct net_device *dev)
return netstats; return netstats;
} }
/** /**
@ingroup init_functions @ingroup init_functions
Register other driver entry points with the kernel Register other driver entry points with the kernel
*/ */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) static const struct net_device_ops bcmNetDevOps = {
static struct net_device_ops bcmNetDevOps = {
.ndo_open = bcm_open, .ndo_open = bcm_open,
.ndo_stop = bcm_close, .ndo_stop = bcm_close,
.ndo_get_stats = bcm_get_stats, .ndo_get_stats = bcm_get_stats,
...@@ -74,47 +74,44 @@ static struct net_device_ops bcmNetDevOps = { ...@@ -74,47 +74,44 @@ static struct net_device_ops bcmNetDevOps = {
.ndo_set_mac_address = eth_mac_addr, .ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
}; };
#endif
static struct device_type wimax_type = {
.name = "wimax",
};
int register_networkdev(PMINI_ADAPTER Adapter) int register_networkdev(PMINI_ADAPTER Adapter)
{ {
int result=0; struct net_device *net;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) PMINI_ADAPTER *temp;
void **temp = NULL; /* actually we're *allocating* the device in alloc_etherdev */ PS_INTERFACE_ADAPTER psIntfAdapter = Adapter->pvInterfaceAdapter;
#endif struct usb_interface *uintf = psIntfAdapter->interface;
Adapter->dev = alloc_etherdev(sizeof(PMINI_ADAPTER)); int result;
if(!Adapter->dev)
{ net = alloc_etherdev(sizeof(PMINI_ADAPTER));
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_INITEXIT, DRV_ENTRY, DBG_LVL_ALL, "ERR: No Dev"); if(!net) {
pr_notice("bcmnet: no memory for device\n");
return -ENOMEM; return -ENOMEM;
} }
gblpnetdev = Adapter->dev;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) Adapter->dev = net; /* FIXME - only allows one adapter! */
Adapter->dev->priv = Adapter; temp = netdev_priv(net);
#else *temp = Adapter;
temp = netdev_priv(Adapter->dev);
*temp = (void *)Adapter; net->netdev_ops = &bcmNetDevOps;
#endif net->mtu = MTU_SIZE; /* 1400 Bytes */
//BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "init adapterptr: %x %x\n", (UINT)Adapter, temp);
SET_NETDEV_DEV(net, &uintf->dev);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29) SET_NETDEV_DEVTYPE(net, &wimax_type);
Adapter->dev->netdev_ops = &bcmNetDevOps;
#else
Adapter->dev->open = bcm_open;
Adapter->dev->stop = bcm_close;
Adapter->dev->get_stats = bcm_get_stats;
Adapter->dev->hard_start_xmit = bcm_transmit;
Adapter->dev->hard_header_len = ETH_HLEN + LEADER_SIZE;
#endif
Adapter->dev->mtu = MTU_SIZE; /* 1400 Bytes */
/* Read the MAC Address from EEPROM */ /* Read the MAC Address from EEPROM */
ReadMacAddressFromNVM(Adapter); ReadMacAddressFromNVM(Adapter);
result = register_netdev(Adapter->dev); result = register_netdev(net);
if (!result) { if (result == 0)
free_netdev(Adapter->dev); gblpnetdev = Adapter->dev = net;
else {
Adapter->dev = NULL; Adapter->dev = NULL;
free_netdev(net);
} }
return result; return result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment