Commit 25e4e938 authored by Alexander Viro's avatar Alexander Viro Committed by David S. Miller

[NET]: Eliminate {init,register,unregister}_fcdev.

parent 58552705
...@@ -1356,16 +1356,16 @@ mpt_lan_post_receive_buckets(void *dev_id) ...@@ -1356,16 +1356,16 @@ mpt_lan_post_receive_buckets(void *dev_id)
} }
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
struct net_device * static struct net_device *
mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
{ {
struct net_device *dev = NULL; struct net_device *dev = alloc_fcdev(sizeof(struct mpt_lan_priv));
struct mpt_lan_priv *priv = NULL; struct mpt_lan_priv *priv = NULL;
u8 HWaddr[FC_ALEN], *a; u8 HWaddr[FC_ALEN], *a;
dev = init_fcdev(NULL, sizeof(struct mpt_lan_priv));
if (!dev) if (!dev)
return (NULL); return NULL;
dev->mtu = MPT_LAN_MTU; dev->mtu = MPT_LAN_MTU;
priv = (struct mpt_lan_priv *) dev->priv; priv = (struct mpt_lan_priv *) dev->priv;
...@@ -1435,15 +1435,18 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum) ...@@ -1435,15 +1435,18 @@ mpt_register_lan_device (MPT_ADAPTER *mpt_dev, int pnum)
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
if (register_netdev(dev) != 0) {
kfree(dev);
dev = NULL;
}
return dev; return dev;
} }
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
int __init static int __init mpt_lan_init (void)
mpt_lan_init (void)
{ {
struct net_device *dev; struct net_device *dev;
MPT_ADAPTER *curadapter; MPT_ADAPTER *p;
int i, j; int i, j;
show_mptmod_ver(LANAME, LANVER); show_mptmod_ver(LANAME, LANVER);
...@@ -1477,51 +1480,49 @@ mpt_lan_init (void) ...@@ -1477,51 +1480,49 @@ mpt_lan_init (void)
mpt_landev[j] = NULL; mpt_landev[j] = NULL;
} }
curadapter = mpt_adapter_find_first(); for (p = mpt_adapter_find_first(); p; p = mpt_adapter_find_next(p)) {
while (curadapter != NULL) { for (i = 0; i < p->facts.NumberOfPorts; i++) {
for (i = 0; i < curadapter->facts.NumberOfPorts; i++) {
printk (KERN_INFO MYNAM ": %s: PortNum=%x, ProtocolFlags=%02Xh (%c%c%c%c)\n", printk (KERN_INFO MYNAM ": %s: PortNum=%x, ProtocolFlags=%02Xh (%c%c%c%c)\n",
curadapter->name, p->name,
curadapter->pfacts[i].PortNumber, p->pfacts[i].PortNumber,
curadapter->pfacts[i].ProtocolFlags, p->pfacts[i].ProtocolFlags,
MPT_PROTOCOL_FLAGS_c_c_c_c(curadapter->pfacts[i].ProtocolFlags)); MPT_PROTOCOL_FLAGS_c_c_c_c(p->pfacts[i].ProtocolFlags));
if (curadapter->pfacts[i].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN) { if (!(p->pfacts[i].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_LAN)) {
dev = mpt_register_lan_device (curadapter, i); printk (KERN_INFO MYNAM ": %s: Hmmm... LAN protocol seems to be disabled on this adapter port!\n",
if (dev != NULL) { p->name);
printk (KERN_INFO MYNAM ": %s: Fusion MPT LAN device registered as '%s'\n", continue;
curadapter->name, dev->name); }
printk (KERN_INFO MYNAM ": %s/%s: LanAddr = %02X:%02X:%02X:%02X:%02X:%02X\n",
IOC_AND_NETDEV_NAMES_s_s(dev), dev = mpt_register_lan_device (p, i);
dev->dev_addr[0], dev->dev_addr[1], if (!dev) {
dev->dev_addr[2], dev->dev_addr[3], printk (KERN_ERR MYNAM ": %s: Unable to register port%d as a LAN device\n",
dev->dev_addr[4], dev->dev_addr[5]); p->name,
p->pfacts[i].PortNumber);
}
printk (KERN_INFO MYNAM ": %s: Fusion MPT LAN device registered as '%s'\n",
p->name, dev->name);
printk (KERN_INFO MYNAM ": %s/%s: LanAddr = %02X:%02X:%02X:%02X:%02X:%02X\n",
IOC_AND_NETDEV_NAMES_s_s(dev),
dev->dev_addr[0], dev->dev_addr[1],
dev->dev_addr[2], dev->dev_addr[3],
dev->dev_addr[4], dev->dev_addr[5]);
// printk (KERN_INFO MYNAM ": %s/%s: Max_TX_outstanding = %d\n", // printk (KERN_INFO MYNAM ": %s/%s: Max_TX_outstanding = %d\n",
// IOC_AND_NETDEV_NAMES_s_s(dev), // IOC_AND_NETDEV_NAMES_s_s(dev),
// NETDEV_TO_LANPRIV_PTR(dev)->tx_max_out); // NETDEV_TO_LANPRIV_PTR(dev)->tx_max_out);
j = curadapter->id; j = p->id;
mpt_landev[j] = dev; mpt_landev[j] = dev;
dlprintk((KERN_INFO MYNAM "/init: dev_addr=%p, mpt_landev[%d]=%p\n", dlprintk((KERN_INFO MYNAM "/init: dev_addr=%p, mpt_landev[%d]=%p\n",
dev, j, mpt_landev[j])); dev, j, mpt_landev[j]));
} else {
printk (KERN_ERR MYNAM ": %s: Unable to register port%d as a LAN device\n",
curadapter->name,
curadapter->pfacts[i].PortNumber);
}
} else {
printk (KERN_INFO MYNAM ": %s: Hmmm... LAN protocol seems to be disabled on this adapter port!\n",
curadapter->name);
}
} }
curadapter = mpt_adapter_find_next(curadapter);
} }
return 0; return 0;
} }
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
static void mpt_lan_exit(void) static void __exit mpt_lan_exit(void)
{ {
int i; int i;
...@@ -1532,7 +1533,7 @@ static void mpt_lan_exit(void) ...@@ -1532,7 +1533,7 @@ static void mpt_lan_exit(void)
printk (KERN_INFO ": %s/%s: Fusion MPT LAN device unregistered\n", printk (KERN_INFO ": %s/%s: Fusion MPT LAN device unregistered\n",
IOC_AND_NETDEV_NAMES_s_s(dev)); IOC_AND_NETDEV_NAMES_s_s(dev));
unregister_fcdev(dev); unregister_netdev(dev);
//mpt_landev[i] = (struct net_device *) 0xdeadbeef; /* Debug */ //mpt_landev[i] = (struct net_device *) 0xdeadbeef; /* Debug */
mpt_landev[i] = NULL; mpt_landev[i] = NULL;
} }
......
...@@ -234,7 +234,7 @@ int __init iph5526_probe(struct net_device *dev) ...@@ -234,7 +234,7 @@ int __init iph5526_probe(struct net_device *dev)
{ {
if (pci_present() && (iph5526_probe_pci(dev) == 0)) if (pci_present() && (iph5526_probe_pci(dev) == 0))
return 0; return 0;
return -ENODEV; return -ENODEV;
} }
static int __init iph5526_probe_pci(struct net_device *dev) static int __init iph5526_probe_pci(struct net_device *dev)
...@@ -242,37 +242,30 @@ static int __init iph5526_probe_pci(struct net_device *dev) ...@@ -242,37 +242,30 @@ static int __init iph5526_probe_pci(struct net_device *dev)
#ifdef MODULE #ifdef MODULE
struct fc_info *fi = (struct fc_info *)dev->priv; struct fc_info *fi = (struct fc_info *)dev->priv;
#else #else
struct fc_info *fi; struct fc_info *fi = fc[count];
static int count; static int count;
int err;
if(fc[count] != NULL) { if (!fi)
if (dev == NULL) {
dev = init_fcdev(NULL, 0);
if (dev == NULL)
return -ENOMEM;
}
fi = fc[count];
#endif
fi->dev = dev;
dev->base_addr = fi->base_addr;
dev->irq = fi->irq;
if (dev->priv == NULL)
dev->priv = fi;
fcdev_init(dev);
/* Assign ur MAC address.
*/
dev->dev_addr[0] = (fi->g.my_port_name_high & 0x0000FF00) >> 8;
dev->dev_addr[1] = fi->g.my_port_name_high;
dev->dev_addr[2] = (fi->g.my_port_name_low & 0xFF000000) >> 24;
dev->dev_addr[3] = (fi->g.my_port_name_low & 0x00FF0000) >> 16;
dev->dev_addr[4] = (fi->g.my_port_name_low & 0x0000FF00) >> 8;
dev->dev_addr[5] = fi->g.my_port_name_low;
#ifndef MODULE
count++;
}
else
return -ENODEV; return -ENODEV;
fc_setup(dev);
count++;
#endif #endif
fi->dev = dev;
dev->base_addr = fi->base_addr;
dev->irq = fi->irq;
if (dev->priv == NULL)
dev->priv = fi;
fcdev_init(dev);
/* Assign ur MAC address.
*/
dev->dev_addr[0] = (fi->g.my_port_name_high & 0x0000FF00) >> 8;
dev->dev_addr[1] = fi->g.my_port_name_high;
dev->dev_addr[2] = (fi->g.my_port_name_low & 0xFF000000) >> 24;
dev->dev_addr[3] = (fi->g.my_port_name_low & 0x00FF0000) >> 16;
dev->dev_addr[4] = (fi->g.my_port_name_low & 0x0000FF00) >> 8;
dev->dev_addr[5] = fi->g.my_port_name_low;
display_cache(fi); display_cache(fi);
return 0; return 0;
} }
...@@ -287,9 +280,6 @@ static int __init fcdev_init(struct net_device *dev) ...@@ -287,9 +280,6 @@ static int __init fcdev_init(struct net_device *dev)
dev->change_mtu = iph5526_change_mtu; dev->change_mtu = iph5526_change_mtu;
dev->tx_timeout = iph5526_timeout; dev->tx_timeout = iph5526_timeout;
dev->watchdog_timeo = 5*HZ; dev->watchdog_timeo = 5*HZ;
#ifndef MODULE
fc_setup(dev);
#endif
return 0; return 0;
} }
...@@ -4507,7 +4497,7 @@ static int scsi_registered; ...@@ -4507,7 +4497,7 @@ static int scsi_registered;
int init_module(void) int init_module(void)
{ {
int i = 0; int i = 0;
driver_template.module = THIS_MODULE; driver_template.module = THIS_MODULE;
scsi_register_host(&driver_template); scsi_register_host(&driver_template);
...@@ -4520,43 +4510,37 @@ int i = 0; ...@@ -4520,43 +4510,37 @@ int i = 0;
} }
while(fc[i] != NULL) { while(fc[i] != NULL) {
dev_fc[i] = NULL; struct net_device *dev = alloc_fcdev(0);
dev_fc[i] = init_fcdev(dev_fc[i], 0); if (!dev) {
if (dev_fc[i] == NULL) {
printk("iph5526.c: init_fcdev failed for card #%d\n", i+1); printk("iph5526.c: init_fcdev failed for card #%d\n", i+1);
break; break;
} }
dev_fc[i]->irq = irq; dev->priv = fc[i];
dev_fc[i]->mem_end = bad; iph5526_probe_pci(dev);
dev_fc[i]->base_addr = io; err = register_netdev(dev);
dev_fc[i]->init = iph5526_probe; if (err < 0) {
dev_fc[i]->priv = fc[i]; kfree(dev);
fc[i]->dev = dev_fc[i]; printk("iph5526.c: init_fcdev failed for card #%d\n", i+1);
if (register_fcdev(dev_fc[i]) != 0) { break;
kfree(dev_fc[i]);
dev_fc[i] = NULL;
if (i == 0) {
printk("iph5526.c: IP registeration failed!!!\n");
return -ENODEV;
}
} }
dev_fc[i] = dev;
i++; i++;
} }
if (i == 0) if (i == 0)
return -ENODEV; return -ENODEV;
return 0; return 0;
} }
void cleanup_module(void) void cleanup_module(void)
{ {
int i = 0; int i = 0;
while(fc[i] != NULL) { while(fc[i] != NULL) {
struct net_device *dev = fc[i]->dev; struct net_device *dev = fc[i]->dev;
void *priv = dev->priv; void *priv = dev->priv;
fc[i]->g.dont_init = TRUE; fc[i]->g.dont_init = TRUE;
take_tachyon_offline(fc[i]); take_tachyon_offline(fc[i]);
unregister_fcdev(dev); unregister_netdev(dev);
clean_up_memory(fc[i]); clean_up_memory(fc[i]);
if (dev->priv) if (dev->priv)
kfree(priv); kfree(priv);
......
...@@ -654,7 +654,6 @@ EXPORT_SYMBOL(unregister_trdev); ...@@ -654,7 +654,6 @@ EXPORT_SYMBOL(unregister_trdev);
#endif /* CONFIG_TR */ #endif /* CONFIG_TR */
#ifdef CONFIG_NET_FC #ifdef CONFIG_NET_FC
void fc_setup(struct net_device *dev) void fc_setup(struct net_device *dev)
...@@ -674,28 +673,6 @@ void fc_setup(struct net_device *dev) ...@@ -674,28 +673,6 @@ void fc_setup(struct net_device *dev)
dev->flags = IFF_BROADCAST; dev->flags = IFF_BROADCAST;
} }
/**
* init_fcdev - Register fibre channel device
* @dev: A fibre channel device structure to be filled in, or %NULL if a new
* struct should be allocated.
* @sizeof_priv: Size of additional driver-private structure to be allocated
* for this ethernet device
*
* Fill in the fields of the device structure with fibre channel-generic values.
*
* If no device structure is passed, a new one is constructed, complete with
* a private data area of size @sizeof_priv. A 32-byte (not bit)
* alignment is enforced for this private data area.
*
* If an empty string area is passed as dev->name, or a new structure is made,
* a new name string is constructed.
*/
struct net_device *init_fcdev(struct net_device *dev, int sizeof_priv)
{
return init_netdev(dev, sizeof_priv, "fc%d", fc_setup);
}
/** /**
* alloc_fcdev - Register fibre channel device * alloc_fcdev - Register fibre channel device
* @sizeof_priv: Size of additional driver-private structure to be allocated * @sizeof_priv: Size of additional driver-private structure to be allocated
...@@ -713,21 +690,8 @@ struct net_device *alloc_fcdev(int sizeof_priv) ...@@ -713,21 +690,8 @@ struct net_device *alloc_fcdev(int sizeof_priv)
return alloc_netdev(sizeof_priv, "fc%d", fc_setup); return alloc_netdev(sizeof_priv, "fc%d", fc_setup);
} }
int register_fcdev(struct net_device *dev)
{
return __register_netdev(dev);
}
void unregister_fcdev(struct net_device *dev)
{
unregister_netdev(dev);
}
EXPORT_SYMBOL(fc_setup); EXPORT_SYMBOL(fc_setup);
EXPORT_SYMBOL(init_fcdev);
EXPORT_SYMBOL(alloc_fcdev); EXPORT_SYMBOL(alloc_fcdev);
EXPORT_SYMBOL(register_fcdev);
EXPORT_SYMBOL(unregister_fcdev);
#endif /* CONFIG_NET_FC */ #endif /* CONFIG_NET_FC */
...@@ -33,11 +33,7 @@ extern int fc_header(struct sk_buff *skb, struct net_device *dev, ...@@ -33,11 +33,7 @@ extern int fc_header(struct sk_buff *skb, struct net_device *dev,
extern int fc_rebuild_header(struct sk_buff *skb); extern int fc_rebuild_header(struct sk_buff *skb);
extern unsigned short fc_type_trans(struct sk_buff *skb, struct net_device *dev); extern unsigned short fc_type_trans(struct sk_buff *skb, struct net_device *dev);
extern struct net_device *init_fcdev(struct net_device *dev, int sizeof_priv);
extern struct net_device *alloc_fcdev(int sizeof_priv); extern struct net_device *alloc_fcdev(int sizeof_priv);
extern int register_fcdev(struct net_device *dev);
extern void unregister_fcdev(struct net_device *dev);
#endif #endif
#endif /* _LINUX_FCDEVICE_H */ #endif /* _LINUX_FCDEVICE_H */
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