aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/3c501.c4
-rw-r--r--drivers/net/3c509.c1
-rw-r--r--drivers/net/3c515.c3
-rw-r--r--drivers/net/3c523.c2
-rw-r--r--drivers/net/3c527.c5
-rw-r--r--drivers/net/3c59x.c265
-rw-r--r--drivers/net/8139cp.c220
-rw-r--r--drivers/net/8139too.c48
-rw-r--r--drivers/net/82596.c4
-rw-r--r--drivers/net/8390.c14
-rw-r--r--drivers/net/8390.h1
-rw-r--r--drivers/net/Kconfig23
-rw-r--r--drivers/net/Makefile1
-rw-r--r--drivers/net/Space.c1
-rw-r--r--drivers/net/a2065.c6
-rw-r--r--drivers/net/acenic.c9
-rw-r--r--drivers/net/acenic.h1
-rw-r--r--drivers/net/acenic_firmware.h1
-rw-r--r--drivers/net/amd8111e.c3
-rw-r--r--drivers/net/apne.c2
-rw-r--r--drivers/net/appletalk/cops.c1
-rw-r--r--drivers/net/appletalk/cops_ffdrv.h1
-rw-r--r--drivers/net/appletalk/cops_ltdrv.h1
-rw-r--r--drivers/net/appletalk/ipddp.c1
-rw-r--r--drivers/net/arcnet/arcnet.c1
-rw-r--r--drivers/net/arcnet/com20020-pci.c2
-rw-r--r--drivers/net/ariadne.c5
-rw-r--r--drivers/net/arm/at91_ether.c157
-rw-r--r--drivers/net/arm/at91_ether.h1
-rw-r--r--drivers/net/arm/ether1.c3
-rw-r--r--drivers/net/arm/ether3.c3
-rw-r--r--drivers/net/at1700.c1
-rw-r--r--drivers/net/atarilance.c3
-rw-r--r--drivers/net/au1000_eth.c1
-rw-r--r--drivers/net/b44.c308
-rw-r--r--drivers/net/b44.h7
-rw-r--r--drivers/net/bmac.c1
-rw-r--r--drivers/net/bnx2.c73
-rw-r--r--drivers/net/bnx2.h1
-rw-r--r--drivers/net/bonding/bond_main.c1
-rw-r--r--drivers/net/bonding/bond_sysfs.c1
-rw-r--r--drivers/net/cassini.c31
-rw-r--r--drivers/net/chelsio/common.h1
-rw-r--r--drivers/net/chelsio/cxgb2.c3
-rw-r--r--drivers/net/chelsio/sge.c5
-rw-r--r--drivers/net/cris/eth_v10.c3
-rw-r--r--drivers/net/cs89x0.c1
-rw-r--r--drivers/net/cs89x0.h1
-rw-r--r--drivers/net/declance.c11
-rw-r--r--drivers/net/defxx.c2
-rw-r--r--drivers/net/depca.c8
-rw-r--r--drivers/net/dgrs.c2
-rw-r--r--drivers/net/dl2k.c47
-rw-r--r--drivers/net/dl2k.h12
-rw-r--r--drivers/net/dm9000.c36
-rw-r--r--drivers/net/dummy.c1
-rw-r--r--drivers/net/e100.c7
-rw-r--r--drivers/net/e1000/e1000.h1
-rw-r--r--drivers/net/e1000/e1000_ethtool.c6
-rw-r--r--drivers/net/e1000/e1000_main.c12
-rw-r--r--drivers/net/eepro.c5
-rw-r--r--drivers/net/eepro100.c14
-rw-r--r--drivers/net/eexpress.c4
-rw-r--r--drivers/net/epic100.c117
-rw-r--r--drivers/net/eth16i.c3
-rw-r--r--drivers/net/fealnx.c46
-rw-r--r--drivers/net/fec.c311
-rw-r--r--drivers/net/fec.h2
-rw-r--r--drivers/net/fec_8xx/fec_8xx-netta.c1
-rw-r--r--drivers/net/fec_8xx/fec_main.c1
-rw-r--r--drivers/net/fec_8xx/fec_mii.c1
-rw-r--r--drivers/net/forcedeth.c72
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c3
-rw-r--r--drivers/net/fs_enet/fs_enet-mii.c4
-rw-r--r--drivers/net/fs_enet/mac-fcc.c1
-rw-r--r--drivers/net/fs_enet/mac-fec.c1
-rw-r--r--drivers/net/fs_enet/mac-scc.c1
-rw-r--r--drivers/net/fs_enet/mii-bitbang.c1
-rw-r--r--drivers/net/fs_enet/mii-fixed.c1
-rw-r--r--drivers/net/gianfar.c1
-rw-r--r--drivers/net/gianfar.h1
-rw-r--r--drivers/net/gianfar_ethtool.c1
-rw-r--r--drivers/net/gianfar_mii.c1
-rw-r--r--drivers/net/gianfar_sysfs.c1
-rw-r--r--drivers/net/gt96100eth.c5
-rw-r--r--drivers/net/gt96100eth.h3
-rw-r--r--drivers/net/hamachi.c18
-rw-r--r--drivers/net/hamradio/6pack.c1
-rw-r--r--drivers/net/hamradio/baycom_ser_fdx.c2
-rw-r--r--drivers/net/hamradio/baycom_ser_hdx.c2
-rw-r--r--drivers/net/hamradio/bpqether.c1
-rw-r--r--drivers/net/hamradio/dmascc.c2
-rw-r--r--drivers/net/hamradio/mkiss.c1
-rw-r--r--drivers/net/hamradio/scc.c3
-rw-r--r--drivers/net/hamradio/yam.c3
-rw-r--r--drivers/net/hp100.c9
-rw-r--r--drivers/net/hydra.c2
-rw-r--r--drivers/net/ibm_emac/ibm_emac.h1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.c1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.h1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_debug.c1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_debug.h1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_mal.c1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_mal.h1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_phy.c1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_rgmii.c1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_rgmii.h1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_tah.c1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_tah.h1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_zmii.c1
-rw-r--r--drivers/net/ibm_emac/ibm_emac_zmii.h1
-rw-r--r--drivers/net/ibmlana.c2
-rw-r--r--drivers/net/ibmveth.c3
-rw-r--r--drivers/net/ifb.c1
-rw-r--r--drivers/net/ioc3-eth.c5
-rw-r--r--drivers/net/irda/Kconfig2
-rw-r--r--drivers/net/irda/au1k_ir.c1
-rw-r--r--drivers/net/irda/donauboe.c4
-rw-r--r--drivers/net/irda/irda-usb.c2
-rw-r--r--drivers/net/irda/irport.c2
-rw-r--r--drivers/net/irda/mcs7780.c2
-rw-r--r--drivers/net/irda/nsc-ircc.c8
-rw-r--r--drivers/net/irda/pxaficp_ir.c1
-rw-r--r--drivers/net/irda/sa1100_ir.c1
-rw-r--r--drivers/net/irda/vlsi_ir.c3
-rw-r--r--drivers/net/iseries_veth.c28
-rw-r--r--drivers/net/ixgb/ixgb.h1
-rw-r--r--drivers/net/ixgb/ixgb_main.c6
-rw-r--r--drivers/net/ixp2000/caleb.c1
-rw-r--r--drivers/net/ixp2000/enp2611.c1
-rw-r--r--drivers/net/ixp2000/ixp2400-msf.c1
-rw-r--r--drivers/net/ixp2000/ixpdev.c3
-rw-r--r--drivers/net/ixp2000/pm3386.c1
-rw-r--r--drivers/net/jazzsonic.c2
-rw-r--r--drivers/net/lance.c3
-rw-r--r--drivers/net/lasi_82596.c3
-rw-r--r--drivers/net/loopback.c4
-rw-r--r--drivers/net/lp486e.c5
-rw-r--r--drivers/net/mace.c5
-rw-r--r--drivers/net/mipsnet.c2
-rw-r--r--drivers/net/mv643xx_eth.c2
-rw-r--r--drivers/net/mv643xx_eth.h2
-rw-r--r--drivers/net/myri10ge/myri10ge.c38
-rw-r--r--drivers/net/myri_sbus.c119
-rw-r--r--drivers/net/myri_sbus.h1
-rw-r--r--drivers/net/natsemi.c220
-rw-r--r--drivers/net/ne2k-pci.c11
-rw-r--r--drivers/net/netx-eth.c516
-rw-r--r--drivers/net/ni5010.c52
-rw-r--r--drivers/net/ns83820.c44
-rw-r--r--drivers/net/pci-skeleton.c22
-rw-r--r--drivers/net/pcmcia/axnet_cs.c2
-rw-r--r--drivers/net/pcmcia/com20020_cs.c5
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c3
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c2
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c2
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c5
-rw-r--r--drivers/net/pcnet32.c528
-rw-r--r--drivers/net/phy/Kconfig5
-rw-r--r--drivers/net/phy/Makefile1
-rw-r--r--drivers/net/phy/cicada.c43
-rw-r--r--drivers/net/phy/davicom.c1
-rw-r--r--drivers/net/phy/lxt.c9
-rw-r--r--drivers/net/phy/marvell.c1
-rw-r--r--drivers/net/phy/mdio_bus.c1
-rw-r--r--drivers/net/phy/phy.c3
-rw-r--r--drivers/net/phy/phy_device.c1
-rw-r--r--drivers/net/phy/qsemi.c1
-rw-r--r--drivers/net/phy/vitesse.c112
-rw-r--r--drivers/net/ppp_generic.c13
-rw-r--r--drivers/net/ppp_mppe.c1
-rw-r--r--drivers/net/r8169.c47
-rw-r--r--drivers/net/rrunner.c3
-rw-r--r--drivers/net/rrunner.h1
-rw-r--r--drivers/net/s2io.c24
-rw-r--r--drivers/net/s2io.h2
-rw-r--r--drivers/net/sb1250-mac.c3
-rw-r--r--drivers/net/seeq8005.c3
-rw-r--r--drivers/net/shaper.c1
-rw-r--r--drivers/net/sis190.c5
-rw-r--r--drivers/net/sis900.c2
-rw-r--r--drivers/net/sk98lin/skge.c10
-rw-r--r--drivers/net/sk98lin/skvpd.c2
-rw-r--r--drivers/net/sk_mca.c2
-rw-r--r--drivers/net/skfp/h/sba.h2
-rw-r--r--drivers/net/skfp/skfddi.c2
-rw-r--r--drivers/net/skge.c10
-rw-r--r--drivers/net/sky2.c15
-rw-r--r--drivers/net/slhc.c1
-rw-r--r--drivers/net/slip.c1
-rw-r--r--drivers/net/slip.h1
-rw-r--r--drivers/net/smc-ultra.c1
-rw-r--r--drivers/net/smc-ultra32.c2
-rw-r--r--drivers/net/smc911x.c2
-rw-r--r--drivers/net/smc9194.c3
-rw-r--r--drivers/net/smc91x.c1
-rw-r--r--drivers/net/smc91x.h48
-rw-r--r--drivers/net/sonic.c3
-rw-r--r--drivers/net/sonic.h1
-rw-r--r--drivers/net/spider_net.c3
-rw-r--r--drivers/net/starfire.c129
-rw-r--r--drivers/net/stnic.c1
-rw-r--r--drivers/net/sun3lance.c4
-rw-r--r--drivers/net/sunbmac.c129
-rw-r--r--drivers/net/sunbmac.h1
-rw-r--r--drivers/net/sundance.c108
-rw-r--r--drivers/net/sungem.c21
-rw-r--r--drivers/net/sungem_phy.c1
-rw-r--r--drivers/net/sunhme.c433
-rw-r--r--drivers/net/sunhme.h2
-rw-r--r--drivers/net/sunlance.c178
-rw-r--r--drivers/net/sunqe.c468
-rw-r--r--drivers/net/tc35815.c2
-rw-r--r--drivers/net/tg3.c157
-rw-r--r--drivers/net/tg3.h5
-rw-r--r--drivers/net/tlan.c2
-rw-r--r--drivers/net/tokenring/3c359.c3
-rw-r--r--drivers/net/tokenring/abyss.c2
-rw-r--r--drivers/net/tokenring/lanstreamer.c3
-rw-r--r--drivers/net/tokenring/madgemc.c2
-rw-r--r--drivers/net/tokenring/olympic.c7
-rw-r--r--drivers/net/tokenring/smctr.c5
-rw-r--r--drivers/net/tokenring/smctr_firmware.h1
-rw-r--r--drivers/net/tokenring/tmspci.c2
-rw-r--r--drivers/net/tulip/de2104x.c12
-rw-r--r--drivers/net/tulip/de4x5.c9
-rw-r--r--drivers/net/tulip/dmfe.c2
-rw-r--r--drivers/net/tulip/interrupt.c1
-rw-r--r--drivers/net/tulip/tulip.h1
-rw-r--r--drivers/net/tulip/tulip_core.c23
-rw-r--r--drivers/net/tulip/uli526x.c2
-rw-r--r--drivers/net/tulip/winbond-840.c51
-rw-r--r--drivers/net/tulip/xircom_cb.c2
-rw-r--r--drivers/net/tulip/xircom_tulip_cb.c30
-rw-r--r--drivers/net/tun.c5
-rw-r--r--drivers/net/typhoon.c9
-rw-r--r--drivers/net/via-rhine.c132
-rw-r--r--drivers/net/via-velocity.c112
-rw-r--r--drivers/net/via-velocity.h4
-rw-r--r--drivers/net/wan/Kconfig12
-rw-r--r--drivers/net/wan/Makefile1
-rw-r--r--drivers/net/wan/c101.c8
-rw-r--r--drivers/net/wan/cosa.c15
-rw-r--r--drivers/net/wan/dscc4.c14
-rw-r--r--drivers/net/wan/farsync.c2
-rw-r--r--drivers/net/wan/hdlc_generic.c25
-rw-r--r--drivers/net/wan/hostess_sv11.c2
-rw-r--r--drivers/net/wan/lmc/lmc_main.c2
-rw-r--r--drivers/net/wan/lmc/lmc_media.c1
-rw-r--r--drivers/net/wan/n2.c7
-rw-r--r--drivers/net/wan/pc300_drv.c6
-rw-r--r--drivers/net/wan/pci200syn.c5
-rw-r--r--drivers/net/wan/sbni.c3
-rw-r--r--drivers/net/wan/sdla.c4
-rw-r--r--drivers/net/wan/sealevel.c2
-rw-r--r--drivers/net/wan/syncppp.c1
-rw-r--r--drivers/net/wan/wanxl.c14
-rw-r--r--drivers/net/wireless/Kconfig1
-rw-r--r--drivers/net/wireless/Makefile1
-rw-r--r--drivers/net/wireless/airo.c3
-rw-r--r--drivers/net/wireless/airo_cs.c1
-rw-r--r--drivers/net/wireless/airport.c1
-rw-r--r--drivers/net/wireless/arlan-main.c1
-rw-r--r--drivers/net/wireless/arlan-proc.c1
-rw-r--r--drivers/net/wireless/arlan.h1
-rw-r--r--drivers/net/wireless/atmel.c3
-rw-r--r--drivers/net/wireless/atmel_cs.c1
-rw-r--r--drivers/net/wireless/atmel_pci.c1
-rw-r--r--drivers/net/wireless/bcm43xx/Kconfig1
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h6
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_ethtool.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c70
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.h24
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_radio.c7
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_wx.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_xmit.c5
-rw-r--r--drivers/net/wireless/hermes.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c3
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c11
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c3
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c5
-rw-r--r--drivers/net/wireless/ipw2100.c7
-rw-r--r--drivers/net/wireless/ipw2200.c24
-rw-r--r--drivers/net/wireless/ipw2200.h1
-rw-r--r--drivers/net/wireless/netwave_cs.c1
-rw-r--r--drivers/net/wireless/orinoco.c1
-rw-r--r--drivers/net/wireless/orinoco_cs.c1
-rw-r--r--drivers/net/wireless/orinoco_nortel.c3
-rw-r--r--drivers/net/wireless/orinoco_pci.c3
-rw-r--r--drivers/net/wireless/orinoco_pci.h2
-rw-r--r--drivers/net/wireless/orinoco_plx.c3
-rw-r--r--drivers/net/wireless/orinoco_tmd.c3
-rw-r--r--drivers/net/wireless/prism54/islpci_hotplug.c2
-rw-r--r--drivers/net/wireless/prism54/islpci_mgt.c1
-rw-r--r--drivers/net/wireless/prism54/prismcompat.h1
-rw-r--r--drivers/net/wireless/ray_cs.c4
-rw-r--r--drivers/net/wireless/spectrum_cs.c1
-rw-r--r--drivers/net/wireless/strip.c1
-rw-r--r--drivers/net/wireless/wavelan.c18
-rw-r--r--drivers/net/wireless/wavelan_cs.c7
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h1
-rw-r--r--drivers/net/wireless/wl3501_cs.c1
-rw-r--r--drivers/net/wireless/zd1211rw/Kconfig19
-rw-r--r--drivers/net/wireless/zd1211rw/Makefile11
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c1615
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h825
-rw-r--r--drivers/net/wireless/zd1211rw/zd_def.h48
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.c191
-rw-r--r--drivers/net/wireless/zd1211rw/zd_ieee80211.h85
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c1057
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h190
-rw-r--r--drivers/net/wireless/zd1211rw/zd_netdev.c267
-rw-r--r--drivers/net/wireless/zd1211rw/zd_netdev.h45
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf.c151
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf.h82
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf_al2230.c308
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf_rf2959.c279
-rw-r--r--drivers/net/wireless/zd1211rw/zd_types.h71
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c1316
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.h240
-rw-r--r--drivers/net/wireless/zd1211rw/zd_util.c82
-rw-r--r--drivers/net/wireless/zd1211rw/zd_util.h29
-rw-r--r--drivers/net/yellowfin.c73
-rw-r--r--drivers/net/znet.c4
-rw-r--r--drivers/net/zorro8390.c2
326 files changed, 10554 insertions, 2970 deletions
diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c
index bb44509fd404..07136ec423bd 100644
--- a/drivers/net/3c501.c
+++ b/drivers/net/3c501.c
@@ -508,11 +508,11 @@ static int el_start_xmit(struct sk_buff *skb, struct net_device *dev)
508 * speak of. We simply pull the packet out of its PIO buffer (which is slow) 508 * speak of. We simply pull the packet out of its PIO buffer (which is slow)
509 * and queue it for the kernel. Then we reset the card for the next packet. 509 * and queue it for the kernel. Then we reset the card for the next packet.
510 * 510 *
511 * We sometimes get suprise interrupts late both because the SMP IRQ delivery 511 * We sometimes get surprise interrupts late both because the SMP IRQ delivery
512 * is message passing and because the card sometimes seems to deliver late. I 512 * is message passing and because the card sometimes seems to deliver late. I
513 * think if it is part way through a receive and the mode is changed it carries 513 * think if it is part way through a receive and the mode is changed it carries
514 * on receiving and sends us an interrupt. We have to band aid all these cases 514 * on receiving and sends us an interrupt. We have to band aid all these cases
515 * to get a sensible 150kbytes/second performance. Even then you want a small 515 * to get a sensible 150kBytes/second performance. Even then you want a small
516 * TCP window. 516 * TCP window.
517 */ 517 */
518 518
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index dc845f36fe49..cbdae54f715f 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -68,7 +68,6 @@
68/* Maximum events (Rx packets, etc.) to handle at each interrupt. */ 68/* Maximum events (Rx packets, etc.) to handle at each interrupt. */
69static int max_interrupt_work = 10; 69static int max_interrupt_work = 10;
70 70
71#include <linux/config.h>
72#include <linux/module.h> 71#include <linux/module.h>
73#ifdef CONFIG_MCA 72#ifdef CONFIG_MCA
74#include <linux/mca.h> 73#include <linux/mca.h>
diff --git a/drivers/net/3c515.c b/drivers/net/3c515.c
index 91d1c4c24d9b..4532b17e40ea 100644
--- a/drivers/net/3c515.c
+++ b/drivers/net/3c515.c
@@ -57,7 +57,6 @@ static int max_interrupt_work = 20;
57#define RX_RING_SIZE 16 57#define RX_RING_SIZE 16
58#define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer. */ 58#define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer. */
59 59
60#include <linux/config.h>
61#include <linux/module.h> 60#include <linux/module.h>
62#include <linux/isapnp.h> 61#include <linux/isapnp.h>
63#include <linux/kernel.h> 62#include <linux/kernel.h>
@@ -761,7 +760,7 @@ static int corkscrew_open(struct net_device *dev)
761 vp->product_name, dev)) return -EAGAIN; 760 vp->product_name, dev)) return -EAGAIN;
762 enable_dma(dev->dma); 761 enable_dma(dev->dma);
763 set_dma_mode(dev->dma, DMA_MODE_CASCADE); 762 set_dma_mode(dev->dma, DMA_MODE_CASCADE);
764 } else if (request_irq(dev->irq, &corkscrew_interrupt, SA_SHIRQ, 763 } else if (request_irq(dev->irq, &corkscrew_interrupt, IRQF_SHARED,
765 vp->product_name, dev)) { 764 vp->product_name, dev)) {
766 return -EAGAIN; 765 return -EAGAIN;
767 } 766 }
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index 4bf8510655c5..5dfd97f0ba9e 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -289,7 +289,7 @@ static int elmc_open(struct net_device *dev)
289 289
290 elmc_id_attn586(); /* disable interrupts */ 290 elmc_id_attn586(); /* disable interrupts */
291 291
292 ret = request_irq(dev->irq, &elmc_interrupt, SA_SHIRQ | SA_SAMPLE_RANDOM, 292 ret = request_irq(dev->irq, &elmc_interrupt, IRQF_SHARED | IRQF_SAMPLE_RANDOM,
293 dev->name, dev); 293 dev->name, dev);
294 if (ret) { 294 if (ret) {
295 printk(KERN_ERR "%s: couldn't get irq %d\n", dev->name, dev->irq); 295 printk(KERN_ERR "%s: couldn't get irq %d\n", dev->name, dev->irq);
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c
index 1b1cb0026072..03c0f7176fc9 100644
--- a/drivers/net/3c527.c
+++ b/drivers/net/3c527.c
@@ -435,7 +435,7 @@ static int __init mc32_probe1(struct net_device *dev, int slot)
435 * Grab the IRQ 435 * Grab the IRQ
436 */ 436 */
437 437
438 err = request_irq(dev->irq, &mc32_interrupt, SA_SHIRQ | SA_SAMPLE_RANDOM, DRV_NAME, dev); 438 err = request_irq(dev->irq, &mc32_interrupt, IRQF_SHARED | IRQF_SAMPLE_RANDOM, DRV_NAME, dev);
439 if (err) { 439 if (err) {
440 release_region(dev->base_addr, MC32_IO_EXTENT); 440 release_region(dev->base_addr, MC32_IO_EXTENT);
441 printk(KERN_ERR "%s: unable to get IRQ %d.\n", DRV_NAME, dev->irq); 441 printk(KERN_ERR "%s: unable to get IRQ %d.\n", DRV_NAME, dev->irq);
@@ -1031,8 +1031,7 @@ static int mc32_send_packet(struct sk_buff *skb, struct net_device *dev)
1031 return 1; 1031 return 1;
1032 } 1032 }
1033 1033
1034 skb = skb_padto(skb, ETH_ZLEN); 1034 if (skb_padto(skb, ETH_ZLEN)) {
1035 if (skb == NULL) {
1036 netif_wake_queue(dev); 1035 netif_wake_queue(dev);
1037 return 0; 1036 return 0;
1038 } 1037 }
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 274b0138d442..80e8ca013e44 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -17,172 +17,6 @@
17 410 Severn Ave., Suite 210 17 410 Severn Ave., Suite 210
18 Annapolis MD 21403 18 Annapolis MD 21403
19 19
20 Linux Kernel Additions:
21
22 0.99H+lk0.9 - David S. Miller - softnet, PCI DMA updates
23 0.99H+lk1.0 - Jeff Garzik <jgarzik@pobox.com>
24 Remove compatibility defines for kernel versions < 2.2.x.
25 Update for new 2.3.x module interface
26 LK1.1.2 (March 19, 2000)
27 * New PCI interface (jgarzik)
28
29 LK1.1.3 25 April 2000, Andrew Morton <andrewm@uow.edu.au>
30 - Merged with 3c575_cb.c
31 - Don't set RxComplete in boomerang interrupt enable reg
32 - spinlock in vortex_timer to protect mdio functions
33 - disable local interrupts around call to vortex_interrupt in
34 vortex_tx_timeout() (So vortex_interrupt can use spin_lock())
35 - Select window 3 in vortex_timer()'s write to Wn3_MAC_Ctrl
36 - In vortex_start_xmit(), move the lock to _after_ we've altered
37 vp->cur_tx and vp->tx_full. This defeats the race between
38 vortex_start_xmit() and vortex_interrupt which was identified
39 by Bogdan Costescu.
40 - Merged back support for six new cards from various sources
41 - Set vortex_have_pci if pci_module_init returns zero (fixes cardbus
42 insertion oops)
43 - Tell it that 3c905C has NWAY for 100bT autoneg
44 - Fix handling of SetStatusEnd in 'Too much work..' code, as
45 per 2.3.99's 3c575_cb (Dave Hinds).
46 - Split ISR into two for vortex & boomerang
47 - Fix MOD_INC/DEC races
48 - Handle resource allocation failures.
49 - Fix 3CCFE575CT LED polarity
50 - Make tx_interrupt_mitigation the default
51
52 LK1.1.4 25 April 2000, Andrew Morton <andrewm@uow.edu.au>
53 - Add extra TxReset to vortex_up() to fix 575_cb hotplug initialisation probs.
54 - Put vortex_info_tbl into __devinitdata
55 - In the vortex_error StatsFull HACK, disable stats in vp->intr_enable as well
56 as in the hardware.
57 - Increased the loop counter in issue_and_wait from 2,000 to 4,000.
58
59 LK1.1.5 28 April 2000, andrewm
60 - Added powerpc defines (John Daniel <jdaniel@etresoft.com> said these work...)
61 - Some extra diagnostics
62 - In vortex_error(), reset the Tx on maxCollisions. Otherwise most
63 chips usually get a Tx timeout.
64 - Added extra_reset module parm
65 - Replaced some inline timer manip with mod_timer
66 (Franois romieu <Francois.Romieu@nic.fr>)
67 - In vortex_up(), don't make Wn3_config initialisation dependent upon has_nway
68 (this came across from 3c575_cb).
69
70 LK1.1.6 06 Jun 2000, andrewm
71 - Backed out the PPC defines.
72 - Use del_timer_sync(), mod_timer().
73 - Fix wrapped ulong comparison in boomerang_rx()
74 - Add IS_TORNADO, use it to suppress 3c905C checksum error msg
75 (Donald Becker, I Lee Hetherington <ilh@sls.lcs.mit.edu>)
76 - Replace union wn3_config with BFINS/BFEXT manipulation for
77 sparc64 (Pete Zaitcev, Peter Jones)
78 - In vortex_error, do_tx_reset and vortex_tx_timeout(Vortex):
79 do a netif_wake_queue() to better recover from errors. (Anders Pedersen,
80 Donald Becker)
81 - Print a warning on out-of-memory (rate limited to 1 per 10 secs)
82 - Added two more Cardbus 575 NICs: 5b57 and 6564 (Paul Wagland)
83
84 LK1.1.7 2 Jul 2000 andrewm
85 - Better handling of shared IRQs
86 - Reset the transmitter on a Tx reclaim error
87 - Fixed crash under OOM during vortex_open() (Mark Hemment)
88 - Fix Rx cessation problem during OOM (help from Mark Hemment)
89 - The spinlocks around the mdio access were blocking interrupts for 300uS.
90 Fix all this to use spin_lock_bh() within mdio_read/write
91 - Only write to TxFreeThreshold if it's a boomerang - other NICs don't
92 have one.
93 - Added 802.3x MAC-layer flow control support
94
95 LK1.1.8 13 Aug 2000 andrewm
96 - Ignore request_region() return value - already reserved if Cardbus.
97 - Merged some additional Cardbus flags from Don's 0.99Qk
98 - Some fixes for 3c556 (Fred Maciel)
99 - Fix for EISA initialisation (Jan Rekorajski)
100 - Renamed MII_XCVR_PWR and EEPROM_230 to align with 3c575_cb and D. Becker's drivers
101 - Fixed MII_XCVR_PWR for 3CCFE575CT
102 - Added INVERT_LED_PWR, used it.
103 - Backed out the extra_reset stuff
104
105 LK1.1.9 12 Sep 2000 andrewm
106 - Backed out the tx_reset_resume flags. It was a no-op.
107 - In vortex_error, don't reset the Tx on txReclaim errors
108 - In vortex_error, don't reset the Tx on maxCollisions errors.
109 Hence backed out all the DownListPtr logic here.
110 - In vortex_error, give Tornado cards a partial TxReset on
111 maxCollisions (David Hinds). Defined MAX_COLLISION_RESET for this.
112 - Redid some driver flags and device names based on pcmcia_cs-3.1.20.
113 - Fixed a bug where, if vp->tx_full is set when the interface
114 is downed, it remains set when the interface is upped. Bad
115 things happen.
116
117 LK1.1.10 17 Sep 2000 andrewm
118 - Added EEPROM_8BIT for 3c555 (Fred Maciel)
119 - Added experimental support for the 3c556B Laptop Hurricane (Louis Gerbarg)
120 - Add HAS_NWAY to "3c900 Cyclone 10Mbps TPO"
121
122 LK1.1.11 13 Nov 2000 andrewm
123 - Dump MOD_INC/DEC_USE_COUNT, use SET_MODULE_OWNER
124
125 LK1.1.12 1 Jan 2001 andrewm (2.4.0-pre1)
126 - Call pci_enable_device before we request our IRQ (Tobias Ringstrom)
127 - Add 3c590 PCI latency timer hack to vortex_probe1 (from 0.99Ra)
128 - Added extended issue_and_wait for the 3c905CX.
129 - Look for an MII on PHY index 24 first (3c905CX oddity).
130 - Add HAS_NWAY to 3cSOHO100-TX (Brett Frankenberger)
131 - Don't free skbs we don't own on oom path in vortex_open().
132
133 LK1.1.13 27 Jan 2001
134 - Added explicit `medialock' flag so we can truly
135 lock the media type down with `options'.
136 - "check ioremap return and some tidbits" (Arnaldo Carvalho de Melo <acme@conectiva.com.br>)
137 - Added and used EEPROM_NORESET for 3c556B PM resumes.
138 - Fixed leakage of vp->rx_ring.
139 - Break out separate HAS_HWCKSM device capability flag.
140 - Kill vp->tx_full (ANK)
141 - Merge zerocopy fragment handling (ANK?)
142
143 LK1.1.14 15 Feb 2001
144 - Enable WOL. Can be turned on with `enable_wol' module option.
145 - EISA and PCI initialisation fixes (jgarzik, Manfred Spraul)
146 - If a device's internalconfig register reports it has NWAY,
147 use it, even if autoselect is enabled.
148
149 LK1.1.15 6 June 2001 akpm
150 - Prevent double counting of received bytes (Lars Christensen)
151 - Add ethtool support (jgarzik)
152 - Add module parm descriptions (Andrzej M. Krzysztofowicz)
153 - Implemented alloc_etherdev() API
154 - Special-case the 'Tx error 82' message.
155
156 LK1.1.16 18 July 2001 akpm
157 - Make NETIF_F_SG dependent upon nr_free_highpages(), not on CONFIG_HIGHMEM
158 - Lessen verbosity of bootup messages
159 - Fix WOL - use new PM API functions.
160 - Use netif_running() instead of vp->open in suspend/resume.
161 - Don't reset the interface logic on open/close/rmmod. It upsets
162 autonegotiation, and hence DHCP (from 0.99T).
163 - Back out EEPROM_NORESET flag because of the above (we do it for all
164 NICs).
165 - Correct 3c982 identification string
166 - Rename wait_for_completion() to issue_and_wait() to avoid completion.h
167 clash.
168
169 LK1.1.17 18Dec01 akpm
170 - PCI ID 9805 is a Python-T, not a dual-port Cyclone. Apparently.
171 And it has NWAY.
172 - Mask our advertised modes (vp->advertising) with our capabilities
173 (MII reg5) when deciding which duplex mode to use.
174 - Add `global_options' as default for options[]. Ditto global_enable_wol,
175 global_full_duplex.
176
177 LK1.1.18 01Jul02 akpm
178 - Fix for undocumented transceiver power-up bit on some 3c566B's
179 (Donald Becker, Rahul Karnik)
180
181 - See http://www.zip.com.au/~akpm/linux/#3c59x-2.3 for more details.
182 - Also see Documentation/networking/vortex.txt
183
184 LK1.1.19 10Nov02 Marc Zyngier <maz@wild-wind.fr.eu.org>
185 - EISA sysfs integration.
186*/ 20*/
187 21
188/* 22/*
@@ -236,7 +70,6 @@ static int vortex_debug = VORTEX_DEBUG;
236static int vortex_debug = 1; 70static int vortex_debug = 1;
237#endif 71#endif
238 72
239#include <linux/config.h>
240#include <linux/module.h> 73#include <linux/module.h>
241#include <linux/kernel.h> 74#include <linux/kernel.h>
242#include <linux/string.h> 75#include <linux/string.h>
@@ -375,8 +208,7 @@ limit of 4K.
375 of the drivers, and will likely be provided by some future kernel. 208 of the drivers, and will likely be provided by some future kernel.
376*/ 209*/
377enum pci_flags_bit { 210enum pci_flags_bit {
378 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4, 211 PCI_USES_MASTER=4,
379 PCI_ADDR0=0x10<<0, PCI_ADDR1=0x10<<1, PCI_ADDR2=0x10<<2, PCI_ADDR3=0x10<<3,
380}; 212};
381 213
382enum { IS_VORTEX=1, IS_BOOMERANG=2, IS_CYCLONE=4, IS_TORNADO=8, 214enum { IS_VORTEX=1, IS_BOOMERANG=2, IS_CYCLONE=4, IS_TORNADO=8,
@@ -446,95 +278,95 @@ static struct vortex_chip_info {
446 int io_size; 278 int io_size;
447} vortex_info_tbl[] __devinitdata = { 279} vortex_info_tbl[] __devinitdata = {
448 {"3c590 Vortex 10Mbps", 280 {"3c590 Vortex 10Mbps",
449 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 281 PCI_USES_MASTER, IS_VORTEX, 32, },
450 {"3c592 EISA 10Mbps Demon/Vortex", /* AKPM: from Don's 3c59x_cb.c 0.49H */ 282 {"3c592 EISA 10Mbps Demon/Vortex", /* AKPM: from Don's 3c59x_cb.c 0.49H */
451 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 283 PCI_USES_MASTER, IS_VORTEX, 32, },
452 {"3c597 EISA Fast Demon/Vortex", /* AKPM: from Don's 3c59x_cb.c 0.49H */ 284 {"3c597 EISA Fast Demon/Vortex", /* AKPM: from Don's 3c59x_cb.c 0.49H */
453 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 285 PCI_USES_MASTER, IS_VORTEX, 32, },
454 {"3c595 Vortex 100baseTx", 286 {"3c595 Vortex 100baseTx",
455 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 287 PCI_USES_MASTER, IS_VORTEX, 32, },
456 {"3c595 Vortex 100baseT4", 288 {"3c595 Vortex 100baseT4",
457 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 289 PCI_USES_MASTER, IS_VORTEX, 32, },
458 290
459 {"3c595 Vortex 100base-MII", 291 {"3c595 Vortex 100base-MII",
460 PCI_USES_IO|PCI_USES_MASTER, IS_VORTEX, 32, }, 292 PCI_USES_MASTER, IS_VORTEX, 32, },
461 {"3c900 Boomerang 10baseT", 293 {"3c900 Boomerang 10baseT",
462 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|EEPROM_RESET, 64, }, 294 PCI_USES_MASTER, IS_BOOMERANG|EEPROM_RESET, 64, },
463 {"3c900 Boomerang 10Mbps Combo", 295 {"3c900 Boomerang 10Mbps Combo",
464 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|EEPROM_RESET, 64, }, 296 PCI_USES_MASTER, IS_BOOMERANG|EEPROM_RESET, 64, },
465 {"3c900 Cyclone 10Mbps TPO", /* AKPM: from Don's 0.99M */ 297 {"3c900 Cyclone 10Mbps TPO", /* AKPM: from Don's 0.99M */
466 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 298 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
467 {"3c900 Cyclone 10Mbps Combo", 299 {"3c900 Cyclone 10Mbps Combo",
468 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 300 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
469 301
470 {"3c900 Cyclone 10Mbps TPC", /* AKPM: from Don's 0.99M */ 302 {"3c900 Cyclone 10Mbps TPC", /* AKPM: from Don's 0.99M */
471 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 303 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
472 {"3c900B-FL Cyclone 10base-FL", 304 {"3c900B-FL Cyclone 10base-FL",
473 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 305 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
474 {"3c905 Boomerang 100baseTx", 306 {"3c905 Boomerang 100baseTx",
475 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, }, 307 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, },
476 {"3c905 Boomerang 100baseT4", 308 {"3c905 Boomerang 100baseT4",
477 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, }, 309 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, },
478 {"3c905B Cyclone 100baseTx", 310 {"3c905B Cyclone 100baseTx",
479 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, }, 311 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, },
480 312
481 {"3c905B Cyclone 10/100/BNC", 313 {"3c905B Cyclone 10/100/BNC",
482 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, }, 314 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, },
483 {"3c905B-FX Cyclone 100baseFx", 315 {"3c905B-FX Cyclone 100baseFx",
484 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 316 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
485 {"3c905C Tornado", 317 {"3c905C Tornado",
486 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, }, 318 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, },
487 {"3c920B-EMB-WNM (ATI Radeon 9100 IGP)", 319 {"3c920B-EMB-WNM (ATI Radeon 9100 IGP)",
488 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_MII|HAS_HWCKSM, 128, }, 320 PCI_USES_MASTER, IS_TORNADO|HAS_MII|HAS_HWCKSM, 128, },
489 {"3c980 Cyclone", 321 {"3c980 Cyclone",
490 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 322 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, },
491 323
492 {"3c980C Python-T", 324 {"3c980C Python-T",
493 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, }, 325 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, },
494 {"3cSOHO100-TX Hurricane", 326 {"3cSOHO100-TX Hurricane",
495 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, }, 327 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, },
496 {"3c555 Laptop Hurricane", 328 {"3c555 Laptop Hurricane",
497 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|EEPROM_8BIT|HAS_HWCKSM, 128, }, 329 PCI_USES_MASTER, IS_CYCLONE|EEPROM_8BIT|HAS_HWCKSM, 128, },
498 {"3c556 Laptop Tornado", 330 {"3c556 Laptop Tornado",
499 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|EEPROM_8BIT|HAS_CB_FNS|INVERT_MII_PWR| 331 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|EEPROM_8BIT|HAS_CB_FNS|INVERT_MII_PWR|
500 HAS_HWCKSM, 128, }, 332 HAS_HWCKSM, 128, },
501 {"3c556B Laptop Hurricane", 333 {"3c556B Laptop Hurricane",
502 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|EEPROM_OFFSET|HAS_CB_FNS|INVERT_MII_PWR| 334 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|EEPROM_OFFSET|HAS_CB_FNS|INVERT_MII_PWR|
503 WNO_XCVR_PWR|HAS_HWCKSM, 128, }, 335 WNO_XCVR_PWR|HAS_HWCKSM, 128, },
504 336
505 {"3c575 [Megahertz] 10/100 LAN CardBus", 337 {"3c575 [Megahertz] 10/100 LAN CardBus",
506 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_8BIT, 128, }, 338 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_8BIT, 128, },
507 {"3c575 Boomerang CardBus", 339 {"3c575 Boomerang CardBus",
508 PCI_USES_IO|PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_8BIT, 128, }, 340 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_8BIT, 128, },
509 {"3CCFE575BT Cyclone CardBus", 341 {"3CCFE575BT Cyclone CardBus",
510 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT| 342 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|
511 INVERT_LED_PWR|HAS_HWCKSM, 128, }, 343 INVERT_LED_PWR|HAS_HWCKSM, 128, },
512 {"3CCFE575CT Tornado CardBus", 344 {"3CCFE575CT Tornado CardBus",
513 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR| 345 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|
514 MAX_COLLISION_RESET|HAS_HWCKSM, 128, }, 346 MAX_COLLISION_RESET|HAS_HWCKSM, 128, },
515 {"3CCFE656 Cyclone CardBus", 347 {"3CCFE656 Cyclone CardBus",
516 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR| 348 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|
517 INVERT_LED_PWR|HAS_HWCKSM, 128, }, 349 INVERT_LED_PWR|HAS_HWCKSM, 128, },
518 350
519 {"3CCFEM656B Cyclone+Winmodem CardBus", 351 {"3CCFEM656B Cyclone+Winmodem CardBus",
520 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR| 352 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|
521 INVERT_LED_PWR|HAS_HWCKSM, 128, }, 353 INVERT_LED_PWR|HAS_HWCKSM, 128, },
522 {"3CXFEM656C Tornado+Winmodem CardBus", /* From pcmcia-cs-3.1.5 */ 354 {"3CXFEM656C Tornado+Winmodem CardBus", /* From pcmcia-cs-3.1.5 */
523 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR| 355 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_CB_FNS|EEPROM_8BIT|INVERT_MII_PWR|
524 MAX_COLLISION_RESET|HAS_HWCKSM, 128, }, 356 MAX_COLLISION_RESET|HAS_HWCKSM, 128, },
525 {"3c450 HomePNA Tornado", /* AKPM: from Don's 0.99Q */ 357 {"3c450 HomePNA Tornado", /* AKPM: from Don's 0.99Q */
526 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, }, 358 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, },
527 {"3c920 Tornado", 359 {"3c920 Tornado",
528 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, }, 360 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, },
529 {"3c982 Hydra Dual Port A", 361 {"3c982 Hydra Dual Port A",
530 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_HWCKSM|HAS_NWAY, 128, }, 362 PCI_USES_MASTER, IS_TORNADO|HAS_HWCKSM|HAS_NWAY, 128, },
531 363
532 {"3c982 Hydra Dual Port B", 364 {"3c982 Hydra Dual Port B",
533 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_HWCKSM|HAS_NWAY, 128, }, 365 PCI_USES_MASTER, IS_TORNADO|HAS_HWCKSM|HAS_NWAY, 128, },
534 {"3c905B-T4", 366 {"3c905B-T4",
535 PCI_USES_IO|PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, }, 367 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, },
536 {"3c920B-EMB-WNM Tornado", 368 {"3c920B-EMB-WNM Tornado",
537 PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, }, 369 PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, },
538 370
539 {NULL,}, /* NULL terminated list. */ 371 {NULL,}, /* NULL terminated list. */
540}; 372};
@@ -998,7 +830,7 @@ static int vortex_resume(struct pci_dev *pdev)
998 pci_enable_device(pdev); 830 pci_enable_device(pdev);
999 pci_set_master(pdev); 831 pci_set_master(pdev);
1000 if (request_irq(dev->irq, vp->full_bus_master_rx ? 832 if (request_irq(dev->irq, vp->full_bus_master_rx ?
1001 &boomerang_interrupt : &vortex_interrupt, SA_SHIRQ, dev->name, dev)) { 833 &boomerang_interrupt : &vortex_interrupt, IRQF_SHARED, dev->name, dev)) {
1002 printk(KERN_WARNING "%s: Could not reserve IRQ %d\n", dev->name, dev->irq); 834 printk(KERN_WARNING "%s: Could not reserve IRQ %d\n", dev->name, dev->irq);
1003 pci_disable_device(pdev); 835 pci_disable_device(pdev);
1004 return -EBUSY; 836 return -EBUSY;
@@ -1382,17 +1214,12 @@ static int __devinit vortex_probe1(struct device *gendev,
1382 for (i = 0; i < 6; i++) 1214 for (i = 0; i < 6; i++)
1383 iowrite8(dev->dev_addr[i], ioaddr + i); 1215 iowrite8(dev->dev_addr[i], ioaddr + i);
1384 1216
1385#ifdef __sparc__
1386 if (print_info)
1387 printk(", IRQ %s\n", __irq_itoa(dev->irq));
1388#else
1389 if (print_info) 1217 if (print_info)
1390 printk(", IRQ %d\n", dev->irq); 1218 printk(", IRQ %d\n", dev->irq);
1391 /* Tell them about an invalid IRQ. */ 1219 /* Tell them about an invalid IRQ. */
1392 if (dev->irq <= 0 || dev->irq >= NR_IRQS) 1220 if (dev->irq <= 0 || dev->irq >= NR_IRQS)
1393 printk(KERN_WARNING " *** Warning: IRQ %d is unlikely to work! ***\n", 1221 printk(KERN_WARNING " *** Warning: IRQ %d is unlikely to work! ***\n",
1394 dev->irq); 1222 dev->irq);
1395#endif
1396 1223
1397 EL3WINDOW(4); 1224 EL3WINDOW(4);
1398 step = (ioread8(ioaddr + Wn4_NetDiag) & 0x1e) >> 1; 1225 step = (ioread8(ioaddr + Wn4_NetDiag) & 0x1e) >> 1;
@@ -1413,8 +1240,10 @@ static int __devinit vortex_probe1(struct device *gendev,
1413 } 1240 }
1414 1241
1415 if (print_info) { 1242 if (print_info) {
1416 printk(KERN_INFO "%s: CardBus functions mapped %8.8lx->%p\n", 1243 printk(KERN_INFO "%s: CardBus functions mapped "
1417 print_name, pci_resource_start(pdev, 2), 1244 "%16.16llx->%p\n",
1245 print_name,
1246 (unsigned long long)pci_resource_start(pdev, 2),
1418 vp->cb_fn_base); 1247 vp->cb_fn_base);
1419 } 1248 }
1420 EL3WINDOW(2); 1249 EL3WINDOW(2);
@@ -1838,7 +1667,7 @@ vortex_open(struct net_device *dev)
1838 1667
1839 /* Use the now-standard shared IRQ implementation. */ 1668 /* Use the now-standard shared IRQ implementation. */
1840 if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ? 1669 if ((retval = request_irq(dev->irq, vp->full_bus_master_rx ?
1841 &boomerang_interrupt : &vortex_interrupt, SA_SHIRQ, dev->name, dev))) { 1670 &boomerang_interrupt : &vortex_interrupt, IRQF_SHARED, dev->name, dev))) {
1842 printk(KERN_ERR "%s: Could not reserve IRQ %d\n", dev->name, dev->irq); 1671 printk(KERN_ERR "%s: Could not reserve IRQ %d\n", dev->name, dev->irq);
1843 goto out; 1672 goto out;
1844 } 1673 }
@@ -1902,7 +1731,7 @@ vortex_timer(unsigned long data)
1902 printk(KERN_DEBUG "dev->watchdog_timeo=%d\n", dev->watchdog_timeo); 1731 printk(KERN_DEBUG "dev->watchdog_timeo=%d\n", dev->watchdog_timeo);
1903 } 1732 }
1904 1733
1905 disable_irq(dev->irq); 1734 disable_irq_lockdep(dev->irq);
1906 old_window = ioread16(ioaddr + EL3_CMD) >> 13; 1735 old_window = ioread16(ioaddr + EL3_CMD) >> 13;
1907 EL3WINDOW(4); 1736 EL3WINDOW(4);
1908 media_status = ioread16(ioaddr + Wn4_Media); 1737 media_status = ioread16(ioaddr + Wn4_Media);
@@ -1983,7 +1812,7 @@ leave_media_alone:
1983 dev->name, media_tbl[dev->if_port].name); 1812 dev->name, media_tbl[dev->if_port].name);
1984 1813
1985 EL3WINDOW(old_window); 1814 EL3WINDOW(old_window);
1986 enable_irq(dev->irq); 1815 enable_irq_lockdep(dev->irq);
1987 mod_timer(&vp->timer, RUN_AT(next_tick)); 1816 mod_timer(&vp->timer, RUN_AT(next_tick));
1988 if (vp->deferred) 1817 if (vp->deferred)
1989 iowrite16(FakeIntr, ioaddr + EL3_CMD); 1818 iowrite16(FakeIntr, ioaddr + EL3_CMD);
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 46d8c01437e9..d2150baa7e35 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -52,7 +52,6 @@
52#define DRV_RELDATE "Mar 22, 2004" 52#define DRV_RELDATE "Mar 22, 2004"
53 53
54 54
55#include <linux/config.h>
56#include <linux/module.h> 55#include <linux/module.h>
57#include <linux/moduleparam.h> 56#include <linux/moduleparam.h>
58#include <linux/kernel.h> 57#include <linux/kernel.h>
@@ -401,6 +400,11 @@ static void cp_clean_rings (struct cp_private *cp);
401#ifdef CONFIG_NET_POLL_CONTROLLER 400#ifdef CONFIG_NET_POLL_CONTROLLER
402static void cp_poll_controller(struct net_device *dev); 401static void cp_poll_controller(struct net_device *dev);
403#endif 402#endif
403static int cp_get_eeprom_len(struct net_device *dev);
404static int cp_get_eeprom(struct net_device *dev,
405 struct ethtool_eeprom *eeprom, u8 *data);
406static int cp_set_eeprom(struct net_device *dev,
407 struct ethtool_eeprom *eeprom, u8 *data);
404 408
405static struct pci_device_id cp_pci_tbl[] = { 409static struct pci_device_id cp_pci_tbl[] = {
406 { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139, 410 { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_8139,
@@ -792,7 +796,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev)
792 entry = cp->tx_head; 796 entry = cp->tx_head;
793 eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0; 797 eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
794 if (dev->features & NETIF_F_TSO) 798 if (dev->features & NETIF_F_TSO)
795 mss = skb_shinfo(skb)->tso_size; 799 mss = skb_shinfo(skb)->gso_size;
796 800
797 if (skb_shinfo(skb)->nr_frags == 0) { 801 if (skb_shinfo(skb)->nr_frags == 0) {
798 struct cp_desc *txd = &cp->tx_ring[entry]; 802 struct cp_desc *txd = &cp->tx_ring[entry];
@@ -1199,7 +1203,7 @@ static int cp_open (struct net_device *dev)
1199 1203
1200 cp_init_hw(cp); 1204 cp_init_hw(cp);
1201 1205
1202 rc = request_irq(dev->irq, cp_interrupt, SA_SHIRQ, dev->name, dev); 1206 rc = request_irq(dev->irq, cp_interrupt, IRQF_SHARED, dev->name, dev);
1203 if (rc) 1207 if (rc)
1204 goto err_out_hw; 1208 goto err_out_hw;
1205 1209
@@ -1577,6 +1581,9 @@ static struct ethtool_ops cp_ethtool_ops = {
1577 .get_strings = cp_get_strings, 1581 .get_strings = cp_get_strings,
1578 .get_ethtool_stats = cp_get_ethtool_stats, 1582 .get_ethtool_stats = cp_get_ethtool_stats,
1579 .get_perm_addr = ethtool_op_get_perm_addr, 1583 .get_perm_addr = ethtool_op_get_perm_addr,
1584 .get_eeprom_len = cp_get_eeprom_len,
1585 .get_eeprom = cp_get_eeprom,
1586 .set_eeprom = cp_set_eeprom,
1580}; 1587};
1581 1588
1582static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) 1589static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
@@ -1612,24 +1619,32 @@ static int cp_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1612#define eeprom_delay() readl(ee_addr) 1619#define eeprom_delay() readl(ee_addr)
1613 1620
1614/* The EEPROM commands include the alway-set leading bit. */ 1621/* The EEPROM commands include the alway-set leading bit. */
1622#define EE_EXTEND_CMD (4)
1615#define EE_WRITE_CMD (5) 1623#define EE_WRITE_CMD (5)
1616#define EE_READ_CMD (6) 1624#define EE_READ_CMD (6)
1617#define EE_ERASE_CMD (7) 1625#define EE_ERASE_CMD (7)
1618 1626
1619static int read_eeprom (void __iomem *ioaddr, int location, int addr_len) 1627#define EE_EWDS_ADDR (0)
1620{ 1628#define EE_WRAL_ADDR (1)
1621 int i; 1629#define EE_ERAL_ADDR (2)
1622 unsigned retval = 0; 1630#define EE_EWEN_ADDR (3)
1623 void __iomem *ee_addr = ioaddr + Cfg9346; 1631
1624 int read_cmd = location | (EE_READ_CMD << addr_len); 1632#define CP_EEPROM_MAGIC PCI_DEVICE_ID_REALTEK_8139
1625 1633
1634static void eeprom_cmd_start(void __iomem *ee_addr)
1635{
1626 writeb (EE_ENB & ~EE_CS, ee_addr); 1636 writeb (EE_ENB & ~EE_CS, ee_addr);
1627 writeb (EE_ENB, ee_addr); 1637 writeb (EE_ENB, ee_addr);
1628 eeprom_delay (); 1638 eeprom_delay ();
1639}
1629 1640
1630 /* Shift the read command bits out. */ 1641static void eeprom_cmd(void __iomem *ee_addr, int cmd, int cmd_len)
1631 for (i = 4 + addr_len; i >= 0; i--) { 1642{
1632 int dataval = (read_cmd & (1 << i)) ? EE_DATA_WRITE : 0; 1643 int i;
1644
1645 /* Shift the command bits out. */
1646 for (i = cmd_len - 1; i >= 0; i--) {
1647 int dataval = (cmd & (1 << i)) ? EE_DATA_WRITE : 0;
1633 writeb (EE_ENB | dataval, ee_addr); 1648 writeb (EE_ENB | dataval, ee_addr);
1634 eeprom_delay (); 1649 eeprom_delay ();
1635 writeb (EE_ENB | dataval | EE_SHIFT_CLK, ee_addr); 1650 writeb (EE_ENB | dataval | EE_SHIFT_CLK, ee_addr);
@@ -1637,6 +1652,33 @@ static int read_eeprom (void __iomem *ioaddr, int location, int addr_len)
1637 } 1652 }
1638 writeb (EE_ENB, ee_addr); 1653 writeb (EE_ENB, ee_addr);
1639 eeprom_delay (); 1654 eeprom_delay ();
1655}
1656
1657static void eeprom_cmd_end(void __iomem *ee_addr)
1658{
1659 writeb (~EE_CS, ee_addr);
1660 eeprom_delay ();
1661}
1662
1663static void eeprom_extend_cmd(void __iomem *ee_addr, int extend_cmd,
1664 int addr_len)
1665{
1666 int cmd = (EE_EXTEND_CMD << addr_len) | (extend_cmd << (addr_len - 2));
1667
1668 eeprom_cmd_start(ee_addr);
1669 eeprom_cmd(ee_addr, cmd, 3 + addr_len);
1670 eeprom_cmd_end(ee_addr);
1671}
1672
1673static u16 read_eeprom (void __iomem *ioaddr, int location, int addr_len)
1674{
1675 int i;
1676 u16 retval = 0;
1677 void __iomem *ee_addr = ioaddr + Cfg9346;
1678 int read_cmd = location | (EE_READ_CMD << addr_len);
1679
1680 eeprom_cmd_start(ee_addr);
1681 eeprom_cmd(ee_addr, read_cmd, 3 + addr_len);
1640 1682
1641 for (i = 16; i > 0; i--) { 1683 for (i = 16; i > 0; i--) {
1642 writeb (EE_ENB | EE_SHIFT_CLK, ee_addr); 1684 writeb (EE_ENB | EE_SHIFT_CLK, ee_addr);
@@ -1648,13 +1690,125 @@ static int read_eeprom (void __iomem *ioaddr, int location, int addr_len)
1648 eeprom_delay (); 1690 eeprom_delay ();
1649 } 1691 }
1650 1692
1651 /* Terminate the EEPROM access. */ 1693 eeprom_cmd_end(ee_addr);
1652 writeb (~EE_CS, ee_addr);
1653 eeprom_delay ();
1654 1694
1655 return retval; 1695 return retval;
1656} 1696}
1657 1697
1698static void write_eeprom(void __iomem *ioaddr, int location, u16 val,
1699 int addr_len)
1700{
1701 int i;
1702 void __iomem *ee_addr = ioaddr + Cfg9346;
1703 int write_cmd = location | (EE_WRITE_CMD << addr_len);
1704
1705 eeprom_extend_cmd(ee_addr, EE_EWEN_ADDR, addr_len);
1706
1707 eeprom_cmd_start(ee_addr);
1708 eeprom_cmd(ee_addr, write_cmd, 3 + addr_len);
1709 eeprom_cmd(ee_addr, val, 16);
1710 eeprom_cmd_end(ee_addr);
1711
1712 eeprom_cmd_start(ee_addr);
1713 for (i = 0; i < 20000; i++)
1714 if (readb(ee_addr) & EE_DATA_READ)
1715 break;
1716 eeprom_cmd_end(ee_addr);
1717
1718 eeprom_extend_cmd(ee_addr, EE_EWDS_ADDR, addr_len);
1719}
1720
1721static int cp_get_eeprom_len(struct net_device *dev)
1722{
1723 struct cp_private *cp = netdev_priv(dev);
1724 int size;
1725
1726 spin_lock_irq(&cp->lock);
1727 size = read_eeprom(cp->regs, 0, 8) == 0x8129 ? 256 : 128;
1728 spin_unlock_irq(&cp->lock);
1729
1730 return size;
1731}
1732
1733static int cp_get_eeprom(struct net_device *dev,
1734 struct ethtool_eeprom *eeprom, u8 *data)
1735{
1736 struct cp_private *cp = netdev_priv(dev);
1737 unsigned int addr_len;
1738 u16 val;
1739 u32 offset = eeprom->offset >> 1;
1740 u32 len = eeprom->len;
1741 u32 i = 0;
1742
1743 eeprom->magic = CP_EEPROM_MAGIC;
1744
1745 spin_lock_irq(&cp->lock);
1746
1747 addr_len = read_eeprom(cp->regs, 0, 8) == 0x8129 ? 8 : 6;
1748
1749 if (eeprom->offset & 1) {
1750 val = read_eeprom(cp->regs, offset, addr_len);
1751 data[i++] = (u8)(val >> 8);
1752 offset++;
1753 }
1754
1755 while (i < len - 1) {
1756 val = read_eeprom(cp->regs, offset, addr_len);
1757 data[i++] = (u8)val;
1758 data[i++] = (u8)(val >> 8);
1759 offset++;
1760 }
1761
1762 if (i < len) {
1763 val = read_eeprom(cp->regs, offset, addr_len);
1764 data[i] = (u8)val;
1765 }
1766
1767 spin_unlock_irq(&cp->lock);
1768 return 0;
1769}
1770
1771static int cp_set_eeprom(struct net_device *dev,
1772 struct ethtool_eeprom *eeprom, u8 *data)
1773{
1774 struct cp_private *cp = netdev_priv(dev);
1775 unsigned int addr_len;
1776 u16 val;
1777 u32 offset = eeprom->offset >> 1;
1778 u32 len = eeprom->len;
1779 u32 i = 0;
1780
1781 if (eeprom->magic != CP_EEPROM_MAGIC)
1782 return -EINVAL;
1783
1784 spin_lock_irq(&cp->lock);
1785
1786 addr_len = read_eeprom(cp->regs, 0, 8) == 0x8129 ? 8 : 6;
1787
1788 if (eeprom->offset & 1) {
1789 val = read_eeprom(cp->regs, offset, addr_len) & 0xff;
1790 val |= (u16)data[i++] << 8;
1791 write_eeprom(cp->regs, offset, val, addr_len);
1792 offset++;
1793 }
1794
1795 while (i < len - 1) {
1796 val = (u16)data[i++];
1797 val |= (u16)data[i++] << 8;
1798 write_eeprom(cp->regs, offset, val, addr_len);
1799 offset++;
1800 }
1801
1802 if (i < len) {
1803 val = read_eeprom(cp->regs, offset, addr_len) & 0xff00;
1804 val |= (u16)data[i];
1805 write_eeprom(cp->regs, offset, val, addr_len);
1806 }
1807
1808 spin_unlock_irq(&cp->lock);
1809 return 0;
1810}
1811
1658/* Put the board into D3cold state and wait for WakeUp signal */ 1812/* Put the board into D3cold state and wait for WakeUp signal */
1659static void cp_set_d3_state (struct cp_private *cp) 1813static void cp_set_d3_state (struct cp_private *cp)
1660{ 1814{
@@ -1668,7 +1822,7 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1668 struct cp_private *cp; 1822 struct cp_private *cp;
1669 int rc; 1823 int rc;
1670 void __iomem *regs; 1824 void __iomem *regs;
1671 long pciaddr; 1825 resource_size_t pciaddr;
1672 unsigned int addr_len, i, pci_using_dac; 1826 unsigned int addr_len, i, pci_using_dac;
1673 u8 pci_rev; 1827 u8 pci_rev;
1674 1828
@@ -1682,9 +1836,10 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1682 1836
1683 if (pdev->vendor == PCI_VENDOR_ID_REALTEK && 1837 if (pdev->vendor == PCI_VENDOR_ID_REALTEK &&
1684 pdev->device == PCI_DEVICE_ID_REALTEK_8139 && pci_rev < 0x20) { 1838 pdev->device == PCI_DEVICE_ID_REALTEK_8139 && pci_rev < 0x20) {
1685 printk(KERN_ERR PFX "pci dev %s (id %04x:%04x rev %02x) is not an 8139C+ compatible chip\n", 1839 dev_err(&pdev->dev,
1686 pci_name(pdev), pdev->vendor, pdev->device, pci_rev); 1840 "This (id %04x:%04x rev %02x) is not an 8139C+ compatible chip\n",
1687 printk(KERN_ERR PFX "Try the \"8139too\" driver instead.\n"); 1841 pdev->vendor, pdev->device, pci_rev);
1842 dev_err(&pdev->dev, "Try the \"8139too\" driver instead.\n");
1688 return -ENODEV; 1843 return -ENODEV;
1689 } 1844 }
1690 1845
@@ -1722,14 +1877,13 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1722 pciaddr = pci_resource_start(pdev, 1); 1877 pciaddr = pci_resource_start(pdev, 1);
1723 if (!pciaddr) { 1878 if (!pciaddr) {
1724 rc = -EIO; 1879 rc = -EIO;
1725 printk(KERN_ERR PFX "no MMIO resource for pci dev %s\n", 1880 dev_err(&pdev->dev, "no MMIO resource\n");
1726 pci_name(pdev));
1727 goto err_out_res; 1881 goto err_out_res;
1728 } 1882 }
1729 if (pci_resource_len(pdev, 1) < CP_REGS_SIZE) { 1883 if (pci_resource_len(pdev, 1) < CP_REGS_SIZE) {
1730 rc = -EIO; 1884 rc = -EIO;
1731 printk(KERN_ERR PFX "MMIO resource (%lx) too small on pci dev %s\n", 1885 dev_err(&pdev->dev, "MMIO resource (%llx) too small\n",
1732 pci_resource_len(pdev, 1), pci_name(pdev)); 1886 (unsigned long long)pci_resource_len(pdev, 1));
1733 goto err_out_res; 1887 goto err_out_res;
1734 } 1888 }
1735 1889
@@ -1743,14 +1897,15 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1743 1897
1744 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 1898 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
1745 if (rc) { 1899 if (rc) {
1746 printk(KERN_ERR PFX "No usable DMA configuration, " 1900 dev_err(&pdev->dev,
1747 "aborting.\n"); 1901 "No usable DMA configuration, aborting.\n");
1748 goto err_out_res; 1902 goto err_out_res;
1749 } 1903 }
1750 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 1904 rc = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
1751 if (rc) { 1905 if (rc) {
1752 printk(KERN_ERR PFX "No usable consistent DMA configuration, " 1906 dev_err(&pdev->dev,
1753 "aborting.\n"); 1907 "No usable consistent DMA configuration, "
1908 "aborting.\n");
1754 goto err_out_res; 1909 goto err_out_res;
1755 } 1910 }
1756 } 1911 }
@@ -1761,8 +1916,9 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1761 regs = ioremap(pciaddr, CP_REGS_SIZE); 1916 regs = ioremap(pciaddr, CP_REGS_SIZE);
1762 if (!regs) { 1917 if (!regs) {
1763 rc = -EIO; 1918 rc = -EIO;
1764 printk(KERN_ERR PFX "Cannot map PCI MMIO (%lx@%lx) on pci dev %s\n", 1919 dev_err(&pdev->dev, "Cannot map PCI MMIO (%lx@%lx)\n",
1765 pci_resource_len(pdev, 1), pciaddr, pci_name(pdev)); 1920 (unsigned long long)pci_resource_len(pdev, 1),
1921 (unsigned long long)pciaddr);
1766 goto err_out_res; 1922 goto err_out_res;
1767 } 1923 }
1768 dev->base_addr = (unsigned long) regs; 1924 dev->base_addr = (unsigned long) regs;
@@ -1831,7 +1987,8 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
1831 /* enable busmastering and memory-write-invalidate */ 1987 /* enable busmastering and memory-write-invalidate */
1832 pci_set_master(pdev); 1988 pci_set_master(pdev);
1833 1989
1834 if (cp->wol_enabled) cp_set_d3_state (cp); 1990 if (cp->wol_enabled)
1991 cp_set_d3_state (cp);
1835 1992
1836 return 0; 1993 return 0;
1837 1994
@@ -1856,7 +2013,8 @@ static void cp_remove_one (struct pci_dev *pdev)
1856 BUG_ON(!dev); 2013 BUG_ON(!dev);
1857 unregister_netdev(dev); 2014 unregister_netdev(dev);
1858 iounmap(cp->regs); 2015 iounmap(cp->regs);
1859 if (cp->wol_enabled) pci_set_power_state (pdev, PCI_D0); 2016 if (cp->wol_enabled)
2017 pci_set_power_state (pdev, PCI_D0);
1860 pci_release_regions(pdev); 2018 pci_release_regions(pdev);
1861 pci_clear_mwi(pdev); 2019 pci_clear_mwi(pdev);
1862 pci_disable_device(pdev); 2020 pci_disable_device(pdev);
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index abd6261465f1..e4f4eaff7679 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -93,7 +93,6 @@
93#define DRV_VERSION "0.9.27" 93#define DRV_VERSION "0.9.27"
94 94
95 95
96#include <linux/config.h>
97#include <linux/module.h> 96#include <linux/module.h>
98#include <linux/kernel.h> 97#include <linux/kernel.h>
99#include <linux/compiler.h> 98#include <linux/compiler.h>
@@ -769,7 +768,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
769 /* dev and priv zeroed in alloc_etherdev */ 768 /* dev and priv zeroed in alloc_etherdev */
770 dev = alloc_etherdev (sizeof (*tp)); 769 dev = alloc_etherdev (sizeof (*tp));
771 if (dev == NULL) { 770 if (dev == NULL) {
772 printk (KERN_ERR PFX "%s: Unable to alloc new net device\n", pci_name(pdev)); 771 dev_err(&pdev->dev, "Unable to alloc new net device\n");
773 return -ENOMEM; 772 return -ENOMEM;
774 } 773 }
775 SET_MODULE_OWNER(dev); 774 SET_MODULE_OWNER(dev);
@@ -801,31 +800,31 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
801#ifdef USE_IO_OPS 800#ifdef USE_IO_OPS
802 /* make sure PCI base addr 0 is PIO */ 801 /* make sure PCI base addr 0 is PIO */
803 if (!(pio_flags & IORESOURCE_IO)) { 802 if (!(pio_flags & IORESOURCE_IO)) {
804 printk (KERN_ERR PFX "%s: region #0 not a PIO resource, aborting\n", pci_name(pdev)); 803 dev_err(&pdev->dev, "region #0 not a PIO resource, aborting\n");
805 rc = -ENODEV; 804 rc = -ENODEV;
806 goto err_out; 805 goto err_out;
807 } 806 }
808 /* check for weird/broken PCI region reporting */ 807 /* check for weird/broken PCI region reporting */
809 if (pio_len < RTL_MIN_IO_SIZE) { 808 if (pio_len < RTL_MIN_IO_SIZE) {
810 printk (KERN_ERR PFX "%s: Invalid PCI I/O region size(s), aborting\n", pci_name(pdev)); 809 dev_err(&pdev->dev, "Invalid PCI I/O region size(s), aborting\n");
811 rc = -ENODEV; 810 rc = -ENODEV;
812 goto err_out; 811 goto err_out;
813 } 812 }
814#else 813#else
815 /* make sure PCI base addr 1 is MMIO */ 814 /* make sure PCI base addr 1 is MMIO */
816 if (!(mmio_flags & IORESOURCE_MEM)) { 815 if (!(mmio_flags & IORESOURCE_MEM)) {
817 printk (KERN_ERR PFX "%s: region #1 not an MMIO resource, aborting\n", pci_name(pdev)); 816 dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n");
818 rc = -ENODEV; 817 rc = -ENODEV;
819 goto err_out; 818 goto err_out;
820 } 819 }
821 if (mmio_len < RTL_MIN_IO_SIZE) { 820 if (mmio_len < RTL_MIN_IO_SIZE) {
822 printk (KERN_ERR PFX "%s: Invalid PCI mem region size(s), aborting\n", pci_name(pdev)); 821 dev_err(&pdev->dev, "Invalid PCI mem region size(s), aborting\n");
823 rc = -ENODEV; 822 rc = -ENODEV;
824 goto err_out; 823 goto err_out;
825 } 824 }
826#endif 825#endif
827 826
828 rc = pci_request_regions (pdev, "8139too"); 827 rc = pci_request_regions (pdev, DRV_NAME);
829 if (rc) 828 if (rc)
830 goto err_out; 829 goto err_out;
831 disable_dev_on_err = 1; 830 disable_dev_on_err = 1;
@@ -836,7 +835,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
836#ifdef USE_IO_OPS 835#ifdef USE_IO_OPS
837 ioaddr = ioport_map(pio_start, pio_len); 836 ioaddr = ioport_map(pio_start, pio_len);
838 if (!ioaddr) { 837 if (!ioaddr) {
839 printk (KERN_ERR PFX "%s: cannot map PIO, aborting\n", pci_name(pdev)); 838 dev_err(&pdev->dev, "cannot map PIO, aborting\n");
840 rc = -EIO; 839 rc = -EIO;
841 goto err_out; 840 goto err_out;
842 } 841 }
@@ -847,7 +846,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
847 /* ioremap MMIO region */ 846 /* ioremap MMIO region */
848 ioaddr = pci_iomap(pdev, 1, 0); 847 ioaddr = pci_iomap(pdev, 1, 0);
849 if (ioaddr == NULL) { 848 if (ioaddr == NULL) {
850 printk (KERN_ERR PFX "%s: cannot remap MMIO, aborting\n", pci_name(pdev)); 849 dev_err(&pdev->dev, "cannot remap MMIO, aborting\n");
851 rc = -EIO; 850 rc = -EIO;
852 goto err_out; 851 goto err_out;
853 } 852 }
@@ -861,8 +860,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
861 860
862 /* check for missing/broken hardware */ 861 /* check for missing/broken hardware */
863 if (RTL_R32 (TxConfig) == 0xFFFFFFFF) { 862 if (RTL_R32 (TxConfig) == 0xFFFFFFFF) {
864 printk (KERN_ERR PFX "%s: Chip not responding, ignoring board\n", 863 dev_err(&pdev->dev, "Chip not responding, ignoring board\n");
865 pci_name(pdev));
866 rc = -EIO; 864 rc = -EIO;
867 goto err_out; 865 goto err_out;
868 } 866 }
@@ -876,9 +874,10 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
876 } 874 }
877 875
878 /* if unknown chip, assume array element #0, original RTL-8139 in this case */ 876 /* if unknown chip, assume array element #0, original RTL-8139 in this case */
879 printk (KERN_DEBUG PFX "%s: unknown chip version, assuming RTL-8139\n", 877 dev_printk (KERN_DEBUG, &pdev->dev,
880 pci_name(pdev)); 878 "unknown chip version, assuming RTL-8139\n");
881 printk (KERN_DEBUG PFX "%s: TxConfig = 0x%lx\n", pci_name(pdev), RTL_R32 (TxConfig)); 879 dev_printk (KERN_DEBUG, &pdev->dev,
880 "TxConfig = 0x%lx\n", RTL_R32 (TxConfig));
882 tp->chipset = 0; 881 tp->chipset = 0;
883 882
884match: 883match:
@@ -955,9 +954,11 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
955 954
956 if (pdev->vendor == PCI_VENDOR_ID_REALTEK && 955 if (pdev->vendor == PCI_VENDOR_ID_REALTEK &&
957 pdev->device == PCI_DEVICE_ID_REALTEK_8139 && pci_rev >= 0x20) { 956 pdev->device == PCI_DEVICE_ID_REALTEK_8139 && pci_rev >= 0x20) {
958 printk(KERN_INFO PFX "pci dev %s (id %04x:%04x rev %02x) is an enhanced 8139C+ chip\n", 957 dev_info(&pdev->dev,
959 pci_name(pdev), pdev->vendor, pdev->device, pci_rev); 958 "This (id %04x:%04x rev %02x) is an enhanced 8139C+ chip\n",
960 printk(KERN_INFO PFX "Use the \"8139cp\" driver for improved performance and stability.\n"); 959 pdev->vendor, pdev->device, pci_rev);
960 dev_info(&pdev->dev,
961 "Use the \"8139cp\" driver for improved performance and stability.\n");
961 } 962 }
962 963
963 i = rtl8139_init_board (pdev, &dev); 964 i = rtl8139_init_board (pdev, &dev);
@@ -1311,7 +1312,7 @@ static int rtl8139_open (struct net_device *dev)
1311 int retval; 1312 int retval;
1312 void __iomem *ioaddr = tp->mmio_addr; 1313 void __iomem *ioaddr = tp->mmio_addr;
1313 1314
1314 retval = request_irq (dev->irq, rtl8139_interrupt, SA_SHIRQ, dev->name, dev); 1315 retval = request_irq (dev->irq, rtl8139_interrupt, IRQF_SHARED, dev->name, dev);
1315 if (retval) 1316 if (retval)
1316 return retval; 1317 return retval;
1317 1318
@@ -1341,9 +1342,9 @@ static int rtl8139_open (struct net_device *dev)
1341 netif_start_queue (dev); 1342 netif_start_queue (dev);
1342 1343
1343 if (netif_msg_ifup(tp)) 1344 if (netif_msg_ifup(tp))
1344 printk(KERN_DEBUG "%s: rtl8139_open() ioaddr %#lx IRQ %d" 1345 printk(KERN_DEBUG "%s: rtl8139_open() ioaddr %#llx IRQ %d"
1345 " GP Pins %2.2x %s-duplex.\n", 1346 " GP Pins %2.2x %s-duplex.\n", dev->name,
1346 dev->name, pci_resource_start (tp->pci_dev, 1), 1347 (unsigned long long)pci_resource_start (tp->pci_dev, 1),
1347 dev->irq, RTL_R8 (MediaStatus), 1348 dev->irq, RTL_R8 (MediaStatus),
1348 tp->mii.full_duplex ? "full" : "half"); 1349 tp->mii.full_duplex ? "full" : "half");
1349 1350
@@ -1708,6 +1709,7 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
1708 void __iomem *ioaddr = tp->mmio_addr; 1709 void __iomem *ioaddr = tp->mmio_addr;
1709 unsigned int entry; 1710 unsigned int entry;
1710 unsigned int len = skb->len; 1711 unsigned int len = skb->len;
1712 unsigned long flags;
1711 1713
1712 /* Calculate the next Tx descriptor entry. */ 1714 /* Calculate the next Tx descriptor entry. */
1713 entry = tp->cur_tx % NUM_TX_DESC; 1715 entry = tp->cur_tx % NUM_TX_DESC;
@@ -1724,7 +1726,7 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
1724 return 0; 1726 return 0;
1725 } 1727 }
1726 1728
1727 spin_lock_irq(&tp->lock); 1729 spin_lock_irqsave(&tp->lock, flags);
1728 RTL_W32_F (TxStatus0 + (entry * sizeof (u32)), 1730 RTL_W32_F (TxStatus0 + (entry * sizeof (u32)),
1729 tp->tx_flag | max(len, (unsigned int)ETH_ZLEN)); 1731 tp->tx_flag | max(len, (unsigned int)ETH_ZLEN));
1730 1732
@@ -1735,7 +1737,7 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
1735 1737
1736 if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx) 1738 if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)
1737 netif_stop_queue (dev); 1739 netif_stop_queue (dev);
1738 spin_unlock_irq(&tp->lock); 1740 spin_unlock_irqrestore(&tp->lock, flags);
1739 1741
1740 if (netif_msg_tx_queued(tp)) 1742 if (netif_msg_tx_queued(tp))
1741 printk (KERN_DEBUG "%s: Queued Tx packet size %u to slot %d.\n", 1743 printk (KERN_DEBUG "%s: Queued Tx packet size %u to slot %d.\n",
diff --git a/drivers/net/82596.c b/drivers/net/82596.c
index da0c878dcba8..7e2ca9571467 100644
--- a/drivers/net/82596.c
+++ b/drivers/net/82596.c
@@ -40,7 +40,6 @@
40 40
41 */ 41 */
42 42
43#include <linux/config.h>
44#include <linux/module.h> 43#include <linux/module.h>
45#include <linux/kernel.h> 44#include <linux/kernel.h>
46#include <linux/string.h> 45#include <linux/string.h>
@@ -1070,8 +1069,7 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
1070 skb->len, (unsigned int)skb->data)); 1069 skb->len, (unsigned int)skb->data));
1071 1070
1072 if (skb->len < ETH_ZLEN) { 1071 if (skb->len < ETH_ZLEN) {
1073 skb = skb_padto(skb, ETH_ZLEN); 1072 if (skb_padto(skb, ETH_ZLEN))
1074 if (skb == NULL)
1075 return 0; 1073 return 0;
1076 length = ETH_ZLEN; 1074 length = ETH_ZLEN;
1077 } 1075 }
diff --git a/drivers/net/8390.c b/drivers/net/8390.c
index f87027420081..d2935ae39814 100644
--- a/drivers/net/8390.c
+++ b/drivers/net/8390.c
@@ -249,7 +249,7 @@ void ei_tx_timeout(struct net_device *dev)
249 249
250 /* Ugly but a reset can be slow, yet must be protected */ 250 /* Ugly but a reset can be slow, yet must be protected */
251 251
252 disable_irq_nosync(dev->irq); 252 disable_irq_nosync_lockdep(dev->irq);
253 spin_lock(&ei_local->page_lock); 253 spin_lock(&ei_local->page_lock);
254 254
255 /* Try to restart the card. Perhaps the user has fixed something. */ 255 /* Try to restart the card. Perhaps the user has fixed something. */
@@ -257,7 +257,7 @@ void ei_tx_timeout(struct net_device *dev)
257 NS8390_init(dev, 1); 257 NS8390_init(dev, 1);
258 258
259 spin_unlock(&ei_local->page_lock); 259 spin_unlock(&ei_local->page_lock);
260 enable_irq(dev->irq); 260 enable_irq_lockdep(dev->irq);
261 netif_wake_queue(dev); 261 netif_wake_queue(dev);
262} 262}
263 263
@@ -275,12 +275,14 @@ static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
275 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev); 275 struct ei_device *ei_local = (struct ei_device *) netdev_priv(dev);
276 int send_length = skb->len, output_page; 276 int send_length = skb->len, output_page;
277 unsigned long flags; 277 unsigned long flags;
278 char buf[ETH_ZLEN];
279 char *data = skb->data;
278 280
279 if (skb->len < ETH_ZLEN) { 281 if (skb->len < ETH_ZLEN) {
280 skb = skb_padto(skb, ETH_ZLEN); 282 memset(buf, 0, ETH_ZLEN); /* more efficient than doing just the needed bits */
281 if (skb == NULL) 283 memcpy(buf, data, skb->len);
282 return 0;
283 send_length = ETH_ZLEN; 284 send_length = ETH_ZLEN;
285 data = buf;
284 } 286 }
285 287
286 /* Mask interrupts from the ethercard. 288 /* Mask interrupts from the ethercard.
@@ -347,7 +349,7 @@ static int ei_start_xmit(struct sk_buff *skb, struct net_device *dev)
347 * trigger the send later, upon receiving a Tx done interrupt. 349 * trigger the send later, upon receiving a Tx done interrupt.
348 */ 350 */
349 351
350 ei_block_output(dev, send_length, skb->data, output_page); 352 ei_block_output(dev, send_length, data, output_page);
351 353
352 if (! ei_local->txing) 354 if (! ei_local->txing)
353 { 355 {
diff --git a/drivers/net/8390.h b/drivers/net/8390.h
index 51e39dcd0603..a9a58f518f45 100644
--- a/drivers/net/8390.h
+++ b/drivers/net/8390.h
@@ -7,7 +7,6 @@
7#ifndef _8390_h 7#ifndef _8390_h
8#define _8390_h 8#define _8390_h
9 9
10#include <linux/config.h>
11#include <linux/if_ether.h> 10#include <linux/if_ether.h>
12#include <linux/ioport.h> 11#include <linux/ioport.h>
13#include <linux/skbuff.h> 12#include <linux/skbuff.h>
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 0c6b45a11d15..39189903e355 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -854,6 +854,17 @@ config SMC9194
854 <file:Documentation/networking/net-modules.txt>. The module 854 <file:Documentation/networking/net-modules.txt>. The module
855 will be called smc9194. 855 will be called smc9194.
856 856
857config NET_NETX
858 tristate "NetX Ethernet support"
859 select MII
860 depends on NET_ETHERNET && ARCH_NETX
861 help
862 This is support for the Hilscher netX builtin Ethernet ports
863
864 To compile this driver as a module, choose M here and read
865 <file:Documentation/networking/net-modules.txt>. The module
866 will be called netx-eth.
867
857config DM9000 868config DM9000
858 tristate "DM9000 support" 869 tristate "DM9000 support"
859 depends on (ARM || MIPS) && NET_ETHERNET 870 depends on (ARM || MIPS) && NET_ETHERNET
@@ -1376,8 +1387,8 @@ config APRICOT
1376 called apricot. 1387 called apricot.
1377 1388
1378config B44 1389config B44
1379 tristate "Broadcom 4400 ethernet support (EXPERIMENTAL)" 1390 tristate "Broadcom 4400 ethernet support"
1380 depends on NET_PCI && PCI && EXPERIMENTAL 1391 depends on NET_PCI && PCI
1381 select MII 1392 select MII
1382 help 1393 help
1383 If you have a network (Ethernet) controller of this type, say Y and 1394 If you have a network (Ethernet) controller of this type, say Y and
@@ -2190,7 +2201,7 @@ config BNX2
2190 2201
2191config SPIDER_NET 2202config SPIDER_NET
2192 tristate "Spider Gigabit Ethernet driver" 2203 tristate "Spider Gigabit Ethernet driver"
2193 depends on PCI && PPC_CELL 2204 depends on PCI && PPC_IBM_CELL_BLADE
2194 select FW_LOADER 2205 select FW_LOADER
2195 help 2206 help
2196 This driver supports the Gigabit Ethernet chips present on the 2207 This driver supports the Gigabit Ethernet chips present on the
@@ -2198,11 +2209,11 @@ config SPIDER_NET
2198 2209
2199config GIANFAR 2210config GIANFAR
2200 tristate "Gianfar Ethernet" 2211 tristate "Gianfar Ethernet"
2201 depends on 85xx || 83xx 2212 depends on 85xx || 83xx || PPC_86xx
2202 select PHYLIB 2213 select PHYLIB
2203 help 2214 help
2204 This driver supports the Gigabit TSEC on the MPC85xx 2215 This driver supports the Gigabit TSEC on the MPC83xx, MPC85xx,
2205 family of chips, and the FEC on the 8540 2216 and MPC86xx family of chips, and the FEC on the 8540.
2206 2217
2207config GFAR_NAPI 2218config GFAR_NAPI
2208 bool "NAPI Support" 2219 bool "NAPI Support"
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 1eced3287507..c91e95126f78 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -187,6 +187,7 @@ obj-$(CONFIG_MACSONIC) += macsonic.o
187obj-$(CONFIG_MACMACE) += macmace.o 187obj-$(CONFIG_MACMACE) += macmace.o
188obj-$(CONFIG_MAC89x0) += mac89x0.o 188obj-$(CONFIG_MAC89x0) += mac89x0.o
189obj-$(CONFIG_TUN) += tun.o 189obj-$(CONFIG_TUN) += tun.o
190obj-$(CONFIG_NET_NETX) += netx-eth.o
190obj-$(CONFIG_DL2K) += dl2k.o 191obj-$(CONFIG_DL2K) += dl2k.o
191obj-$(CONFIG_R8169) += r8169.o 192obj-$(CONFIG_R8169) += r8169.o
192obj-$(CONFIG_AMD8111_ETH) += amd8111e.o 193obj-$(CONFIG_AMD8111_ETH) += amd8111e.o
diff --git a/drivers/net/Space.c b/drivers/net/Space.c
index 60304f7e7e5b..a8c245a82261 100644
--- a/drivers/net/Space.c
+++ b/drivers/net/Space.c
@@ -27,7 +27,6 @@
27 * as published by the Free Software Foundation; either version 27 * as published by the Free Software Foundation; either version
28 * 2 of the License, or (at your option) any later version. 28 * 2 of the License, or (at your option) any later version.
29 */ 29 */
30#include <linux/config.h>
31#include <linux/netdevice.h> 30#include <linux/netdevice.h>
32#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
33#include <linux/trdevice.h> 32#include <linux/trdevice.h>
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c
index 79bb56b8dcef..f4ea62641acd 100644
--- a/drivers/net/a2065.c
+++ b/drivers/net/a2065.c
@@ -48,7 +48,6 @@
48#include <linux/skbuff.h> 48#include <linux/skbuff.h>
49#include <linux/slab.h> 49#include <linux/slab.h>
50#include <linux/string.h> 50#include <linux/string.h>
51#include <linux/config.h>
52#include <linux/init.h> 51#include <linux/init.h>
53#include <linux/crc32.h> 52#include <linux/crc32.h>
54#include <linux/zorro.h> 53#include <linux/zorro.h>
@@ -496,7 +495,7 @@ static int lance_open (struct net_device *dev)
496 ll->rdp = LE_C0_STOP; 495 ll->rdp = LE_C0_STOP;
497 496
498 /* Install the Interrupt handler */ 497 /* Install the Interrupt handler */
499 ret = request_irq(IRQ_AMIGA_PORTS, lance_interrupt, SA_SHIRQ, 498 ret = request_irq(IRQ_AMIGA_PORTS, lance_interrupt, IRQF_SHARED,
500 dev->name, dev); 499 dev->name, dev);
501 if (ret) return ret; 500 if (ret) return ret;
502 501
@@ -573,8 +572,7 @@ static int lance_start_xmit (struct sk_buff *skb, struct net_device *dev)
573 572
574 if (len < ETH_ZLEN) { 573 if (len < ETH_ZLEN) {
575 len = ETH_ZLEN; 574 len = ETH_ZLEN;
576 skb = skb_padto(skb, ETH_ZLEN); 575 if (skb_padto(skb, ETH_ZLEN))
577 if (skb == NULL)
578 return 0; 576 return 0;
579 } 577 }
580 578
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index b508812e97ac..1c01e9b3d07c 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -50,7 +50,6 @@
50 * Grant Grundler <grundler@cup.hp.com>: PCI write posting fixes. 50 * Grant Grundler <grundler@cup.hp.com>: PCI write posting fixes.
51 */ 51 */
52 52
53#include <linux/config.h>
54#include <linux/module.h> 53#include <linux/module.h>
55#include <linux/moduleparam.h> 54#include <linux/moduleparam.h>
56#include <linux/version.h> 55#include <linux/version.h>
@@ -579,11 +578,7 @@ static int __devinit acenic_probe_one(struct pci_dev *pdev,
579 } 578 }
580 579
581 printk("Gigabit Ethernet at 0x%08lx, ", dev->base_addr); 580 printk("Gigabit Ethernet at 0x%08lx, ", dev->base_addr);
582#ifdef __sparc__ 581 printk("irq %d\n", pdev->irq);
583 printk("irq %s\n", __irq_itoa(pdev->irq));
584#else
585 printk("irq %i\n", pdev->irq);
586#endif
587 582
588#ifdef CONFIG_ACENIC_OMIT_TIGON_I 583#ifdef CONFIG_ACENIC_OMIT_TIGON_I
589 if ((readl(&ap->regs->HostCtrl) >> 28) == 4) { 584 if ((readl(&ap->regs->HostCtrl) >> 28) == 4) {
@@ -1199,7 +1194,7 @@ static int __devinit ace_init(struct net_device *dev)
1199 goto init_error; 1194 goto init_error;
1200 } 1195 }
1201 1196
1202 ecode = request_irq(pdev->irq, ace_interrupt, SA_SHIRQ, 1197 ecode = request_irq(pdev->irq, ace_interrupt, IRQF_SHARED,
1203 DRV_NAME, dev); 1198 DRV_NAME, dev);
1204 if (ecode) { 1199 if (ecode) {
1205 printk(KERN_WARNING "%s: Requested IRQ %d is busy\n", 1200 printk(KERN_WARNING "%s: Requested IRQ %d is busy\n",
diff --git a/drivers/net/acenic.h b/drivers/net/acenic.h
index a97107023495..62ec8ceee698 100644
--- a/drivers/net/acenic.h
+++ b/drivers/net/acenic.h
@@ -1,7 +1,6 @@
1#ifndef _ACENIC_H_ 1#ifndef _ACENIC_H_
2#define _ACENIC_H_ 2#define _ACENIC_H_
3 3
4#include <linux/config.h>
5 4
6/* 5/*
7 * Generate TX index update each time, when TX ring is closed. 6 * Generate TX index update each time, when TX ring is closed.
diff --git a/drivers/net/acenic_firmware.h b/drivers/net/acenic_firmware.h
index d7882dd783c8..ec146f60d77b 100644
--- a/drivers/net/acenic_firmware.h
+++ b/drivers/net/acenic_firmware.h
@@ -1,4 +1,3 @@
1#include <linux/config.h>
2/* 1/*
3 * Declare these here even if Tigon I support is disabled to avoid 2 * Declare these here even if Tigon I support is disabled to avoid
4 * the compiler complaining about undefined symbols. 3 * the compiler complaining about undefined symbols.
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c
index d9ba8be72af8..ed322a76980d 100644
--- a/drivers/net/amd8111e.c
+++ b/drivers/net/amd8111e.c
@@ -69,7 +69,6 @@ Revision History:
69*/ 69*/
70 70
71 71
72#include <linux/config.h>
73#include <linux/module.h> 72#include <linux/module.h>
74#include <linux/kernel.h> 73#include <linux/kernel.h>
75#include <linux/types.h> 74#include <linux/types.h>
@@ -1377,7 +1376,7 @@ static int amd8111e_open(struct net_device * dev )
1377{ 1376{
1378 struct amd8111e_priv *lp = netdev_priv(dev); 1377 struct amd8111e_priv *lp = netdev_priv(dev);
1379 1378
1380 if(dev->irq ==0 || request_irq(dev->irq, amd8111e_interrupt, SA_SHIRQ, 1379 if(dev->irq ==0 || request_irq(dev->irq, amd8111e_interrupt, IRQF_SHARED,
1381 dev->name, dev)) 1380 dev->name, dev))
1382 return -EAGAIN; 1381 return -EAGAIN;
1383 1382
diff --git a/drivers/net/apne.c b/drivers/net/apne.c
index b9820b86cdcc..9cc13a0250d6 100644
--- a/drivers/net/apne.c
+++ b/drivers/net/apne.c
@@ -313,7 +313,7 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr)
313 dev->base_addr = ioaddr; 313 dev->base_addr = ioaddr;
314 314
315 /* Install the Interrupt handler */ 315 /* Install the Interrupt handler */
316 i = request_irq(IRQ_AMIGA_PORTS, apne_interrupt, SA_SHIRQ, DRV_NAME, dev); 316 i = request_irq(IRQ_AMIGA_PORTS, apne_interrupt, IRQF_SHARED, DRV_NAME, dev);
317 if (i) return i; 317 if (i) return i;
318 318
319 for(i = 0; i < ETHER_ADDR_LEN; i++) { 319 for(i = 0; i < ETHER_ADDR_LEN; i++) {
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index 9edaa183227a..1d01ac0000e4 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -48,7 +48,6 @@ static const char *version =
48 * the driver figure it out. 48 * the driver figure it out.
49 */ 49 */
50 50
51#include <linux/config.h>
52#include <linux/module.h> 51#include <linux/module.h>
53#include <linux/kernel.h> 52#include <linux/kernel.h>
54#include <linux/types.h> 53#include <linux/types.h>
diff --git a/drivers/net/appletalk/cops_ffdrv.h b/drivers/net/appletalk/cops_ffdrv.h
index 31cf8c9c947f..b02005087c1b 100644
--- a/drivers/net/appletalk/cops_ffdrv.h
+++ b/drivers/net/appletalk/cops_ffdrv.h
@@ -24,7 +24,6 @@
24 * - Jay Schulist <jschlst@samba.org> 24 * - Jay Schulist <jschlst@samba.org>
25 */ 25 */
26 26
27#include <linux/config.h>
28 27
29#ifdef CONFIG_COPS_DAYNA 28#ifdef CONFIG_COPS_DAYNA
30 29
diff --git a/drivers/net/appletalk/cops_ltdrv.h b/drivers/net/appletalk/cops_ltdrv.h
index 4afb8e18ba65..c699b1ad31da 100644
--- a/drivers/net/appletalk/cops_ltdrv.h
+++ b/drivers/net/appletalk/cops_ltdrv.h
@@ -23,7 +23,6 @@
23 * - Jay Schulist <jschlst@samba.org> 23 * - Jay Schulist <jschlst@samba.org>
24 */ 24 */
25 25
26#include <linux/config.h>
27 26
28#ifdef CONFIG_COPS_TANGENT 27#ifdef CONFIG_COPS_TANGENT
29 28
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c
index 1a44a79ed064..7f7dd450226a 100644
--- a/drivers/net/appletalk/ipddp.c
+++ b/drivers/net/appletalk/ipddp.c
@@ -23,7 +23,6 @@
23 * of the GNU General Public License, incorporated herein by reference. 23 * of the GNU General Public License, incorporated herein by reference.
24 */ 24 */
25 25
26#include <linux/config.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <linux/kernel.h> 27#include <linux/kernel.h>
29#include <linux/init.h> 28#include <linux/init.h>
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index fabc0607b0f1..5a95005253fa 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -44,7 +44,6 @@
44#define VERSION "arcnet: v3.93 BETA 2000/04/29 - by Avery Pennarun et al.\n" 44#define VERSION "arcnet: v3.93 BETA 2000/04/29 - by Avery Pennarun et al.\n"
45 45
46#include <linux/module.h> 46#include <linux/module.h>
47#include <linux/config.h>
48#include <linux/types.h> 47#include <linux/types.h>
49#include <linux/delay.h> 48#include <linux/delay.h>
50#include <linux/netdevice.h> 49#include <linux/netdevice.h>
diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index 96636ca8754e..979a33df0a8c 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -120,7 +120,7 @@ static int __devinit com20020pci_probe(struct pci_dev *pdev, const struct pci_de
120 goto out_port; 120 goto out_port;
121 } 121 }
122 122
123 if ((err = com20020_found(dev, SA_SHIRQ)) != 0) 123 if ((err = com20020_found(dev, IRQF_SHARED)) != 0)
124 goto out_port; 124 goto out_port;
125 125
126 return 0; 126 return 0;
diff --git a/drivers/net/ariadne.c b/drivers/net/ariadne.c
index d1b6b1f794e2..cc721addd576 100644
--- a/drivers/net/ariadne.c
+++ b/drivers/net/ariadne.c
@@ -320,7 +320,7 @@ static int ariadne_open(struct net_device *dev)
320 320
321 netif_start_queue(dev); 321 netif_start_queue(dev);
322 322
323 i = request_irq(IRQ_AMIGA_PORTS, ariadne_interrupt, SA_SHIRQ, 323 i = request_irq(IRQ_AMIGA_PORTS, ariadne_interrupt, IRQF_SHARED,
324 dev->name, dev); 324 dev->name, dev);
325 if (i) return i; 325 if (i) return i;
326 326
@@ -607,8 +607,7 @@ static int ariadne_start_xmit(struct sk_buff *skb, struct net_device *dev)
607 /* FIXME: is the 79C960 new enough to do its own padding right ? */ 607 /* FIXME: is the 79C960 new enough to do its own padding right ? */
608 if (skb->len < ETH_ZLEN) 608 if (skb->len < ETH_ZLEN)
609 { 609 {
610 skb = skb_padto(skb, ETH_ZLEN); 610 if (skb_padto(skb, ETH_ZLEN))
611 if (skb == NULL)
612 return 0; 611 return 0;
613 len = ETH_ZLEN; 612 len = ETH_ZLEN;
614 } 613 }
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index 5503dc8a66e4..85493b7b924f 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -19,7 +19,6 @@
19 19
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/config.h>
23#include <linux/mii.h> 22#include <linux/mii.h>
24#include <linux/netdevice.h> 23#include <linux/netdevice.h>
25#include <linux/etherdevice.h> 24#include <linux/etherdevice.h>
@@ -43,7 +42,9 @@
43#define DRV_VERSION "1.0" 42#define DRV_VERSION "1.0"
44 43
45static struct net_device *at91_dev; 44static struct net_device *at91_dev;
46static struct clk *ether_clk; 45
46static struct timer_list check_timer;
47#define LINK_POLL_INTERVAL (HZ)
47 48
48/* ..................................................................... */ 49/* ..................................................................... */
49 50
@@ -143,7 +144,7 @@ static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int
143 * MAC accordingly. 144 * MAC accordingly.
144 * If no link or auto-negotiation is busy, then no changes are made. 145 * If no link or auto-negotiation is busy, then no changes are made.
145 */ 146 */
146static void update_linkspeed(struct net_device *dev) 147static void update_linkspeed(struct net_device *dev, int silent)
147{ 148{
148 struct at91_private *lp = (struct at91_private *) dev->priv; 149 struct at91_private *lp = (struct at91_private *) dev->priv;
149 unsigned int bmsr, bmcr, lpa, mac_cfg; 150 unsigned int bmsr, bmcr, lpa, mac_cfg;
@@ -151,7 +152,8 @@ static void update_linkspeed(struct net_device *dev)
151 152
152 if (!mii_link_ok(&lp->mii)) { /* no link */ 153 if (!mii_link_ok(&lp->mii)) { /* no link */
153 netif_carrier_off(dev); 154 netif_carrier_off(dev);
154 printk(KERN_INFO "%s: Link down.\n", dev->name); 155 if (!silent)
156 printk(KERN_INFO "%s: Link down.\n", dev->name);
155 return; 157 return;
156 } 158 }
157 159
@@ -186,7 +188,8 @@ static void update_linkspeed(struct net_device *dev)
186 } 188 }
187 at91_emac_write(AT91_EMAC_CFG, mac_cfg); 189 at91_emac_write(AT91_EMAC_CFG, mac_cfg);
188 190
189 printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex"); 191 if (!silent)
192 printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex");
190 netif_carrier_on(dev); 193 netif_carrier_on(dev);
191} 194}
192 195
@@ -226,7 +229,7 @@ static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id, struct pt_regs
226 goto done; 229 goto done;
227 } 230 }
228 231
229 update_linkspeed(dev); 232 update_linkspeed(dev, 0);
230 233
231done: 234done:
232 disable_mdi(); 235 disable_mdi();
@@ -243,14 +246,17 @@ static void enable_phyirq(struct net_device *dev)
243 unsigned int dsintr, irq_number; 246 unsigned int dsintr, irq_number;
244 int status; 247 int status;
245 248
246 if (lp->phy_type == MII_RTL8201_ID) /* RTL8201 does not have an interrupt */ 249 irq_number = lp->board_data.phy_irq_pin;
247 return; 250 if (!irq_number) {
248 if (lp->phy_type == MII_DP83847_ID) /* DP83847 does not have an interrupt */ 251 /*
249 return; 252 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
250 if (lp->phy_type == MII_AC101L_ID) /* AC101L interrupt not supported yet */ 253 * or board does not have it connected.
254 */
255 check_timer.expires = jiffies + LINK_POLL_INTERVAL;
256 add_timer(&check_timer);
251 return; 257 return;
258 }
252 259
253 irq_number = lp->board_data.phy_irq_pin;
254 status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev); 260 status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev);
255 if (status) { 261 if (status) {
256 printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status); 262 printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status);
@@ -292,12 +298,11 @@ static void disable_phyirq(struct net_device *dev)
292 unsigned int dsintr; 298 unsigned int dsintr;
293 unsigned int irq_number; 299 unsigned int irq_number;
294 300
295 if (lp->phy_type == MII_RTL8201_ID) /* RTL8201 does not have an interrupt */ 301 irq_number = lp->board_data.phy_irq_pin;
296 return; 302 if (!irq_number) {
297 if (lp->phy_type == MII_DP83847_ID) /* DP83847 does not have an interrupt */ 303 del_timer_sync(&check_timer);
298 return;
299 if (lp->phy_type == MII_AC101L_ID) /* AC101L interrupt not supported yet */
300 return; 304 return;
305 }
301 306
302 spin_lock_irq(&lp->lock); 307 spin_lock_irq(&lp->lock);
303 enable_mdi(); 308 enable_mdi();
@@ -326,7 +331,6 @@ static void disable_phyirq(struct net_device *dev)
326 disable_mdi(); 331 disable_mdi();
327 spin_unlock_irq(&lp->lock); 332 spin_unlock_irq(&lp->lock);
328 333
329 irq_number = lp->board_data.phy_irq_pin;
330 free_irq(irq_number, dev); /* Free interrupt handler */ 334 free_irq(irq_number, dev); /* Free interrupt handler */
331} 335}
332 336
@@ -355,6 +359,18 @@ static void reset_phy(struct net_device *dev)
355} 359}
356#endif 360#endif
357 361
362static void at91ether_check_link(unsigned long dev_id)
363{
364 struct net_device *dev = (struct net_device *) dev_id;
365
366 enable_mdi();
367 update_linkspeed(dev, 1);
368 disable_mdi();
369
370 check_timer.expires = jiffies + LINK_POLL_INTERVAL;
371 add_timer(&check_timer);
372}
373
358/* ......................... ADDRESS MANAGEMENT ........................ */ 374/* ......................... ADDRESS MANAGEMENT ........................ */
359 375
360/* 376/*
@@ -501,7 +517,7 @@ static int hash_get_index(__u8 *addr)
501 hash_index |= (bitval << j); 517 hash_index |= (bitval << j);
502 } 518 }
503 519
504 return hash_index; 520 return hash_index;
505} 521}
506 522
507/* 523/*
@@ -557,10 +573,8 @@ static void at91ether_set_rx_mode(struct net_device *dev)
557 at91_emac_write(AT91_EMAC_CFG, cfg); 573 at91_emac_write(AT91_EMAC_CFG, cfg);
558} 574}
559 575
560
561/* ......................... ETHTOOL SUPPORT ........................... */ 576/* ......................... ETHTOOL SUPPORT ........................... */
562 577
563
564static int mdio_read(struct net_device *dev, int phy_id, int location) 578static int mdio_read(struct net_device *dev, int phy_id, int location)
565{ 579{
566 unsigned int value; 580 unsigned int value;
@@ -642,6 +656,22 @@ static struct ethtool_ops at91ether_ethtool_ops = {
642 .get_link = ethtool_op_get_link, 656 .get_link = ethtool_op_get_link,
643}; 657};
644 658
659static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
660{
661 struct at91_private *lp = (struct at91_private *) dev->priv;
662 int res;
663
664 if (!netif_running(dev))
665 return -EINVAL;
666
667 spin_lock_irq(&lp->lock);
668 enable_mdi();
669 res = generic_mii_ioctl(&lp->mii, if_mii(rq), cmd, NULL);
670 disable_mdi();
671 spin_unlock_irq(&lp->lock);
672
673 return res;
674}
645 675
646/* ................................ MAC ................................ */ 676/* ................................ MAC ................................ */
647 677
@@ -685,10 +715,10 @@ static int at91ether_open(struct net_device *dev)
685 struct at91_private *lp = (struct at91_private *) dev->priv; 715 struct at91_private *lp = (struct at91_private *) dev->priv;
686 unsigned long ctl; 716 unsigned long ctl;
687 717
688 if (!is_valid_ether_addr(dev->dev_addr)) 718 if (!is_valid_ether_addr(dev->dev_addr))
689 return -EADDRNOTAVAIL; 719 return -EADDRNOTAVAIL;
690 720
691 clk_enable(ether_clk); /* Re-enable Peripheral clock */ 721 clk_enable(lp->ether_clk); /* Re-enable Peripheral clock */
692 722
693 /* Clear internal statistics */ 723 /* Clear internal statistics */
694 ctl = at91_emac_read(AT91_EMAC_CTL); 724 ctl = at91_emac_read(AT91_EMAC_CTL);
@@ -708,7 +738,7 @@ static int at91ether_open(struct net_device *dev)
708 /* Determine current link speed */ 738 /* Determine current link speed */
709 spin_lock_irq(&lp->lock); 739 spin_lock_irq(&lp->lock);
710 enable_mdi(); 740 enable_mdi();
711 update_linkspeed(dev); 741 update_linkspeed(dev, 0);
712 disable_mdi(); 742 disable_mdi();
713 spin_unlock_irq(&lp->lock); 743 spin_unlock_irq(&lp->lock);
714 744
@@ -722,6 +752,7 @@ static int at91ether_open(struct net_device *dev)
722 */ 752 */
723static int at91ether_close(struct net_device *dev) 753static int at91ether_close(struct net_device *dev)
724{ 754{
755 struct at91_private *lp = (struct at91_private *) dev->priv;
725 unsigned long ctl; 756 unsigned long ctl;
726 757
727 /* Disable Receiver and Transmitter */ 758 /* Disable Receiver and Transmitter */
@@ -738,7 +769,7 @@ static int at91ether_close(struct net_device *dev)
738 769
739 netif_stop_queue(dev); 770 netif_stop_queue(dev);
740 771
741 clk_disable(ether_clk); /* Disable Peripheral clock */ 772 clk_disable(lp->ether_clk); /* Disable Peripheral clock */
742 773
743 return 0; 774 return 0;
744} 775}
@@ -870,7 +901,7 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *re
870 if (intstatus & AT91_EMAC_RCOM) /* Receive complete */ 901 if (intstatus & AT91_EMAC_RCOM) /* Receive complete */
871 at91ether_rx(dev); 902 at91ether_rx(dev);
872 903
873 if (intstatus & AT91_EMAC_TCOM) { /* Transmit complete */ 904 if (intstatus & AT91_EMAC_TCOM) { /* Transmit complete */
874 /* The TCOM bit is set even if the transmission failed. */ 905 /* The TCOM bit is set even if the transmission failed. */
875 if (intstatus & (AT91_EMAC_TUND | AT91_EMAC_RTRY)) 906 if (intstatus & (AT91_EMAC_TUND | AT91_EMAC_RTRY))
876 lp->stats.tx_errors += 1; 907 lp->stats.tx_errors += 1;
@@ -899,7 +930,8 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *re
899/* 930/*
900 * Initialize the ethernet interface 931 * Initialize the ethernet interface
901 */ 932 */
902static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, struct platform_device *pdev) 933static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address,
934 struct platform_device *pdev, struct clk *ether_clk)
903{ 935{
904 struct at91_eth_data *board_data = pdev->dev.platform_data; 936 struct at91_eth_data *board_data = pdev->dev.platform_data;
905 struct net_device *dev; 937 struct net_device *dev;
@@ -933,6 +965,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
933 return -ENOMEM; 965 return -ENOMEM;
934 } 966 }
935 lp->board_data = *board_data; 967 lp->board_data = *board_data;
968 lp->ether_clk = ether_clk;
936 platform_set_drvdata(pdev, dev); 969 platform_set_drvdata(pdev, dev);
937 970
938 spin_lock_init(&lp->lock); 971 spin_lock_init(&lp->lock);
@@ -945,6 +978,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
945 dev->set_multicast_list = at91ether_set_rx_mode; 978 dev->set_multicast_list = at91ether_set_rx_mode;
946 dev->set_mac_address = set_mac_address; 979 dev->set_mac_address = set_mac_address;
947 dev->ethtool_ops = &at91ether_ethtool_ops; 980 dev->ethtool_ops = &at91ether_ethtool_ops;
981 dev->do_ioctl = at91ether_ioctl;
948 982
949 SET_NETDEV_DEV(dev, &pdev->dev); 983 SET_NETDEV_DEV(dev, &pdev->dev);
950 984
@@ -975,6 +1009,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
975 lp->mii.dev = dev; /* Support for ethtool */ 1009 lp->mii.dev = dev; /* Support for ethtool */
976 lp->mii.mdio_read = mdio_read; 1010 lp->mii.mdio_read = mdio_read;
977 lp->mii.mdio_write = mdio_write; 1011 lp->mii.mdio_write = mdio_write;
1012 lp->mii.phy_id = phy_address;
1013 lp->mii.phy_id_mask = 0x1f;
1014 lp->mii.reg_num_mask = 0x1f;
978 1015
979 lp->phy_type = phy_type; /* Type of PHY connected */ 1016 lp->phy_type = phy_type; /* Type of PHY connected */
980 lp->phy_address = phy_address; /* MDI address of PHY */ 1017 lp->phy_address = phy_address; /* MDI address of PHY */
@@ -992,11 +1029,18 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
992 /* Determine current link speed */ 1029 /* Determine current link speed */
993 spin_lock_irq(&lp->lock); 1030 spin_lock_irq(&lp->lock);
994 enable_mdi(); 1031 enable_mdi();
995 update_linkspeed(dev); 1032 update_linkspeed(dev, 0);
996 disable_mdi(); 1033 disable_mdi();
997 spin_unlock_irq(&lp->lock); 1034 spin_unlock_irq(&lp->lock);
998 netif_carrier_off(dev); /* will be enabled in open() */ 1035 netif_carrier_off(dev); /* will be enabled in open() */
999 1036
1037 /* If board has no PHY IRQ, use a timer to poll the PHY */
1038 if (!lp->board_data.phy_irq_pin) {
1039 init_timer(&check_timer);
1040 check_timer.data = (unsigned long)dev;
1041 check_timer.function = at91ether_check_link;
1042 }
1043
1000 /* Display ethernet banner */ 1044 /* Display ethernet banner */
1001 printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%02x:%02x:%02x:%02x:%02x:%02x)\n", 1045 printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%02x:%02x:%02x:%02x:%02x:%02x)\n",
1002 dev->name, (uint) dev->base_addr, dev->irq, 1046 dev->name, (uint) dev->base_addr, dev->irq,
@@ -1005,7 +1049,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1005 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], 1049 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
1006 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); 1050 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
1007 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) 1051 if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID))
1008 printk(KERN_INFO "%s: Davicom 9196 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)"); 1052 printk(KERN_INFO "%s: Davicom 9161 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)");
1009 else if (phy_type == MII_LXT971A_ID) 1053 else if (phy_type == MII_LXT971A_ID)
1010 printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name); 1054 printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name);
1011 else if (phy_type == MII_RTL8201_ID) 1055 else if (phy_type == MII_RTL8201_ID)
@@ -1031,9 +1075,10 @@ static int __init at91ether_probe(struct platform_device *pdev)
1031 int detected = -1; 1075 int detected = -1;
1032 unsigned long phy_id; 1076 unsigned long phy_id;
1033 unsigned short phy_address = 0; 1077 unsigned short phy_address = 0;
1078 struct clk *ether_clk;
1034 1079
1035 ether_clk = clk_get(&pdev->dev, "ether_clk"); 1080 ether_clk = clk_get(&pdev->dev, "ether_clk");
1036 if (!ether_clk) { 1081 if (IS_ERR(ether_clk)) {
1037 printk(KERN_ERR "at91_ether: no clock defined\n"); 1082 printk(KERN_ERR "at91_ether: no clock defined\n");
1038 return -ENODEV; 1083 return -ENODEV;
1039 } 1084 }
@@ -1056,7 +1101,7 @@ static int __init at91ether_probe(struct platform_device *pdev)
1056 case MII_DP83847_ID: /* National Semiconductor DP83847: */ 1101 case MII_DP83847_ID: /* National Semiconductor DP83847: */
1057 case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */ 1102 case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */
1058 case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */ 1103 case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */
1059 detected = at91ether_setup(phy_id, phy_address, pdev); 1104 detected = at91ether_setup(phy_id, phy_address, pdev, ether_clk);
1060 break; 1105 break;
1061 } 1106 }
1062 1107
@@ -1075,17 +1120,61 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
1075 unregister_netdev(at91_dev); 1120 unregister_netdev(at91_dev);
1076 free_irq(at91_dev->irq, at91_dev); 1121 free_irq(at91_dev->irq, at91_dev);
1077 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); 1122 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1078 clk_put(ether_clk); 1123 clk_put(lp->ether_clk);
1079 1124
1080 free_netdev(at91_dev); 1125 free_netdev(at91_dev);
1081 at91_dev = NULL; 1126 at91_dev = NULL;
1082 return 0; 1127 return 0;
1083} 1128}
1084 1129
1130#ifdef CONFIG_PM
1131
1132static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
1133{
1134 struct at91_private *lp = (struct at91_private *) at91_dev->priv;
1135 struct net_device *net_dev = platform_get_drvdata(pdev);
1136 int phy_irq = lp->board_data.phy_irq_pin;
1137
1138 if (netif_running(net_dev)) {
1139 if (phy_irq)
1140 disable_irq(phy_irq);
1141
1142 netif_stop_queue(net_dev);
1143 netif_device_detach(net_dev);
1144
1145 clk_disable(lp->ether_clk);
1146 }
1147 return 0;
1148}
1149
1150static int at91ether_resume(struct platform_device *pdev)
1151{
1152 struct at91_private *lp = (struct at91_private *) at91_dev->priv;
1153 struct net_device *net_dev = platform_get_drvdata(pdev);
1154 int phy_irq = lp->board_data.phy_irq_pin;
1155
1156 if (netif_running(net_dev)) {
1157 clk_enable(lp->ether_clk);
1158
1159 netif_device_attach(net_dev);
1160 netif_start_queue(net_dev);
1161
1162 if (phy_irq)
1163 enable_irq(phy_irq);
1164 }
1165 return 0;
1166}
1167
1168#else
1169#define at91ether_suspend NULL
1170#define at91ether_resume NULL
1171#endif
1172
1085static struct platform_driver at91ether_driver = { 1173static struct platform_driver at91ether_driver = {
1086 .probe = at91ether_probe, 1174 .probe = at91ether_probe,
1087 .remove = __devexit_p(at91ether_remove), 1175 .remove = __devexit_p(at91ether_remove),
1088 /* FIXME: support suspend and resume */ 1176 .suspend = at91ether_suspend,
1177 .resume = at91ether_resume,
1089 .driver = { 1178 .driver = {
1090 .name = DRV_NAME, 1179 .name = DRV_NAME,
1091 .owner = THIS_MODULE, 1180 .owner = THIS_MODULE,
diff --git a/drivers/net/arm/at91_ether.h b/drivers/net/arm/at91_ether.h
index 9885735c9c8a..d1e72e02be3a 100644
--- a/drivers/net/arm/at91_ether.h
+++ b/drivers/net/arm/at91_ether.h
@@ -80,6 +80,7 @@ struct at91_private
80 struct net_device_stats stats; 80 struct net_device_stats stats;
81 struct mii_if_info mii; /* ethtool support */ 81 struct mii_if_info mii; /* ethtool support */
82 struct at91_eth_data board_data; /* board-specific configuration */ 82 struct at91_eth_data board_data; /* board-specific configuration */
83 struct clk *ether_clk; /* clock */
83 84
84 /* PHY */ 85 /* PHY */
85 unsigned long phy_type; /* type of PHY (PHY_ID) */ 86 unsigned long phy_type; /* type of PHY (PHY_ID) */
diff --git a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c
index 36475eb2727f..312955d07b28 100644
--- a/drivers/net/arm/ether1.c
+++ b/drivers/net/arm/ether1.c
@@ -700,8 +700,7 @@ ether1_sendpacket (struct sk_buff *skb, struct net_device *dev)
700 } 700 }
701 701
702 if (skb->len < ETH_ZLEN) { 702 if (skb->len < ETH_ZLEN) {
703 skb = skb_padto(skb, ETH_ZLEN); 703 if (skb_padto(skb, ETH_ZLEN))
704 if (skb == NULL)
705 goto out; 704 goto out;
706 } 705 }
707 706
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c
index f1d5b1027ff7..081074180e62 100644
--- a/drivers/net/arm/ether3.c
+++ b/drivers/net/arm/ether3.c
@@ -518,8 +518,7 @@ ether3_sendpacket(struct sk_buff *skb, struct net_device *dev)
518 518
519 length = (length + 1) & ~1; 519 length = (length + 1) & ~1;
520 if (length != skb->len) { 520 if (length != skb->len) {
521 skb = skb_padto(skb, length); 521 if (skb_padto(skb, length))
522 if (skb == NULL)
523 goto out; 522 goto out;
524 } 523 }
525 524
diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c
index e613cc289749..5d7929c79bce 100644
--- a/drivers/net/at1700.c
+++ b/drivers/net/at1700.c
@@ -35,7 +35,6 @@
35 response to inb()s from other device probes! 35 response to inb()s from other device probes!
36*/ 36*/
37 37
38#include <linux/config.h>
39#include <linux/errno.h> 38#include <linux/errno.h>
40#include <linux/netdevice.h> 39#include <linux/netdevice.h>
41#include <linux/etherdevice.h> 40#include <linux/etherdevice.h>
diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c
index 442b2cbeb58a..91783a8008be 100644
--- a/drivers/net/atarilance.c
+++ b/drivers/net/atarilance.c
@@ -804,8 +804,7 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev )
804 ++len; 804 ++len;
805 805
806 if (len > skb->len) { 806 if (len > skb->len) {
807 skb = skb_padto(skb, len); 807 if (skb_padto(skb, len))
808 if (skb == NULL)
809 return 0; 808 return 0;
810 } 809 }
811 810
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 038d5fcb15e6..55f6e3f65b53 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -35,7 +35,6 @@
35 * 35 *
36 */ 36 */
37 37
38#include <linux/config.h>
39#include <linux/module.h> 38#include <linux/module.h>
40#include <linux/kernel.h> 39#include <linux/kernel.h>
41#include <linux/sched.h> 40#include <linux/sched.h>
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index d8233e0b7899..bea0fc0ede2f 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -29,8 +29,8 @@
29 29
30#define DRV_MODULE_NAME "b44" 30#define DRV_MODULE_NAME "b44"
31#define PFX DRV_MODULE_NAME ": " 31#define PFX DRV_MODULE_NAME ": "
32#define DRV_MODULE_VERSION "1.00" 32#define DRV_MODULE_VERSION "1.01"
33#define DRV_MODULE_RELDATE "Apr 7, 2006" 33#define DRV_MODULE_RELDATE "Jun 16, 2006"
34 34
35#define B44_DEF_MSG_ENABLE \ 35#define B44_DEF_MSG_ENABLE \
36 (NETIF_MSG_DRV | \ 36 (NETIF_MSG_DRV | \
@@ -75,6 +75,15 @@
75/* minimum number of free TX descriptors required to wake up TX process */ 75/* minimum number of free TX descriptors required to wake up TX process */
76#define B44_TX_WAKEUP_THRESH (B44_TX_RING_SIZE / 4) 76#define B44_TX_WAKEUP_THRESH (B44_TX_RING_SIZE / 4)
77 77
78/* b44 internal pattern match filter info */
79#define B44_PATTERN_BASE 0x400
80#define B44_PATTERN_SIZE 0x80
81#define B44_PMASK_BASE 0x600
82#define B44_PMASK_SIZE 0x10
83#define B44_MAX_PATTERNS 16
84#define B44_ETHIPV6UDP_HLEN 62
85#define B44_ETHIPV4UDP_HLEN 42
86
78static char version[] __devinitdata = 87static char version[] __devinitdata =
79 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; 88 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
80 89
@@ -101,7 +110,7 @@ MODULE_DEVICE_TABLE(pci, b44_pci_tbl);
101 110
102static void b44_halt(struct b44 *); 111static void b44_halt(struct b44 *);
103static void b44_init_rings(struct b44 *); 112static void b44_init_rings(struct b44 *);
104static void b44_init_hw(struct b44 *); 113static void b44_init_hw(struct b44 *, int);
105 114
106static int dma_desc_align_mask; 115static int dma_desc_align_mask;
107static int dma_desc_sync_size; 116static int dma_desc_sync_size;
@@ -873,7 +882,7 @@ static int b44_poll(struct net_device *netdev, int *budget)
873 spin_lock_irq(&bp->lock); 882 spin_lock_irq(&bp->lock);
874 b44_halt(bp); 883 b44_halt(bp);
875 b44_init_rings(bp); 884 b44_init_rings(bp);
876 b44_init_hw(bp); 885 b44_init_hw(bp, 1);
877 netif_wake_queue(bp->dev); 886 netif_wake_queue(bp->dev);
878 spin_unlock_irq(&bp->lock); 887 spin_unlock_irq(&bp->lock);
879 done = 1; 888 done = 1;
@@ -942,7 +951,7 @@ static void b44_tx_timeout(struct net_device *dev)
942 951
943 b44_halt(bp); 952 b44_halt(bp);
944 b44_init_rings(bp); 953 b44_init_rings(bp);
945 b44_init_hw(bp); 954 b44_init_hw(bp, 1);
946 955
947 spin_unlock_irq(&bp->lock); 956 spin_unlock_irq(&bp->lock);
948 957
@@ -1059,7 +1068,7 @@ static int b44_change_mtu(struct net_device *dev, int new_mtu)
1059 b44_halt(bp); 1068 b44_halt(bp);
1060 dev->mtu = new_mtu; 1069 dev->mtu = new_mtu;
1061 b44_init_rings(bp); 1070 b44_init_rings(bp);
1062 b44_init_hw(bp); 1071 b44_init_hw(bp, 1);
1063 spin_unlock_irq(&bp->lock); 1072 spin_unlock_irq(&bp->lock);
1064 1073
1065 b44_enable_ints(bp); 1074 b44_enable_ints(bp);
@@ -1356,13 +1365,15 @@ static int b44_set_mac_addr(struct net_device *dev, void *p)
1356 * packet processing. Invoked with bp->lock held. 1365 * packet processing. Invoked with bp->lock held.
1357 */ 1366 */
1358static void __b44_set_rx_mode(struct net_device *); 1367static void __b44_set_rx_mode(struct net_device *);
1359static void b44_init_hw(struct b44 *bp) 1368static void b44_init_hw(struct b44 *bp, int full_reset)
1360{ 1369{
1361 u32 val; 1370 u32 val;
1362 1371
1363 b44_chip_reset(bp); 1372 b44_chip_reset(bp);
1364 b44_phy_reset(bp); 1373 if (full_reset) {
1365 b44_setup_phy(bp); 1374 b44_phy_reset(bp);
1375 b44_setup_phy(bp);
1376 }
1366 1377
1367 /* Enable CRC32, set proper LED modes and power on PHY */ 1378 /* Enable CRC32, set proper LED modes and power on PHY */
1368 bw32(bp, B44_MAC_CTRL, MAC_CTRL_CRC32_ENAB | MAC_CTRL_PHY_LEDCTRL); 1379 bw32(bp, B44_MAC_CTRL, MAC_CTRL_CRC32_ENAB | MAC_CTRL_PHY_LEDCTRL);
@@ -1376,16 +1387,21 @@ static void b44_init_hw(struct b44 *bp)
1376 bw32(bp, B44_TXMAXLEN, bp->dev->mtu + ETH_HLEN + 8 + RX_HEADER_LEN); 1387 bw32(bp, B44_TXMAXLEN, bp->dev->mtu + ETH_HLEN + 8 + RX_HEADER_LEN);
1377 1388
1378 bw32(bp, B44_TX_WMARK, 56); /* XXX magic */ 1389 bw32(bp, B44_TX_WMARK, 56); /* XXX magic */
1379 bw32(bp, B44_DMATX_CTRL, DMATX_CTRL_ENABLE); 1390 if (full_reset) {
1380 bw32(bp, B44_DMATX_ADDR, bp->tx_ring_dma + bp->dma_offset); 1391 bw32(bp, B44_DMATX_CTRL, DMATX_CTRL_ENABLE);
1381 bw32(bp, B44_DMARX_CTRL, (DMARX_CTRL_ENABLE | 1392 bw32(bp, B44_DMATX_ADDR, bp->tx_ring_dma + bp->dma_offset);
1382 (bp->rx_offset << DMARX_CTRL_ROSHIFT))); 1393 bw32(bp, B44_DMARX_CTRL, (DMARX_CTRL_ENABLE |
1383 bw32(bp, B44_DMARX_ADDR, bp->rx_ring_dma + bp->dma_offset); 1394 (bp->rx_offset << DMARX_CTRL_ROSHIFT)));
1395 bw32(bp, B44_DMARX_ADDR, bp->rx_ring_dma + bp->dma_offset);
1384 1396
1385 bw32(bp, B44_DMARX_PTR, bp->rx_pending); 1397 bw32(bp, B44_DMARX_PTR, bp->rx_pending);
1386 bp->rx_prod = bp->rx_pending; 1398 bp->rx_prod = bp->rx_pending;
1387 1399
1388 bw32(bp, B44_MIB_CTRL, MIB_CTRL_CLR_ON_READ); 1400 bw32(bp, B44_MIB_CTRL, MIB_CTRL_CLR_ON_READ);
1401 } else {
1402 bw32(bp, B44_DMARX_CTRL, (DMARX_CTRL_ENABLE |
1403 (bp->rx_offset << DMARX_CTRL_ROSHIFT)));
1404 }
1389 1405
1390 val = br32(bp, B44_ENET_CTRL); 1406 val = br32(bp, B44_ENET_CTRL);
1391 bw32(bp, B44_ENET_CTRL, (val | ENET_CTRL_ENABLE)); 1407 bw32(bp, B44_ENET_CTRL, (val | ENET_CTRL_ENABLE));
@@ -1401,11 +1417,11 @@ static int b44_open(struct net_device *dev)
1401 goto out; 1417 goto out;
1402 1418
1403 b44_init_rings(bp); 1419 b44_init_rings(bp);
1404 b44_init_hw(bp); 1420 b44_init_hw(bp, 1);
1405 1421
1406 b44_check_phy(bp); 1422 b44_check_phy(bp);
1407 1423
1408 err = request_irq(dev->irq, b44_interrupt, SA_SHIRQ, dev->name, dev); 1424 err = request_irq(dev->irq, b44_interrupt, IRQF_SHARED, dev->name, dev);
1409 if (unlikely(err < 0)) { 1425 if (unlikely(err < 0)) {
1410 b44_chip_reset(bp); 1426 b44_chip_reset(bp);
1411 b44_free_rings(bp); 1427 b44_free_rings(bp);
@@ -1450,6 +1466,140 @@ static void b44_poll_controller(struct net_device *dev)
1450} 1466}
1451#endif 1467#endif
1452 1468
1469static void bwfilter_table(struct b44 *bp, u8 *pp, u32 bytes, u32 table_offset)
1470{
1471 u32 i;
1472 u32 *pattern = (u32 *) pp;
1473
1474 for (i = 0; i < bytes; i += sizeof(u32)) {
1475 bw32(bp, B44_FILT_ADDR, table_offset + i);
1476 bw32(bp, B44_FILT_DATA, pattern[i / sizeof(u32)]);
1477 }
1478}
1479
1480static int b44_magic_pattern(u8 *macaddr, u8 *ppattern, u8 *pmask, int offset)
1481{
1482 int magicsync = 6;
1483 int k, j, len = offset;
1484 int ethaddr_bytes = ETH_ALEN;
1485
1486 memset(ppattern + offset, 0xff, magicsync);
1487 for (j = 0; j < magicsync; j++)
1488 set_bit(len++, (unsigned long *) pmask);
1489
1490 for (j = 0; j < B44_MAX_PATTERNS; j++) {
1491 if ((B44_PATTERN_SIZE - len) >= ETH_ALEN)
1492 ethaddr_bytes = ETH_ALEN;
1493 else
1494 ethaddr_bytes = B44_PATTERN_SIZE - len;
1495 if (ethaddr_bytes <=0)
1496 break;
1497 for (k = 0; k< ethaddr_bytes; k++) {
1498 ppattern[offset + magicsync +
1499 (j * ETH_ALEN) + k] = macaddr[k];
1500 len++;
1501 set_bit(len, (unsigned long *) pmask);
1502 }
1503 }
1504 return len - 1;
1505}
1506
1507/* Setup magic packet patterns in the b44 WOL
1508 * pattern matching filter.
1509 */
1510static void b44_setup_pseudo_magicp(struct b44 *bp)
1511{
1512
1513 u32 val;
1514 int plen0, plen1, plen2;
1515 u8 *pwol_pattern;
1516 u8 pwol_mask[B44_PMASK_SIZE];
1517
1518 pwol_pattern = kmalloc(B44_PATTERN_SIZE, GFP_KERNEL);
1519 if (!pwol_pattern) {
1520 printk(KERN_ERR PFX "Memory not available for WOL\n");
1521 return;
1522 }
1523
1524 /* Ipv4 magic packet pattern - pattern 0.*/
1525 memset(pwol_pattern, 0, B44_PATTERN_SIZE);
1526 memset(pwol_mask, 0, B44_PMASK_SIZE);
1527 plen0 = b44_magic_pattern(bp->dev->dev_addr, pwol_pattern, pwol_mask,
1528 B44_ETHIPV4UDP_HLEN);
1529
1530 bwfilter_table(bp, pwol_pattern, B44_PATTERN_SIZE, B44_PATTERN_BASE);
1531 bwfilter_table(bp, pwol_mask, B44_PMASK_SIZE, B44_PMASK_BASE);
1532
1533 /* Raw ethernet II magic packet pattern - pattern 1 */
1534 memset(pwol_pattern, 0, B44_PATTERN_SIZE);
1535 memset(pwol_mask, 0, B44_PMASK_SIZE);
1536 plen1 = b44_magic_pattern(bp->dev->dev_addr, pwol_pattern, pwol_mask,
1537 ETH_HLEN);
1538
1539 bwfilter_table(bp, pwol_pattern, B44_PATTERN_SIZE,
1540 B44_PATTERN_BASE + B44_PATTERN_SIZE);
1541 bwfilter_table(bp, pwol_mask, B44_PMASK_SIZE,
1542 B44_PMASK_BASE + B44_PMASK_SIZE);
1543
1544 /* Ipv6 magic packet pattern - pattern 2 */
1545 memset(pwol_pattern, 0, B44_PATTERN_SIZE);
1546 memset(pwol_mask, 0, B44_PMASK_SIZE);
1547 plen2 = b44_magic_pattern(bp->dev->dev_addr, pwol_pattern, pwol_mask,
1548 B44_ETHIPV6UDP_HLEN);
1549
1550 bwfilter_table(bp, pwol_pattern, B44_PATTERN_SIZE,
1551 B44_PATTERN_BASE + B44_PATTERN_SIZE + B44_PATTERN_SIZE);
1552 bwfilter_table(bp, pwol_mask, B44_PMASK_SIZE,
1553 B44_PMASK_BASE + B44_PMASK_SIZE + B44_PMASK_SIZE);
1554
1555 kfree(pwol_pattern);
1556
1557 /* set these pattern's lengths: one less than each real length */
1558 val = plen0 | (plen1 << 8) | (plen2 << 16) | WKUP_LEN_ENABLE_THREE;
1559 bw32(bp, B44_WKUP_LEN, val);
1560
1561 /* enable wakeup pattern matching */
1562 val = br32(bp, B44_DEVCTRL);
1563 bw32(bp, B44_DEVCTRL, val | DEVCTRL_PFE);
1564
1565}
1566
1567static void b44_setup_wol(struct b44 *bp)
1568{
1569 u32 val;
1570 u16 pmval;
1571
1572 bw32(bp, B44_RXCONFIG, RXCONFIG_ALLMULTI);
1573
1574 if (bp->flags & B44_FLAG_B0_ANDLATER) {
1575
1576 bw32(bp, B44_WKUP_LEN, WKUP_LEN_DISABLE);
1577
1578 val = bp->dev->dev_addr[2] << 24 |
1579 bp->dev->dev_addr[3] << 16 |
1580 bp->dev->dev_addr[4] << 8 |
1581 bp->dev->dev_addr[5];
1582 bw32(bp, B44_ADDR_LO, val);
1583
1584 val = bp->dev->dev_addr[0] << 8 |
1585 bp->dev->dev_addr[1];
1586 bw32(bp, B44_ADDR_HI, val);
1587
1588 val = br32(bp, B44_DEVCTRL);
1589 bw32(bp, B44_DEVCTRL, val | DEVCTRL_MPM | DEVCTRL_PFE);
1590
1591 } else {
1592 b44_setup_pseudo_magicp(bp);
1593 }
1594
1595 val = br32(bp, B44_SBTMSLOW);
1596 bw32(bp, B44_SBTMSLOW, val | SBTMSLOW_PE);
1597
1598 pci_read_config_word(bp->pdev, SSB_PMCSR, &pmval);
1599 pci_write_config_word(bp->pdev, SSB_PMCSR, pmval | SSB_PE);
1600
1601}
1602
1453static int b44_close(struct net_device *dev) 1603static int b44_close(struct net_device *dev)
1454{ 1604{
1455 struct b44 *bp = netdev_priv(dev); 1605 struct b44 *bp = netdev_priv(dev);
@@ -1475,6 +1625,11 @@ static int b44_close(struct net_device *dev)
1475 1625
1476 netif_poll_enable(dev); 1626 netif_poll_enable(dev);
1477 1627
1628 if (bp->flags & B44_FLAG_WOL_ENABLE) {
1629 b44_init_hw(bp, 0);
1630 b44_setup_wol(bp);
1631 }
1632
1478 b44_free_consistent(bp); 1633 b44_free_consistent(bp);
1479 1634
1480 return 0; 1635 return 0;
@@ -1620,8 +1775,6 @@ static int b44_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1620{ 1775{
1621 struct b44 *bp = netdev_priv(dev); 1776 struct b44 *bp = netdev_priv(dev);
1622 1777
1623 if (!netif_running(dev))
1624 return -EAGAIN;
1625 cmd->supported = (SUPPORTED_Autoneg); 1778 cmd->supported = (SUPPORTED_Autoneg);
1626 cmd->supported |= (SUPPORTED_100baseT_Half | 1779 cmd->supported |= (SUPPORTED_100baseT_Half |
1627 SUPPORTED_100baseT_Full | 1780 SUPPORTED_100baseT_Full |
@@ -1649,6 +1802,12 @@ static int b44_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1649 XCVR_INTERNAL : XCVR_EXTERNAL; 1802 XCVR_INTERNAL : XCVR_EXTERNAL;
1650 cmd->autoneg = (bp->flags & B44_FLAG_FORCE_LINK) ? 1803 cmd->autoneg = (bp->flags & B44_FLAG_FORCE_LINK) ?
1651 AUTONEG_DISABLE : AUTONEG_ENABLE; 1804 AUTONEG_DISABLE : AUTONEG_ENABLE;
1805 if (cmd->autoneg == AUTONEG_ENABLE)
1806 cmd->advertising |= ADVERTISED_Autoneg;
1807 if (!netif_running(dev)){
1808 cmd->speed = 0;
1809 cmd->duplex = 0xff;
1810 }
1652 cmd->maxtxpkt = 0; 1811 cmd->maxtxpkt = 0;
1653 cmd->maxrxpkt = 0; 1812 cmd->maxrxpkt = 0;
1654 return 0; 1813 return 0;
@@ -1658,9 +1817,6 @@ static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1658{ 1817{
1659 struct b44 *bp = netdev_priv(dev); 1818 struct b44 *bp = netdev_priv(dev);
1660 1819
1661 if (!netif_running(dev))
1662 return -EAGAIN;
1663
1664 /* We do not support gigabit. */ 1820 /* We do not support gigabit. */
1665 if (cmd->autoneg == AUTONEG_ENABLE) { 1821 if (cmd->autoneg == AUTONEG_ENABLE) {
1666 if (cmd->advertising & 1822 if (cmd->advertising &
@@ -1677,28 +1833,39 @@ static int b44_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1677 spin_lock_irq(&bp->lock); 1833 spin_lock_irq(&bp->lock);
1678 1834
1679 if (cmd->autoneg == AUTONEG_ENABLE) { 1835 if (cmd->autoneg == AUTONEG_ENABLE) {
1680 bp->flags &= ~B44_FLAG_FORCE_LINK; 1836 bp->flags &= ~(B44_FLAG_FORCE_LINK |
1681 bp->flags &= ~(B44_FLAG_ADV_10HALF | 1837 B44_FLAG_100_BASE_T |
1838 B44_FLAG_FULL_DUPLEX |
1839 B44_FLAG_ADV_10HALF |
1682 B44_FLAG_ADV_10FULL | 1840 B44_FLAG_ADV_10FULL |
1683 B44_FLAG_ADV_100HALF | 1841 B44_FLAG_ADV_100HALF |
1684 B44_FLAG_ADV_100FULL); 1842 B44_FLAG_ADV_100FULL);
1685 if (cmd->advertising & ADVERTISE_10HALF) 1843 if (cmd->advertising == 0) {
1686 bp->flags |= B44_FLAG_ADV_10HALF; 1844 bp->flags |= (B44_FLAG_ADV_10HALF |
1687 if (cmd->advertising & ADVERTISE_10FULL) 1845 B44_FLAG_ADV_10FULL |
1688 bp->flags |= B44_FLAG_ADV_10FULL; 1846 B44_FLAG_ADV_100HALF |
1689 if (cmd->advertising & ADVERTISE_100HALF) 1847 B44_FLAG_ADV_100FULL);
1690 bp->flags |= B44_FLAG_ADV_100HALF; 1848 } else {
1691 if (cmd->advertising & ADVERTISE_100FULL) 1849 if (cmd->advertising & ADVERTISED_10baseT_Half)
1692 bp->flags |= B44_FLAG_ADV_100FULL; 1850 bp->flags |= B44_FLAG_ADV_10HALF;
1851 if (cmd->advertising & ADVERTISED_10baseT_Full)
1852 bp->flags |= B44_FLAG_ADV_10FULL;
1853 if (cmd->advertising & ADVERTISED_100baseT_Half)
1854 bp->flags |= B44_FLAG_ADV_100HALF;
1855 if (cmd->advertising & ADVERTISED_100baseT_Full)
1856 bp->flags |= B44_FLAG_ADV_100FULL;
1857 }
1693 } else { 1858 } else {
1694 bp->flags |= B44_FLAG_FORCE_LINK; 1859 bp->flags |= B44_FLAG_FORCE_LINK;
1860 bp->flags &= ~(B44_FLAG_100_BASE_T | B44_FLAG_FULL_DUPLEX);
1695 if (cmd->speed == SPEED_100) 1861 if (cmd->speed == SPEED_100)
1696 bp->flags |= B44_FLAG_100_BASE_T; 1862 bp->flags |= B44_FLAG_100_BASE_T;
1697 if (cmd->duplex == DUPLEX_FULL) 1863 if (cmd->duplex == DUPLEX_FULL)
1698 bp->flags |= B44_FLAG_FULL_DUPLEX; 1864 bp->flags |= B44_FLAG_FULL_DUPLEX;
1699 } 1865 }
1700 1866
1701 b44_setup_phy(bp); 1867 if (netif_running(dev))
1868 b44_setup_phy(bp);
1702 1869
1703 spin_unlock_irq(&bp->lock); 1870 spin_unlock_irq(&bp->lock);
1704 1871
@@ -1734,7 +1901,7 @@ static int b44_set_ringparam(struct net_device *dev,
1734 1901
1735 b44_halt(bp); 1902 b44_halt(bp);
1736 b44_init_rings(bp); 1903 b44_init_rings(bp);
1737 b44_init_hw(bp); 1904 b44_init_hw(bp, 1);
1738 netif_wake_queue(bp->dev); 1905 netif_wake_queue(bp->dev);
1739 spin_unlock_irq(&bp->lock); 1906 spin_unlock_irq(&bp->lock);
1740 1907
@@ -1777,7 +1944,7 @@ static int b44_set_pauseparam(struct net_device *dev,
1777 if (bp->flags & B44_FLAG_PAUSE_AUTO) { 1944 if (bp->flags & B44_FLAG_PAUSE_AUTO) {
1778 b44_halt(bp); 1945 b44_halt(bp);
1779 b44_init_rings(bp); 1946 b44_init_rings(bp);
1780 b44_init_hw(bp); 1947 b44_init_hw(bp, 1);
1781 } else { 1948 } else {
1782 __b44_set_flow_ctrl(bp, bp->flags); 1949 __b44_set_flow_ctrl(bp, bp->flags);
1783 } 1950 }
@@ -1819,12 +1986,40 @@ static void b44_get_ethtool_stats(struct net_device *dev,
1819 spin_unlock_irq(&bp->lock); 1986 spin_unlock_irq(&bp->lock);
1820} 1987}
1821 1988
1989static void b44_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
1990{
1991 struct b44 *bp = netdev_priv(dev);
1992
1993 wol->supported = WAKE_MAGIC;
1994 if (bp->flags & B44_FLAG_WOL_ENABLE)
1995 wol->wolopts = WAKE_MAGIC;
1996 else
1997 wol->wolopts = 0;
1998 memset(&wol->sopass, 0, sizeof(wol->sopass));
1999}
2000
2001static int b44_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2002{
2003 struct b44 *bp = netdev_priv(dev);
2004
2005 spin_lock_irq(&bp->lock);
2006 if (wol->wolopts & WAKE_MAGIC)
2007 bp->flags |= B44_FLAG_WOL_ENABLE;
2008 else
2009 bp->flags &= ~B44_FLAG_WOL_ENABLE;
2010 spin_unlock_irq(&bp->lock);
2011
2012 return 0;
2013}
2014
1822static struct ethtool_ops b44_ethtool_ops = { 2015static struct ethtool_ops b44_ethtool_ops = {
1823 .get_drvinfo = b44_get_drvinfo, 2016 .get_drvinfo = b44_get_drvinfo,
1824 .get_settings = b44_get_settings, 2017 .get_settings = b44_get_settings,
1825 .set_settings = b44_set_settings, 2018 .set_settings = b44_set_settings,
1826 .nway_reset = b44_nway_reset, 2019 .nway_reset = b44_nway_reset,
1827 .get_link = ethtool_op_get_link, 2020 .get_link = ethtool_op_get_link,
2021 .get_wol = b44_get_wol,
2022 .set_wol = b44_set_wol,
1828 .get_ringparam = b44_get_ringparam, 2023 .get_ringparam = b44_get_ringparam,
1829 .set_ringparam = b44_set_ringparam, 2024 .set_ringparam = b44_set_ringparam,
1830 .get_pauseparam = b44_get_pauseparam, 2025 .get_pauseparam = b44_get_pauseparam,
@@ -1903,6 +2098,10 @@ static int __devinit b44_get_invariants(struct b44 *bp)
1903 /* XXX - really required? 2098 /* XXX - really required?
1904 bp->flags |= B44_FLAG_BUGGY_TXPTR; 2099 bp->flags |= B44_FLAG_BUGGY_TXPTR;
1905 */ 2100 */
2101
2102 if (ssb_get_core_rev(bp) >= 7)
2103 bp->flags |= B44_FLAG_B0_ANDLATER;
2104
1906out: 2105out:
1907 return err; 2106 return err;
1908} 2107}
@@ -1921,13 +2120,14 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
1921 2120
1922 err = pci_enable_device(pdev); 2121 err = pci_enable_device(pdev);
1923 if (err) { 2122 if (err) {
1924 printk(KERN_ERR PFX "Cannot enable PCI device, " 2123 dev_err(&pdev->dev, "Cannot enable PCI device, "
1925 "aborting.\n"); 2124 "aborting.\n");
1926 return err; 2125 return err;
1927 } 2126 }
1928 2127
1929 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 2128 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
1930 printk(KERN_ERR PFX "Cannot find proper PCI device " 2129 dev_err(&pdev->dev,
2130 "Cannot find proper PCI device "
1931 "base address, aborting.\n"); 2131 "base address, aborting.\n");
1932 err = -ENODEV; 2132 err = -ENODEV;
1933 goto err_out_disable_pdev; 2133 goto err_out_disable_pdev;
@@ -1935,8 +2135,8 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
1935 2135
1936 err = pci_request_regions(pdev, DRV_MODULE_NAME); 2136 err = pci_request_regions(pdev, DRV_MODULE_NAME);
1937 if (err) { 2137 if (err) {
1938 printk(KERN_ERR PFX "Cannot obtain PCI resources, " 2138 dev_err(&pdev->dev,
1939 "aborting.\n"); 2139 "Cannot obtain PCI resources, aborting.\n");
1940 goto err_out_disable_pdev; 2140 goto err_out_disable_pdev;
1941 } 2141 }
1942 2142
@@ -1944,15 +2144,13 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
1944 2144
1945 err = pci_set_dma_mask(pdev, (u64) B44_DMA_MASK); 2145 err = pci_set_dma_mask(pdev, (u64) B44_DMA_MASK);
1946 if (err) { 2146 if (err) {
1947 printk(KERN_ERR PFX "No usable DMA configuration, " 2147 dev_err(&pdev->dev, "No usable DMA configuration, aborting.\n");
1948 "aborting.\n");
1949 goto err_out_free_res; 2148 goto err_out_free_res;
1950 } 2149 }
1951 2150
1952 err = pci_set_consistent_dma_mask(pdev, (u64) B44_DMA_MASK); 2151 err = pci_set_consistent_dma_mask(pdev, (u64) B44_DMA_MASK);
1953 if (err) { 2152 if (err) {
1954 printk(KERN_ERR PFX "No usable DMA configuration, " 2153 dev_err(&pdev->dev, "No usable DMA configuration, aborting.\n");
1955 "aborting.\n");
1956 goto err_out_free_res; 2154 goto err_out_free_res;
1957 } 2155 }
1958 2156
@@ -1961,7 +2159,7 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
1961 2159
1962 dev = alloc_etherdev(sizeof(*bp)); 2160 dev = alloc_etherdev(sizeof(*bp));
1963 if (!dev) { 2161 if (!dev) {
1964 printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n"); 2162 dev_err(&pdev->dev, "Etherdev alloc failed, aborting.\n");
1965 err = -ENOMEM; 2163 err = -ENOMEM;
1966 goto err_out_free_res; 2164 goto err_out_free_res;
1967 } 2165 }
@@ -1982,8 +2180,7 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
1982 2180
1983 bp->regs = ioremap(b44reg_base, b44reg_len); 2181 bp->regs = ioremap(b44reg_base, b44reg_len);
1984 if (bp->regs == 0UL) { 2182 if (bp->regs == 0UL) {
1985 printk(KERN_ERR PFX "Cannot map device registers, " 2183 dev_err(&pdev->dev, "Cannot map device registers, aborting.\n");
1986 "aborting.\n");
1987 err = -ENOMEM; 2184 err = -ENOMEM;
1988 goto err_out_free_dev; 2185 goto err_out_free_dev;
1989 } 2186 }
@@ -2013,8 +2210,8 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
2013 2210
2014 err = b44_get_invariants(bp); 2211 err = b44_get_invariants(bp);
2015 if (err) { 2212 if (err) {
2016 printk(KERN_ERR PFX "Problem fetching invariants of chip, " 2213 dev_err(&pdev->dev,
2017 "aborting.\n"); 2214 "Problem fetching invariants of chip, aborting.\n");
2018 goto err_out_iounmap; 2215 goto err_out_iounmap;
2019 } 2216 }
2020 2217
@@ -2034,8 +2231,7 @@ static int __devinit b44_init_one(struct pci_dev *pdev,
2034 2231
2035 err = register_netdev(dev); 2232 err = register_netdev(dev);
2036 if (err) { 2233 if (err) {
2037 printk(KERN_ERR PFX "Cannot register net device, " 2234 dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
2038 "aborting.\n");
2039 goto err_out_iounmap; 2235 goto err_out_iounmap;
2040 } 2236 }
2041 2237
@@ -2103,6 +2299,10 @@ static int b44_suspend(struct pci_dev *pdev, pm_message_t state)
2103 spin_unlock_irq(&bp->lock); 2299 spin_unlock_irq(&bp->lock);
2104 2300
2105 free_irq(dev->irq, dev); 2301 free_irq(dev->irq, dev);
2302 if (bp->flags & B44_FLAG_WOL_ENABLE) {
2303 b44_init_hw(bp, 0);
2304 b44_setup_wol(bp);
2305 }
2106 pci_disable_device(pdev); 2306 pci_disable_device(pdev);
2107 return 0; 2307 return 0;
2108} 2308}
@@ -2119,13 +2319,13 @@ static int b44_resume(struct pci_dev *pdev)
2119 if (!netif_running(dev)) 2319 if (!netif_running(dev))
2120 return 0; 2320 return 0;
2121 2321
2122 if (request_irq(dev->irq, b44_interrupt, SA_SHIRQ, dev->name, dev)) 2322 if (request_irq(dev->irq, b44_interrupt, IRQF_SHARED, dev->name, dev))
2123 printk(KERN_ERR PFX "%s: request_irq failed\n", dev->name); 2323 printk(KERN_ERR PFX "%s: request_irq failed\n", dev->name);
2124 2324
2125 spin_lock_irq(&bp->lock); 2325 spin_lock_irq(&bp->lock);
2126 2326
2127 b44_init_rings(bp); 2327 b44_init_rings(bp);
2128 b44_init_hw(bp); 2328 b44_init_hw(bp, 1);
2129 netif_device_attach(bp->dev); 2329 netif_device_attach(bp->dev);
2130 spin_unlock_irq(&bp->lock); 2330 spin_unlock_irq(&bp->lock);
2131 2331
diff --git a/drivers/net/b44.h b/drivers/net/b44.h
index b178662978f3..4944507fad23 100644
--- a/drivers/net/b44.h
+++ b/drivers/net/b44.h
@@ -24,6 +24,9 @@
24#define WKUP_LEN_P3_MASK 0x7f000000 /* Pattern 3 */ 24#define WKUP_LEN_P3_MASK 0x7f000000 /* Pattern 3 */
25#define WKUP_LEN_P3_SHIFT 24 25#define WKUP_LEN_P3_SHIFT 24
26#define WKUP_LEN_D3 0x80000000 26#define WKUP_LEN_D3 0x80000000
27#define WKUP_LEN_DISABLE 0x80808080
28#define WKUP_LEN_ENABLE_TWO 0x80800000
29#define WKUP_LEN_ENABLE_THREE 0x80000000
27#define B44_ISTAT 0x0020UL /* Interrupt Status */ 30#define B44_ISTAT 0x0020UL /* Interrupt Status */
28#define ISTAT_LS 0x00000020 /* Link Change (B0 only) */ 31#define ISTAT_LS 0x00000020 /* Link Change (B0 only) */
29#define ISTAT_PME 0x00000040 /* Power Management Event */ 32#define ISTAT_PME 0x00000040 /* Power Management Event */
@@ -264,6 +267,8 @@
264#define SBIDHIGH_VC_SHIFT 16 267#define SBIDHIGH_VC_SHIFT 16
265 268
266/* SSB PCI config space registers. */ 269/* SSB PCI config space registers. */
270#define SSB_PMCSR 0x44
271#define SSB_PE 0x100
267#define SSB_BAR0_WIN 0x80 272#define SSB_BAR0_WIN 0x80
268#define SSB_BAR1_WIN 0x84 273#define SSB_BAR1_WIN 0x84
269#define SSB_SPROM_CONTROL 0x88 274#define SSB_SPROM_CONTROL 0x88
@@ -420,6 +425,7 @@ struct b44 {
420 425
421 u32 dma_offset; 426 u32 dma_offset;
422 u32 flags; 427 u32 flags;
428#define B44_FLAG_B0_ANDLATER 0x00000001
423#define B44_FLAG_BUGGY_TXPTR 0x00000002 429#define B44_FLAG_BUGGY_TXPTR 0x00000002
424#define B44_FLAG_REORDER_BUG 0x00000004 430#define B44_FLAG_REORDER_BUG 0x00000004
425#define B44_FLAG_PAUSE_AUTO 0x00008000 431#define B44_FLAG_PAUSE_AUTO 0x00008000
@@ -435,6 +441,7 @@ struct b44 {
435#define B44_FLAG_INTERNAL_PHY 0x10000000 441#define B44_FLAG_INTERNAL_PHY 0x10000000
436#define B44_FLAG_RX_RING_HACK 0x20000000 442#define B44_FLAG_RX_RING_HACK 0x20000000
437#define B44_FLAG_TX_RING_HACK 0x40000000 443#define B44_FLAG_TX_RING_HACK 0x40000000
444#define B44_FLAG_WOL_ENABLE 0x80000000
438 445
439 u32 rx_offset; 446 u32 rx_offset;
440 447
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index bbca8ae8018c..6fad83f24c4f 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -7,7 +7,6 @@
7 * May 1999, Al Viro: proper release of /proc/net/bmac entry, switched to 7 * May 1999, Al Viro: proper release of /proc/net/bmac entry, switched to
8 * dynamic procfs inode. 8 * dynamic procfs inode.
9 */ 9 */
10#include <linux/config.h>
11#include <linux/module.h> 10#include <linux/module.h>
12#include <linux/kernel.h> 11#include <linux/kernel.h>
13#include <linux/netdevice.h> 12#include <linux/netdevice.h>
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 702d546567ad..64b6a72b4f6a 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -9,7 +9,6 @@
9 * Written by: Michael Chan (mchan@broadcom.com) 9 * Written by: Michael Chan (mchan@broadcom.com)
10 */ 10 */
11 11
12#include <linux/config.h>
13 12
14#include <linux/module.h> 13#include <linux/module.h>
15#include <linux/moduleparam.h> 14#include <linux/moduleparam.h>
@@ -57,8 +56,8 @@
57 56
58#define DRV_MODULE_NAME "bnx2" 57#define DRV_MODULE_NAME "bnx2"
59#define PFX DRV_MODULE_NAME ": " 58#define PFX DRV_MODULE_NAME ": "
60#define DRV_MODULE_VERSION "1.4.42" 59#define DRV_MODULE_VERSION "1.4.43"
61#define DRV_MODULE_RELDATE "June 12, 2006" 60#define DRV_MODULE_RELDATE "June 28, 2006"
62 61
63#define RUN_AT(x) (jiffies + (x)) 62#define RUN_AT(x) (jiffies + (x))
64 63
@@ -1640,7 +1639,7 @@ bnx2_tx_int(struct bnx2 *bp)
1640 skb = tx_buf->skb; 1639 skb = tx_buf->skb;
1641#ifdef BCM_TSO 1640#ifdef BCM_TSO
1642 /* partial BD completions possible with TSO packets */ 1641 /* partial BD completions possible with TSO packets */
1643 if (skb_shinfo(skb)->tso_size) { 1642 if (skb_shinfo(skb)->gso_size) {
1644 u16 last_idx, last_ring_idx; 1643 u16 last_idx, last_ring_idx;
1645 1644
1646 last_idx = sw_cons + 1645 last_idx = sw_cons +
@@ -1676,7 +1675,7 @@ bnx2_tx_int(struct bnx2 *bp)
1676 1675
1677 tx_free_bd += last + 1; 1676 tx_free_bd += last + 1;
1678 1677
1679 dev_kfree_skb_irq(skb); 1678 dev_kfree_skb(skb);
1680 1679
1681 hw_cons = bp->hw_tx_cons = 1680 hw_cons = bp->hw_tx_cons =
1682 sblk->status_tx_quick_consumer_index0; 1681 sblk->status_tx_quick_consumer_index0;
@@ -1824,7 +1823,7 @@ reuse_rx:
1824 if ((len > (bp->dev->mtu + ETH_HLEN)) && 1823 if ((len > (bp->dev->mtu + ETH_HLEN)) &&
1825 (ntohs(skb->protocol) != 0x8100)) { 1824 (ntohs(skb->protocol) != 0x8100)) {
1826 1825
1827 dev_kfree_skb_irq(skb); 1826 dev_kfree_skb(skb);
1828 goto next_rx; 1827 goto next_rx;
1829 1828
1830 } 1829 }
@@ -3643,7 +3642,7 @@ bnx2_free_tx_skbs(struct bnx2 *bp)
3643 skb_shinfo(skb)->frags[j].size, 3642 skb_shinfo(skb)->frags[j].size,
3644 PCI_DMA_TODEVICE); 3643 PCI_DMA_TODEVICE);
3645 } 3644 }
3646 dev_kfree_skb_any(skb); 3645 dev_kfree_skb(skb);
3647 i += j + 1; 3646 i += j + 1;
3648 } 3647 }
3649 3648
@@ -3669,7 +3668,7 @@ bnx2_free_rx_skbs(struct bnx2 *bp)
3669 3668
3670 rx_buf->skb = NULL; 3669 rx_buf->skb = NULL;
3671 3670
3672 dev_kfree_skb_any(skb); 3671 dev_kfree_skb(skb);
3673 } 3672 }
3674} 3673}
3675 3674
@@ -3999,7 +3998,7 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
3999 udelay(5); 3998 udelay(5);
4000 3999
4001 pci_unmap_single(bp->pdev, map, pkt_size, PCI_DMA_TODEVICE); 4000 pci_unmap_single(bp->pdev, map, pkt_size, PCI_DMA_TODEVICE);
4002 dev_kfree_skb_irq(skb); 4001 dev_kfree_skb(skb);
4003 4002
4004 if (bp->status_blk->status_tx_quick_consumer_index0 != bp->tx_prod) { 4003 if (bp->status_blk->status_tx_quick_consumer_index0 != bp->tx_prod) {
4005 goto loopback_test_done; 4004 goto loopback_test_done;
@@ -4261,11 +4260,11 @@ bnx2_open(struct net_device *dev)
4261 } 4260 }
4262 else { 4261 else {
4263 rc = request_irq(bp->pdev->irq, bnx2_interrupt, 4262 rc = request_irq(bp->pdev->irq, bnx2_interrupt,
4264 SA_SHIRQ, dev->name, dev); 4263 IRQF_SHARED, dev->name, dev);
4265 } 4264 }
4266 } 4265 }
4267 else { 4266 else {
4268 rc = request_irq(bp->pdev->irq, bnx2_interrupt, SA_SHIRQ, 4267 rc = request_irq(bp->pdev->irq, bnx2_interrupt, IRQF_SHARED,
4269 dev->name, dev); 4268 dev->name, dev);
4270 } 4269 }
4271 if (rc) { 4270 if (rc) {
@@ -4312,7 +4311,7 @@ bnx2_open(struct net_device *dev)
4312 4311
4313 if (!rc) { 4312 if (!rc) {
4314 rc = request_irq(bp->pdev->irq, bnx2_interrupt, 4313 rc = request_irq(bp->pdev->irq, bnx2_interrupt,
4315 SA_SHIRQ, dev->name, dev); 4314 IRQF_SHARED, dev->name, dev);
4316 } 4315 }
4317 if (rc) { 4316 if (rc) {
4318 bnx2_free_skbs(bp); 4317 bnx2_free_skbs(bp);
@@ -4428,7 +4427,7 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev)
4428 (TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16)); 4427 (TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16));
4429 } 4428 }
4430#ifdef BCM_TSO 4429#ifdef BCM_TSO
4431 if ((mss = skb_shinfo(skb)->tso_size) && 4430 if ((mss = skb_shinfo(skb)->gso_size) &&
4432 (skb->len > (bp->dev->mtu + ETH_HLEN))) { 4431 (skb->len > (bp->dev->mtu + ETH_HLEN))) {
4433 u32 tcp_opt_len, ip_tcp_len; 4432 u32 tcp_opt_len, ip_tcp_len;
4434 4433
@@ -4541,7 +4540,7 @@ bnx2_close(struct net_device *dev)
4541 bnx2_netif_stop(bp); 4540 bnx2_netif_stop(bp);
4542 del_timer_sync(&bp->timer); 4541 del_timer_sync(&bp->timer);
4543 if (bp->flags & NO_WOL_FLAG) 4542 if (bp->flags & NO_WOL_FLAG)
4544 reset_code = BNX2_DRV_MSG_CODE_UNLOAD; 4543 reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
4545 else if (bp->wol) 4544 else if (bp->wol)
4546 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL; 4545 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
4547 else 4546 else
@@ -5128,6 +5127,16 @@ bnx2_set_rx_csum(struct net_device *dev, u32 data)
5128 return 0; 5127 return 0;
5129} 5128}
5130 5129
5130static int
5131bnx2_set_tso(struct net_device *dev, u32 data)
5132{
5133 if (data)
5134 dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
5135 else
5136 dev->features &= ~(NETIF_F_TSO | NETIF_F_TSO_ECN);
5137 return 0;
5138}
5139
5131#define BNX2_NUM_STATS 46 5140#define BNX2_NUM_STATS 46
5132 5141
5133static struct { 5142static struct {
@@ -5445,7 +5454,7 @@ static struct ethtool_ops bnx2_ethtool_ops = {
5445 .set_sg = ethtool_op_set_sg, 5454 .set_sg = ethtool_op_set_sg,
5446#ifdef BCM_TSO 5455#ifdef BCM_TSO
5447 .get_tso = ethtool_op_get_tso, 5456 .get_tso = ethtool_op_get_tso,
5448 .set_tso = ethtool_op_set_tso, 5457 .set_tso = bnx2_set_tso,
5449#endif 5458#endif
5450 .self_test_count = bnx2_self_test_count, 5459 .self_test_count = bnx2_self_test_count,
5451 .self_test = bnx2_self_test, 5460 .self_test = bnx2_self_test,
@@ -5566,20 +5575,20 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5566 /* enable device (incl. PCI PM wakeup), and bus-mastering */ 5575 /* enable device (incl. PCI PM wakeup), and bus-mastering */
5567 rc = pci_enable_device(pdev); 5576 rc = pci_enable_device(pdev);
5568 if (rc) { 5577 if (rc) {
5569 printk(KERN_ERR PFX "Cannot enable PCI device, aborting."); 5578 dev_err(&pdev->dev, "Cannot enable PCI device, aborting.");
5570 goto err_out; 5579 goto err_out;
5571 } 5580 }
5572 5581
5573 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 5582 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
5574 printk(KERN_ERR PFX "Cannot find PCI device base address, " 5583 dev_err(&pdev->dev,
5575 "aborting.\n"); 5584 "Cannot find PCI device base address, aborting.\n");
5576 rc = -ENODEV; 5585 rc = -ENODEV;
5577 goto err_out_disable; 5586 goto err_out_disable;
5578 } 5587 }
5579 5588
5580 rc = pci_request_regions(pdev, DRV_MODULE_NAME); 5589 rc = pci_request_regions(pdev, DRV_MODULE_NAME);
5581 if (rc) { 5590 if (rc) {
5582 printk(KERN_ERR PFX "Cannot obtain PCI resources, aborting.\n"); 5591 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting.\n");
5583 goto err_out_disable; 5592 goto err_out_disable;
5584 } 5593 }
5585 5594
@@ -5587,15 +5596,15 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5587 5596
5588 bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM); 5597 bp->pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
5589 if (bp->pm_cap == 0) { 5598 if (bp->pm_cap == 0) {
5590 printk(KERN_ERR PFX "Cannot find power management capability, " 5599 dev_err(&pdev->dev,
5591 "aborting.\n"); 5600 "Cannot find power management capability, aborting.\n");
5592 rc = -EIO; 5601 rc = -EIO;
5593 goto err_out_release; 5602 goto err_out_release;
5594 } 5603 }
5595 5604
5596 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX); 5605 bp->pcix_cap = pci_find_capability(pdev, PCI_CAP_ID_PCIX);
5597 if (bp->pcix_cap == 0) { 5606 if (bp->pcix_cap == 0) {
5598 printk(KERN_ERR PFX "Cannot find PCIX capability, aborting.\n"); 5607 dev_err(&pdev->dev, "Cannot find PCIX capability, aborting.\n");
5599 rc = -EIO; 5608 rc = -EIO;
5600 goto err_out_release; 5609 goto err_out_release;
5601 } 5610 }
@@ -5603,14 +5612,14 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5603 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) { 5612 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) {
5604 bp->flags |= USING_DAC_FLAG; 5613 bp->flags |= USING_DAC_FLAG;
5605 if (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) != 0) { 5614 if (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) != 0) {
5606 printk(KERN_ERR PFX "pci_set_consistent_dma_mask " 5615 dev_err(&pdev->dev,
5607 "failed, aborting.\n"); 5616 "pci_set_consistent_dma_mask failed, aborting.\n");
5608 rc = -EIO; 5617 rc = -EIO;
5609 goto err_out_release; 5618 goto err_out_release;
5610 } 5619 }
5611 } 5620 }
5612 else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0) { 5621 else if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) != 0) {
5613 printk(KERN_ERR PFX "System does not support DMA, aborting.\n"); 5622 dev_err(&pdev->dev, "System does not support DMA, aborting.\n");
5614 rc = -EIO; 5623 rc = -EIO;
5615 goto err_out_release; 5624 goto err_out_release;
5616 } 5625 }
@@ -5630,7 +5639,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5630 bp->regview = ioremap_nocache(dev->base_addr, mem_len); 5639 bp->regview = ioremap_nocache(dev->base_addr, mem_len);
5631 5640
5632 if (!bp->regview) { 5641 if (!bp->regview) {
5633 printk(KERN_ERR PFX "Cannot map register space, aborting.\n"); 5642 dev_err(&pdev->dev, "Cannot map register space, aborting.\n");
5634 rc = -ENOMEM; 5643 rc = -ENOMEM;
5635 goto err_out_release; 5644 goto err_out_release;
5636 } 5645 }
@@ -5702,8 +5711,8 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5702 else if ((CHIP_ID(bp) == CHIP_ID_5706_A1) && 5711 else if ((CHIP_ID(bp) == CHIP_ID_5706_A1) &&
5703 !(bp->flags & PCIX_FLAG)) { 5712 !(bp->flags & PCIX_FLAG)) {
5704 5713
5705 printk(KERN_ERR PFX "5706 A1 can only be used in a PCIX bus, " 5714 dev_err(&pdev->dev,
5706 "aborting.\n"); 5715 "5706 A1 can only be used in a PCIX bus, aborting.\n");
5707 goto err_out_unmap; 5716 goto err_out_unmap;
5708 } 5717 }
5709 5718
@@ -5724,7 +5733,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
5724 5733
5725 if ((reg & BNX2_DEV_INFO_SIGNATURE_MAGIC_MASK) != 5734 if ((reg & BNX2_DEV_INFO_SIGNATURE_MAGIC_MASK) !=
5726 BNX2_DEV_INFO_SIGNATURE_MAGIC) { 5735 BNX2_DEV_INFO_SIGNATURE_MAGIC) {
5727 printk(KERN_ERR PFX "Firmware not running, aborting.\n"); 5736 dev_err(&pdev->dev, "Firmware not running, aborting.\n");
5728 rc = -ENODEV; 5737 rc = -ENODEV;
5729 goto err_out_unmap; 5738 goto err_out_unmap;
5730 } 5739 }
@@ -5886,7 +5895,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
5886#endif 5895#endif
5887 5896
5888 if ((rc = register_netdev(dev))) { 5897 if ((rc = register_netdev(dev))) {
5889 printk(KERN_ERR PFX "Cannot register net device\n"); 5898 dev_err(&pdev->dev, "Cannot register net device\n");
5890 if (bp->regview) 5899 if (bp->regview)
5891 iounmap(bp->regview); 5900 iounmap(bp->regview);
5892 pci_release_regions(pdev); 5901 pci_release_regions(pdev);
@@ -5926,7 +5935,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
5926 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 5935 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
5927#endif 5936#endif
5928#ifdef BCM_TSO 5937#ifdef BCM_TSO
5929 dev->features |= NETIF_F_TSO; 5938 dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN;
5930#endif 5939#endif
5931 5940
5932 netif_carrier_off(bp->dev); 5941 netif_carrier_off(bp->dev);
@@ -5968,7 +5977,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
5968 netif_device_detach(dev); 5977 netif_device_detach(dev);
5969 del_timer_sync(&bp->timer); 5978 del_timer_sync(&bp->timer);
5970 if (bp->flags & NO_WOL_FLAG) 5979 if (bp->flags & NO_WOL_FLAG)
5971 reset_code = BNX2_DRV_MSG_CODE_UNLOAD; 5980 reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
5972 else if (bp->wol) 5981 else if (bp->wol)
5973 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL; 5982 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
5974 else 5983 else
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index 5845e334941b..658c5ee95c73 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -4174,6 +4174,7 @@ struct fw_info {
4174#define BNX2_DRV_MSG_CODE_PULSE 0x06000000 4174#define BNX2_DRV_MSG_CODE_PULSE 0x06000000
4175#define BNX2_DRV_MSG_CODE_DIAG 0x07000000 4175#define BNX2_DRV_MSG_CODE_DIAG 0x07000000
4176#define BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL 0x09000000 4176#define BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL 0x09000000
4177#define BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN 0x0b000000
4177 4178
4178#define BNX2_DRV_MSG_DATA 0x00ff0000 4179#define BNX2_DRV_MSG_DATA 0x00ff0000
4179#define BNX2_DRV_MSG_DATA_WAIT0 0x00010000 4180#define BNX2_DRV_MSG_DATA_WAIT0 0x00010000
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 8171cae06688..8b951238f3a2 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -33,7 +33,6 @@
33 33
34//#define BONDING_DEBUG 1 34//#define BONDING_DEBUG 1
35 35
36#include <linux/config.h>
37#include <linux/kernel.h> 36#include <linux/kernel.h>
38#include <linux/module.h> 37#include <linux/module.h>
39#include <linux/sched.h> 38#include <linux/sched.h>
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 5a9bd95884be..cfe4dc3a93a3 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -20,7 +20,6 @@
20 * file called LICENSE. 20 * file called LICENSE.
21 * 21 *
22 */ 22 */
23#include <linux/config.h>
24#include <linux/kernel.h> 23#include <linux/kernel.h>
25#include <linux/module.h> 24#include <linux/module.h>
26#include <linux/sched.h> 25#include <linux/sched.h>
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 39f36aa05aa8..a31544ccb3c4 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -66,7 +66,6 @@
66 * by default, the selective clear mask is set up to process rx packets. 66 * by default, the selective clear mask is set up to process rx packets.
67 */ 67 */
68 68
69#include <linux/config.h>
70 69
71#include <linux/module.h> 70#include <linux/module.h>
72#include <linux/kernel.h> 71#include <linux/kernel.h>
@@ -2915,8 +2914,7 @@ static int cas_start_xmit(struct sk_buff *skb, struct net_device *dev)
2915 */ 2914 */
2916 static int ring; 2915 static int ring;
2917 2916
2918 skb = skb_padto(skb, cp->min_frame_size); 2917 if (skb_padto(skb, cp->min_frame_size))
2919 if (!skb)
2920 return 0; 2918 return 0;
2921 2919
2922 /* XXX: we need some higher-level QoS hooks to steer packets to 2920 /* XXX: we need some higher-level QoS hooks to steer packets to
@@ -4351,7 +4349,7 @@ static int cas_open(struct net_device *dev)
4351 * mapping to expose them 4349 * mapping to expose them
4352 */ 4350 */
4353 if (request_irq(cp->pdev->irq, cas_interrupt, 4351 if (request_irq(cp->pdev->irq, cas_interrupt,
4354 SA_SHIRQ, dev->name, (void *) dev)) { 4352 IRQF_SHARED, dev->name, (void *) dev)) {
4355 printk(KERN_ERR "%s: failed to request irq !\n", 4353 printk(KERN_ERR "%s: failed to request irq !\n",
4356 cp->dev->name); 4354 cp->dev->name);
4357 err = -EAGAIN; 4355 err = -EAGAIN;
@@ -4889,13 +4887,12 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4889 4887
4890 err = pci_enable_device(pdev); 4888 err = pci_enable_device(pdev);
4891 if (err) { 4889 if (err) {
4892 printk(KERN_ERR PFX "Cannot enable PCI device, " 4890 dev_err(&pdev->dev, "Cannot enable PCI device, aborting.\n");
4893 "aborting.\n");
4894 return err; 4891 return err;
4895 } 4892 }
4896 4893
4897 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 4894 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
4898 printk(KERN_ERR PFX "Cannot find proper PCI device " 4895 dev_err(&pdev->dev, "Cannot find proper PCI device "
4899 "base address, aborting.\n"); 4896 "base address, aborting.\n");
4900 err = -ENODEV; 4897 err = -ENODEV;
4901 goto err_out_disable_pdev; 4898 goto err_out_disable_pdev;
@@ -4903,7 +4900,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4903 4900
4904 dev = alloc_etherdev(sizeof(*cp)); 4901 dev = alloc_etherdev(sizeof(*cp));
4905 if (!dev) { 4902 if (!dev) {
4906 printk(KERN_ERR PFX "Etherdev alloc failed, aborting.\n"); 4903 dev_err(&pdev->dev, "Etherdev alloc failed, aborting.\n");
4907 err = -ENOMEM; 4904 err = -ENOMEM;
4908 goto err_out_disable_pdev; 4905 goto err_out_disable_pdev;
4909 } 4906 }
@@ -4912,8 +4909,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4912 4909
4913 err = pci_request_regions(pdev, dev->name); 4910 err = pci_request_regions(pdev, dev->name);
4914 if (err) { 4911 if (err) {
4915 printk(KERN_ERR PFX "Cannot obtain PCI resources, " 4912 dev_err(&pdev->dev, "Cannot obtain PCI resources, aborting.\n");
4916 "aborting.\n");
4917 goto err_out_free_netdev; 4913 goto err_out_free_netdev;
4918 } 4914 }
4919 pci_set_master(pdev); 4915 pci_set_master(pdev);
@@ -4943,7 +4939,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4943 if (pci_write_config_byte(pdev, 4939 if (pci_write_config_byte(pdev,
4944 PCI_CACHE_LINE_SIZE, 4940 PCI_CACHE_LINE_SIZE,
4945 cas_cacheline_size)) { 4941 cas_cacheline_size)) {
4946 printk(KERN_ERR PFX "Could not set PCI cache " 4942 dev_err(&pdev->dev, "Could not set PCI cache "
4947 "line size\n"); 4943 "line size\n");
4948 goto err_write_cacheline; 4944 goto err_write_cacheline;
4949 } 4945 }
@@ -4957,7 +4953,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4957 err = pci_set_consistent_dma_mask(pdev, 4953 err = pci_set_consistent_dma_mask(pdev,
4958 DMA_64BIT_MASK); 4954 DMA_64BIT_MASK);
4959 if (err < 0) { 4955 if (err < 0) {
4960 printk(KERN_ERR PFX "Unable to obtain 64-bit DMA " 4956 dev_err(&pdev->dev, "Unable to obtain 64-bit DMA "
4961 "for consistent allocations\n"); 4957 "for consistent allocations\n");
4962 goto err_out_free_res; 4958 goto err_out_free_res;
4963 } 4959 }
@@ -4965,7 +4961,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
4965 } else { 4961 } else {
4966 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 4962 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
4967 if (err) { 4963 if (err) {
4968 printk(KERN_ERR PFX "No usable DMA configuration, " 4964 dev_err(&pdev->dev, "No usable DMA configuration, "
4969 "aborting.\n"); 4965 "aborting.\n");
4970 goto err_out_free_res; 4966 goto err_out_free_res;
4971 } 4967 }
@@ -5025,8 +5021,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5025 /* give us access to cassini registers */ 5021 /* give us access to cassini registers */
5026 cp->regs = pci_iomap(pdev, 0, casreg_len); 5022 cp->regs = pci_iomap(pdev, 0, casreg_len);
5027 if (cp->regs == 0UL) { 5023 if (cp->regs == 0UL) {
5028 printk(KERN_ERR PFX "Cannot map device registers, " 5024 dev_err(&pdev->dev, "Cannot map device registers, aborting.\n");
5029 "aborting.\n");
5030 goto err_out_free_res; 5025 goto err_out_free_res;
5031 } 5026 }
5032 cp->casreg_len = casreg_len; 5027 cp->casreg_len = casreg_len;
@@ -5042,8 +5037,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5042 pci_alloc_consistent(pdev, sizeof(struct cas_init_block), 5037 pci_alloc_consistent(pdev, sizeof(struct cas_init_block),
5043 &cp->block_dvma); 5038 &cp->block_dvma);
5044 if (!cp->init_block) { 5039 if (!cp->init_block) {
5045 printk(KERN_ERR PFX "Cannot allocate init block, " 5040 dev_err(&pdev->dev, "Cannot allocate init block, aborting.\n");
5046 "aborting.\n");
5047 goto err_out_iounmap; 5041 goto err_out_iounmap;
5048 } 5042 }
5049 5043
@@ -5087,8 +5081,7 @@ static int __devinit cas_init_one(struct pci_dev *pdev,
5087 dev->features |= NETIF_F_HIGHDMA; 5081 dev->features |= NETIF_F_HIGHDMA;
5088 5082
5089 if (register_netdev(dev)) { 5083 if (register_netdev(dev)) {
5090 printk(KERN_ERR PFX "Cannot register net device, " 5084 dev_err(&pdev->dev, "Cannot register net device, aborting.\n");
5091 "aborting.\n");
5092 goto err_out_free_consistent; 5085 goto err_out_free_consistent;
5093 } 5086 }
5094 5087
diff --git a/drivers/net/chelsio/common.h b/drivers/net/chelsio/common.h
index bf3e7b6a7a18..5d9dd14427c5 100644
--- a/drivers/net/chelsio/common.h
+++ b/drivers/net/chelsio/common.h
@@ -39,7 +39,6 @@
39#ifndef _CXGB_COMMON_H_ 39#ifndef _CXGB_COMMON_H_
40#define _CXGB_COMMON_H_ 40#define _CXGB_COMMON_H_
41 41
42#include <linux/config.h>
43#include <linux/module.h> 42#include <linux/module.h>
44#include <linux/netdevice.h> 43#include <linux/netdevice.h>
45#include <linux/types.h> 44#include <linux/types.h>
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index 7fe2638ae06d..e67872433e92 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -37,7 +37,6 @@
37 ****************************************************************************/ 37 ****************************************************************************/
38 38
39#include "common.h" 39#include "common.h"
40#include <linux/config.h>
41#include <linux/module.h> 40#include <linux/module.h>
42#include <linux/init.h> 41#include <linux/init.h>
43#include <linux/pci.h> 42#include <linux/pci.h>
@@ -219,7 +218,7 @@ static int cxgb_up(struct adapter *adapter)
219 218
220 t1_interrupts_clear(adapter); 219 t1_interrupts_clear(adapter);
221 if ((err = request_irq(adapter->pdev->irq, 220 if ((err = request_irq(adapter->pdev->irq,
222 t1_select_intr_handler(adapter), SA_SHIRQ, 221 t1_select_intr_handler(adapter), IRQF_SHARED,
223 adapter->name, adapter))) { 222 adapter->name, adapter))) {
224 goto out_err; 223 goto out_err;
225 } 224 }
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 4391bf4bf573..87f94d939ff8 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -39,7 +39,6 @@
39 39
40#include "common.h" 40#include "common.h"
41 41
42#include <linux/config.h>
43#include <linux/types.h> 42#include <linux/types.h>
44#include <linux/errno.h> 43#include <linux/errno.h>
45#include <linux/pci.h> 44#include <linux/pci.h>
@@ -1418,7 +1417,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1418 struct cpl_tx_pkt *cpl; 1417 struct cpl_tx_pkt *cpl;
1419 1418
1420#ifdef NETIF_F_TSO 1419#ifdef NETIF_F_TSO
1421 if (skb_shinfo(skb)->tso_size) { 1420 if (skb_shinfo(skb)->gso_size) {
1422 int eth_type; 1421 int eth_type;
1423 struct cpl_tx_pkt_lso *hdr; 1422 struct cpl_tx_pkt_lso *hdr;
1424 1423
@@ -1433,7 +1432,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1433 hdr->ip_hdr_words = skb->nh.iph->ihl; 1432 hdr->ip_hdr_words = skb->nh.iph->ihl;
1434 hdr->tcp_hdr_words = skb->h.th->doff; 1433 hdr->tcp_hdr_words = skb->h.th->doff;
1435 hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type, 1434 hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type,
1436 skb_shinfo(skb)->tso_size)); 1435 skb_shinfo(skb)->gso_size));
1437 hdr->len = htonl(skb->len - sizeof(*hdr)); 1436 hdr->len = htonl(skb->len - sizeof(*hdr));
1438 cpl = (struct cpl_tx_pkt *)hdr; 1437 cpl = (struct cpl_tx_pkt *)hdr;
1439 sge->stats.tx_lso_pkts++; 1438 sge->stats.tx_lso_pkts++;
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c
index 64105e4eaf31..0eb1f8787ed7 100644
--- a/drivers/net/cris/eth_v10.c
+++ b/drivers/net/cris/eth_v10.c
@@ -218,7 +218,6 @@
218 * 218 *
219 */ 219 */
220 220
221#include <linux/config.h>
222 221
223#include <linux/module.h> 222#include <linux/module.h>
224 223
@@ -672,7 +671,7 @@ e100_open(struct net_device *dev)
672 /* allocate the irq corresponding to the receiving DMA */ 671 /* allocate the irq corresponding to the receiving DMA */
673 672
674 if (request_irq(NETWORK_DMA_RX_IRQ_NBR, e100rxtx_interrupt, 673 if (request_irq(NETWORK_DMA_RX_IRQ_NBR, e100rxtx_interrupt,
675 SA_SAMPLE_RANDOM, cardname, (void *)dev)) { 674 IRQF_SAMPLE_RANDOM, cardname, (void *)dev)) {
676 goto grace_exit0; 675 goto grace_exit0;
677 } 676 }
678 677
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index ef54ebeb29b8..47eecce35fa4 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -100,7 +100,6 @@
100 100
101/* Always include 'config.h' first in case the user wants to turn on 101/* Always include 'config.h' first in case the user wants to turn on
102 or override something. */ 102 or override something. */
103#include <linux/config.h>
104#include <linux/module.h> 103#include <linux/module.h>
105 104
106/* 105/*
diff --git a/drivers/net/cs89x0.h b/drivers/net/cs89x0.h
index bd954aaa636f..968fe11a0bf0 100644
--- a/drivers/net/cs89x0.h
+++ b/drivers/net/cs89x0.h
@@ -14,7 +14,6 @@
14 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 14 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */ 15 */
16 16
17#include <linux/config.h>
18 17
19#define PP_ChipID 0x0000 /* offset 0h -> Corp -ID */ 18#define PP_ChipID 0x0000 /* offset 0h -> Corp -ID */
20 /* offset 2h -> Model/Product Number */ 19 /* offset 2h -> Model/Product Number */
diff --git a/drivers/net/declance.c b/drivers/net/declance.c
index f130bdab3fd3..6ad5796121c8 100644
--- a/drivers/net/declance.c
+++ b/drivers/net/declance.c
@@ -42,7 +42,6 @@
42 * bits. macro 42 * bits. macro
43 */ 43 */
44 44
45#include <linux/config.h>
46#include <linux/crc32.h> 45#include <linux/crc32.h>
47#include <linux/delay.h> 46#include <linux/delay.h>
48#include <linux/errno.h> 47#include <linux/errno.h>
@@ -704,8 +703,8 @@ static irqreturn_t lance_dma_merr_int(const int irq, void *dev_id,
704 return IRQ_HANDLED; 703 return IRQ_HANDLED;
705} 704}
706 705
707static irqreturn_t 706static irqreturn_t lance_interrupt(const int irq, void *dev_id,
708lance_interrupt(const int irq, void *dev_id, struct pt_regs *regs) 707 struct pt_regs *regs)
709{ 708{
710 struct net_device *dev = (struct net_device *) dev_id; 709 struct net_device *dev = (struct net_device *) dev_id;
711 struct lance_private *lp = netdev_priv(dev); 710 struct lance_private *lp = netdev_priv(dev);
@@ -885,8 +884,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
885 len = skblen; 884 len = skblen;
886 885
887 if (len < ETH_ZLEN) { 886 if (len < ETH_ZLEN) {
888 skb = skb_padto(skb, ETH_ZLEN); 887 if (skb_padto(skb, ETH_ZLEN))
889 if (skb == NULL)
890 return 0; 888 return 0;
891 len = ETH_ZLEN; 889 len = ETH_ZLEN;
892 } 890 }
@@ -1255,7 +1253,7 @@ static int __init dec_lance_init(const int type, const int slot)
1255 return 0; 1253 return 0;
1256 1254
1257err_out_free_dev: 1255err_out_free_dev:
1258 kfree(dev); 1256 free_netdev(dev);
1259 1257
1260err_out: 1258err_out:
1261 return ret; 1259 return ret;
@@ -1301,6 +1299,7 @@ static void __exit dec_lance_cleanup(void)
1301 while (root_lance_dev) { 1299 while (root_lance_dev) {
1302 struct net_device *dev = root_lance_dev; 1300 struct net_device *dev = root_lance_dev;
1303 struct lance_private *lp = netdev_priv(dev); 1301 struct lance_private *lp = netdev_priv(dev);
1302
1304 unregister_netdev(dev); 1303 unregister_netdev(dev);
1305#ifdef CONFIG_TC 1304#ifdef CONFIG_TC
1306 if (lp->slot >= 0) 1305 if (lp->slot >= 0)
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c
index 5acd35c312ac..91cc8cbdd440 100644
--- a/drivers/net/defxx.c
+++ b/drivers/net/defxx.c
@@ -1228,7 +1228,7 @@ static int dfx_open(struct net_device *dev)
1228 1228
1229 /* Register IRQ - support shared interrupts by passing device ptr */ 1229 /* Register IRQ - support shared interrupts by passing device ptr */
1230 1230
1231 ret = request_irq(dev->irq, dfx_interrupt, SA_SHIRQ, dev->name, dev); 1231 ret = request_irq(dev->irq, dfx_interrupt, IRQF_SHARED, dev->name, dev);
1232 if (ret) { 1232 if (ret) {
1233 printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq); 1233 printk(KERN_ERR "%s: Requested IRQ %d is busy\n", dev->name, dev->irq);
1234 return ret; 1234 return ret;
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 0941d40f046f..b1cbe99249c1 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -235,7 +235,6 @@
235 ========================================================================= 235 =========================================================================
236*/ 236*/
237 237
238#include <linux/config.h>
239#include <linux/module.h> 238#include <linux/module.h>
240#include <linux/kernel.h> 239#include <linux/kernel.h>
241#include <linux/string.h> 240#include <linux/string.h>
@@ -938,11 +937,8 @@ static int depca_start_xmit(struct sk_buff *skb, struct net_device *dev)
938 if (skb->len < 1) 937 if (skb->len < 1)
939 goto out; 938 goto out;
940 939
941 if (skb->len < ETH_ZLEN) { 940 if (skb_padto(skb, ETH_ZLEN))
942 skb = skb_padto(skb, ETH_ZLEN); 941 goto out;
943 if (skb == NULL)
944 goto out;
945 }
946 942
947 netif_stop_queue(dev); 943 netif_stop_queue(dev);
948 944
diff --git a/drivers/net/dgrs.c b/drivers/net/dgrs.c
index e175d4876682..fa4f09432975 100644
--- a/drivers/net/dgrs.c
+++ b/drivers/net/dgrs.c
@@ -1191,7 +1191,7 @@ dgrs_probe1(struct net_device *dev)
1191 if (priv->plxreg) 1191 if (priv->plxreg)
1192 OUTL(dev->base_addr + PLX_LCL2PCI_DOORBELL, 1); 1192 OUTL(dev->base_addr + PLX_LCL2PCI_DOORBELL, 1);
1193 1193
1194 rc = request_irq(dev->irq, &dgrs_intr, SA_SHIRQ, "RightSwitch", dev); 1194 rc = request_irq(dev->irq, &dgrs_intr, IRQF_SHARED, "RightSwitch", dev);
1195 if (rc) 1195 if (rc)
1196 goto err_out; 1196 goto err_out;
1197 1197
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index 038447fb5c5e..402961e68c89 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -9,49 +9,10 @@
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11*/ 11*/
12/*
13 Rev Date Description
14 ==========================================================================
15 0.01 2001/05/03 Created DL2000-based linux driver
16 0.02 2001/05/21 Added VLAN and hardware checksum support.
17 1.00 2001/06/26 Added jumbo frame support.
18 1.01 2001/08/21 Added two parameters, rx_coalesce and rx_timeout.
19 1.02 2001/10/08 Supported fiber media.
20 Added flow control parameters.
21 1.03 2001/10/12 Changed the default media to 1000mbps_fd for
22 the fiber devices.
23 1.04 2001/11/08 Fixed Tx stopped when tx very busy.
24 1.05 2001/11/22 Fixed Tx stopped when unidirectional tx busy.
25 1.06 2001/12/13 Fixed disconnect bug at 10Mbps mode.
26 Fixed tx_full flag incorrect.
27 Added tx_coalesce paramter.
28 1.07 2002/01/03 Fixed miscount of RX frame error.
29 1.08 2002/01/17 Fixed the multicast bug.
30 1.09 2002/03/07 Move rx-poll-now to re-fill loop.
31 Added rio_timer() to watch rx buffers.
32 1.10 2002/04/16 Fixed miscount of carrier error.
33 1.11 2002/05/23 Added ISR schedule scheme
34 Fixed miscount of rx frame error for DGE-550SX.
35 Fixed VLAN bug.
36 1.12 2002/06/13 Lock tx_coalesce=1 on 10/100Mbps mode.
37 1.13 2002/08/13 1. Fix disconnection (many tx:carrier/rx:frame
38 errs) with some mainboards.
39 2. Use definition "DRV_NAME" "DRV_VERSION"
40 "DRV_RELDATE" for flexibility.
41 1.14 2002/08/14 Support ethtool.
42 1.15 2002/08/27 Changed the default media to Auto-Negotiation
43 for the fiber devices.
44 1.16 2002/09/04 More power down time for fiber devices auto-
45 negotiation.
46 Fix disconnect bug after ifup and ifdown.
47 1.17 2002/10/03 Fix RMON statistics overflow.
48 Always use I/O mapping to access eeprom,
49 avoid system freezing with some chipsets.
50 12
51*/
52#define DRV_NAME "D-Link DL2000-based linux driver" 13#define DRV_NAME "D-Link DL2000-based linux driver"
53#define DRV_VERSION "v1.17b" 14#define DRV_VERSION "v1.18"
54#define DRV_RELDATE "2006/03/10" 15#define DRV_RELDATE "2006/06/27"
55#include "dl2k.h" 16#include "dl2k.h"
56#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
57 18
@@ -390,7 +351,7 @@ parse_eeprom (struct net_device *dev)
390 for (i = 0; i < 6; i++) 351 for (i = 0; i < 6; i++)
391 dev->dev_addr[i] = psrom->mac_addr[i]; 352 dev->dev_addr[i] = psrom->mac_addr[i];
392 353
393 /* Parse Software Infomation Block */ 354 /* Parse Software Information Block */
394 i = 0x30; 355 i = 0x30;
395 psib = (u8 *) sromdata; 356 psib = (u8 *) sromdata;
396 do { 357 do {
@@ -440,7 +401,7 @@ rio_open (struct net_device *dev)
440 int i; 401 int i;
441 u16 macctrl; 402 u16 macctrl;
442 403
443 i = request_irq (dev->irq, &rio_interrupt, SA_SHIRQ, dev->name, dev); 404 i = request_irq (dev->irq, &rio_interrupt, IRQF_SHARED, dev->name, dev);
444 if (i) 405 if (i)
445 return i; 406 return i;
446 407
diff --git a/drivers/net/dl2k.h b/drivers/net/dl2k.h
index 6e75482d75f2..53449207e53b 100644
--- a/drivers/net/dl2k.h
+++ b/drivers/net/dl2k.h
@@ -683,11 +683,6 @@ struct netdev_private {
683}; 683};
684 684
685/* The station address location in the EEPROM. */ 685/* The station address location in the EEPROM. */
686#ifdef MEM_MAPPING
687#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_MEM | PCI_ADDR1)
688#else
689#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0)
690#endif
691/* The struct pci_device_id consist of: 686/* The struct pci_device_id consist of:
692 vendor, device Vendor and device ID to match (or PCI_ANY_ID) 687 vendor, device Vendor and device ID to match (or PCI_ANY_ID)
693 subvendor, subdevice Subsystem vendor and device ID to match (or PCI_ANY_ID) 688 subvendor, subdevice Subsystem vendor and device ID to match (or PCI_ANY_ID)
@@ -695,9 +690,10 @@ struct netdev_private {
695 class_mask of the class are honored during the comparison. 690 class_mask of the class are honored during the comparison.
696 driver_data Data private to the driver. 691 driver_data Data private to the driver.
697*/ 692*/
698static struct pci_device_id rio_pci_tbl[] = { 693
699 {0x1186, 0x4000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 694static const struct pci_device_id rio_pci_tbl[] = {
700 {0,} 695 {0x1186, 0x4000, PCI_ANY_ID, PCI_ANY_ID, },
696 { }
701}; 697};
702MODULE_DEVICE_TABLE (pci, rio_pci_tbl); 698MODULE_DEVICE_TABLE (pci, rio_pci_tbl);
703#define TX_TIMEOUT (4*HZ) 699#define TX_TIMEOUT (4*HZ)
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 24996da4c1c4..1b758b707134 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -410,10 +410,7 @@ dm9000_probe(struct platform_device *pdev)
410 if (pdev->num_resources < 2) { 410 if (pdev->num_resources < 2) {
411 ret = -ENODEV; 411 ret = -ENODEV;
412 goto out; 412 goto out;
413 } 413 } else if (pdev->num_resources == 2) {
414
415 switch (pdev->num_resources) {
416 case 2:
417 base = pdev->resource[0].start; 414 base = pdev->resource[0].start;
418 415
419 if (!request_mem_region(base, 4, ndev->name)) { 416 if (!request_mem_region(base, 4, ndev->name)) {
@@ -423,17 +420,16 @@ dm9000_probe(struct platform_device *pdev)
423 420
424 ndev->base_addr = base; 421 ndev->base_addr = base;
425 ndev->irq = pdev->resource[1].start; 422 ndev->irq = pdev->resource[1].start;
426 db->io_addr = (void *)base; 423 db->io_addr = (void __iomem *)base;
427 db->io_data = (void *)(base + 4); 424 db->io_data = (void __iomem *)(base + 4);
428
429 break;
430 425
431 case 3: 426 } else {
432 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 427 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
433 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 428 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
434 db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 429 db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
435 430
436 if (db->addr_res == NULL || db->data_res == NULL) { 431 if (db->addr_res == NULL || db->data_res == NULL ||
432 db->irq_res == NULL) {
437 printk(KERN_ERR PFX "insufficient resources\n"); 433 printk(KERN_ERR PFX "insufficient resources\n");
438 ret = -ENOENT; 434 ret = -ENOENT;
439 goto out; 435 goto out;
@@ -482,7 +478,6 @@ dm9000_probe(struct platform_device *pdev)
482 478
483 /* ensure at least we have a default set of IO routines */ 479 /* ensure at least we have a default set of IO routines */
484 dm9000_set_io(db, iosize); 480 dm9000_set_io(db, iosize);
485
486 } 481 }
487 482
488 /* check to see if anything is being over-ridden */ 483 /* check to see if anything is being over-ridden */
@@ -564,6 +559,13 @@ dm9000_probe(struct platform_device *pdev)
564 for (i = 0; i < 6; i++) 559 for (i = 0; i < 6; i++)
565 ndev->dev_addr[i] = db->srom[i]; 560 ndev->dev_addr[i] = db->srom[i];
566 561
562 if (!is_valid_ether_addr(ndev->dev_addr)) {
563 /* try reading from mac */
564
565 for (i = 0; i < 6; i++)
566 ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
567 }
568
567 if (!is_valid_ether_addr(ndev->dev_addr)) 569 if (!is_valid_ether_addr(ndev->dev_addr))
568 printk("%s: Invalid ethernet MAC address. Please " 570 printk("%s: Invalid ethernet MAC address. Please "
569 "set using ifconfig\n", ndev->name); 571 "set using ifconfig\n", ndev->name);
@@ -601,7 +603,7 @@ dm9000_open(struct net_device *dev)
601 603
602 PRINTK2("entering dm9000_open\n"); 604 PRINTK2("entering dm9000_open\n");
603 605
604 if (request_irq(dev->irq, &dm9000_interrupt, SA_SHIRQ, dev->name, dev)) 606 if (request_irq(dev->irq, &dm9000_interrupt, IRQF_SHARED, dev->name, dev))
605 return -EAGAIN; 607 return -EAGAIN;
606 608
607 /* Initialize DM9000 board */ 609 /* Initialize DM9000 board */
@@ -663,7 +665,6 @@ dm9000_init_dm9000(struct net_device *dev)
663 db->tx_pkt_cnt = 0; 665 db->tx_pkt_cnt = 0;
664 db->queue_pkt_len = 0; 666 db->queue_pkt_len = 0;
665 dev->trans_start = 0; 667 dev->trans_start = 0;
666 spin_lock_init(&db->lock);
667} 668}
668 669
669/* 670/*
@@ -767,7 +768,7 @@ dm9000_stop(struct net_device *ndev)
767 * receive the packet to upper layer, free the transmitted packet 768 * receive the packet to upper layer, free the transmitted packet
768 */ 769 */
769 770
770void 771static void
771dm9000_tx_done(struct net_device *dev, board_info_t * db) 772dm9000_tx_done(struct net_device *dev, board_info_t * db)
772{ 773{
773 int tx_status = ior(db, DM9000_NSR); /* Got TX status */ 774 int tx_status = ior(db, DM9000_NSR); /* Got TX status */
@@ -1187,13 +1188,14 @@ dm9000_drv_remove(struct platform_device *pdev)
1187} 1188}
1188 1189
1189static struct platform_driver dm9000_driver = { 1190static struct platform_driver dm9000_driver = {
1191 .driver = {
1192 .name = "dm9000",
1193 .owner = THIS_MODULE,
1194 },
1190 .probe = dm9000_probe, 1195 .probe = dm9000_probe,
1191 .remove = dm9000_drv_remove, 1196 .remove = dm9000_drv_remove,
1192 .suspend = dm9000_drv_suspend, 1197 .suspend = dm9000_drv_suspend,
1193 .resume = dm9000_drv_resume, 1198 .resume = dm9000_drv_resume,
1194 .driver = {
1195 .name = "dm9000",
1196 },
1197}; 1199};
1198 1200
1199static int __init 1201static int __init
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c
index dd8c15ac5c77..36d511729f71 100644
--- a/drivers/net/dummy.c
+++ b/drivers/net/dummy.c
@@ -28,7 +28,6 @@
28 Alan Cox, 30th May 1994 28 Alan Cox, 30th May 1994
29*/ 29*/
30 30
31#include <linux/config.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <linux/kernel.h> 32#include <linux/kernel.h>
34#include <linux/netdevice.h> 33#include <linux/netdevice.h>
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index f37170cc1a37..91ef5f2fd768 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -138,7 +138,6 @@
138 * - Stratus87247: protect MDI control register manipulations 138 * - Stratus87247: protect MDI control register manipulations
139 */ 139 */
140 140
141#include <linux/config.h>
142#include <linux/module.h> 141#include <linux/module.h>
143#include <linux/moduleparam.h> 142#include <linux/moduleparam.h>
144#include <linux/kernel.h> 143#include <linux/kernel.h>
@@ -2064,7 +2063,7 @@ static int e100_up(struct nic *nic)
2064 e100_set_multicast_list(nic->netdev); 2063 e100_set_multicast_list(nic->netdev);
2065 e100_start_receiver(nic, NULL); 2064 e100_start_receiver(nic, NULL);
2066 mod_timer(&nic->watchdog, jiffies); 2065 mod_timer(&nic->watchdog, jiffies);
2067 if((err = request_irq(nic->pdev->irq, e100_intr, SA_SHIRQ, 2066 if((err = request_irq(nic->pdev->irq, e100_intr, IRQF_SHARED,
2068 nic->netdev->name, nic->netdev))) 2067 nic->netdev->name, nic->netdev)))
2069 goto err_no_irq; 2068 goto err_no_irq;
2070 netif_wake_queue(nic->netdev); 2069 netif_wake_queue(nic->netdev);
@@ -2678,9 +2677,9 @@ static int __devinit e100_probe(struct pci_dev *pdev,
2678 goto err_out_free; 2677 goto err_out_free;
2679 } 2678 }
2680 2679
2681 DPRINTK(PROBE, INFO, "addr 0x%lx, irq %d, " 2680 DPRINTK(PROBE, INFO, "addr 0x%llx, irq %d, "
2682 "MAC addr %02X:%02X:%02X:%02X:%02X:%02X\n", 2681 "MAC addr %02X:%02X:%02X:%02X:%02X:%02X\n",
2683 pci_resource_start(pdev, 0), pdev->irq, 2682 (unsigned long long)pci_resource_start(pdev, 0), pdev->irq,
2684 netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2], 2683 netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2],
2685 netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]); 2684 netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]);
2686 2685
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 323a2683417f..f411bbb44f86 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -34,7 +34,6 @@
34#define _E1000_H_ 34#define _E1000_H_
35 35
36#include <linux/stddef.h> 36#include <linux/stddef.h>
37#include <linux/config.h>
38#include <linux/module.h> 37#include <linux/module.h>
39#include <linux/types.h> 38#include <linux/types.h>
40#include <asm/byteorder.h> 39#include <asm/byteorder.h>
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 3a0b847fac31..88a82ba88f57 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -882,10 +882,10 @@ e1000_intr_test(struct e1000_adapter *adapter, uint64_t *data)
882 *data = 0; 882 *data = 0;
883 883
884 /* Hook up test interrupt handler just for this test */ 884 /* Hook up test interrupt handler just for this test */
885 if (!request_irq(irq, &e1000_test_intr, SA_PROBEIRQ, netdev->name, 885 if (!request_irq(irq, &e1000_test_intr, IRQF_PROBE_SHARED,
886 netdev)) { 886 netdev->name, netdev)) {
887 shared_int = FALSE; 887 shared_int = FALSE;
888 } else if (request_irq(irq, &e1000_test_intr, SA_SHIRQ, 888 } else if (request_irq(irq, &e1000_test_intr, IRQF_SHARED,
889 netdev->name, netdev)){ 889 netdev->name, netdev)){
890 *data = 1; 890 *data = 1;
891 return -1; 891 return -1;
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index f9a02c1ab523..f06b281c8f6e 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -272,7 +272,7 @@ static int e1000_request_irq(struct e1000_adapter *adapter)
272 struct net_device *netdev = adapter->netdev; 272 struct net_device *netdev = adapter->netdev;
273 int flags, err = 0; 273 int flags, err = 0;
274 274
275 flags = SA_SHIRQ | SA_SAMPLE_RANDOM; 275 flags = IRQF_SHARED;
276#ifdef CONFIG_PCI_MSI 276#ifdef CONFIG_PCI_MSI
277 if (adapter->hw.mac_type > e1000_82547_rev_2) { 277 if (adapter->hw.mac_type > e1000_82547_rev_2) {
278 adapter->have_msi = TRUE; 278 adapter->have_msi = TRUE;
@@ -2524,7 +2524,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2524 uint8_t ipcss, ipcso, tucss, tucso, hdr_len; 2524 uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
2525 int err; 2525 int err;
2526 2526
2527 if (skb_shinfo(skb)->tso_size) { 2527 if (skb_shinfo(skb)->gso_size) {
2528 if (skb_header_cloned(skb)) { 2528 if (skb_header_cloned(skb)) {
2529 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 2529 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
2530 if (err) 2530 if (err)
@@ -2532,7 +2532,7 @@ e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2532 } 2532 }
2533 2533
2534 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); 2534 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
2535 mss = skb_shinfo(skb)->tso_size; 2535 mss = skb_shinfo(skb)->gso_size;
2536 if (skb->protocol == htons(ETH_P_IP)) { 2536 if (skb->protocol == htons(ETH_P_IP)) {
2537 skb->nh.iph->tot_len = 0; 2537 skb->nh.iph->tot_len = 0;
2538 skb->nh.iph->check = 0; 2538 skb->nh.iph->check = 0;
@@ -2649,7 +2649,7 @@ e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2649 * tso gets written back prematurely before the data is fully 2649 * tso gets written back prematurely before the data is fully
2650 * DMA'd to the controller */ 2650 * DMA'd to the controller */
2651 if (!skb->data_len && tx_ring->last_tx_tso && 2651 if (!skb->data_len && tx_ring->last_tx_tso &&
2652 !skb_shinfo(skb)->tso_size) { 2652 !skb_shinfo(skb)->gso_size) {
2653 tx_ring->last_tx_tso = 0; 2653 tx_ring->last_tx_tso = 0;
2654 size -= 4; 2654 size -= 4;
2655 } 2655 }
@@ -2887,7 +2887,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2887 } 2887 }
2888 2888
2889#ifdef NETIF_F_TSO 2889#ifdef NETIF_F_TSO
2890 mss = skb_shinfo(skb)->tso_size; 2890 mss = skb_shinfo(skb)->gso_size;
2891 /* The controller does a simple calculation to 2891 /* The controller does a simple calculation to
2892 * make sure there is enough room in the FIFO before 2892 * make sure there is enough room in the FIFO before
2893 * initiating the DMA for each buffer. The calc is: 2893 * initiating the DMA for each buffer. The calc is:
@@ -2938,7 +2938,7 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2938#ifdef NETIF_F_TSO 2938#ifdef NETIF_F_TSO
2939 /* Controller Erratum workaround */ 2939 /* Controller Erratum workaround */
2940 if (!skb->data_len && tx_ring->last_tx_tso && 2940 if (!skb->data_len && tx_ring->last_tx_tso &&
2941 !skb_shinfo(skb)->tso_size) 2941 !skb_shinfo(skb)->gso_size)
2942 count++; 2942 count++;
2943#endif 2943#endif
2944 2944
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c
index a806dfe54d23..20d31430c74f 100644
--- a/drivers/net/eepro.c
+++ b/drivers/net/eepro.c
@@ -920,7 +920,7 @@ static int eepro_grab_irq(struct net_device *dev)
920 920
921 eepro_sw2bank0(ioaddr); /* Switch back to Bank 0 */ 921 eepro_sw2bank0(ioaddr); /* Switch back to Bank 0 */
922 922
923 if (request_irq (*irqp, NULL, SA_SHIRQ, "bogus", dev) != EBUSY) { 923 if (request_irq (*irqp, NULL, IRQF_SHARED, "bogus", dev) != EBUSY) {
924 unsigned long irq_mask; 924 unsigned long irq_mask;
925 /* Twinkle the interrupt, and check if it's seen */ 925 /* Twinkle the interrupt, and check if it's seen */
926 irq_mask = probe_irq_on(); 926 irq_mask = probe_irq_on();
@@ -1154,8 +1154,7 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev)
1154 printk(KERN_DEBUG "%s: entering eepro_send_packet routine.\n", dev->name); 1154 printk(KERN_DEBUG "%s: entering eepro_send_packet routine.\n", dev->name);
1155 1155
1156 if (length < ETH_ZLEN) { 1156 if (length < ETH_ZLEN) {
1157 skb = skb_padto(skb, ETH_ZLEN); 1157 if (skb_padto(skb, ETH_ZLEN))
1158 if (skb == NULL)
1159 return 0; 1158 return 0;
1160 length = ETH_ZLEN; 1159 length = ETH_ZLEN;
1161 } 1160 }
diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 467fc861360d..e445988c92ee 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -87,7 +87,6 @@ static int options[] = {-1, -1, -1, -1, -1, -1, -1, -1};
87/* Size of an pre-allocated Rx buffer: <Ethernet MTU> + slack.*/ 87/* Size of an pre-allocated Rx buffer: <Ethernet MTU> + slack.*/
88#define PKT_BUF_SZ 1536 88#define PKT_BUF_SZ 1536
89 89
90#include <linux/config.h>
91#include <linux/module.h> 90#include <linux/module.h>
92 91
93#include <linux/kernel.h> 92#include <linux/kernel.h>
@@ -278,11 +277,6 @@ having to sign an Intel NDA when I'm helping Intel sell their own product!
278 277
279static int speedo_found1(struct pci_dev *pdev, void __iomem *ioaddr, int fnd_cnt, int acpi_idle_state); 278static int speedo_found1(struct pci_dev *pdev, void __iomem *ioaddr, int fnd_cnt, int acpi_idle_state);
280 279
281enum pci_flags_bit {
282 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
283 PCI_ADDR0=0x10<<0, PCI_ADDR1=0x10<<1, PCI_ADDR2=0x10<<2, PCI_ADDR3=0x10<<3,
284};
285
286/* Offsets to the various registers. 280/* Offsets to the various registers.
287 All accesses need not be longword aligned. */ 281 All accesses need not be longword aligned. */
288enum speedo_offsets { 282enum speedo_offsets {
@@ -561,12 +555,12 @@ static int __devinit eepro100_init_one (struct pci_dev *pdev,
561 555
562 if (!request_region(pci_resource_start(pdev, 1), 556 if (!request_region(pci_resource_start(pdev, 1),
563 pci_resource_len(pdev, 1), "eepro100")) { 557 pci_resource_len(pdev, 1), "eepro100")) {
564 printk (KERN_ERR "eepro100: cannot reserve I/O ports\n"); 558 dev_err(&pdev->dev, "eepro100: cannot reserve I/O ports\n");
565 goto err_out_none; 559 goto err_out_none;
566 } 560 }
567 if (!request_mem_region(pci_resource_start(pdev, 0), 561 if (!request_mem_region(pci_resource_start(pdev, 0),
568 pci_resource_len(pdev, 0), "eepro100")) { 562 pci_resource_len(pdev, 0), "eepro100")) {
569 printk (KERN_ERR "eepro100: cannot reserve MMIO region\n"); 563 dev_err(&pdev->dev, "eepro100: cannot reserve MMIO region\n");
570 goto err_out_free_pio_region; 564 goto err_out_free_pio_region;
571 } 565 }
572 566
@@ -579,7 +573,7 @@ static int __devinit eepro100_init_one (struct pci_dev *pdev,
579 573
580 ioaddr = pci_iomap(pdev, pci_bar, 0); 574 ioaddr = pci_iomap(pdev, pci_bar, 0);
581 if (!ioaddr) { 575 if (!ioaddr) {
582 printk (KERN_ERR "eepro100: cannot remap IO\n"); 576 dev_err(&pdev->dev, "eepro100: cannot remap IO\n");
583 goto err_out_free_mmio_region; 577 goto err_out_free_mmio_region;
584 } 578 }
585 579
@@ -983,7 +977,7 @@ speedo_open(struct net_device *dev)
983 sp->in_interrupt = 0; 977 sp->in_interrupt = 0;
984 978
985 /* .. we can safely take handler calls during init. */ 979 /* .. we can safely take handler calls during init. */
986 retval = request_irq(dev->irq, &speedo_interrupt, SA_SHIRQ, dev->name, dev); 980 retval = request_irq(dev->irq, &speedo_interrupt, IRQF_SHARED, dev->name, dev);
987 if (retval) { 981 if (retval) {
988 return retval; 982 return retval;
989 } 983 }
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index 82bd356e4f3a..33291bcf6d4c 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -97,7 +97,6 @@
97#define LOCKUP16 0 97#define LOCKUP16 0
98#endif 98#endif
99 99
100#include <linux/config.h>
101#include <linux/module.h> 100#include <linux/module.h>
102#include <linux/kernel.h> 101#include <linux/kernel.h>
103#include <linux/types.h> 102#include <linux/types.h>
@@ -677,8 +676,7 @@ static int eexp_xmit(struct sk_buff *buf, struct net_device *dev)
677#endif 676#endif
678 677
679 if (buf->len < ETH_ZLEN) { 678 if (buf->len < ETH_ZLEN) {
680 buf = skb_padto(buf, ETH_ZLEN); 679 if (skb_padto(buf, ETH_ZLEN))
681 if (buf == NULL)
682 return 0; 680 return 0;
683 length = ETH_ZLEN; 681 length = ETH_ZLEN;
684 } 682 }
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c
index 8d680ce600d7..a67650ccf084 100644
--- a/drivers/net/epic100.c
+++ b/drivers/net/epic100.c
@@ -19,62 +19,15 @@
19 19
20 Information and updates available at 20 Information and updates available at
21 http://www.scyld.com/network/epic100.html 21 http://www.scyld.com/network/epic100.html
22 [this link no longer provides anything useful -jgarzik]
22 23
23 --------------------------------------------------------------------- 24 ---------------------------------------------------------------------
24 25
25 Linux kernel-specific changes:
26
27 LK1.1.2 (jgarzik):
28 * Merge becker version 1.09 (4/08/2000)
29
30 LK1.1.3:
31 * Major bugfix to 1.09 driver (Francis Romieu)
32
33 LK1.1.4 (jgarzik):
34 * Merge becker test version 1.09 (5/29/2000)
35
36 LK1.1.5:
37 * Fix locking (jgarzik)
38 * Limit 83c175 probe to ethernet-class PCI devices (rgooch)
39
40 LK1.1.6:
41 * Merge becker version 1.11
42 * Move pci_enable_device before any PCI BAR len checks
43
44 LK1.1.7:
45 * { fill me in }
46
47 LK1.1.8:
48 * ethtool driver info support (jgarzik)
49
50 LK1.1.9:
51 * ethtool media get/set support (jgarzik)
52
53 LK1.1.10:
54 * revert MII transceiver init change (jgarzik)
55
56 LK1.1.11:
57 * implement ETHTOOL_[GS]SET, _NWAY_RST, _[GS]MSGLVL, _GLINK (jgarzik)
58 * replace some MII-related magic numbers with constants
59
60 LK1.1.12:
61 * fix power-up sequence
62
63 LK1.1.13:
64 * revert version 1.1.12, power-up sequence "fix"
65
66 LK1.1.14 (Kryzsztof Halasa):
67 * fix spurious bad initializations
68 * pound phy a la SMSC's app note on the subject
69
70 AC1.1.14ac
71 * fix power up/down for ethtool that broke in 1.11
72
73*/ 26*/
74 27
75#define DRV_NAME "epic100" 28#define DRV_NAME "epic100"
76#define DRV_VERSION "1.11+LK1.1.14+AC1.1.14" 29#define DRV_VERSION "2.0"
77#define DRV_RELDATE "June 2, 2004" 30#define DRV_RELDATE "June 27, 2006"
78 31
79/* The user-configurable values. 32/* The user-configurable values.
80 These may be modified when a driver module is loaded.*/ 33 These may be modified when a driver module is loaded.*/
@@ -114,7 +67,6 @@ static int rx_copybreak;
114#define TX_FIFO_THRESH 256 67#define TX_FIFO_THRESH 256
115#define RX_FIFO_THRESH 1 /* 0-3, 0==32, 64,96, or 3==128 bytes */ 68#define RX_FIFO_THRESH 1 /* 0-3, 0==32, 64,96, or 3==128 bytes */
116 69
117#include <linux/config.h>
118#include <linux/module.h> 70#include <linux/module.h>
119#include <linux/kernel.h> 71#include <linux/kernel.h>
120#include <linux/string.h> 72#include <linux/string.h>
@@ -191,23 +143,10 @@ IVc. Errata
191*/ 143*/
192 144
193 145
194enum pci_id_flags_bits {
195 /* Set PCI command register bits before calling probe1(). */
196 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
197 /* Read and map the single following PCI BAR. */
198 PCI_ADDR0=0<<4, PCI_ADDR1=1<<4, PCI_ADDR2=2<<4, PCI_ADDR3=3<<4,
199 PCI_ADDR_64BITS=0x100, PCI_NO_ACPI_WAKE=0x200, PCI_NO_MIN_LATENCY=0x400,
200};
201
202enum chip_capability_flags { MII_PWRDWN=1, TYPE2_INTR=2, NO_MII=4 }; 146enum chip_capability_flags { MII_PWRDWN=1, TYPE2_INTR=2, NO_MII=4 };
203 147
204#define EPIC_TOTAL_SIZE 0x100 148#define EPIC_TOTAL_SIZE 0x100
205#define USE_IO_OPS 1 149#define USE_IO_OPS 1
206#ifdef USE_IO_OPS
207#define EPIC_IOTYPE PCI_USES_MASTER|PCI_USES_IO|PCI_ADDR0
208#else
209#define EPIC_IOTYPE PCI_USES_MASTER|PCI_USES_MEM|PCI_ADDR1
210#endif
211 150
212typedef enum { 151typedef enum {
213 SMSC_83C170_0, 152 SMSC_83C170_0,
@@ -218,20 +157,15 @@ typedef enum {
218 157
219struct epic_chip_info { 158struct epic_chip_info {
220 const char *name; 159 const char *name;
221 enum pci_id_flags_bits pci_flags;
222 int io_size; /* Needed for I/O region check or ioremap(). */
223 int drv_flags; /* Driver use, intended as capability flags. */ 160 int drv_flags; /* Driver use, intended as capability flags. */
224}; 161};
225 162
226 163
227/* indexed by chip_t */ 164/* indexed by chip_t */
228static const struct epic_chip_info pci_id_tbl[] = { 165static const struct epic_chip_info pci_id_tbl[] = {
229 { "SMSC EPIC/100 83c170", 166 { "SMSC EPIC/100 83c170", TYPE2_INTR | NO_MII | MII_PWRDWN },
230 EPIC_IOTYPE, EPIC_TOTAL_SIZE, TYPE2_INTR | NO_MII | MII_PWRDWN }, 167 { "SMSC EPIC/100 83c170", TYPE2_INTR },
231 { "SMSC EPIC/100 83c170", 168 { "SMSC EPIC/C 83c175", TYPE2_INTR | MII_PWRDWN },
232 EPIC_IOTYPE, EPIC_TOTAL_SIZE, TYPE2_INTR },
233 { "SMSC EPIC/C 83c175",
234 EPIC_IOTYPE, EPIC_TOTAL_SIZE, TYPE2_INTR | MII_PWRDWN },
235}; 169};
236 170
237 171
@@ -400,8 +334,8 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
400 goto out; 334 goto out;
401 irq = pdev->irq; 335 irq = pdev->irq;
402 336
403 if (pci_resource_len(pdev, 0) < pci_id_tbl[chip_idx].io_size) { 337 if (pci_resource_len(pdev, 0) < EPIC_TOTAL_SIZE) {
404 printk (KERN_ERR "card %d: no PCI region space\n", card_idx); 338 dev_err(&pdev->dev, "no PCI region space\n");
405 ret = -ENODEV; 339 ret = -ENODEV;
406 goto err_out_disable; 340 goto err_out_disable;
407 } 341 }
@@ -416,7 +350,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
416 350
417 dev = alloc_etherdev(sizeof (*ep)); 351 dev = alloc_etherdev(sizeof (*ep));
418 if (!dev) { 352 if (!dev) {
419 printk (KERN_ERR "card %d: no memory for eth device\n", card_idx); 353 dev_err(&pdev->dev, "no memory for eth device\n");
420 goto err_out_free_res; 354 goto err_out_free_res;
421 } 355 }
422 SET_MODULE_OWNER(dev); 356 SET_MODULE_OWNER(dev);
@@ -428,7 +362,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
428 ioaddr = pci_resource_start (pdev, 1); 362 ioaddr = pci_resource_start (pdev, 1);
429 ioaddr = (long) ioremap (ioaddr, pci_resource_len (pdev, 1)); 363 ioaddr = (long) ioremap (ioaddr, pci_resource_len (pdev, 1));
430 if (!ioaddr) { 364 if (!ioaddr) {
431 printk (KERN_ERR DRV_NAME " %d: ioremap failed\n", card_idx); 365 dev_err(&pdev->dev, "ioremap failed\n");
432 goto err_out_free_netdev; 366 goto err_out_free_netdev;
433 } 367 }
434#endif 368#endif
@@ -488,8 +422,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
488 ((u16 *)dev->dev_addr)[i] = le16_to_cpu(inw(ioaddr + LAN0 + i*4)); 422 ((u16 *)dev->dev_addr)[i] = le16_to_cpu(inw(ioaddr + LAN0 + i*4));
489 423
490 if (debug > 2) { 424 if (debug > 2) {
491 printk(KERN_DEBUG DRV_NAME "(%s): EEPROM contents\n", 425 dev_printk(KERN_DEBUG, &pdev->dev, "EEPROM contents:\n");
492 pci_name(pdev));
493 for (i = 0; i < 64; i++) 426 for (i = 0; i < 64; i++)
494 printk(" %4.4x%s", read_eeprom(ioaddr, i), 427 printk(" %4.4x%s", read_eeprom(ioaddr, i),
495 i % 16 == 15 ? "\n" : ""); 428 i % 16 == 15 ? "\n" : "");
@@ -511,21 +444,23 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
511 int mii_status = mdio_read(dev, phy, MII_BMSR); 444 int mii_status = mdio_read(dev, phy, MII_BMSR);
512 if (mii_status != 0xffff && mii_status != 0x0000) { 445 if (mii_status != 0xffff && mii_status != 0x0000) {
513 ep->phys[phy_idx++] = phy; 446 ep->phys[phy_idx++] = phy;
514 printk(KERN_INFO DRV_NAME "(%s): MII transceiver #%d control " 447 dev_info(&pdev->dev,
515 "%4.4x status %4.4x.\n", 448 "MII transceiver #%d control "
516 pci_name(pdev), phy, mdio_read(dev, phy, 0), mii_status); 449 "%4.4x status %4.4x.\n",
450 phy, mdio_read(dev, phy, 0), mii_status);
517 } 451 }
518 } 452 }
519 ep->mii_phy_cnt = phy_idx; 453 ep->mii_phy_cnt = phy_idx;
520 if (phy_idx != 0) { 454 if (phy_idx != 0) {
521 phy = ep->phys[0]; 455 phy = ep->phys[0];
522 ep->mii.advertising = mdio_read(dev, phy, MII_ADVERTISE); 456 ep->mii.advertising = mdio_read(dev, phy, MII_ADVERTISE);
523 printk(KERN_INFO DRV_NAME "(%s): Autonegotiation advertising %4.4x link " 457 dev_info(&pdev->dev,
458 "Autonegotiation advertising %4.4x link "
524 "partner %4.4x.\n", 459 "partner %4.4x.\n",
525 pci_name(pdev), ep->mii.advertising, mdio_read(dev, phy, 5)); 460 ep->mii.advertising, mdio_read(dev, phy, 5));
526 } else if ( ! (ep->chip_flags & NO_MII)) { 461 } else if ( ! (ep->chip_flags & NO_MII)) {
527 printk(KERN_WARNING DRV_NAME "(%s): ***WARNING***: No MII transceiver found!\n", 462 dev_warn(&pdev->dev,
528 pci_name(pdev)); 463 "***WARNING***: No MII transceiver found!\n");
529 /* Use the known PHY address of the EPII. */ 464 /* Use the known PHY address of the EPII. */
530 ep->phys[0] = 3; 465 ep->phys[0] = 3;
531 } 466 }
@@ -540,8 +475,7 @@ static int __devinit epic_init_one (struct pci_dev *pdev,
540 /* The lower four bits are the media type. */ 475 /* The lower four bits are the media type. */
541 if (duplex) { 476 if (duplex) {
542 ep->mii.force_media = ep->mii.full_duplex = 1; 477 ep->mii.force_media = ep->mii.full_duplex = 1;
543 printk(KERN_INFO DRV_NAME "(%s): Forced full duplex operation requested.\n", 478 dev_info(&pdev->dev, "Forced full duplex requested.\n");
544 pci_name(pdev));
545 } 479 }
546 dev->if_port = ep->default_port = option; 480 dev->if_port = ep->default_port = option;
547 481
@@ -728,7 +662,7 @@ static int epic_open(struct net_device *dev)
728 /* Soft reset the chip. */ 662 /* Soft reset the chip. */
729 outl(0x4001, ioaddr + GENCTL); 663 outl(0x4001, ioaddr + GENCTL);
730 664
731 if ((retval = request_irq(dev->irq, &epic_interrupt, SA_SHIRQ, dev->name, dev))) 665 if ((retval = request_irq(dev->irq, &epic_interrupt, IRQF_SHARED, dev->name, dev)))
732 return retval; 666 return retval;
733 667
734 epic_init_ring(dev); 668 epic_init_ring(dev);
@@ -1027,11 +961,8 @@ static int epic_start_xmit(struct sk_buff *skb, struct net_device *dev)
1027 u32 ctrl_word; 961 u32 ctrl_word;
1028 unsigned long flags; 962 unsigned long flags;
1029 963
1030 if (skb->len < ETH_ZLEN) { 964 if (skb_padto(skb, ETH_ZLEN))
1031 skb = skb_padto(skb, ETH_ZLEN); 965 return 0;
1032 if (skb == NULL)
1033 return 0;
1034 }
1035 966
1036 /* Caution: the write order is important here, set the field with the 967 /* Caution: the write order is important here, set the field with the
1037 "ownership" bit last. */ 968 "ownership" bit last. */
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index b67545be2caa..4bf76f86d8e9 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -1064,8 +1064,7 @@ static int eth16i_tx(struct sk_buff *skb, struct net_device *dev)
1064 unsigned long flags; 1064 unsigned long flags;
1065 1065
1066 if (length < ETH_ZLEN) { 1066 if (length < ETH_ZLEN) {
1067 skb = skb_padto(skb, ETH_ZLEN); 1067 if (skb_padto(skb, ETH_ZLEN))
1068 if (skb == NULL)
1069 return 0; 1068 return 0;
1070 length = ETH_ZLEN; 1069 length = ETH_ZLEN;
1071 } 1070 }
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c
index a8449265e5fd..97d34fee8c1f 100644
--- a/drivers/net/fealnx.c
+++ b/drivers/net/fealnx.c
@@ -124,16 +124,8 @@ MODULE_PARM_DESC(multicast_filter_limit, "fealnx maximum number of filtered mult
124MODULE_PARM_DESC(options, "fealnx: Bits 0-3: media type, bit 17: full duplex"); 124MODULE_PARM_DESC(options, "fealnx: Bits 0-3: media type, bit 17: full duplex");
125MODULE_PARM_DESC(full_duplex, "fealnx full duplex setting(s) (1)"); 125MODULE_PARM_DESC(full_duplex, "fealnx full duplex setting(s) (1)");
126 126
127#define MIN_REGION_SIZE 136 127enum {
128 128 MIN_REGION_SIZE = 136,
129enum pci_flags_bit {
130 PCI_USES_IO = 1,
131 PCI_USES_MEM = 2,
132 PCI_USES_MASTER = 4,
133 PCI_ADDR0 = 0x10 << 0,
134 PCI_ADDR1 = 0x10 << 1,
135 PCI_ADDR2 = 0x10 << 2,
136 PCI_ADDR3 = 0x10 << 3,
137}; 129};
138 130
139/* A chip capabilities table, matching the entries in pci_tbl[] above. */ 131/* A chip capabilities table, matching the entries in pci_tbl[] above. */
@@ -156,14 +148,13 @@ enum phy_type_flags {
156 148
157struct chip_info { 149struct chip_info {
158 char *chip_name; 150 char *chip_name;
159 int io_size;
160 int flags; 151 int flags;
161}; 152};
162 153
163static const struct chip_info skel_netdrv_tbl[] = { 154static const struct chip_info skel_netdrv_tbl[] __devinitdata = {
164 {"100/10M Ethernet PCI Adapter", 136, HAS_MII_XCVR}, 155 { "100/10M Ethernet PCI Adapter", HAS_MII_XCVR },
165 {"100/10M Ethernet PCI Adapter", 136, HAS_CHIP_XCVR}, 156 { "100/10M Ethernet PCI Adapter", HAS_CHIP_XCVR },
166 {"1000/100/10M Ethernet PCI Adapter", 136, HAS_MII_XCVR}, 157 { "1000/100/10M Ethernet PCI Adapter", HAS_MII_XCVR },
167}; 158};
168 159
169/* Offsets to the Command and Status Registers. */ 160/* Offsets to the Command and Status Registers. */
@@ -514,13 +505,14 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
514 505
515 len = pci_resource_len(pdev, bar); 506 len = pci_resource_len(pdev, bar);
516 if (len < MIN_REGION_SIZE) { 507 if (len < MIN_REGION_SIZE) {
517 printk(KERN_ERR "%s: region size %ld too small, aborting\n", 508 dev_err(&pdev->dev,
518 boardname, len); 509 "region size %ld too small, aborting\n", len);
519 return -ENODEV; 510 return -ENODEV;
520 } 511 }
521 512
522 i = pci_request_regions(pdev, boardname); 513 i = pci_request_regions(pdev, boardname);
523 if (i) return i; 514 if (i)
515 return i;
524 516
525 irq = pdev->irq; 517 irq = pdev->irq;
526 518
@@ -586,9 +578,9 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
586 578
587 if (mii_status != 0xffff && mii_status != 0x0000) { 579 if (mii_status != 0xffff && mii_status != 0x0000) {
588 np->phys[phy_idx++] = phy; 580 np->phys[phy_idx++] = phy;
589 printk(KERN_INFO 581 dev_info(&pdev->dev,
590 "%s: MII PHY found at address %d, status " 582 "MII PHY found at address %d, status "
591 "0x%4.4x.\n", dev->name, phy, mii_status); 583 "0x%4.4x.\n", phy, mii_status);
592 /* get phy type */ 584 /* get phy type */
593 { 585 {
594 unsigned int data; 586 unsigned int data;
@@ -611,10 +603,10 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
611 } 603 }
612 604
613 np->mii_cnt = phy_idx; 605 np->mii_cnt = phy_idx;
614 if (phy_idx == 0) { 606 if (phy_idx == 0)
615 printk(KERN_WARNING "%s: MII PHY not found -- this device may " 607 dev_warn(&pdev->dev,
616 "not operate correctly.\n", dev->name); 608 "MII PHY not found -- this device may "
617 } 609 "not operate correctly.\n");
618 } else { 610 } else {
619 np->phys[0] = 32; 611 np->phys[0] = 32;
620/* 89/6/23 add, (begin) */ 612/* 89/6/23 add, (begin) */
@@ -640,7 +632,7 @@ static int __devinit fealnx_init_one(struct pci_dev *pdev,
640 np->mii.full_duplex = full_duplex[card_idx]; 632 np->mii.full_duplex = full_duplex[card_idx];
641 633
642 if (np->mii.full_duplex) { 634 if (np->mii.full_duplex) {
643 printk(KERN_INFO "%s: Media type forced to Full Duplex.\n", dev->name); 635 dev_info(&pdev->dev, "Media type forced to Full Duplex.\n");
644/* 89/6/13 add, (begin) */ 636/* 89/6/13 add, (begin) */
645// if (np->PHYType==MarvellPHY) 637// if (np->PHYType==MarvellPHY)
646 if ((np->PHYType == MarvellPHY) || (np->PHYType == LevelOnePHY)) { 638 if ((np->PHYType == MarvellPHY) || (np->PHYType == LevelOnePHY)) {
@@ -844,7 +836,7 @@ static int netdev_open(struct net_device *dev)
844 836
845 iowrite32(0x00000001, ioaddr + BCR); /* Reset */ 837 iowrite32(0x00000001, ioaddr + BCR); /* Reset */
846 838
847 if (request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev)) 839 if (request_irq(dev->irq, &intr_handler, IRQF_SHARED, dev->name, dev))
848 return -EAGAIN; 840 return -EAGAIN;
849 841
850 for (i = 0; i < 3; i++) 842 for (i = 0; i < 3; i++)
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index bd6983d1afba..9b4030031744 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -22,10 +22,9 @@
22 * Copyright (c) 2001-2005 Greg Ungerer (gerg@snapgear.com) 22 * Copyright (c) 2001-2005 Greg Ungerer (gerg@snapgear.com)
23 * 23 *
24 * Bug fixes and cleanup by Philippe De Muyter (phdm@macqel.be) 24 * Bug fixes and cleanup by Philippe De Muyter (phdm@macqel.be)
25 * Copyright (c) 2004-2005 Macq Electronique SA. 25 * Copyright (c) 2004-2006 Macq Electronique SA.
26 */ 26 */
27 27
28#include <linux/config.h>
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/kernel.h> 29#include <linux/kernel.h>
31#include <linux/string.h> 30#include <linux/string.h>
@@ -51,7 +50,7 @@
51 50
52#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \ 51#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || \
53 defined(CONFIG_M5272) || defined(CONFIG_M528x) || \ 52 defined(CONFIG_M5272) || defined(CONFIG_M528x) || \
54 defined(CONFIG_M520x) 53 defined(CONFIG_M520x) || defined(CONFIG_M532x)
55#include <asm/coldfire.h> 54#include <asm/coldfire.h>
56#include <asm/mcfsim.h> 55#include <asm/mcfsim.h>
57#include "fec.h" 56#include "fec.h"
@@ -80,6 +79,8 @@ static unsigned int fec_hw[] = {
80 (MCF_MBAR + 0x1000), 79 (MCF_MBAR + 0x1000),
81#elif defined(CONFIG_M520x) 80#elif defined(CONFIG_M520x)
82 (MCF_MBAR+0x30000), 81 (MCF_MBAR+0x30000),
82#elif defined(CONFIG_M532x)
83 (MCF_MBAR+0xfc030000),
83#else 84#else
84 &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec), 85 &(((immap_t *)IMAP_ADDR)->im_cpm.cp_fec),
85#endif 86#endif
@@ -143,7 +144,7 @@ typedef struct {
143#define TX_RING_MOD_MASK 15 /* for this to work */ 144#define TX_RING_MOD_MASK 15 /* for this to work */
144 145
145#if (((RX_RING_SIZE + TX_RING_SIZE) * 8) > PAGE_SIZE) 146#if (((RX_RING_SIZE + TX_RING_SIZE) * 8) > PAGE_SIZE)
146#error "FEC: descriptor ring size contants too large" 147#error "FEC: descriptor ring size constants too large"
147#endif 148#endif
148 149
149/* Interrupt events/masks. 150/* Interrupt events/masks.
@@ -167,12 +168,12 @@ typedef struct {
167 168
168 169
169/* 170/*
170 * The 5270/5271/5280/5282 RX control register also contains maximum frame 171 * The 5270/5271/5280/5282/532x RX control register also contains maximum frame
171 * size bits. Other FEC hardware does not, so we need to take that into 172 * size bits. Other FEC hardware does not, so we need to take that into
172 * account when setting it. 173 * account when setting it.
173 */ 174 */
174#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ 175#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
175 defined(CONFIG_M520x) 176 defined(CONFIG_M520x) || defined(CONFIG_M532x)
176#define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16) 177#define OPT_FRAME_SIZE (PKT_MAXBUF_SIZE << 16)
177#else 178#else
178#define OPT_FRAME_SIZE 0 179#define OPT_FRAME_SIZE 0
@@ -308,6 +309,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
308 struct fec_enet_private *fep; 309 struct fec_enet_private *fep;
309 volatile fec_t *fecp; 310 volatile fec_t *fecp;
310 volatile cbd_t *bdp; 311 volatile cbd_t *bdp;
312 unsigned short status;
311 313
312 fep = netdev_priv(dev); 314 fep = netdev_priv(dev);
313 fecp = (volatile fec_t*)dev->base_addr; 315 fecp = (volatile fec_t*)dev->base_addr;
@@ -320,8 +322,9 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
320 /* Fill in a Tx ring entry */ 322 /* Fill in a Tx ring entry */
321 bdp = fep->cur_tx; 323 bdp = fep->cur_tx;
322 324
325 status = bdp->cbd_sc;
323#ifndef final_version 326#ifndef final_version
324 if (bdp->cbd_sc & BD_ENET_TX_READY) { 327 if (status & BD_ENET_TX_READY) {
325 /* Ooops. All transmit buffers are full. Bail out. 328 /* Ooops. All transmit buffers are full. Bail out.
326 * This should not happen, since dev->tbusy should be set. 329 * This should not happen, since dev->tbusy should be set.
327 */ 330 */
@@ -332,7 +335,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
332 335
333 /* Clear all of the status flags. 336 /* Clear all of the status flags.
334 */ 337 */
335 bdp->cbd_sc &= ~BD_ENET_TX_STATS; 338 status &= ~BD_ENET_TX_STATS;
336 339
337 /* Set buffer length and buffer pointer. 340 /* Set buffer length and buffer pointer.
338 */ 341 */
@@ -366,21 +369,22 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
366 369
367 spin_lock_irq(&fep->lock); 370 spin_lock_irq(&fep->lock);
368 371
369 /* Send it on its way. Tell FEC its ready, interrupt when done, 372 /* Send it on its way. Tell FEC it's ready, interrupt when done,
370 * its the last BD of the frame, and to put the CRC on the end. 373 * it's the last BD of the frame, and to put the CRC on the end.
371 */ 374 */
372 375
373 bdp->cbd_sc |= (BD_ENET_TX_READY | BD_ENET_TX_INTR 376 status |= (BD_ENET_TX_READY | BD_ENET_TX_INTR
374 | BD_ENET_TX_LAST | BD_ENET_TX_TC); 377 | BD_ENET_TX_LAST | BD_ENET_TX_TC);
378 bdp->cbd_sc = status;
375 379
376 dev->trans_start = jiffies; 380 dev->trans_start = jiffies;
377 381
378 /* Trigger transmission start */ 382 /* Trigger transmission start */
379 fecp->fec_x_des_active = 0x01000000; 383 fecp->fec_x_des_active = 0;
380 384
381 /* If this was the last BD in the ring, start at the beginning again. 385 /* If this was the last BD in the ring, start at the beginning again.
382 */ 386 */
383 if (bdp->cbd_sc & BD_ENET_TX_WRAP) { 387 if (status & BD_ENET_TX_WRAP) {
384 bdp = fep->tx_bd_base; 388 bdp = fep->tx_bd_base;
385 } else { 389 } else {
386 bdp++; 390 bdp++;
@@ -491,43 +495,44 @@ fec_enet_tx(struct net_device *dev)
491{ 495{
492 struct fec_enet_private *fep; 496 struct fec_enet_private *fep;
493 volatile cbd_t *bdp; 497 volatile cbd_t *bdp;
498 unsigned short status;
494 struct sk_buff *skb; 499 struct sk_buff *skb;
495 500
496 fep = netdev_priv(dev); 501 fep = netdev_priv(dev);
497 spin_lock(&fep->lock); 502 spin_lock(&fep->lock);
498 bdp = fep->dirty_tx; 503 bdp = fep->dirty_tx;
499 504
500 while ((bdp->cbd_sc&BD_ENET_TX_READY) == 0) { 505 while (((status = bdp->cbd_sc) & BD_ENET_TX_READY) == 0) {
501 if (bdp == fep->cur_tx && fep->tx_full == 0) break; 506 if (bdp == fep->cur_tx && fep->tx_full == 0) break;
502 507
503 skb = fep->tx_skbuff[fep->skb_dirty]; 508 skb = fep->tx_skbuff[fep->skb_dirty];
504 /* Check for errors. */ 509 /* Check for errors. */
505 if (bdp->cbd_sc & (BD_ENET_TX_HB | BD_ENET_TX_LC | 510 if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC |
506 BD_ENET_TX_RL | BD_ENET_TX_UN | 511 BD_ENET_TX_RL | BD_ENET_TX_UN |
507 BD_ENET_TX_CSL)) { 512 BD_ENET_TX_CSL)) {
508 fep->stats.tx_errors++; 513 fep->stats.tx_errors++;
509 if (bdp->cbd_sc & BD_ENET_TX_HB) /* No heartbeat */ 514 if (status & BD_ENET_TX_HB) /* No heartbeat */
510 fep->stats.tx_heartbeat_errors++; 515 fep->stats.tx_heartbeat_errors++;
511 if (bdp->cbd_sc & BD_ENET_TX_LC) /* Late collision */ 516 if (status & BD_ENET_TX_LC) /* Late collision */
512 fep->stats.tx_window_errors++; 517 fep->stats.tx_window_errors++;
513 if (bdp->cbd_sc & BD_ENET_TX_RL) /* Retrans limit */ 518 if (status & BD_ENET_TX_RL) /* Retrans limit */
514 fep->stats.tx_aborted_errors++; 519 fep->stats.tx_aborted_errors++;
515 if (bdp->cbd_sc & BD_ENET_TX_UN) /* Underrun */ 520 if (status & BD_ENET_TX_UN) /* Underrun */
516 fep->stats.tx_fifo_errors++; 521 fep->stats.tx_fifo_errors++;
517 if (bdp->cbd_sc & BD_ENET_TX_CSL) /* Carrier lost */ 522 if (status & BD_ENET_TX_CSL) /* Carrier lost */
518 fep->stats.tx_carrier_errors++; 523 fep->stats.tx_carrier_errors++;
519 } else { 524 } else {
520 fep->stats.tx_packets++; 525 fep->stats.tx_packets++;
521 } 526 }
522 527
523#ifndef final_version 528#ifndef final_version
524 if (bdp->cbd_sc & BD_ENET_TX_READY) 529 if (status & BD_ENET_TX_READY)
525 printk("HEY! Enet xmit interrupt and TX_READY.\n"); 530 printk("HEY! Enet xmit interrupt and TX_READY.\n");
526#endif 531#endif
527 /* Deferred means some collisions occurred during transmit, 532 /* Deferred means some collisions occurred during transmit,
528 * but we eventually sent the packet OK. 533 * but we eventually sent the packet OK.
529 */ 534 */
530 if (bdp->cbd_sc & BD_ENET_TX_DEF) 535 if (status & BD_ENET_TX_DEF)
531 fep->stats.collisions++; 536 fep->stats.collisions++;
532 537
533 /* Free the sk buffer associated with this last transmit. 538 /* Free the sk buffer associated with this last transmit.
@@ -538,7 +543,7 @@ fec_enet_tx(struct net_device *dev)
538 543
539 /* Update pointer to next buffer descriptor to be transmitted. 544 /* Update pointer to next buffer descriptor to be transmitted.
540 */ 545 */
541 if (bdp->cbd_sc & BD_ENET_TX_WRAP) 546 if (status & BD_ENET_TX_WRAP)
542 bdp = fep->tx_bd_base; 547 bdp = fep->tx_bd_base;
543 else 548 else
544 bdp++; 549 bdp++;
@@ -568,9 +573,14 @@ fec_enet_rx(struct net_device *dev)
568 struct fec_enet_private *fep; 573 struct fec_enet_private *fep;
569 volatile fec_t *fecp; 574 volatile fec_t *fecp;
570 volatile cbd_t *bdp; 575 volatile cbd_t *bdp;
576 unsigned short status;
571 struct sk_buff *skb; 577 struct sk_buff *skb;
572 ushort pkt_len; 578 ushort pkt_len;
573 __u8 *data; 579 __u8 *data;
580
581#ifdef CONFIG_M532x
582 flush_cache_all();
583#endif
574 584
575 fep = netdev_priv(dev); 585 fep = netdev_priv(dev);
576 fecp = (volatile fec_t*)dev->base_addr; 586 fecp = (volatile fec_t*)dev->base_addr;
@@ -580,13 +590,13 @@ fec_enet_rx(struct net_device *dev)
580 */ 590 */
581 bdp = fep->cur_rx; 591 bdp = fep->cur_rx;
582 592
583while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) { 593while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) {
584 594
585#ifndef final_version 595#ifndef final_version
586 /* Since we have allocated space to hold a complete frame, 596 /* Since we have allocated space to hold a complete frame,
587 * the last indicator should be set. 597 * the last indicator should be set.
588 */ 598 */
589 if ((bdp->cbd_sc & BD_ENET_RX_LAST) == 0) 599 if ((status & BD_ENET_RX_LAST) == 0)
590 printk("FEC ENET: rcv is not +last\n"); 600 printk("FEC ENET: rcv is not +last\n");
591#endif 601#endif
592 602
@@ -594,26 +604,26 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
594 goto rx_processing_done; 604 goto rx_processing_done;
595 605
596 /* Check for errors. */ 606 /* Check for errors. */
597 if (bdp->cbd_sc & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO | 607 if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH | BD_ENET_RX_NO |
598 BD_ENET_RX_CR | BD_ENET_RX_OV)) { 608 BD_ENET_RX_CR | BD_ENET_RX_OV)) {
599 fep->stats.rx_errors++; 609 fep->stats.rx_errors++;
600 if (bdp->cbd_sc & (BD_ENET_RX_LG | BD_ENET_RX_SH)) { 610 if (status & (BD_ENET_RX_LG | BD_ENET_RX_SH)) {
601 /* Frame too long or too short. */ 611 /* Frame too long or too short. */
602 fep->stats.rx_length_errors++; 612 fep->stats.rx_length_errors++;
603 } 613 }
604 if (bdp->cbd_sc & BD_ENET_RX_NO) /* Frame alignment */ 614 if (status & BD_ENET_RX_NO) /* Frame alignment */
605 fep->stats.rx_frame_errors++; 615 fep->stats.rx_frame_errors++;
606 if (bdp->cbd_sc & BD_ENET_RX_CR) /* CRC Error */ 616 if (status & BD_ENET_RX_CR) /* CRC Error */
607 fep->stats.rx_crc_errors++;
608 if (bdp->cbd_sc & BD_ENET_RX_OV) /* FIFO overrun */
609 fep->stats.rx_crc_errors++; 617 fep->stats.rx_crc_errors++;
618 if (status & BD_ENET_RX_OV) /* FIFO overrun */
619 fep->stats.rx_fifo_errors++;
610 } 620 }
611 621
612 /* Report late collisions as a frame error. 622 /* Report late collisions as a frame error.
613 * On this error, the BD is closed, but we don't know what we 623 * On this error, the BD is closed, but we don't know what we
614 * have in the buffer. So, just drop this frame on the floor. 624 * have in the buffer. So, just drop this frame on the floor.
615 */ 625 */
616 if (bdp->cbd_sc & BD_ENET_RX_CL) { 626 if (status & BD_ENET_RX_CL) {
617 fep->stats.rx_errors++; 627 fep->stats.rx_errors++;
618 fep->stats.rx_frame_errors++; 628 fep->stats.rx_frame_errors++;
619 goto rx_processing_done; 629 goto rx_processing_done;
@@ -639,9 +649,7 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
639 } else { 649 } else {
640 skb->dev = dev; 650 skb->dev = dev;
641 skb_put(skb,pkt_len-4); /* Make room */ 651 skb_put(skb,pkt_len-4); /* Make room */
642 eth_copy_and_sum(skb, 652 eth_copy_and_sum(skb, data, pkt_len-4, 0);
643 (unsigned char *)__va(bdp->cbd_bufaddr),
644 pkt_len-4, 0);
645 skb->protocol=eth_type_trans(skb,dev); 653 skb->protocol=eth_type_trans(skb,dev);
646 netif_rx(skb); 654 netif_rx(skb);
647 } 655 }
@@ -649,15 +657,16 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
649 657
650 /* Clear the status flags for this buffer. 658 /* Clear the status flags for this buffer.
651 */ 659 */
652 bdp->cbd_sc &= ~BD_ENET_RX_STATS; 660 status &= ~BD_ENET_RX_STATS;
653 661
654 /* Mark the buffer empty. 662 /* Mark the buffer empty.
655 */ 663 */
656 bdp->cbd_sc |= BD_ENET_RX_EMPTY; 664 status |= BD_ENET_RX_EMPTY;
665 bdp->cbd_sc = status;
657 666
658 /* Update BD pointer to next entry. 667 /* Update BD pointer to next entry.
659 */ 668 */
660 if (bdp->cbd_sc & BD_ENET_RX_WRAP) 669 if (status & BD_ENET_RX_WRAP)
661 bdp = fep->rx_bd_base; 670 bdp = fep->rx_bd_base;
662 else 671 else
663 bdp++; 672 bdp++;
@@ -667,9 +676,9 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
667 * incoming frames. On a heavily loaded network, we should be 676 * incoming frames. On a heavily loaded network, we should be
668 * able to keep up at the expense of system resources. 677 * able to keep up at the expense of system resources.
669 */ 678 */
670 fecp->fec_r_des_active = 0x01000000; 679 fecp->fec_r_des_active = 0;
671#endif 680#endif
672 } /* while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) */ 681 } /* while (!((status = bdp->cbd_sc) & BD_ENET_RX_EMPTY)) */
673 fep->cur_rx = (cbd_t *)bdp; 682 fep->cur_rx = (cbd_t *)bdp;
674 683
675#if 0 684#if 0
@@ -680,11 +689,12 @@ while (!(bdp->cbd_sc & BD_ENET_RX_EMPTY)) {
680 * our way back to the interrupt return only to come right back 689 * our way back to the interrupt return only to come right back
681 * here. 690 * here.
682 */ 691 */
683 fecp->fec_r_des_active = 0x01000000; 692 fecp->fec_r_des_active = 0;
684#endif 693#endif
685} 694}
686 695
687 696
697/* called from interrupt context */
688static void 698static void
689fec_enet_mii(struct net_device *dev) 699fec_enet_mii(struct net_device *dev)
690{ 700{
@@ -696,10 +706,12 @@ fec_enet_mii(struct net_device *dev)
696 fep = netdev_priv(dev); 706 fep = netdev_priv(dev);
697 ep = fep->hwp; 707 ep = fep->hwp;
698 mii_reg = ep->fec_mii_data; 708 mii_reg = ep->fec_mii_data;
709
710 spin_lock(&fep->lock);
699 711
700 if ((mip = mii_head) == NULL) { 712 if ((mip = mii_head) == NULL) {
701 printk("MII and no head!\n"); 713 printk("MII and no head!\n");
702 return; 714 goto unlock;
703 } 715 }
704 716
705 if (mip->mii_func != NULL) 717 if (mip->mii_func != NULL)
@@ -711,6 +723,9 @@ fec_enet_mii(struct net_device *dev)
711 723
712 if ((mip = mii_head) != NULL) 724 if ((mip = mii_head) != NULL)
713 ep->fec_mii_data = mip->mii_regval; 725 ep->fec_mii_data = mip->mii_regval;
726
727unlock:
728 spin_unlock(&fep->lock);
714} 729}
715 730
716static int 731static int
@@ -728,8 +743,7 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi
728 743
729 retval = 0; 744 retval = 0;
730 745
731 save_flags(flags); 746 spin_lock_irqsave(&fep->lock,flags);
732 cli();
733 747
734 if ((mip = mii_free) != NULL) { 748 if ((mip = mii_free) != NULL) {
735 mii_free = mip->mii_next; 749 mii_free = mip->mii_next;
@@ -749,7 +763,7 @@ mii_queue(struct net_device *dev, int regval, void (*func)(uint, struct net_devi
749 retval = 1; 763 retval = 1;
750 } 764 }
751 765
752 restore_flags(flags); 766 spin_unlock_irqrestore(&fep->lock,flags);
753 767
754 return(retval); 768 return(retval);
755} 769}
@@ -1216,7 +1230,7 @@ static phy_info_t const * const phy_info[] = {
1216}; 1230};
1217 1231
1218/* ------------------------------------------------------------------------- */ 1232/* ------------------------------------------------------------------------- */
1219 1233#if !defined(CONFIG_M532x)
1220#ifdef CONFIG_RPXCLASSIC 1234#ifdef CONFIG_RPXCLASSIC
1221static void 1235static void
1222mii_link_interrupt(void *dev_id); 1236mii_link_interrupt(void *dev_id);
@@ -1224,6 +1238,7 @@ mii_link_interrupt(void *dev_id);
1224static irqreturn_t 1238static irqreturn_t
1225mii_link_interrupt(int irq, void * dev_id, struct pt_regs * regs); 1239mii_link_interrupt(int irq, void * dev_id, struct pt_regs * regs);
1226#endif 1240#endif
1241#endif
1227 1242
1228#if defined(CONFIG_M5272) 1243#if defined(CONFIG_M5272)
1229 1244
@@ -1384,13 +1399,13 @@ static void __inline__ fec_request_intrs(struct net_device *dev)
1384 { 1399 {
1385 volatile unsigned char *icrp; 1400 volatile unsigned char *icrp;
1386 volatile unsigned long *imrp; 1401 volatile unsigned long *imrp;
1387 int i; 1402 int i, ilip;
1388 1403
1389 b = (fep->index) ? MCFICM_INTC1 : MCFICM_INTC0; 1404 b = (fep->index) ? MCFICM_INTC1 : MCFICM_INTC0;
1390 icrp = (volatile unsigned char *) (MCF_IPSBAR + b + 1405 icrp = (volatile unsigned char *) (MCF_IPSBAR + b +
1391 MCFINTC_ICR0); 1406 MCFINTC_ICR0);
1392 for (i = 23; (i < 36); i++) 1407 for (i = 23, ilip = 0x28; (i < 36); i++)
1393 icrp[i] = 0x23; 1408 icrp[i] = ilip--;
1394 1409
1395 imrp = (volatile unsigned long *) (MCF_IPSBAR + b + 1410 imrp = (volatile unsigned long *) (MCF_IPSBAR + b +
1396 MCFINTC_IMRH); 1411 MCFINTC_IMRH);
@@ -1618,6 +1633,159 @@ static void __inline__ fec_uncache(unsigned long addr)
1618 1633
1619/* ------------------------------------------------------------------------- */ 1634/* ------------------------------------------------------------------------- */
1620 1635
1636#elif defined(CONFIG_M532x)
1637/*
1638 * Code specific for M532x
1639 */
1640static void __inline__ fec_request_intrs(struct net_device *dev)
1641{
1642 struct fec_enet_private *fep;
1643 int b;
1644 static const struct idesc {
1645 char *name;
1646 unsigned short irq;
1647 } *idp, id[] = {
1648 { "fec(TXF)", 36 },
1649 { "fec(TXB)", 37 },
1650 { "fec(TXFIFO)", 38 },
1651 { "fec(TXCR)", 39 },
1652 { "fec(RXF)", 40 },
1653 { "fec(RXB)", 41 },
1654 { "fec(MII)", 42 },
1655 { "fec(LC)", 43 },
1656 { "fec(HBERR)", 44 },
1657 { "fec(GRA)", 45 },
1658 { "fec(EBERR)", 46 },
1659 { "fec(BABT)", 47 },
1660 { "fec(BABR)", 48 },
1661 { NULL },
1662 };
1663
1664 fep = netdev_priv(dev);
1665 b = (fep->index) ? 128 : 64;
1666
1667 /* Setup interrupt handlers. */
1668 for (idp = id; idp->name; idp++) {
1669 if (request_irq(b+idp->irq,fec_enet_interrupt,0,idp->name,dev)!=0)
1670 printk("FEC: Could not allocate %s IRQ(%d)!\n",
1671 idp->name, b+idp->irq);
1672 }
1673
1674 /* Unmask interrupts */
1675 MCF_INTC0_ICR36 = 0x2;
1676 MCF_INTC0_ICR37 = 0x2;
1677 MCF_INTC0_ICR38 = 0x2;
1678 MCF_INTC0_ICR39 = 0x2;
1679 MCF_INTC0_ICR40 = 0x2;
1680 MCF_INTC0_ICR41 = 0x2;
1681 MCF_INTC0_ICR42 = 0x2;
1682 MCF_INTC0_ICR43 = 0x2;
1683 MCF_INTC0_ICR44 = 0x2;
1684 MCF_INTC0_ICR45 = 0x2;
1685 MCF_INTC0_ICR46 = 0x2;
1686 MCF_INTC0_ICR47 = 0x2;
1687 MCF_INTC0_ICR48 = 0x2;
1688
1689 MCF_INTC0_IMRH &= ~(
1690 MCF_INTC_IMRH_INT_MASK36 |
1691 MCF_INTC_IMRH_INT_MASK37 |
1692 MCF_INTC_IMRH_INT_MASK38 |
1693 MCF_INTC_IMRH_INT_MASK39 |
1694 MCF_INTC_IMRH_INT_MASK40 |
1695 MCF_INTC_IMRH_INT_MASK41 |
1696 MCF_INTC_IMRH_INT_MASK42 |
1697 MCF_INTC_IMRH_INT_MASK43 |
1698 MCF_INTC_IMRH_INT_MASK44 |
1699 MCF_INTC_IMRH_INT_MASK45 |
1700 MCF_INTC_IMRH_INT_MASK46 |
1701 MCF_INTC_IMRH_INT_MASK47 |
1702 MCF_INTC_IMRH_INT_MASK48 );
1703
1704 /* Set up gpio outputs for MII lines */
1705 MCF_GPIO_PAR_FECI2C |= (0 |
1706 MCF_GPIO_PAR_FECI2C_PAR_MDC_EMDC |
1707 MCF_GPIO_PAR_FECI2C_PAR_MDIO_EMDIO);
1708 MCF_GPIO_PAR_FEC = (0 |
1709 MCF_GPIO_PAR_FEC_PAR_FEC_7W_FEC |
1710 MCF_GPIO_PAR_FEC_PAR_FEC_MII_FEC);
1711}
1712
1713static void __inline__ fec_set_mii(struct net_device *dev, struct fec_enet_private *fep)
1714{
1715 volatile fec_t *fecp;
1716
1717 fecp = fep->hwp;
1718 fecp->fec_r_cntrl = OPT_FRAME_SIZE | 0x04;
1719 fecp->fec_x_cntrl = 0x00;
1720
1721 /*
1722 * Set MII speed to 2.5 MHz
1723 */
1724 fep->phy_speed = ((((MCF_CLK / 2) / (2500000 / 10)) + 5) / 10) * 2;
1725 fecp->fec_mii_speed = fep->phy_speed;
1726
1727 fec_restart(dev, 0);
1728}
1729
1730static void __inline__ fec_get_mac(struct net_device *dev)
1731{
1732 struct fec_enet_private *fep = netdev_priv(dev);
1733 volatile fec_t *fecp;
1734 unsigned char *iap, tmpaddr[ETH_ALEN];
1735
1736 fecp = fep->hwp;
1737
1738 if (FEC_FLASHMAC) {
1739 /*
1740 * Get MAC address from FLASH.
1741 * If it is all 1's or 0's, use the default.
1742 */
1743 iap = FEC_FLASHMAC;
1744 if ((iap[0] == 0) && (iap[1] == 0) && (iap[2] == 0) &&
1745 (iap[3] == 0) && (iap[4] == 0) && (iap[5] == 0))
1746 iap = fec_mac_default;
1747 if ((iap[0] == 0xff) && (iap[1] == 0xff) && (iap[2] == 0xff) &&
1748 (iap[3] == 0xff) && (iap[4] == 0xff) && (iap[5] == 0xff))
1749 iap = fec_mac_default;
1750 } else {
1751 *((unsigned long *) &tmpaddr[0]) = fecp->fec_addr_low;
1752 *((unsigned short *) &tmpaddr[4]) = (fecp->fec_addr_high >> 16);
1753 iap = &tmpaddr[0];
1754 }
1755
1756 memcpy(dev->dev_addr, iap, ETH_ALEN);
1757
1758 /* Adjust MAC if using default MAC address */
1759 if (iap == fec_mac_default)
1760 dev->dev_addr[ETH_ALEN-1] = fec_mac_default[ETH_ALEN-1] + fep->index;
1761}
1762
1763static void __inline__ fec_enable_phy_intr(void)
1764{
1765}
1766
1767static void __inline__ fec_disable_phy_intr(void)
1768{
1769}
1770
1771static void __inline__ fec_phy_ack_intr(void)
1772{
1773}
1774
1775static void __inline__ fec_localhw_setup(void)
1776{
1777}
1778
1779/*
1780 * Do not need to make region uncached on 532x.
1781 */
1782static void __inline__ fec_uncache(unsigned long addr)
1783{
1784}
1785
1786/* ------------------------------------------------------------------------- */
1787
1788
1621#else 1789#else
1622 1790
1623/* 1791/*
@@ -1985,9 +2153,12 @@ fec_enet_open(struct net_device *dev)
1985 mii_do_cmd(dev, fep->phy->config); 2153 mii_do_cmd(dev, fep->phy->config);
1986 mii_do_cmd(dev, phy_cmd_config); /* display configuration */ 2154 mii_do_cmd(dev, phy_cmd_config); /* display configuration */
1987 2155
1988 /* FIXME: use netif_carrier_{on,off} ; this polls 2156 /* Poll until the PHY tells us its configuration
1989 * until link is up which is wrong... could be 2157 * (not link state).
1990 * 30 seconds or more we are trapped in here. -jgarzik 2158 * Request is initiated by mii_do_cmd above, but answer
2159 * comes by interrupt.
2160 * This should take about 25 usec per register at 2.5 MHz,
2161 * and we read approximately 5 registers.
1991 */ 2162 */
1992 while(!fep->sequence_done) 2163 while(!fep->sequence_done)
1993 schedule(); 2164 schedule();
@@ -2253,15 +2424,11 @@ int __init fec_enet_init(struct net_device *dev)
2253 */ 2424 */
2254 fec_request_intrs(dev); 2425 fec_request_intrs(dev);
2255 2426
2256 /* Clear and enable interrupts */
2257 fecp->fec_ievent = 0xffc00000;
2258 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |
2259 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2260 fecp->fec_hash_table_high = 0; 2427 fecp->fec_hash_table_high = 0;
2261 fecp->fec_hash_table_low = 0; 2428 fecp->fec_hash_table_low = 0;
2262 fecp->fec_r_buff_size = PKT_MAXBLR_SIZE; 2429 fecp->fec_r_buff_size = PKT_MAXBLR_SIZE;
2263 fecp->fec_ecntrl = 2; 2430 fecp->fec_ecntrl = 2;
2264 fecp->fec_r_des_active = 0x01000000; 2431 fecp->fec_r_des_active = 0;
2265 2432
2266 dev->base_addr = (unsigned long)fecp; 2433 dev->base_addr = (unsigned long)fecp;
2267 2434
@@ -2281,6 +2448,11 @@ int __init fec_enet_init(struct net_device *dev)
2281 /* setup MII interface */ 2448 /* setup MII interface */
2282 fec_set_mii(dev, fep); 2449 fec_set_mii(dev, fep);
2283 2450
2451 /* Clear and enable interrupts */
2452 fecp->fec_ievent = 0xffc00000;
2453 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |
2454 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2455
2284 /* Queue up command to detect the PHY and initialize the 2456 /* Queue up command to detect the PHY and initialize the
2285 * remainder of the interface. 2457 * remainder of the interface.
2286 */ 2458 */
@@ -2312,11 +2484,6 @@ fec_restart(struct net_device *dev, int duplex)
2312 fecp->fec_ecntrl = 1; 2484 fecp->fec_ecntrl = 1;
2313 udelay(10); 2485 udelay(10);
2314 2486
2315 /* Enable interrupts we wish to service.
2316 */
2317 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |
2318 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2319
2320 /* Clear any outstanding interrupt. 2487 /* Clear any outstanding interrupt.
2321 */ 2488 */
2322 fecp->fec_ievent = 0xffc00000; 2489 fecp->fec_ievent = 0xffc00000;
@@ -2408,7 +2575,12 @@ fec_restart(struct net_device *dev, int duplex)
2408 /* And last, enable the transmit and receive processing. 2575 /* And last, enable the transmit and receive processing.
2409 */ 2576 */
2410 fecp->fec_ecntrl = 2; 2577 fecp->fec_ecntrl = 2;
2411 fecp->fec_r_des_active = 0x01000000; 2578 fecp->fec_r_des_active = 0;
2579
2580 /* Enable interrupts we wish to service.
2581 */
2582 fecp->fec_imask = (FEC_ENET_TXF | FEC_ENET_TXB |
2583 FEC_ENET_RXF | FEC_ENET_RXB | FEC_ENET_MII);
2412} 2584}
2413 2585
2414static void 2586static void
@@ -2420,9 +2592,16 @@ fec_stop(struct net_device *dev)
2420 fep = netdev_priv(dev); 2592 fep = netdev_priv(dev);
2421 fecp = fep->hwp; 2593 fecp = fep->hwp;
2422 2594
2423 fecp->fec_x_cntrl = 0x01; /* Graceful transmit stop */ 2595 /*
2424 2596 ** We cannot expect a graceful transmit stop without link !!!
2425 while(!(fecp->fec_ievent & FEC_ENET_GRA)); 2597 */
2598 if (fep->link)
2599 {
2600 fecp->fec_x_cntrl = 0x01; /* Graceful transmit stop */
2601 udelay(10);
2602 if (!(fecp->fec_ievent & FEC_ENET_GRA))
2603 printk("fec_stop : Graceful transmit stop did not complete !\n");
2604 }
2426 2605
2427 /* Whack a reset. We should wait for this. 2606 /* Whack a reset. We should wait for this.
2428 */ 2607 */
diff --git a/drivers/net/fec.h b/drivers/net/fec.h
index 965c5c49fcdc..1d421606984f 100644
--- a/drivers/net/fec.h
+++ b/drivers/net/fec.h
@@ -14,7 +14,7 @@
14/****************************************************************************/ 14/****************************************************************************/
15 15
16#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ 16#if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \
17 defined(CONFIG_M520x) 17 defined(CONFIG_M520x) || defined(CONFIG_M532x)
18/* 18/*
19 * Just figures, Motorola would have to change the offsets for 19 * Just figures, Motorola would have to change the offsets for
20 * registers in the same peripheral device on different models 20 * registers in the same peripheral device on different models
diff --git a/drivers/net/fec_8xx/fec_8xx-netta.c b/drivers/net/fec_8xx/fec_8xx-netta.c
index 29c275e1d566..790d9dbe42dd 100644
--- a/drivers/net/fec_8xx/fec_8xx-netta.c
+++ b/drivers/net/fec_8xx/fec_8xx-netta.c
@@ -2,7 +2,6 @@
2 * FEC instantatiation file for NETTA 2 * FEC instantatiation file for NETTA
3 */ 3 */
4 4
5#include <linux/config.h>
6#include <linux/kernel.h> 5#include <linux/kernel.h>
7#include <linux/types.h> 6#include <linux/types.h>
8#include <linux/sched.h> 7#include <linux/sched.h>
diff --git a/drivers/net/fec_8xx/fec_main.c b/drivers/net/fec_8xx/fec_main.c
index 7e4338097139..282b1452c39a 100644
--- a/drivers/net/fec_8xx/fec_main.c
+++ b/drivers/net/fec_8xx/fec_main.c
@@ -10,7 +10,6 @@
10 * Released under the GPL 10 * Released under the GPL
11 */ 11 */
12 12
13#include <linux/config.h>
14#include <linux/module.h> 13#include <linux/module.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/types.h> 15#include <linux/types.h>
diff --git a/drivers/net/fec_8xx/fec_mii.c b/drivers/net/fec_8xx/fec_mii.c
index 3b44ac1a7bfe..d3c16b85d9a4 100644
--- a/drivers/net/fec_8xx/fec_mii.c
+++ b/drivers/net/fec_8xx/fec_mii.c
@@ -10,7 +10,6 @@
10 * Released under the GPL 10 * Released under the GPL
11 */ 11 */
12 12
13#include <linux/config.h>
14#include <linux/module.h> 13#include <linux/module.h>
15#include <linux/types.h> 14#include <linux/types.h>
16#include <linux/kernel.h> 15#include <linux/kernel.h>
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 04a53f1dfdbd..037d870712ff 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -1495,8 +1495,8 @@ static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
1495 np->tx_skbuff[nr] = skb; 1495 np->tx_skbuff[nr] = skb;
1496 1496
1497#ifdef NETIF_F_TSO 1497#ifdef NETIF_F_TSO
1498 if (skb_shinfo(skb)->tso_size) 1498 if (skb_shinfo(skb)->gso_size)
1499 tx_flags_extra = NV_TX2_TSO | (skb_shinfo(skb)->tso_size << NV_TX2_TSO_SHIFT); 1499 tx_flags_extra = NV_TX2_TSO | (skb_shinfo(skb)->gso_size << NV_TX2_TSO_SHIFT);
1500 else 1500 else
1501#endif 1501#endif
1502 tx_flags_extra = (skb->ip_summed == CHECKSUM_HW ? (NV_TX2_CHECKSUM_L3|NV_TX2_CHECKSUM_L4) : 0); 1502 tx_flags_extra = (skb->ip_summed == CHECKSUM_HW ? (NV_TX2_CHECKSUM_L3|NV_TX2_CHECKSUM_L4) : 0);
@@ -2076,7 +2076,7 @@ static void nv_set_multicast(struct net_device *dev)
2076 spin_unlock_irq(&np->lock); 2076 spin_unlock_irq(&np->lock);
2077} 2077}
2078 2078
2079void nv_update_pause(struct net_device *dev, u32 pause_flags) 2079static void nv_update_pause(struct net_device *dev, u32 pause_flags)
2080{ 2080{
2081 struct fe_priv *np = netdev_priv(dev); 2081 struct fe_priv *np = netdev_priv(dev);
2082 u8 __iomem *base = get_hwbase(dev); 2082 u8 __iomem *base = get_hwbase(dev);
@@ -2622,21 +2622,21 @@ static int nv_request_irq(struct net_device *dev, int intr_test)
2622 np->msi_flags |= NV_MSI_X_ENABLED; 2622 np->msi_flags |= NV_MSI_X_ENABLED;
2623 if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT && !intr_test) { 2623 if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT && !intr_test) {
2624 /* Request irq for rx handling */ 2624 /* Request irq for rx handling */
2625 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, &nv_nic_irq_rx, SA_SHIRQ, dev->name, dev) != 0) { 2625 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, &nv_nic_irq_rx, IRQF_SHARED, dev->name, dev) != 0) {
2626 printk(KERN_INFO "forcedeth: request_irq failed for rx %d\n", ret); 2626 printk(KERN_INFO "forcedeth: request_irq failed for rx %d\n", ret);
2627 pci_disable_msix(np->pci_dev); 2627 pci_disable_msix(np->pci_dev);
2628 np->msi_flags &= ~NV_MSI_X_ENABLED; 2628 np->msi_flags &= ~NV_MSI_X_ENABLED;
2629 goto out_err; 2629 goto out_err;
2630 } 2630 }
2631 /* Request irq for tx handling */ 2631 /* Request irq for tx handling */
2632 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, &nv_nic_irq_tx, SA_SHIRQ, dev->name, dev) != 0) { 2632 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, &nv_nic_irq_tx, IRQF_SHARED, dev->name, dev) != 0) {
2633 printk(KERN_INFO "forcedeth: request_irq failed for tx %d\n", ret); 2633 printk(KERN_INFO "forcedeth: request_irq failed for tx %d\n", ret);
2634 pci_disable_msix(np->pci_dev); 2634 pci_disable_msix(np->pci_dev);
2635 np->msi_flags &= ~NV_MSI_X_ENABLED; 2635 np->msi_flags &= ~NV_MSI_X_ENABLED;
2636 goto out_free_rx; 2636 goto out_free_rx;
2637 } 2637 }
2638 /* Request irq for link and timer handling */ 2638 /* Request irq for link and timer handling */
2639 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector, &nv_nic_irq_other, SA_SHIRQ, dev->name, dev) != 0) { 2639 if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector, &nv_nic_irq_other, IRQF_SHARED, dev->name, dev) != 0) {
2640 printk(KERN_INFO "forcedeth: request_irq failed for link %d\n", ret); 2640 printk(KERN_INFO "forcedeth: request_irq failed for link %d\n", ret);
2641 pci_disable_msix(np->pci_dev); 2641 pci_disable_msix(np->pci_dev);
2642 np->msi_flags &= ~NV_MSI_X_ENABLED; 2642 np->msi_flags &= ~NV_MSI_X_ENABLED;
@@ -2651,9 +2651,9 @@ static int nv_request_irq(struct net_device *dev, int intr_test)
2651 } else { 2651 } else {
2652 /* Request irq for all interrupts */ 2652 /* Request irq for all interrupts */
2653 if ((!intr_test && 2653 if ((!intr_test &&
2654 request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) || 2654 request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq, IRQF_SHARED, dev->name, dev) != 0) ||
2655 (intr_test && 2655 (intr_test &&
2656 request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq_test, SA_SHIRQ, dev->name, dev) != 0)) { 2656 request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq_test, IRQF_SHARED, dev->name, dev) != 0)) {
2657 printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret); 2657 printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
2658 pci_disable_msix(np->pci_dev); 2658 pci_disable_msix(np->pci_dev);
2659 np->msi_flags &= ~NV_MSI_X_ENABLED; 2659 np->msi_flags &= ~NV_MSI_X_ENABLED;
@@ -2669,8 +2669,8 @@ static int nv_request_irq(struct net_device *dev, int intr_test)
2669 if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) { 2669 if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) {
2670 if ((ret = pci_enable_msi(np->pci_dev)) == 0) { 2670 if ((ret = pci_enable_msi(np->pci_dev)) == 0) {
2671 np->msi_flags |= NV_MSI_ENABLED; 2671 np->msi_flags |= NV_MSI_ENABLED;
2672 if ((!intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) || 2672 if ((!intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq, IRQF_SHARED, dev->name, dev) != 0) ||
2673 (intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq_test, SA_SHIRQ, dev->name, dev) != 0)) { 2673 (intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq_test, IRQF_SHARED, dev->name, dev) != 0)) {
2674 printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret); 2674 printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
2675 pci_disable_msi(np->pci_dev); 2675 pci_disable_msi(np->pci_dev);
2676 np->msi_flags &= ~NV_MSI_ENABLED; 2676 np->msi_flags &= ~NV_MSI_ENABLED;
@@ -2685,8 +2685,8 @@ static int nv_request_irq(struct net_device *dev, int intr_test)
2685 } 2685 }
2686 } 2686 }
2687 if (ret != 0) { 2687 if (ret != 0) {
2688 if ((!intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) || 2688 if ((!intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq, IRQF_SHARED, dev->name, dev) != 0) ||
2689 (intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq_test, SA_SHIRQ, dev->name, dev) != 0)) 2689 (intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq_test, IRQF_SHARED, dev->name, dev) != 0))
2690 goto out_err; 2690 goto out_err;
2691 2691
2692 } 2692 }
@@ -2735,21 +2735,21 @@ static void nv_do_nic_poll(unsigned long data)
2735 2735
2736 if (!using_multi_irqs(dev)) { 2736 if (!using_multi_irqs(dev)) {
2737 if (np->msi_flags & NV_MSI_X_ENABLED) 2737 if (np->msi_flags & NV_MSI_X_ENABLED)
2738 disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); 2738 disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector);
2739 else 2739 else
2740 disable_irq(dev->irq); 2740 disable_irq_lockdep(dev->irq);
2741 mask = np->irqmask; 2741 mask = np->irqmask;
2742 } else { 2742 } else {
2743 if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { 2743 if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) {
2744 disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); 2744 disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector);
2745 mask |= NVREG_IRQ_RX_ALL; 2745 mask |= NVREG_IRQ_RX_ALL;
2746 } 2746 }
2747 if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) { 2747 if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) {
2748 disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); 2748 disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector);
2749 mask |= NVREG_IRQ_TX_ALL; 2749 mask |= NVREG_IRQ_TX_ALL;
2750 } 2750 }
2751 if (np->nic_poll_irq & NVREG_IRQ_OTHER) { 2751 if (np->nic_poll_irq & NVREG_IRQ_OTHER) {
2752 disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector); 2752 disable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector);
2753 mask |= NVREG_IRQ_OTHER; 2753 mask |= NVREG_IRQ_OTHER;
2754 } 2754 }
2755 } 2755 }
@@ -2761,23 +2761,23 @@ static void nv_do_nic_poll(unsigned long data)
2761 pci_push(base); 2761 pci_push(base);
2762 2762
2763 if (!using_multi_irqs(dev)) { 2763 if (!using_multi_irqs(dev)) {
2764 nv_nic_irq((int) 0, (void *) data, (struct pt_regs *) NULL); 2764 nv_nic_irq(0, dev, NULL);
2765 if (np->msi_flags & NV_MSI_X_ENABLED) 2765 if (np->msi_flags & NV_MSI_X_ENABLED)
2766 enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); 2766 enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector);
2767 else 2767 else
2768 enable_irq(dev->irq); 2768 enable_irq_lockdep(dev->irq);
2769 } else { 2769 } else {
2770 if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { 2770 if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) {
2771 nv_nic_irq_rx((int) 0, (void *) data, (struct pt_regs *) NULL); 2771 nv_nic_irq_rx(0, dev, NULL);
2772 enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); 2772 enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector);
2773 } 2773 }
2774 if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) { 2774 if (np->nic_poll_irq & NVREG_IRQ_TX_ALL) {
2775 nv_nic_irq_tx((int) 0, (void *) data, (struct pt_regs *) NULL); 2775 nv_nic_irq_tx(0, dev, NULL);
2776 enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); 2776 enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector);
2777 } 2777 }
2778 if (np->nic_poll_irq & NVREG_IRQ_OTHER) { 2778 if (np->nic_poll_irq & NVREG_IRQ_OTHER) {
2779 nv_nic_irq_other((int) 0, (void *) data, (struct pt_regs *) NULL); 2779 nv_nic_irq_other(0, dev, NULL);
2780 enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector); 2780 enable_irq_lockdep(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector);
2781 } 2781 }
2782 } 2782 }
2783} 2783}
@@ -2991,13 +2991,13 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2991 netif_carrier_off(dev); 2991 netif_carrier_off(dev);
2992 if (netif_running(dev)) { 2992 if (netif_running(dev)) {
2993 nv_disable_irq(dev); 2993 nv_disable_irq(dev);
2994 spin_lock_bh(&dev->xmit_lock); 2994 netif_tx_lock_bh(dev);
2995 spin_lock(&np->lock); 2995 spin_lock(&np->lock);
2996 /* stop engines */ 2996 /* stop engines */
2997 nv_stop_rx(dev); 2997 nv_stop_rx(dev);
2998 nv_stop_tx(dev); 2998 nv_stop_tx(dev);
2999 spin_unlock(&np->lock); 2999 spin_unlock(&np->lock);
3000 spin_unlock_bh(&dev->xmit_lock); 3000 netif_tx_unlock_bh(dev);
3001 } 3001 }
3002 3002
3003 if (ecmd->autoneg == AUTONEG_ENABLE) { 3003 if (ecmd->autoneg == AUTONEG_ENABLE) {
@@ -3131,13 +3131,13 @@ static int nv_nway_reset(struct net_device *dev)
3131 netif_carrier_off(dev); 3131 netif_carrier_off(dev);
3132 if (netif_running(dev)) { 3132 if (netif_running(dev)) {
3133 nv_disable_irq(dev); 3133 nv_disable_irq(dev);
3134 spin_lock_bh(&dev->xmit_lock); 3134 netif_tx_lock_bh(dev);
3135 spin_lock(&np->lock); 3135 spin_lock(&np->lock);
3136 /* stop engines */ 3136 /* stop engines */
3137 nv_stop_rx(dev); 3137 nv_stop_rx(dev);
3138 nv_stop_tx(dev); 3138 nv_stop_tx(dev);
3139 spin_unlock(&np->lock); 3139 spin_unlock(&np->lock);
3140 spin_unlock_bh(&dev->xmit_lock); 3140 netif_tx_unlock_bh(dev);
3141 printk(KERN_INFO "%s: link down.\n", dev->name); 3141 printk(KERN_INFO "%s: link down.\n", dev->name);
3142 } 3142 }
3143 3143
@@ -3244,7 +3244,7 @@ static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ri
3244 3244
3245 if (netif_running(dev)) { 3245 if (netif_running(dev)) {
3246 nv_disable_irq(dev); 3246 nv_disable_irq(dev);
3247 spin_lock_bh(&dev->xmit_lock); 3247 netif_tx_lock_bh(dev);
3248 spin_lock(&np->lock); 3248 spin_lock(&np->lock);
3249 /* stop engines */ 3249 /* stop engines */
3250 nv_stop_rx(dev); 3250 nv_stop_rx(dev);
@@ -3303,7 +3303,7 @@ static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ri
3303 nv_start_rx(dev); 3303 nv_start_rx(dev);
3304 nv_start_tx(dev); 3304 nv_start_tx(dev);
3305 spin_unlock(&np->lock); 3305 spin_unlock(&np->lock);
3306 spin_unlock_bh(&dev->xmit_lock); 3306 netif_tx_unlock_bh(dev);
3307 nv_enable_irq(dev); 3307 nv_enable_irq(dev);
3308 } 3308 }
3309 return 0; 3309 return 0;
@@ -3339,13 +3339,13 @@ static int nv_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam*
3339 netif_carrier_off(dev); 3339 netif_carrier_off(dev);
3340 if (netif_running(dev)) { 3340 if (netif_running(dev)) {
3341 nv_disable_irq(dev); 3341 nv_disable_irq(dev);
3342 spin_lock_bh(&dev->xmit_lock); 3342 netif_tx_lock_bh(dev);
3343 spin_lock(&np->lock); 3343 spin_lock(&np->lock);
3344 /* stop engines */ 3344 /* stop engines */
3345 nv_stop_rx(dev); 3345 nv_stop_rx(dev);
3346 nv_stop_tx(dev); 3346 nv_stop_tx(dev);
3347 spin_unlock(&np->lock); 3347 spin_unlock(&np->lock);
3348 spin_unlock_bh(&dev->xmit_lock); 3348 netif_tx_unlock_bh(dev);
3349 } 3349 }
3350 3350
3351 np->pause_flags &= ~(NV_PAUSEFRAME_RX_REQ|NV_PAUSEFRAME_TX_REQ); 3351 np->pause_flags &= ~(NV_PAUSEFRAME_RX_REQ|NV_PAUSEFRAME_TX_REQ);
@@ -3729,7 +3729,7 @@ static void nv_self_test(struct net_device *dev, struct ethtool_test *test, u64
3729 if (test->flags & ETH_TEST_FL_OFFLINE) { 3729 if (test->flags & ETH_TEST_FL_OFFLINE) {
3730 if (netif_running(dev)) { 3730 if (netif_running(dev)) {
3731 netif_stop_queue(dev); 3731 netif_stop_queue(dev);
3732 spin_lock_bh(&dev->xmit_lock); 3732 netif_tx_lock_bh(dev);
3733 spin_lock_irq(&np->lock); 3733 spin_lock_irq(&np->lock);
3734 nv_disable_hw_interrupts(dev, np->irqmask); 3734 nv_disable_hw_interrupts(dev, np->irqmask);
3735 if (!(np->msi_flags & NV_MSI_X_ENABLED)) { 3735 if (!(np->msi_flags & NV_MSI_X_ENABLED)) {
@@ -3745,7 +3745,7 @@ static void nv_self_test(struct net_device *dev, struct ethtool_test *test, u64
3745 nv_drain_rx(dev); 3745 nv_drain_rx(dev);
3746 nv_drain_tx(dev); 3746 nv_drain_tx(dev);
3747 spin_unlock_irq(&np->lock); 3747 spin_unlock_irq(&np->lock);
3748 spin_unlock_bh(&dev->xmit_lock); 3748 netif_tx_unlock_bh(dev);
3749 } 3749 }
3750 3750
3751 if (!nv_register_test(dev)) { 3751 if (!nv_register_test(dev)) {
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 196298f33db8..f6abff5846b3 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -15,7 +15,6 @@
15 * kind, whether express or implied. 15 * kind, whether express or implied.
16 */ 16 */
17 17
18#include <linux/config.h>
19#include <linux/module.h> 18#include <linux/module.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/types.h> 20#include <linux/types.h>
@@ -672,7 +671,7 @@ static int fs_request_irq(struct net_device *dev, int irq, const char *name,
672 struct fs_enet_private *fep = netdev_priv(dev); 671 struct fs_enet_private *fep = netdev_priv(dev);
673 672
674 (*fep->ops->pre_request_irq)(dev, irq); 673 (*fep->ops->pre_request_irq)(dev, irq);
675 return request_irq(irq, irqf, SA_SHIRQ, name, dev); 674 return request_irq(irq, irqf, IRQF_SHARED, name, dev);
676} 675}
677 676
678static void fs_free_irq(struct net_device *dev, int irq) 677static void fs_free_irq(struct net_device *dev, int irq)
diff --git a/drivers/net/fs_enet/fs_enet-mii.c b/drivers/net/fs_enet/fs_enet-mii.c
index c6770377ef87..b7e6e21725cb 100644
--- a/drivers/net/fs_enet/fs_enet-mii.c
+++ b/drivers/net/fs_enet/fs_enet-mii.c
@@ -16,7 +16,6 @@
16 */ 16 */
17 17
18 18
19#include <linux/config.h>
20#include <linux/module.h> 19#include <linux/module.h>
21#include <linux/types.h> 20#include <linux/types.h>
22#include <linux/kernel.h> 21#include <linux/kernel.h>
@@ -431,8 +430,7 @@ static struct fs_enet_mii_bus *create_bus(const struct fs_mii_bus_info *bi)
431 return bus; 430 return bus;
432 431
433err: 432err:
434 if (bus) 433 kfree(bus);
435 kfree(bus);
436 return ERR_PTR(ret); 434 return ERR_PTR(ret);
437} 435}
438 436
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index 95e2bb8dd7b4..64e20982c1fe 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -12,7 +12,6 @@
12 * kind, whether express or implied. 12 * kind, whether express or implied.
13 */ 13 */
14 14
15#include <linux/config.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/types.h> 17#include <linux/types.h>
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index 3dad69dfdb2c..e09547077529 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -12,7 +12,6 @@
12 * kind, whether express or implied. 12 * kind, whether express or implied.
13 */ 13 */
14 14
15#include <linux/config.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/types.h> 17#include <linux/types.h>
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c
index a772b286f96d..eaa24fab645f 100644
--- a/drivers/net/fs_enet/mac-scc.c
+++ b/drivers/net/fs_enet/mac-scc.c
@@ -12,7 +12,6 @@
12 * kind, whether express or implied. 12 * kind, whether express or implied.
13 */ 13 */
14 14
15#include <linux/config.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/types.h> 17#include <linux/types.h>
diff --git a/drivers/net/fs_enet/mii-bitbang.c b/drivers/net/fs_enet/mii-bitbang.c
index 24a5e2e23d18..48f9cf83ab6f 100644
--- a/drivers/net/fs_enet/mii-bitbang.c
+++ b/drivers/net/fs_enet/mii-bitbang.c
@@ -13,7 +13,6 @@
13 */ 13 */
14 14
15 15
16#include <linux/config.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/types.h> 17#include <linux/types.h>
19#include <linux/kernel.h> 18#include <linux/kernel.h>
diff --git a/drivers/net/fs_enet/mii-fixed.c b/drivers/net/fs_enet/mii-fixed.c
index b3e192d612e5..ae4a9c3bb393 100644
--- a/drivers/net/fs_enet/mii-fixed.c
+++ b/drivers/net/fs_enet/mii-fixed.c
@@ -13,7 +13,6 @@
13 */ 13 */
14 14
15 15
16#include <linux/config.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/types.h> 17#include <linux/types.h>
19#include <linux/kernel.h> 18#include <linux/kernel.h>
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 218d31764c52..ebbbd6ca6204 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -64,7 +64,6 @@
64 * The driver then cleans up the buffer. 64 * The driver then cleans up the buffer.
65 */ 65 */
66 66
67#include <linux/config.h>
68#include <linux/kernel.h> 67#include <linux/kernel.h>
69#include <linux/sched.h> 68#include <linux/sched.h>
70#include <linux/string.h> 69#include <linux/string.h>
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 127c98cf3336..f87bbc408dae 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -22,7 +22,6 @@
22#ifndef __GIANFAR_H 22#ifndef __GIANFAR_H
23#define __GIANFAR_H 23#define __GIANFAR_H
24 24
25#include <linux/config.h>
26#include <linux/kernel.h> 25#include <linux/kernel.h>
27#include <linux/sched.h> 26#include <linux/sched.h>
28#include <linux/string.h> 27#include <linux/string.h>
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index d69698c695ef..e0f505285e50 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -15,7 +15,6 @@
15 * by reference. 15 * by reference.
16 */ 16 */
17 17
18#include <linux/config.h>
19#include <linux/kernel.h> 18#include <linux/kernel.h>
20#include <linux/sched.h> 19#include <linux/sched.h>
21#include <linux/string.h> 20#include <linux/string.h>
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c
index c6b725529af5..c92e65984fd0 100644
--- a/drivers/net/gianfar_mii.c
+++ b/drivers/net/gianfar_mii.c
@@ -16,7 +16,6 @@
16 * 16 *
17 */ 17 */
18 18
19#include <linux/config.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/sched.h> 20#include <linux/sched.h>
22#include <linux/string.h> 21#include <linux/string.h>
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c
index a6d5c43199cb..e8a18f18d08c 100644
--- a/drivers/net/gianfar_sysfs.c
+++ b/drivers/net/gianfar_sysfs.c
@@ -19,7 +19,6 @@
19 * Sysfs file creation and management 19 * Sysfs file creation and management
20 */ 20 */
21 21
22#include <linux/config.h>
23#include <linux/kernel.h> 22#include <linux/kernel.h>
24#include <linux/sched.h> 23#include <linux/sched.h>
25#include <linux/string.h> 24#include <linux/string.h>
diff --git a/drivers/net/gt96100eth.c b/drivers/net/gt96100eth.c
index 2d2435404614..2b4db7414475 100644
--- a/drivers/net/gt96100eth.c
+++ b/drivers/net/gt96100eth.c
@@ -699,7 +699,6 @@ static int __init gt96100_probe1(struct pci_dev *pci, int port_num)
699 memset(gp, 0, sizeof(*gp)); // clear it 699 memset(gp, 0, sizeof(*gp)); // clear it
700 700
701 gp->port_num = port_num; 701 gp->port_num = port_num;
702 gp->io_size = GT96100_ETH_IO_SIZE;
703 gp->port_offset = port_num * GT96100_ETH_IO_SIZE; 702 gp->port_offset = port_num * GT96100_ETH_IO_SIZE;
704 gp->phy_addr = phy_addr; 703 gp->phy_addr = phy_addr;
705 gp->chip_rev = chip_rev; 704 gp->chip_rev = chip_rev;
@@ -1030,7 +1029,7 @@ gt96100_open(struct net_device *dev)
1030 } 1029 }
1031 1030
1032 if ((retval = request_irq(dev->irq, &gt96100_interrupt, 1031 if ((retval = request_irq(dev->irq, &gt96100_interrupt,
1033 SA_SHIRQ, dev->name, dev))) { 1032 IRQF_SHARED, dev->name, dev))) {
1034 err("unable to get IRQ %d\n", dev->irq); 1033 err("unable to get IRQ %d\n", dev->irq);
1035 return retval; 1034 return retval;
1036 } 1035 }
@@ -1531,7 +1530,7 @@ static void gt96100_cleanup_module(void)
1531 + sizeof(gt96100_td_t) * TX_RING_SIZE, 1530 + sizeof(gt96100_td_t) * TX_RING_SIZE,
1532 gp->rx_ring); 1531 gp->rx_ring);
1533 free_netdev(gtif->dev); 1532 free_netdev(gtif->dev);
1534 release_region(gtif->iobase, gp->io_size); 1533 release_region(gtif->iobase, GT96100_ETH_IO_SIZE);
1535 } 1534 }
1536 } 1535 }
1537} 1536}
diff --git a/drivers/net/gt96100eth.h b/drivers/net/gt96100eth.h
index 395869c5ed3e..3b62a87c7d7f 100644
--- a/drivers/net/gt96100eth.h
+++ b/drivers/net/gt96100eth.h
@@ -27,7 +27,6 @@
27#ifndef _GT96100ETH_H 27#ifndef _GT96100ETH_H
28#define _GT96100ETH_H 28#define _GT96100ETH_H
29 29
30#include <linux/config.h>
31#include <asm/galileo-boards/gt96100.h> 30#include <asm/galileo-boards/gt96100.h>
32 31
33#define dbg(lvl, format, arg...) \ 32#define dbg(lvl, format, arg...) \
@@ -332,7 +331,6 @@ struct gt96100_private {
332 mib_counters_t mib; 331 mib_counters_t mib;
333 struct net_device_stats stats; 332 struct net_device_stats stats;
334 333
335 int io_size;
336 int port_num; // 0 or 1 334 int port_num; // 0 or 1
337 int chip_rev; 335 int chip_rev;
338 u32 port_offset; 336 u32 port_offset;
@@ -341,7 +339,6 @@ struct gt96100_private {
341 u32 last_psr; // last value of the port status register 339 u32 last_psr; // last value of the port status register
342 340
343 int options; /* User-settable misc. driver options. */ 341 int options; /* User-settable misc. driver options. */
344 int drv_flags;
345 struct timer_list timer; 342 struct timer_list timer;
346 spinlock_t lock; /* Serialise access to device */ 343 spinlock_t lock; /* Serialise access to device */
347}; 344};
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index 0ea4cb4a0d80..409c6aab0411 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -20,22 +20,15 @@
20 20
21 Support and updates available at 21 Support and updates available at
22 http://www.scyld.com/network/hamachi.html 22 http://www.scyld.com/network/hamachi.html
23 [link no longer provides useful info -jgarzik]
23 or 24 or
24 http://www.parl.clemson.edu/~keithu/hamachi.html 25 http://www.parl.clemson.edu/~keithu/hamachi.html
25 26
26
27
28 Linux kernel changelog:
29
30 LK1.0.1:
31 - fix lack of pci_dev<->dev association
32 - ethtool support (jgarzik)
33
34*/ 27*/
35 28
36#define DRV_NAME "hamachi" 29#define DRV_NAME "hamachi"
37#define DRV_VERSION "1.01+LK1.0.1" 30#define DRV_VERSION "2.0"
38#define DRV_RELDATE "5/18/2001" 31#define DRV_RELDATE "June 27, 2006"
39 32
40 33
41/* A few user-configurable values. */ 34/* A few user-configurable values. */
@@ -608,7 +601,8 @@ static int __devinit hamachi_init_one (struct pci_dev *pdev,
608 pci_set_master(pdev); 601 pci_set_master(pdev);
609 602
610 i = pci_request_regions(pdev, DRV_NAME); 603 i = pci_request_regions(pdev, DRV_NAME);
611 if (i) return i; 604 if (i)
605 return i;
612 606
613 irq = pdev->irq; 607 irq = pdev->irq;
614 ioaddr = ioremap(base, 0x400); 608 ioaddr = ioremap(base, 0x400);
@@ -871,7 +865,7 @@ static int hamachi_open(struct net_device *dev)
871 u32 rx_int_var, tx_int_var; 865 u32 rx_int_var, tx_int_var;
872 u16 fifo_info; 866 u16 fifo_info;
873 867
874 i = request_irq(dev->irq, &hamachi_interrupt, SA_SHIRQ, dev->name, dev); 868 i = request_irq(dev->irq, &hamachi_interrupt, IRQF_SHARED, dev->name, dev);
875 if (i) 869 if (i)
876 return i; 870 return i;
877 871
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index d12605f0ac7c..86b3bb9bec2d 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -12,7 +12,6 @@
12 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> 12 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
13 */ 13 */
14 14
15#include <linux/config.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <asm/system.h> 16#include <asm/system.h>
18#include <asm/uaccess.h> 17#include <asm/uaccess.h>
diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
index 232793d2ce6b..55906c7b4bb1 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -434,7 +434,7 @@ static int ser12_open(struct net_device *dev)
434 outb(0, FCR(dev->base_addr)); /* disable FIFOs */ 434 outb(0, FCR(dev->base_addr)); /* disable FIFOs */
435 outb(0x0d, MCR(dev->base_addr)); 435 outb(0x0d, MCR(dev->base_addr));
436 outb(0, IER(dev->base_addr)); 436 outb(0, IER(dev->base_addr));
437 if (request_irq(dev->irq, ser12_interrupt, SA_INTERRUPT | SA_SHIRQ, 437 if (request_irq(dev->irq, ser12_interrupt, IRQF_DISABLED | IRQF_SHARED,
438 "baycom_ser_fdx", dev)) { 438 "baycom_ser_fdx", dev)) {
439 release_region(dev->base_addr, SER12_EXTENT); 439 release_region(dev->base_addr, SER12_EXTENT);
440 return -EBUSY; 440 return -EBUSY;
diff --git a/drivers/net/hamradio/baycom_ser_hdx.c b/drivers/net/hamradio/baycom_ser_hdx.c
index be596a3eb3fd..de95de8983da 100644
--- a/drivers/net/hamradio/baycom_ser_hdx.c
+++ b/drivers/net/hamradio/baycom_ser_hdx.c
@@ -488,7 +488,7 @@ static int ser12_open(struct net_device *dev)
488 outb(0, FCR(dev->base_addr)); /* disable FIFOs */ 488 outb(0, FCR(dev->base_addr)); /* disable FIFOs */
489 outb(0x0d, MCR(dev->base_addr)); 489 outb(0x0d, MCR(dev->base_addr));
490 outb(0, IER(dev->base_addr)); 490 outb(0, IER(dev->base_addr));
491 if (request_irq(dev->irq, ser12_interrupt, SA_INTERRUPT | SA_SHIRQ, 491 if (request_irq(dev->irq, ser12_interrupt, IRQF_DISABLED | IRQF_SHARED,
492 "baycom_ser12", dev)) { 492 "baycom_ser12", dev)) {
493 release_region(dev->base_addr, SER12_EXTENT); 493 release_region(dev->base_addr, SER12_EXTENT);
494 return -EBUSY; 494 return -EBUSY;
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c
index cb43a9d28774..0641f54fc638 100644
--- a/drivers/net/hamradio/bpqether.c
+++ b/drivers/net/hamradio/bpqether.c
@@ -54,7 +54,6 @@
54 * BPQ 004 Joerg(DL1BKE) Fixed to not lock up on ifconfig. 54 * BPQ 004 Joerg(DL1BKE) Fixed to not lock up on ifconfig.
55 */ 55 */
56 56
57#include <linux/config.h>
58#include <linux/errno.h> 57#include <linux/errno.h>
59#include <linux/types.h> 58#include <linux/types.h>
60#include <linux/socket.h> 59#include <linux/socket.h>
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index 0d5fccc984bb..c9a46b89942a 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -436,7 +436,7 @@ static int __init dmascc_init(void)
436module_init(dmascc_init); 436module_init(dmascc_init);
437module_exit(dmascc_exit); 437module_exit(dmascc_exit);
438 438
439static void dev_setup(struct net_device *dev) 439static void __init dev_setup(struct net_device *dev)
440{ 440{
441 dev->type = ARPHRD_AX25; 441 dev->type = ARPHRD_AX25;
442 dev->hard_header_len = AX25_MAX_HEADER_LEN; 442 dev->hard_header_len = AX25_MAX_HEADER_LEN;
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index 3ebbbe56b6e9..d8715b200c17 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -16,7 +16,6 @@
16 * Copyright (C) 2004, 05 Ralf Baechle DL5RB <ralf@linux-mips.org> 16 * Copyright (C) 2004, 05 Ralf Baechle DL5RB <ralf@linux-mips.org>
17 * Copyright (C) 2004, 05 Thomas Osterried DL9SAU <thomas@x-berg.in-berlin.de> 17 * Copyright (C) 2004, 05 Thomas Osterried DL9SAU <thomas@x-berg.in-berlin.de>
18 */ 18 */
19#include <linux/config.h>
20#include <linux/module.h> 19#include <linux/module.h>
21#include <asm/system.h> 20#include <asm/system.h>
22#include <linux/bitops.h> 21#include <linux/bitops.h>
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index 5927784df3f9..df4b68142ac7 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -148,7 +148,6 @@
148 148
149/* ----------------------------------------------------------------------- */ 149/* ----------------------------------------------------------------------- */
150 150
151#include <linux/config.h>
152#include <linux/module.h> 151#include <linux/module.h>
153#include <linux/errno.h> 152#include <linux/errno.h>
154#include <linux/signal.h> 153#include <linux/signal.h>
@@ -1737,7 +1736,7 @@ static int scc_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1737 1736
1738 if (!Ivec[hwcfg.irq].used && hwcfg.irq) 1737 if (!Ivec[hwcfg.irq].used && hwcfg.irq)
1739 { 1738 {
1740 if (request_irq(hwcfg.irq, scc_isr, SA_INTERRUPT, "AX.25 SCC", NULL)) 1739 if (request_irq(hwcfg.irq, scc_isr, IRQF_DISABLED, "AX.25 SCC", NULL))
1741 printk(KERN_WARNING "z8530drv: warning, cannot get IRQ %d\n", hwcfg.irq); 1740 printk(KERN_WARNING "z8530drv: warning, cannot get IRQ %d\n", hwcfg.irq);
1742 else 1741 else
1743 Ivec[hwcfg.irq].used = 1; 1742 Ivec[hwcfg.irq].used = 1;
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index b49884048caa..f98f5777dfbb 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -42,7 +42,6 @@
42 42
43/*****************************************************************************/ 43/*****************************************************************************/
44 44
45#include <linux/config.h>
46#include <linux/module.h> 45#include <linux/module.h>
47#include <linux/types.h> 46#include <linux/types.h>
48#include <linux/net.h> 47#include <linux/net.h>
@@ -874,7 +873,7 @@ static int yam_open(struct net_device *dev)
874 goto out_release_base; 873 goto out_release_base;
875 } 874 }
876 outb(0, IER(dev->base_addr)); 875 outb(0, IER(dev->base_addr));
877 if (request_irq(dev->irq, yam_interrupt, SA_INTERRUPT | SA_SHIRQ, dev->name, dev)) { 876 if (request_irq(dev->irq, yam_interrupt, IRQF_DISABLED | IRQF_SHARED, dev->name, dev)) {
878 printk(KERN_ERR "%s: irq %d busy\n", dev->name, dev->irq); 877 printk(KERN_ERR "%s: irq %d busy\n", dev->name, dev->irq);
879 ret = -EBUSY; 878 ret = -EBUSY;
880 goto out_release_base; 879 goto out_release_base;
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c
index 247c8ca86033..e7d9bf330287 100644
--- a/drivers/net/hp100.c
+++ b/drivers/net/hp100.c
@@ -1079,7 +1079,7 @@ static int hp100_open(struct net_device *dev)
1079 /* New: if bus is PCI or EISA, interrupts might be shared interrupts */ 1079 /* New: if bus is PCI or EISA, interrupts might be shared interrupts */
1080 if (request_irq(dev->irq, hp100_interrupt, 1080 if (request_irq(dev->irq, hp100_interrupt,
1081 lp->bus == HP100_BUS_PCI || lp->bus == 1081 lp->bus == HP100_BUS_PCI || lp->bus ==
1082 HP100_BUS_EISA ? SA_SHIRQ : SA_INTERRUPT, 1082 HP100_BUS_EISA ? IRQF_SHARED : IRQF_DISABLED,
1083 "hp100", dev)) { 1083 "hp100", dev)) {
1084 printk("hp100: %s: unable to get IRQ %d\n", dev->name, dev->irq); 1084 printk("hp100: %s: unable to get IRQ %d\n", dev->name, dev->irq);
1085 return -EAGAIN; 1085 return -EAGAIN;
@@ -1487,11 +1487,8 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev)
1487 if (skb->len <= 0) 1487 if (skb->len <= 0)
1488 return 0; 1488 return 0;
1489 1489
1490 if (skb->len < ETH_ZLEN && lp->chip == HP100_CHIPID_SHASTA) { 1490 if (lp->chip == HP100_CHIPID_SHASTA && skb_padto(skb, ETH_ZLEN))
1491 skb = skb_padto(skb, ETH_ZLEN); 1491 return 0;
1492 if (skb == NULL)
1493 return 0;
1494 }
1495 1492
1496 /* Get Tx ring tail pointer */ 1493 /* Get Tx ring tail pointer */
1497 if (lp->txrtail->next == lp->txrhead) { 1494 if (lp->txrtail->next == lp->txrhead) {
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index d9fb8e74e631..91326ea3e12b 100644
--- a/drivers/net/hydra.c
+++ b/drivers/net/hydra.c
@@ -117,7 +117,7 @@ static int __devinit hydra_init(struct zorro_dev *z)
117 dev->irq = IRQ_AMIGA_PORTS; 117 dev->irq = IRQ_AMIGA_PORTS;
118 118
119 /* Install the Interrupt handler */ 119 /* Install the Interrupt handler */
120 if (request_irq(IRQ_AMIGA_PORTS, ei_interrupt, SA_SHIRQ, "Hydra Ethernet", 120 if (request_irq(IRQ_AMIGA_PORTS, ei_interrupt, IRQF_SHARED, "Hydra Ethernet",
121 dev)) { 121 dev)) {
122 free_netdev(dev); 122 free_netdev(dev);
123 return -EAGAIN; 123 return -EAGAIN;
diff --git a/drivers/net/ibm_emac/ibm_emac.h b/drivers/net/ibm_emac/ibm_emac.h
index c2dae6092c4c..97ed22bb4320 100644
--- a/drivers/net/ibm_emac/ibm_emac.h
+++ b/drivers/net/ibm_emac/ibm_emac.h
@@ -20,7 +20,6 @@
20#ifndef __IBM_EMAC_H_ 20#ifndef __IBM_EMAC_H_
21#define __IBM_EMAC_H_ 21#define __IBM_EMAC_H_
22 22
23#include <linux/config.h>
24#include <linux/types.h> 23#include <linux/types.h>
25 24
26/* This is a simple check to prevent use of this driver on non-tested SoCs */ 25/* This is a simple check to prevent use of this driver on non-tested SoCs */
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
index 7e49522b8b3c..82468e2dc799 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -19,7 +19,6 @@
19 * 19 *
20 */ 20 */
21 21
22#include <linux/config.h>
23#include <linux/module.h> 22#include <linux/module.h>
24#include <linux/kernel.h> 23#include <linux/kernel.h>
25#include <linux/sched.h> 24#include <linux/sched.h>
diff --git a/drivers/net/ibm_emac/ibm_emac_core.h b/drivers/net/ibm_emac/ibm_emac_core.h
index f61273b2e94f..dabb94afeb98 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.h
+++ b/drivers/net/ibm_emac/ibm_emac_core.h
@@ -20,7 +20,6 @@
20#ifndef __IBM_EMAC_CORE_H_ 20#ifndef __IBM_EMAC_CORE_H_
21#define __IBM_EMAC_CORE_H_ 21#define __IBM_EMAC_CORE_H_
22 22
23#include <linux/config.h>
24#include <linux/netdevice.h> 23#include <linux/netdevice.h>
25#include <linux/dma-mapping.h> 24#include <linux/dma-mapping.h>
26#include <asm/ocp.h> 25#include <asm/ocp.h>
diff --git a/drivers/net/ibm_emac/ibm_emac_debug.c b/drivers/net/ibm_emac/ibm_emac_debug.c
index c7e1ecfa08fe..c3645908034d 100644
--- a/drivers/net/ibm_emac/ibm_emac_debug.c
+++ b/drivers/net/ibm_emac/ibm_emac_debug.c
@@ -12,7 +12,6 @@
12 * option) any later version. 12 * option) any later version.
13 * 13 *
14 */ 14 */
15#include <linux/config.h>
16#include <linux/init.h> 15#include <linux/init.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/kernel.h> 17#include <linux/kernel.h>
diff --git a/drivers/net/ibm_emac/ibm_emac_debug.h b/drivers/net/ibm_emac/ibm_emac_debug.h
index e85fbe0a8da9..5761389495d0 100644
--- a/drivers/net/ibm_emac/ibm_emac_debug.h
+++ b/drivers/net/ibm_emac/ibm_emac_debug.h
@@ -15,7 +15,6 @@
15#ifndef __IBM_EMAC_DEBUG_H_ 15#ifndef __IBM_EMAC_DEBUG_H_
16#define __IBM_EMAC_DEBUG_H_ 16#define __IBM_EMAC_DEBUG_H_
17 17
18#include <linux/config.h>
19#include <linux/init.h> 18#include <linux/init.h>
20#include "ibm_emac_core.h" 19#include "ibm_emac_core.h"
21#include "ibm_emac_mal.h" 20#include "ibm_emac_mal.h"
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.c b/drivers/net/ibm_emac/ibm_emac_mal.c
index da88d43081cc..af50e7b2e0d7 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.c
+++ b/drivers/net/ibm_emac/ibm_emac_mal.c
@@ -19,7 +19,6 @@
19 * option) any later version. 19 * option) any later version.
20 * 20 *
21 */ 21 */
22#include <linux/config.h>
23#include <linux/module.h> 22#include <linux/module.h>
24#include <linux/kernel.h> 23#include <linux/kernel.h>
25#include <linux/errno.h> 24#include <linux/errno.h>
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h b/drivers/net/ibm_emac/ibm_emac_mal.h
index 2a2d3b24b037..f73f10a0a562 100644
--- a/drivers/net/ibm_emac/ibm_emac_mal.h
+++ b/drivers/net/ibm_emac/ibm_emac_mal.h
@@ -19,7 +19,6 @@
19#ifndef __IBM_EMAC_MAL_H_ 19#ifndef __IBM_EMAC_MAL_H_
20#define __IBM_EMAC_MAL_H_ 20#define __IBM_EMAC_MAL_H_
21 21
22#include <linux/config.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/list.h> 23#include <linux/list.h>
25#include <linux/netdevice.h> 24#include <linux/netdevice.h>
diff --git a/drivers/net/ibm_emac/ibm_emac_phy.c b/drivers/net/ibm_emac/ibm_emac_phy.c
index 67935dd33a65..4a97024061e5 100644
--- a/drivers/net/ibm_emac/ibm_emac_phy.c
+++ b/drivers/net/ibm_emac/ibm_emac_phy.c
@@ -12,7 +12,6 @@
12 * (c) 2004-2005, Eugene Surovegin <ebs@ebshome.net> 12 * (c) 2004-2005, Eugene Surovegin <ebs@ebshome.net>
13 * 13 *
14 */ 14 */
15#include <linux/config.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/types.h> 17#include <linux/types.h>
diff --git a/drivers/net/ibm_emac/ibm_emac_rgmii.c b/drivers/net/ibm_emac/ibm_emac_rgmii.c
index f0b1ffb2dbbf..53d281cb9a16 100644
--- a/drivers/net/ibm_emac/ibm_emac_rgmii.c
+++ b/drivers/net/ibm_emac/ibm_emac_rgmii.c
@@ -16,7 +16,6 @@
16 * option) any later version. 16 * option) any later version.
17 * 17 *
18 */ 18 */
19#include <linux/config.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/ethtool.h> 20#include <linux/ethtool.h>
22#include <asm/io.h> 21#include <asm/io.h>
diff --git a/drivers/net/ibm_emac/ibm_emac_rgmii.h b/drivers/net/ibm_emac/ibm_emac_rgmii.h
index 7f03d536c9a3..94abde55e2e9 100644
--- a/drivers/net/ibm_emac/ibm_emac_rgmii.h
+++ b/drivers/net/ibm_emac/ibm_emac_rgmii.h
@@ -21,7 +21,6 @@
21#ifndef _IBM_EMAC_RGMII_H_ 21#ifndef _IBM_EMAC_RGMII_H_
22#define _IBM_EMAC_RGMII_H_ 22#define _IBM_EMAC_RGMII_H_
23 23
24#include <linux/config.h>
25 24
26/* RGMII bridge */ 25/* RGMII bridge */
27struct rgmii_regs { 26struct rgmii_regs {
diff --git a/drivers/net/ibm_emac/ibm_emac_tah.c b/drivers/net/ibm_emac/ibm_emac_tah.c
index af08afc22f9f..e287b451bb44 100644
--- a/drivers/net/ibm_emac/ibm_emac_tah.c
+++ b/drivers/net/ibm_emac/ibm_emac_tah.c
@@ -13,7 +13,6 @@
13 * Free Software Foundation; either version 2 of the License, or (at your 13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version. 14 * option) any later version.
15 */ 15 */
16#include <linux/config.h>
17#include <asm/io.h> 16#include <asm/io.h>
18 17
19#include "ibm_emac_core.h" 18#include "ibm_emac_core.h"
diff --git a/drivers/net/ibm_emac/ibm_emac_tah.h b/drivers/net/ibm_emac/ibm_emac_tah.h
index 9299b5dd7eb1..38153945a240 100644
--- a/drivers/net/ibm_emac/ibm_emac_tah.h
+++ b/drivers/net/ibm_emac/ibm_emac_tah.h
@@ -17,7 +17,6 @@
17#ifndef _IBM_EMAC_TAH_H 17#ifndef _IBM_EMAC_TAH_H
18#define _IBM_EMAC_TAH_H 18#define _IBM_EMAC_TAH_H
19 19
20#include <linux/config.h>
21#include <linux/init.h> 20#include <linux/init.h>
22#include <asm/ocp.h> 21#include <asm/ocp.h>
23 22
diff --git a/drivers/net/ibm_emac/ibm_emac_zmii.c b/drivers/net/ibm_emac/ibm_emac_zmii.c
index e129e0aaa045..37dc8f342868 100644
--- a/drivers/net/ibm_emac/ibm_emac_zmii.c
+++ b/drivers/net/ibm_emac/ibm_emac_zmii.c
@@ -16,7 +16,6 @@
16 * option) any later version. 16 * option) any later version.
17 * 17 *
18 */ 18 */
19#include <linux/config.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/ethtool.h> 20#include <linux/ethtool.h>
22#include <asm/io.h> 21#include <asm/io.h>
diff --git a/drivers/net/ibm_emac/ibm_emac_zmii.h b/drivers/net/ibm_emac/ibm_emac_zmii.h
index 92c854410753..972e3a44a09f 100644
--- a/drivers/net/ibm_emac/ibm_emac_zmii.h
+++ b/drivers/net/ibm_emac/ibm_emac_zmii.h
@@ -19,7 +19,6 @@
19#ifndef _IBM_EMAC_ZMII_H_ 19#ifndef _IBM_EMAC_ZMII_H_
20#define _IBM_EMAC_ZMII_H_ 20#define _IBM_EMAC_ZMII_H_
21 21
22#include <linux/config.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <asm/ocp.h> 23#include <asm/ocp.h>
25 24
diff --git a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c
index 51fd51609ea9..2a95d72fa593 100644
--- a/drivers/net/ibmlana.c
+++ b/drivers/net/ibmlana.c
@@ -782,7 +782,7 @@ static int ibmlana_open(struct net_device *dev)
782 782
783 /* register resources - only necessary for IRQ */ 783 /* register resources - only necessary for IRQ */
784 784
785 result = request_irq(priv->realirq, irq_handler, SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 785 result = request_irq(priv->realirq, irq_handler, IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
786 if (result != 0) { 786 if (result != 0) {
787 printk(KERN_ERR "%s: failed to register irq %d\n", dev->name, dev->irq); 787 printk(KERN_ERR "%s: failed to register irq %d\n", dev->name, dev->irq);
788 return result; 788 return result;
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 666346f6469e..0464e78f733a 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -33,7 +33,6 @@
33 - possibly remove procfs support 33 - possibly remove procfs support
34*/ 34*/
35 35
36#include <linux/config.h>
37#include <linux/module.h> 36#include <linux/module.h>
38#include <linux/types.h> 37#include <linux/types.h>
39#include <linux/errno.h> 38#include <linux/errno.h>
@@ -61,7 +60,7 @@
61#undef DEBUG 60#undef DEBUG
62 61
63#define ibmveth_printk(fmt, args...) \ 62#define ibmveth_printk(fmt, args...) \
64 printk(KERN_INFO "%s: " fmt, __FILE__, ## args) 63 printk(KERN_DEBUG "%s: " fmt, __FILE__, ## args)
65 64
66#define ibmveth_error_printk(fmt, args...) \ 65#define ibmveth_error_printk(fmt, args...) \
67 printk(KERN_ERR "(%s:%3.3d ua:%x) ERROR: " fmt, __FILE__, __LINE__ , adapter->vdev->unit_address, ## args) 66 printk(KERN_ERR "(%s:%3.3d ua:%x) ERROR: " fmt, __FILE__, __LINE__ , adapter->vdev->unit_address, ## args)
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 2e222ef91e22..3a42afab5036 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -27,7 +27,6 @@
27*/ 27*/
28 28
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/netdevice.h> 32#include <linux/netdevice.h>
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index ae71ed57c12d..68d8af7df08e 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -30,7 +30,6 @@
30#define IOC3_NAME "ioc3-eth" 30#define IOC3_NAME "ioc3-eth"
31#define IOC3_VERSION "2.6.3-3" 31#define IOC3_VERSION "2.6.3-3"
32 32
33#include <linux/config.h>
34#include <linux/init.h> 33#include <linux/init.h>
35#include <linux/delay.h> 34#include <linux/delay.h>
36#include <linux/kernel.h> 35#include <linux/kernel.h>
@@ -145,7 +144,7 @@ static inline struct sk_buff * ioc3_alloc_skb(unsigned long length,
145static inline unsigned long ioc3_map(void *ptr, unsigned long vdev) 144static inline unsigned long ioc3_map(void *ptr, unsigned long vdev)
146{ 145{
147#ifdef CONFIG_SGI_IP27 146#ifdef CONFIG_SGI_IP27
148 vdev <<= 58; /* Shift to PCI64_ATTR_VIRTUAL */ 147 vdev <<= 57; /* Shift to PCI64_ATTR_VIRTUAL */
149 148
150 return vdev | (0xaUL << PCI64_ATTR_TARG_SHFT) | PCI64_ATTR_PREF | 149 return vdev | (0xaUL << PCI64_ATTR_TARG_SHFT) | PCI64_ATTR_PREF |
151 ((unsigned long)ptr & TO_PHYS_MASK); 150 ((unsigned long)ptr & TO_PHYS_MASK);
@@ -1064,7 +1063,7 @@ static int ioc3_open(struct net_device *dev)
1064{ 1063{
1065 struct ioc3_private *ip = netdev_priv(dev); 1064 struct ioc3_private *ip = netdev_priv(dev);
1066 1065
1067 if (request_irq(dev->irq, ioc3_interrupt, SA_SHIRQ, ioc3_str, dev)) { 1066 if (request_irq(dev->irq, ioc3_interrupt, IRQF_SHARED, ioc3_str, dev)) {
1068 printk(KERN_ERR "%s: Can't get irq %d\n", dev->name, dev->irq); 1067 printk(KERN_ERR "%s: Can't get irq %d\n", dev->name, dev->irq);
1069 1068
1070 return -EAGAIN; 1069 return -EAGAIN;
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index d2ce4896abff..e9e6d99a9add 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -350,7 +350,7 @@ config TOSHIBA_FIR
350 350
351config AU1000_FIR 351config AU1000_FIR
352 tristate "Alchemy Au1000 SIR/FIR" 352 tristate "Alchemy Au1000 SIR/FIR"
353 depends on MIPS_AU1000 && IRDA 353 depends on SOC_AU1000 && IRDA
354 354
355config SMC_IRCC_FIR 355config SMC_IRCC_FIR
356 tristate "SMSC IrCC (EXPERIMENTAL)" 356 tristate "SMSC IrCC (EXPERIMENTAL)"
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index e6b1985767c2..7b2b4135bb23 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -18,7 +18,6 @@
18 * with this program; if not, write to the Free Software Foundation, Inc., 18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 19 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
20 */ 20 */
21#include <linux/config.h>
22#include <linux/module.h> 21#include <linux/module.h>
23#include <linux/types.h> 22#include <linux/types.h>
24#include <linux/init.h> 23#include <linux/init.h>
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 910c0cab35b0..33c07d5275da 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -1372,7 +1372,7 @@ toshoboe_net_open (struct net_device *dev)
1372 return 0; 1372 return 0;
1373 1373
1374 if (request_irq (self->io.irq, toshoboe_interrupt, 1374 if (request_irq (self->io.irq, toshoboe_interrupt,
1375 SA_SHIRQ | SA_INTERRUPT, dev->name, (void *) self)) 1375 IRQF_SHARED | IRQF_DISABLED, dev->name, (void *) self))
1376 { 1376 {
1377 return -EAGAIN; 1377 return -EAGAIN;
1378 } 1378 }
@@ -1573,7 +1573,7 @@ toshoboe_open (struct pci_dev *pci_dev, const struct pci_device_id *pdid)
1573 self->io.fir_base = self->base; 1573 self->io.fir_base = self->base;
1574 self->io.fir_ext = OBOE_IO_EXTENT; 1574 self->io.fir_ext = OBOE_IO_EXTENT;
1575 self->io.irq = pci_dev->irq; 1575 self->io.irq = pci_dev->irq;
1576 self->io.irqflags = SA_SHIRQ | SA_INTERRUPT; 1576 self->io.irqflags = IRQF_SHARED | IRQF_DISABLED;
1577 1577
1578 self->speed = self->io.speed = 9600; 1578 self->speed = self->io.speed = 9600;
1579 self->async = 0; 1579 self->async = 0;
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 844fa74ac9ec..2a0d538b387f 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1105,7 +1105,7 @@ static int stir421x_patch_device(struct irda_usb_cb *self)
1105 return ret; 1105 return ret;
1106 1106
1107 /* We get a patch from userspace */ 1107 /* We get a patch from userspace */
1108 IRDA_MESSAGE("%s(): Received firmware %s (%u bytes)\n", 1108 IRDA_MESSAGE("%s(): Received firmware %s (%zu bytes)\n",
1109 __FUNCTION__, stir421x_fw_name, fw->size); 1109 __FUNCTION__, stir421x_fw_name, fw->size);
1110 1110
1111 ret = -EINVAL; 1111 ret = -EINVAL;
diff --git a/drivers/net/irda/irport.c b/drivers/net/irda/irport.c
index 98fa5319e5cc..44efd49bf4a9 100644
--- a/drivers/net/irda/irport.c
+++ b/drivers/net/irda/irport.c
@@ -386,7 +386,7 @@ static int __irport_change_speed(struct irda_task *task)
386 /* Locking notes : this function may be called from irq context with 386 /* Locking notes : this function may be called from irq context with
387 * spinlock, via irport_write_wakeup(), or from non-interrupt without 387 * spinlock, via irport_write_wakeup(), or from non-interrupt without
388 * spinlock (from the task timer). Yuck ! 388 * spinlock (from the task timer). Yuck !
389 * This is ugly, and unsafe is the spinlock is not already aquired. 389 * This is ugly, and unsafe is the spinlock is not already acquired.
390 * This will be fixed when irda-task get rewritten. 390 * This will be fixed when irda-task get rewritten.
391 * Jean II */ 391 * Jean II */
392 if (!spin_is_locked(&self->lock)) { 392 if (!spin_is_locked(&self->lock)) {
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index 754297fc8f22..47f6f64d604c 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -101,7 +101,7 @@ static int transceiver_type = MCS_TSC_VISHAY;
101module_param(transceiver_type, int, 0444); 101module_param(transceiver_type, int, 0444);
102MODULE_PARM_DESC(transceiver_type, "IR transceiver type, see mcs7780.h."); 102MODULE_PARM_DESC(transceiver_type, "IR transceiver type, see mcs7780.h.");
103 103
104struct usb_driver mcs_driver = { 104static struct usb_driver mcs_driver = {
105 .name = "mcs7780", 105 .name = "mcs7780",
106 .probe = mcs_probe, 106 .probe = mcs_probe,
107 .disconnect = mcs_disconnect, 107 .disconnect = mcs_disconnect,
diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c
index cc7ff8f00e42..cb62f2a9676a 100644
--- a/drivers/net/irda/nsc-ircc.c
+++ b/drivers/net/irda/nsc-ircc.c
@@ -115,8 +115,12 @@ static nsc_chip_t chips[] = {
115 /* Contributed by Jan Frey - IBM A30/A31 */ 115 /* Contributed by Jan Frey - IBM A30/A31 */
116 { "PC8739x", { 0x2e, 0x4e, 0x0 }, 0x20, 0xea, 0xff, 116 { "PC8739x", { 0x2e, 0x4e, 0x0 }, 0x20, 0xea, 0xff,
117 nsc_ircc_probe_39x, nsc_ircc_init_39x }, 117 nsc_ircc_probe_39x, nsc_ircc_init_39x },
118 { "IBM", { 0x2e, 0x4e, 0x0 }, 0x20, 0xf4, 0xff, 118 /* IBM ThinkPads using PC8738x (T60/X60/Z60) */
119 nsc_ircc_probe_39x, nsc_ircc_init_39x }, 119 { "IBM-PC8738x", { 0x2e, 0x4e, 0x0 }, 0x20, 0xf4, 0xff,
120 nsc_ircc_probe_39x, nsc_ircc_init_39x },
121 /* IBM ThinkPads using PC8394T (T43/R52/?) */
122 { "IBM-PC8394T", { 0x2e, 0x4e, 0x0 }, 0x20, 0xf9, 0xff,
123 nsc_ircc_probe_39x, nsc_ircc_init_39x },
120 { NULL } 124 { NULL }
121}; 125};
122 126
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index e1aa9910503b..afb19e8d95c8 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -12,7 +12,6 @@
12 * Infra-red driver (SIR/FIR) for the PXA2xx embedded microprocessor 12 * Infra-red driver (SIR/FIR) for the PXA2xx embedded microprocessor
13 * 13 *
14 */ 14 */
15#include <linux/config.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/types.h> 16#include <linux/types.h>
18#include <linux/init.h> 17#include <linux/init.h>
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index f530686bd09f..8d5a288d7976 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -18,7 +18,6 @@
18 * power_leve:level - set the transmitter power level 18 * power_leve:level - set the transmitter power level
19 * tx_lpm:0|1 - set transmit low power mode 19 * tx_lpm:0|1 - set transmit low power mode
20 */ 20 */
21#include <linux/config.h>
22#include <linux/module.h> 21#include <linux/module.h>
23#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
24#include <linux/types.h> 23#include <linux/types.h>
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index d70b9e8d6e60..92d646cc9edc 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -21,7 +21,6 @@
21 * 21 *
22 ********************************************************************/ 22 ********************************************************************/
23 23
24#include <linux/config.h>
25#include <linux/module.h> 24#include <linux/module.h>
26 25
27#define DRIVER_NAME "vlsi_ir" 26#define DRIVER_NAME "vlsi_ir"
@@ -1518,7 +1517,7 @@ static int vlsi_open(struct net_device *ndev)
1518 1517
1519 outb(IRINTR_INT_MASK, ndev->base_addr+VLSI_PIO_IRINTR); 1518 outb(IRINTR_INT_MASK, ndev->base_addr+VLSI_PIO_IRINTR);
1520 1519
1521 if (request_irq(ndev->irq, vlsi_interrupt, SA_SHIRQ, 1520 if (request_irq(ndev->irq, vlsi_interrupt, IRQF_SHARED,
1522 drivername, ndev)) { 1521 drivername, ndev)) {
1523 IRDA_WARNING("%s: couldn't get IRQ: %d\n", 1522 IRDA_WARNING("%s: couldn't get IRQ: %d\n",
1524 __FUNCTION__, ndev->irq); 1523 __FUNCTION__, ndev->irq);
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c
index f0f04be989d6..cdc14401cdbe 100644
--- a/drivers/net/iseries_veth.c
+++ b/drivers/net/iseries_veth.c
@@ -56,7 +56,6 @@
56 * number of packets outstanding to a remote partition at a time. 56 * number of packets outstanding to a remote partition at a time.
57 */ 57 */
58 58
59#include <linux/config.h>
60#include <linux/module.h> 59#include <linux/module.h>
61#include <linux/types.h> 60#include <linux/types.h>
62#include <linux/errno.h> 61#include <linux/errno.h>
@@ -69,6 +68,7 @@
69#include <linux/delay.h> 68#include <linux/delay.h>
70#include <linux/mm.h> 69#include <linux/mm.h>
71#include <linux/ethtool.h> 70#include <linux/ethtool.h>
71#include <linux/if_ether.h>
72 72
73#include <asm/abs_addr.h> 73#include <asm/abs_addr.h>
74#include <asm/iseries/mf.h> 74#include <asm/iseries/mf.h>
@@ -1035,11 +1035,22 @@ static struct ethtool_ops ops = {
1035 .get_link = veth_get_link, 1035 .get_link = veth_get_link,
1036}; 1036};
1037 1037
1038static struct net_device * __init veth_probe_one(int vlan, struct device *vdev) 1038static struct net_device * __init veth_probe_one(int vlan,
1039 struct vio_dev *vio_dev)
1039{ 1040{
1040 struct net_device *dev; 1041 struct net_device *dev;
1041 struct veth_port *port; 1042 struct veth_port *port;
1043 struct device *vdev = &vio_dev->dev;
1042 int i, rc; 1044 int i, rc;
1045 const unsigned char *mac_addr;
1046
1047 mac_addr = vio_get_attribute(vio_dev, "local-mac-address", NULL);
1048 if (mac_addr == NULL)
1049 mac_addr = vio_get_attribute(vio_dev, "mac-address", NULL);
1050 if (mac_addr == NULL) {
1051 veth_error("Unable to fetch MAC address from device tree.\n");
1052 return NULL;
1053 }
1043 1054
1044 dev = alloc_etherdev(sizeof (struct veth_port)); 1055 dev = alloc_etherdev(sizeof (struct veth_port));
1045 if (! dev) { 1056 if (! dev) {
@@ -1064,16 +1075,11 @@ static struct net_device * __init veth_probe_one(int vlan, struct device *vdev)
1064 } 1075 }
1065 port->dev = vdev; 1076 port->dev = vdev;
1066 1077
1067 dev->dev_addr[0] = 0x02; 1078 memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
1068 dev->dev_addr[1] = 0x01;
1069 dev->dev_addr[2] = 0xff;
1070 dev->dev_addr[3] = vlan;
1071 dev->dev_addr[4] = 0xff;
1072 dev->dev_addr[5] = this_lp;
1073 1079
1074 dev->mtu = VETH_MAX_MTU; 1080 dev->mtu = VETH_MAX_MTU;
1075 1081
1076 memcpy(&port->mac_addr, dev->dev_addr, 6); 1082 memcpy(&port->mac_addr, mac_addr, ETH_ALEN);
1077 1083
1078 dev->open = veth_open; 1084 dev->open = veth_open;
1079 dev->hard_start_xmit = veth_start_xmit; 1085 dev->hard_start_xmit = veth_start_xmit;
@@ -1608,7 +1614,7 @@ static int veth_probe(struct vio_dev *vdev, const struct vio_device_id *id)
1608 struct net_device *dev; 1614 struct net_device *dev;
1609 struct veth_port *port; 1615 struct veth_port *port;
1610 1616
1611 dev = veth_probe_one(i, &vdev->dev); 1617 dev = veth_probe_one(i, vdev);
1612 if (dev == NULL) { 1618 if (dev == NULL) {
1613 veth_remove(vdev); 1619 veth_remove(vdev);
1614 return 1; 1620 return 1;
@@ -1641,7 +1647,7 @@ static int veth_probe(struct vio_dev *vdev, const struct vio_device_id *id)
1641 * support. 1647 * support.
1642 */ 1648 */
1643static struct vio_device_id veth_device_table[] __devinitdata = { 1649static struct vio_device_id veth_device_table[] __devinitdata = {
1644 { "vlan", "" }, 1650 { "network", "IBM,iSeries-l-lan" },
1645 { "", "" } 1651 { "", "" }
1646}; 1652};
1647MODULE_DEVICE_TABLE(vio, veth_device_table); 1653MODULE_DEVICE_TABLE(vio, veth_device_table);
diff --git a/drivers/net/ixgb/ixgb.h b/drivers/net/ixgb/ixgb.h
index a83ef28dadb0..82b67af54c94 100644
--- a/drivers/net/ixgb/ixgb.h
+++ b/drivers/net/ixgb/ixgb.h
@@ -30,7 +30,6 @@
30#define _IXGB_H_ 30#define _IXGB_H_
31 31
32#include <linux/stddef.h> 32#include <linux/stddef.h>
33#include <linux/config.h>
34#include <linux/module.h> 33#include <linux/module.h>
35#include <linux/types.h> 34#include <linux/types.h>
36#include <asm/byteorder.h> 35#include <asm/byteorder.h>
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index 57006fb8840e..b91e082483f6 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -253,7 +253,7 @@ ixgb_up(struct ixgb_adapter *adapter)
253 253
254#endif 254#endif
255 if((err = request_irq(adapter->pdev->irq, &ixgb_intr, 255 if((err = request_irq(adapter->pdev->irq, &ixgb_intr,
256 SA_SHIRQ | SA_SAMPLE_RANDOM, 256 IRQF_SHARED | IRQF_SAMPLE_RANDOM,
257 netdev->name, netdev))) { 257 netdev->name, netdev))) {
258 DPRINTK(PROBE, ERR, 258 DPRINTK(PROBE, ERR,
259 "Unable to allocate interrupt Error: %d\n", err); 259 "Unable to allocate interrupt Error: %d\n", err);
@@ -1173,7 +1173,7 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1173 uint16_t ipcse, tucse, mss; 1173 uint16_t ipcse, tucse, mss;
1174 int err; 1174 int err;
1175 1175
1176 if(likely(skb_shinfo(skb)->tso_size)) { 1176 if(likely(skb_shinfo(skb)->gso_size)) {
1177 if (skb_header_cloned(skb)) { 1177 if (skb_header_cloned(skb)) {
1178 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); 1178 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
1179 if (err) 1179 if (err)
@@ -1181,7 +1181,7 @@ ixgb_tso(struct ixgb_adapter *adapter, struct sk_buff *skb)
1181 } 1181 }
1182 1182
1183 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2)); 1183 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
1184 mss = skb_shinfo(skb)->tso_size; 1184 mss = skb_shinfo(skb)->gso_size;
1185 skb->nh.iph->tot_len = 0; 1185 skb->nh.iph->tot_len = 0;
1186 skb->nh.iph->check = 0; 1186 skb->nh.iph->check = 0;
1187 skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr, 1187 skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
diff --git a/drivers/net/ixp2000/caleb.c b/drivers/net/ixp2000/caleb.c
index 3595e107df22..7dea5b95012c 100644
--- a/drivers/net/ixp2000/caleb.c
+++ b/drivers/net/ixp2000/caleb.c
@@ -9,7 +9,6 @@
9 * (at your option) any later version. 9 * (at your option) any later version.
10 */ 10 */
11 11
12#include <linux/config.h>
13#include <linux/module.h> 12#include <linux/module.h>
14#include <linux/delay.h> 13#include <linux/delay.h>
15#include <asm/io.h> 14#include <asm/io.h>
diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c
index b67f586d7392..d3f4235c585d 100644
--- a/drivers/net/ixp2000/enp2611.c
+++ b/drivers/net/ixp2000/enp2611.c
@@ -9,7 +9,6 @@
9 * (at your option) any later version. 9 * (at your option) any later version.
10 */ 10 */
11 11
12#include <linux/config.h>
13#include <linux/module.h> 12#include <linux/module.h>
14#include <linux/kernel.h> 13#include <linux/kernel.h>
15#include <linux/netdevice.h> 14#include <linux/netdevice.h>
diff --git a/drivers/net/ixp2000/ixp2400-msf.c b/drivers/net/ixp2000/ixp2400-msf.c
index 48a3a891d3a4..9ec38eebfb56 100644
--- a/drivers/net/ixp2000/ixp2400-msf.c
+++ b/drivers/net/ixp2000/ixp2400-msf.c
@@ -11,7 +11,6 @@
11 * License, or (at your option) any later version. 11 * License, or (at your option) any later version.
12 */ 12 */
13 13
14#include <linux/config.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/init.h> 15#include <linux/init.h>
17#include <asm/hardware.h> 16#include <asm/hardware.h>
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
index fbc2d21020f4..6eeb965b4d72 100644
--- a/drivers/net/ixp2000/ixpdev.c
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -9,7 +9,6 @@
9 * (at your option) any later version. 9 * (at your option) any later version.
10 */ 10 */
11 11
12#include <linux/config.h>
13#include <linux/module.h> 12#include <linux/module.h>
14#include <linux/kernel.h> 13#include <linux/kernel.h>
15#include <linux/netdevice.h> 14#include <linux/netdevice.h>
@@ -236,7 +235,7 @@ static int ixpdev_open(struct net_device *dev)
236 235
237 if (!nds_open++) { 236 if (!nds_open++) {
238 err = request_irq(IRQ_IXP2000_THDA0, ixpdev_interrupt, 237 err = request_irq(IRQ_IXP2000_THDA0, ixpdev_interrupt,
239 SA_SHIRQ, "ixp2000_eth", nds); 238 IRQF_SHARED, "ixp2000_eth", nds);
240 if (err) { 239 if (err) {
241 nds_open--; 240 nds_open--;
242 return err; 241 return err;
diff --git a/drivers/net/ixp2000/pm3386.c b/drivers/net/ixp2000/pm3386.c
index 5224651c9aac..e08d3f9863b8 100644
--- a/drivers/net/ixp2000/pm3386.c
+++ b/drivers/net/ixp2000/pm3386.c
@@ -9,7 +9,6 @@
9 * (at your option) any later version. 9 * (at your option) any later version.
10 */ 10 */
11 11
12#include <linux/config.h>
13#include <linux/module.h> 12#include <linux/module.h>
14#include <linux/delay.h> 13#include <linux/delay.h>
15#include <linux/netdevice.h> 14#include <linux/netdevice.h>
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index 272d331d29cd..661d75b4cad2 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -260,7 +260,7 @@ MODULE_DESCRIPTION("Jazz SONIC ethernet driver");
260module_param(sonic_debug, int, 0); 260module_param(sonic_debug, int, 0);
261MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)"); 261MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)");
262 262
263#define SONIC_IRQ_FLAG SA_INTERRUPT 263#define SONIC_IRQ_FLAG IRQF_DISABLED
264 264
265#include "sonic.c" 265#include "sonic.c"
266 266
diff --git a/drivers/net/lance.c b/drivers/net/lance.c
index bb5ad479210b..c1c3452c90ca 100644
--- a/drivers/net/lance.c
+++ b/drivers/net/lance.c
@@ -968,8 +968,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
968 /* The old LANCE chips doesn't automatically pad buffers to min. size. */ 968 /* The old LANCE chips doesn't automatically pad buffers to min. size. */
969 if (chip_table[lp->chip_version].flags & LANCE_MUST_PAD) { 969 if (chip_table[lp->chip_version].flags & LANCE_MUST_PAD) {
970 if (skb->len < ETH_ZLEN) { 970 if (skb->len < ETH_ZLEN) {
971 skb = skb_padto(skb, ETH_ZLEN); 971 if (skb_padto(skb, ETH_ZLEN))
972 if (skb == NULL)
973 goto out; 972 goto out;
974 lp->tx_ring[entry].length = -ETH_ZLEN; 973 lp->tx_ring[entry].length = -ETH_ZLEN;
975 } 974 }
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index 957888de3d7e..1ab09447baa5 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -1083,8 +1083,7 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
1083 skb->len, skb->data)); 1083 skb->len, skb->data));
1084 1084
1085 if (length < ETH_ZLEN) { 1085 if (length < ETH_ZLEN) {
1086 skb = skb_padto(skb, ETH_ZLEN); 1086 if (skb_padto(skb, ETH_ZLEN))
1087 if (skb == NULL)
1088 return 0; 1087 return 0;
1089 length = ETH_ZLEN; 1088 length = ETH_ZLEN;
1090 } 1089 }
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index b79d6e8d3045..43fef7de8cb9 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -74,7 +74,7 @@ static void emulate_large_send_offload(struct sk_buff *skb)
74 struct iphdr *iph = skb->nh.iph; 74 struct iphdr *iph = skb->nh.iph;
75 struct tcphdr *th = (struct tcphdr*)(skb->nh.raw + (iph->ihl * 4)); 75 struct tcphdr *th = (struct tcphdr*)(skb->nh.raw + (iph->ihl * 4));
76 unsigned int doffset = (iph->ihl + th->doff) * 4; 76 unsigned int doffset = (iph->ihl + th->doff) * 4;
77 unsigned int mtu = skb_shinfo(skb)->tso_size + doffset; 77 unsigned int mtu = skb_shinfo(skb)->gso_size + doffset;
78 unsigned int offset = 0; 78 unsigned int offset = 0;
79 u32 seq = ntohl(th->seq); 79 u32 seq = ntohl(th->seq);
80 u16 id = ntohs(iph->id); 80 u16 id = ntohs(iph->id);
@@ -139,7 +139,7 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
139#endif 139#endif
140 140
141#ifdef LOOPBACK_TSO 141#ifdef LOOPBACK_TSO
142 if (skb_shinfo(skb)->tso_size) { 142 if (skb_shinfo(skb)->gso_size) {
143 BUG_ON(skb->protocol != htons(ETH_P_IP)); 143 BUG_ON(skb->protocol != htons(ETH_P_IP));
144 BUG_ON(skb->nh.iph->protocol != IPPROTO_TCP); 144 BUG_ON(skb->nh.iph->protocol != IPPROTO_TCP);
145 145
diff --git a/drivers/net/lp486e.c b/drivers/net/lp486e.c
index 94d5ea1ce8bd..b783a6984abc 100644
--- a/drivers/net/lp486e.c
+++ b/drivers/net/lp486e.c
@@ -851,7 +851,7 @@ static int i596_open(struct net_device *dev)
851{ 851{
852 int i; 852 int i;
853 853
854 i = request_irq(dev->irq, &i596_interrupt, SA_SHIRQ, dev->name, dev); 854 i = request_irq(dev->irq, &i596_interrupt, IRQF_SHARED, dev->name, dev);
855 if (i) { 855 if (i) {
856 printk(KERN_ERR "%s: IRQ %d not free\n", dev->name, dev->irq); 856 printk(KERN_ERR "%s: IRQ %d not free\n", dev->name, dev->irq);
857 return i; 857 return i;
@@ -877,8 +877,7 @@ static int i596_start_xmit (struct sk_buff *skb, struct net_device *dev) {
877 length = skb->len; 877 length = skb->len;
878 878
879 if (length < ETH_ZLEN) { 879 if (length < ETH_ZLEN) {
880 skb = skb_padto(skb, ETH_ZLEN); 880 if (skb_padto(skb, ETH_ZLEN))
881 if (skb == NULL)
882 return 0; 881 return 0;
883 length = ETH_ZLEN; 882 length = ETH_ZLEN;
884 } 883 }
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index 77792b286027..29e4b5aa6ead 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -5,7 +5,6 @@
5 * Copyright (C) 1996 Paul Mackerras. 5 * Copyright (C) 1996 Paul Mackerras.
6 */ 6 */
7 7
8#include <linux/config.h>
9#include <linux/module.h> 8#include <linux/module.h>
10#include <linux/kernel.h> 9#include <linux/kernel.h>
11#include <linux/netdevice.h> 10#include <linux/netdevice.h>
@@ -243,12 +242,12 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
243 } 242 }
244 rc = request_irq(mp->tx_dma_intr, mace_txdma_intr, 0, "MACE-txdma", dev); 243 rc = request_irq(mp->tx_dma_intr, mace_txdma_intr, 0, "MACE-txdma", dev);
245 if (rc) { 244 if (rc) {
246 printk(KERN_ERR "MACE: can't get irq %d\n", mace->intrs[1].line); 245 printk(KERN_ERR "MACE: can't get irq %d\n", mp->tx_dma_intr);
247 goto err_free_irq; 246 goto err_free_irq;
248 } 247 }
249 rc = request_irq(mp->rx_dma_intr, mace_rxdma_intr, 0, "MACE-rxdma", dev); 248 rc = request_irq(mp->rx_dma_intr, mace_rxdma_intr, 0, "MACE-rxdma", dev);
250 if (rc) { 249 if (rc) {
251 printk(KERN_ERR "MACE: can't get irq %d\n", mace->intrs[2].line); 250 printk(KERN_ERR "MACE: can't get irq %d\n", mp->rx_dma_intr);
252 goto err_free_tx_irq; 251 goto err_free_tx_irq;
253 } 252 }
254 253
diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c
index bbffb585b3b3..07e58f4a2916 100644
--- a/drivers/net/mipsnet.c
+++ b/drivers/net/mipsnet.c
@@ -179,7 +179,7 @@ static int mipsnet_open(struct net_device *dev)
179 pr_debug("%s: mipsnet_open\n", dev->name); 179 pr_debug("%s: mipsnet_open\n", dev->name);
180 180
181 err = request_irq(dev->irq, &mipsnet_interrupt, 181 err = request_irq(dev->irq, &mipsnet_interrupt,
182 SA_SHIRQ, dev->name, (void *) dev); 182 IRQF_SHARED, dev->name, (void *) dev);
183 183
184 if (err) { 184 if (err) {
185 pr_debug("%s: %s(): can't get irq %d\n", 185 pr_debug("%s: %s(): can't get irq %d\n",
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 625ff61c9988..760c61b98867 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -778,7 +778,7 @@ static int mv643xx_eth_open(struct net_device *dev)
778 int err; 778 int err;
779 779
780 err = request_irq(dev->irq, mv643xx_eth_int_handler, 780 err = request_irq(dev->irq, mv643xx_eth_int_handler,
781 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 781 IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
782 if (err) { 782 if (err) {
783 printk(KERN_ERR "Can not assign IRQ number to MV643XX_eth%d\n", 783 printk(KERN_ERR "Can not assign IRQ number to MV643XX_eth%d\n",
784 port_num); 784 port_num);
diff --git a/drivers/net/mv643xx_eth.h b/drivers/net/mv643xx_eth.h
index 4262c1da6d4a..33c5fafdbbd3 100644
--- a/drivers/net/mv643xx_eth.h
+++ b/drivers/net/mv643xx_eth.h
@@ -258,7 +258,7 @@ struct pkt_info {
258 struct sk_buff *return_info; /* User resource return information */ 258 struct sk_buff *return_info; /* User resource return information */
259}; 259};
260 260
261/* Ethernet port specific infomation */ 261/* Ethernet port specific information */
262 262
263struct mv643xx_mib_counters { 263struct mv643xx_mib_counters {
264 u64 good_octets_received; 264 u64 good_octets_received;
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index e1feb58bd661..f4c8fd373b9b 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -188,7 +188,6 @@ struct myri10ge_priv {
188 int vendor_specific_offset; 188 int vendor_specific_offset;
189 u32 devctl; 189 u32 devctl;
190 u16 msi_flags; 190 u16 msi_flags;
191 u32 pm_state[16];
192 u32 read_dma; 191 u32 read_dma;
193 u32 write_dma; 192 u32 write_dma;
194 u32 read_write_dma; 193 u32 read_write_dma;
@@ -1289,6 +1288,7 @@ static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = {
1289 "tx_aborted_errors", "tx_carrier_errors", "tx_fifo_errors", 1288 "tx_aborted_errors", "tx_carrier_errors", "tx_fifo_errors",
1290 "tx_heartbeat_errors", "tx_window_errors", 1289 "tx_heartbeat_errors", "tx_window_errors",
1291 /* device-specific stats */ 1290 /* device-specific stats */
1291 "tx_boundary", "WC", "irq", "MSI",
1292 "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs", 1292 "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs",
1293 "serial_number", "tx_pkt_start", "tx_pkt_done", 1293 "serial_number", "tx_pkt_start", "tx_pkt_done",
1294 "tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt", 1294 "tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt",
@@ -1327,6 +1327,10 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
1327 for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++) 1327 for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++)
1328 data[i] = ((unsigned long *)&mgp->stats)[i]; 1328 data[i] = ((unsigned long *)&mgp->stats)[i];
1329 1329
1330 data[i++] = (unsigned int)mgp->tx.boundary;
1331 data[i++] = (unsigned int)(mgp->mtrr >= 0);
1332 data[i++] = (unsigned int)mgp->pdev->irq;
1333 data[i++] = (unsigned int)mgp->msi_enabled;
1330 data[i++] = (unsigned int)mgp->read_dma; 1334 data[i++] = (unsigned int)mgp->read_dma;
1331 data[i++] = (unsigned int)mgp->write_dma; 1335 data[i++] = (unsigned int)mgp->write_dma;
1332 data[i++] = (unsigned int)mgp->read_write_dma; 1336 data[i++] = (unsigned int)mgp->read_write_dma;
@@ -1879,7 +1883,7 @@ again:
1879 1883
1880#ifdef NETIF_F_TSO 1884#ifdef NETIF_F_TSO
1881 if (skb->len > (dev->mtu + ETH_HLEN)) { 1885 if (skb->len > (dev->mtu + ETH_HLEN)) {
1882 mss = skb_shinfo(skb)->tso_size; 1886 mss = skb_shinfo(skb)->gso_size;
1883 if (mss != 0) 1887 if (mss != 0)
1884 max_segments = MYRI10GE_MAX_SEND_DESC_TSO; 1888 max_segments = MYRI10GE_MAX_SEND_DESC_TSO;
1885 } 1889 }
@@ -1939,8 +1943,7 @@ again:
1939 1943
1940 /* pad frames to at least ETH_ZLEN bytes */ 1944 /* pad frames to at least ETH_ZLEN bytes */
1941 if (unlikely(skb->len < ETH_ZLEN)) { 1945 if (unlikely(skb->len < ETH_ZLEN)) {
1942 skb = skb_padto(skb, ETH_ZLEN); 1946 if (skb_padto(skb, ETH_ZLEN)) {
1943 if (skb == NULL) {
1944 /* The packet is gone, so we must 1947 /* The packet is gone, so we must
1945 * return 0 */ 1948 * return 0 */
1946 mgp->stats.tx_dropped += 1; 1949 mgp->stats.tx_dropped += 1;
@@ -2113,14 +2116,14 @@ abort_linearize:
2113 } 2116 }
2114 idx = (idx + 1) & tx->mask; 2117 idx = (idx + 1) & tx->mask;
2115 } while (idx != last_idx); 2118 } while (idx != last_idx);
2116 if (skb_shinfo(skb)->tso_size) { 2119 if (skb_shinfo(skb)->gso_size) {
2117 printk(KERN_ERR 2120 printk(KERN_ERR
2118 "myri10ge: %s: TSO but wanted to linearize?!?!?\n", 2121 "myri10ge: %s: TSO but wanted to linearize?!?!?\n",
2119 mgp->dev->name); 2122 mgp->dev->name);
2120 goto drop; 2123 goto drop;
2121 } 2124 }
2122 2125
2123 if (skb_linearize(skb, GFP_ATOMIC)) 2126 if (skb_linearize(skb))
2124 goto drop; 2127 goto drop;
2125 2128
2126 mgp->tx_linearized++; 2129 mgp->tx_linearized++;
@@ -2198,8 +2201,6 @@ static int myri10ge_change_mtu(struct net_device *dev, int new_mtu)
2198 * any other device, except if forced with myri10ge_ecrc_enable > 1. 2201 * any other device, except if forced with myri10ge_ecrc_enable > 1.
2199 */ 2202 */
2200 2203
2201#define PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_PCIE 0x005d
2202
2203static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp) 2204static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2204{ 2205{
2205 struct pci_dev *bridge = mgp->pdev->bus->self; 2206 struct pci_dev *bridge = mgp->pdev->bus->self;
@@ -2251,12 +2252,6 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2251 } 2252 }
2252 2253
2253 cap = pci_find_ext_capability(bridge, PCI_EXT_CAP_ID_ERR); 2254 cap = pci_find_ext_capability(bridge, PCI_EXT_CAP_ID_ERR);
2254 /* nvidia ext cap is not always linked in ext cap chain */
2255 if (!cap
2256 && bridge->vendor == PCI_VENDOR_ID_NVIDIA
2257 && bridge->device == PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_PCIE)
2258 cap = 0x160;
2259
2260 if (!cap) 2255 if (!cap)
2261 return; 2256 return;
2262 2257
@@ -2420,7 +2415,7 @@ static int myri10ge_resume(struct pci_dev *pdev)
2420 pci_enable_device(pdev); 2415 pci_enable_device(pdev);
2421 pci_set_master(pdev); 2416 pci_set_master(pdev);
2422 2417
2423 status = request_irq(pdev->irq, myri10ge_intr, SA_SHIRQ, 2418 status = request_irq(pdev->irq, myri10ge_intr, IRQF_SHARED,
2424 netdev->name, mgp); 2419 netdev->name, mgp);
2425 if (status != 0) { 2420 if (status != 0) {
2426 dev_err(&pdev->dev, "failed to allocate IRQ\n"); 2421 dev_err(&pdev->dev, "failed to allocate IRQ\n");
@@ -2701,7 +2696,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2701 mgp->msi_enabled = 1; 2696 mgp->msi_enabled = 1;
2702 } 2697 }
2703 2698
2704 status = request_irq(pdev->irq, myri10ge_intr, SA_SHIRQ, 2699 status = request_irq(pdev->irq, myri10ge_intr, IRQF_SHARED,
2705 netdev->name, mgp); 2700 netdev->name, mgp);
2706 if (status != 0) { 2701 if (status != 0) {
2707 dev_err(&pdev->dev, "failed to allocate IRQ\n"); 2702 dev_err(&pdev->dev, "failed to allocate IRQ\n");
@@ -2732,8 +2727,6 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2732 /* Save configuration space to be restored if the 2727 /* Save configuration space to be restored if the
2733 * nic resets due to a parity error */ 2728 * nic resets due to a parity error */
2734 myri10ge_save_state(mgp); 2729 myri10ge_save_state(mgp);
2735 /* Restore state immediately since pci_save_msi_state disables MSI */
2736 myri10ge_restore_state(mgp);
2737 2730
2738 /* Setup the watchdog timer */ 2731 /* Setup the watchdog timer */
2739 setup_timer(&mgp->watchdog_timer, myri10ge_watchdog_timer, 2732 setup_timer(&mgp->watchdog_timer, myri10ge_watchdog_timer,
@@ -2746,11 +2739,10 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2746 dev_err(&pdev->dev, "register_netdev failed: %d\n", status); 2739 dev_err(&pdev->dev, "register_netdev failed: %d\n", status);
2747 goto abort_with_irq; 2740 goto abort_with_irq;
2748 } 2741 }
2749 2742 dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n",
2750 printk(KERN_INFO "myri10ge: %s: %s IRQ %d, tx bndry %d, fw %s, WC %s\n", 2743 (mgp->msi_enabled ? "MSI" : "xPIC"),
2751 netdev->name, (mgp->msi_enabled ? "MSI" : "xPIC"), 2744 pdev->irq, mgp->tx.boundary, mgp->fw_name,
2752 pdev->irq, mgp->tx.boundary, mgp->fw_name, 2745 (mgp->mtrr >= 0 ? "Enabled" : "Disabled"));
2753 (mgp->mtrr >= 0 ? "Enabled" : "Disabled"));
2754 2746
2755 return 0; 2747 return 0;
2756 2748
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c
index 6c86dca62e2a..1b965a2b56e4 100644
--- a/drivers/net/myri_sbus.c
+++ b/drivers/net/myri_sbus.c
@@ -1,13 +1,12 @@
1/* myri_sbus.h: MyriCOM MyriNET SBUS card driver. 1/* myri_sbus.c: MyriCOM MyriNET SBUS card driver.
2 * 2 *
3 * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com) 3 * Copyright (C) 1996, 1999, 2006 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6static char version[] = 6static char version[] =
7 "myri_sbus.c:v1.9 12/Sep/99 David S. Miller (davem@redhat.com)\n"; 7 "myri_sbus.c:v2.0 June 23, 2006 David S. Miller (davem@davemloft.net)\n";
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/config.h>
11#include <linux/errno.h> 10#include <linux/errno.h>
12#include <linux/kernel.h> 11#include <linux/kernel.h>
13#include <linux/types.h> 12#include <linux/types.h>
@@ -81,10 +80,6 @@ static char version[] =
81#define DHDR(x) 80#define DHDR(x)
82#endif 81#endif
83 82
84#ifdef MODULE
85static struct myri_eth *root_myri_dev;
86#endif
87
88static void myri_reset_off(void __iomem *lp, void __iomem *cregs) 83static void myri_reset_off(void __iomem *lp, void __iomem *cregs)
89{ 84{
90 /* Clear IRQ mask. */ 85 /* Clear IRQ mask. */
@@ -896,8 +891,9 @@ static void dump_eeprom(struct myri_eth *mp)
896} 891}
897#endif 892#endif
898 893
899static int __init myri_ether_init(struct sbus_dev *sdev, int num) 894static int __init myri_ether_init(struct sbus_dev *sdev)
900{ 895{
896 static int num;
901 static unsigned version_printed; 897 static unsigned version_printed;
902 struct net_device *dev; 898 struct net_device *dev;
903 struct myri_eth *mp; 899 struct myri_eth *mp;
@@ -913,6 +909,9 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num)
913 if (version_printed++ == 0) 909 if (version_printed++ == 0)
914 printk(version); 910 printk(version);
915 911
912 SET_MODULE_OWNER(dev);
913 SET_NETDEV_DEV(dev, &sdev->ofdev.dev);
914
916 mp = (struct myri_eth *) dev->priv; 915 mp = (struct myri_eth *) dev->priv;
917 spin_lock_init(&mp->irq_lock); 916 spin_lock_init(&mp->irq_lock);
918 mp->myri_sdev = sdev; 917 mp->myri_sdev = sdev;
@@ -1070,7 +1069,7 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num)
1070 /* Register interrupt handler now. */ 1069 /* Register interrupt handler now. */
1071 DET(("Requesting MYRIcom IRQ line.\n")); 1070 DET(("Requesting MYRIcom IRQ line.\n"));
1072 if (request_irq(dev->irq, &myri_interrupt, 1071 if (request_irq(dev->irq, &myri_interrupt,
1073 SA_SHIRQ, "MyriCOM Ethernet", (void *) dev)) { 1072 IRQF_SHARED, "MyriCOM Ethernet", (void *) dev)) {
1074 printk("MyriCOM: Cannot register interrupt handler.\n"); 1073 printk("MyriCOM: Cannot register interrupt handler.\n");
1075 goto err; 1074 goto err;
1076 } 1075 }
@@ -1092,10 +1091,9 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num)
1092 goto err_free_irq; 1091 goto err_free_irq;
1093 } 1092 }
1094 1093
1095#ifdef MODULE 1094 dev_set_drvdata(&sdev->ofdev.dev, mp);
1096 mp->next_module = root_myri_dev; 1095
1097 root_myri_dev = mp; 1096 num++;
1098#endif
1099 1097
1100 printk("%s: MyriCOM MyriNET Ethernet ", dev->name); 1098 printk("%s: MyriCOM MyriNET Ethernet ", dev->name);
1101 1099
@@ -1114,61 +1112,68 @@ err:
1114 return -ENODEV; 1112 return -ENODEV;
1115} 1113}
1116 1114
1117static int __init myri_sbus_match(struct sbus_dev *sdev)
1118{
1119 char *name = sdev->prom_name;
1120 1115
1121 if (!strcmp(name, "MYRICOM,mlanai") || 1116static int __devinit myri_sbus_probe(struct of_device *dev, const struct of_device_id *match)
1122 !strcmp(name, "myri")) 1117{
1123 return 1; 1118 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
1124 1119
1125 return 0; 1120 return myri_ether_init(sdev);
1126} 1121}
1127 1122
1128static int __init myri_sbus_probe(void) 1123static int __devexit myri_sbus_remove(struct of_device *dev)
1129{ 1124{
1130 struct sbus_bus *bus; 1125 struct myri_eth *mp = dev_get_drvdata(&dev->dev);
1131 struct sbus_dev *sdev = NULL; 1126 struct net_device *net_dev = mp->dev;
1132 static int called;
1133 int cards = 0, v;
1134 1127
1135#ifdef MODULE 1128 unregister_netdevice(net_dev);
1136 root_myri_dev = NULL;
1137#endif
1138 1129
1139 if (called) 1130 free_irq(net_dev->irq, net_dev);
1140 return -ENODEV; 1131
1141 called++; 1132 if (mp->eeprom.cpuvers < CPUVERS_4_0) {
1142 1133 sbus_iounmap(mp->regs, mp->reg_size);
1143 for_each_sbus(bus) { 1134 } else {
1144 for_each_sbusdev(sdev, bus) { 1135 sbus_iounmap(mp->cregs, PAGE_SIZE);
1145 if (myri_sbus_match(sdev)) { 1136 sbus_iounmap(mp->lregs, (256 * 1024));
1146 cards++; 1137 sbus_iounmap(mp->lanai, (512 * 1024));
1147 DET(("Found myricom myrinet as %s\n", sdev->prom_name));
1148 if ((v = myri_ether_init(sdev, (cards - 1))))
1149 return v;
1150 }
1151 }
1152 } 1138 }
1153 if (!cards) 1139
1154 return -ENODEV; 1140 free_netdev(net_dev);
1141
1142 dev_set_drvdata(&dev->dev, NULL);
1143
1155 return 0; 1144 return 0;
1156} 1145}
1157 1146
1158static void __exit myri_sbus_cleanup(void) 1147static struct of_device_id myri_sbus_match[] = {
1148 {
1149 .name = "MYRICOM,mlanai",
1150 },
1151 {
1152 .name = "myri",
1153 },
1154 {},
1155};
1156
1157MODULE_DEVICE_TABLE(of, myri_sbus_match);
1158
1159static struct of_platform_driver myri_sbus_driver = {
1160 .name = "myri",
1161 .match_table = myri_sbus_match,
1162 .probe = myri_sbus_probe,
1163 .remove = __devexit_p(myri_sbus_remove),
1164};
1165
1166static int __init myri_sbus_init(void)
1167{
1168 return of_register_driver(&myri_sbus_driver, &sbus_bus_type);
1169}
1170
1171static void __exit myri_sbus_exit(void)
1159{ 1172{
1160#ifdef MODULE 1173 of_unregister_driver(&myri_sbus_driver);
1161 while (root_myri_dev) {
1162 struct myri_eth *next = root_myri_dev->next_module;
1163
1164 unregister_netdev(root_myri_dev->dev);
1165 /* this will also free the co-allocated 'root_myri_dev' */
1166 free_netdev(root_myri_dev->dev);
1167 root_myri_dev = next;
1168 }
1169#endif /* MODULE */
1170} 1174}
1171 1175
1172module_init(myri_sbus_probe); 1176module_init(myri_sbus_init);
1173module_exit(myri_sbus_cleanup); 1177module_exit(myri_sbus_exit);
1178
1174MODULE_LICENSE("GPL"); 1179MODULE_LICENSE("GPL");
diff --git a/drivers/net/myri_sbus.h b/drivers/net/myri_sbus.h
index 47722f708a41..2f69ef7cdccb 100644
--- a/drivers/net/myri_sbus.h
+++ b/drivers/net/myri_sbus.h
@@ -290,7 +290,6 @@ struct myri_eth {
290 unsigned int reg_size; /* Size of register space. */ 290 unsigned int reg_size; /* Size of register space. */
291 unsigned int shmem_base; /* Offset to shared ram. */ 291 unsigned int shmem_base; /* Offset to shared ram. */
292 struct sbus_dev *myri_sdev; /* Our SBUS device struct. */ 292 struct sbus_dev *myri_sdev; /* Our SBUS device struct. */
293 struct myri_eth *next_module; /* Next in adapter chain. */
294}; 293};
295 294
296/* We use this to acquire receive skb's that we can DMA directly into. */ 295/* We use this to acquire receive skb's that we can DMA directly into. */
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index 2e4ecedba057..db0475a1102f 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -20,125 +20,13 @@
20 20
21 Support information and updates available at 21 Support information and updates available at
22 http://www.scyld.com/network/netsemi.html 22 http://www.scyld.com/network/netsemi.html
23 [link no longer provides useful info -jgarzik]
23 24
24 25
25 Linux kernel modifications:
26
27 Version 1.0.1:
28 - Spinlock fixes
29 - Bug fixes and better intr performance (Tjeerd)
30 Version 1.0.2:
31 - Now reads correct MAC address from eeprom
32 Version 1.0.3:
33 - Eliminate redundant priv->tx_full flag
34 - Call netif_start_queue from dev->tx_timeout
35 - wmb() in start_tx() to flush data
36 - Update Tx locking
37 - Clean up PCI enable (davej)
38 Version 1.0.4:
39 - Merge Donald Becker's natsemi.c version 1.07
40 Version 1.0.5:
41 - { fill me in }
42 Version 1.0.6:
43 * ethtool support (jgarzik)
44 * Proper initialization of the card (which sometimes
45 fails to occur and leaves the card in a non-functional
46 state). (uzi)
47
48 * Some documented register settings to optimize some
49 of the 100Mbit autodetection circuitry in rev C cards. (uzi)
50
51 * Polling of the PHY intr for stuff like link state
52 change and auto- negotiation to finally work properly. (uzi)
53
54 * One-liner removal of a duplicate declaration of
55 netdev_error(). (uzi)
56
57 Version 1.0.7: (Manfred Spraul)
58 * pci dma
59 * SMP locking update
60 * full reset added into tx_timeout
61 * correct multicast hash generation (both big and little endian)
62 [copied from a natsemi driver version
63 from Myrio Corporation, Greg Smith]
64 * suspend/resume
65
66 version 1.0.8 (Tim Hockin <thockin@sun.com>)
67 * ETHTOOL_* support
68 * Wake on lan support (Erik Gilling)
69 * MXDMA fixes for serverworks
70 * EEPROM reload
71
72 version 1.0.9 (Manfred Spraul)
73 * Main change: fix lack of synchronize
74 netif_close/netif_suspend against a last interrupt
75 or packet.
76 * do not enable superflous interrupts (e.g. the
77 drivers relies on TxDone - TxIntr not needed)
78 * wait that the hardware has really stopped in close
79 and suspend.
80 * workaround for the (at least) gcc-2.95.1 compiler
81 problem. Also simplifies the code a bit.
82 * disable_irq() in tx_timeout - needed to protect
83 against rx interrupts.
84 * stop the nic before switching into silent rx mode
85 for wol (required according to docu).
86
87 version 1.0.10:
88 * use long for ee_addr (various)
89 * print pointers properly (DaveM)
90 * include asm/irq.h (?)
91
92 version 1.0.11:
93 * check and reset if PHY errors appear (Adrian Sun)
94 * WoL cleanup (Tim Hockin)
95 * Magic number cleanup (Tim Hockin)
96 * Don't reload EEPROM on every reset (Tim Hockin)
97 * Save and restore EEPROM state across reset (Tim Hockin)
98 * MDIO Cleanup (Tim Hockin)
99 * Reformat register offsets/bits (jgarzik)
100
101 version 1.0.12:
102 * ETHTOOL_* further support (Tim Hockin)
103
104 version 1.0.13:
105 * ETHTOOL_[G]EEPROM support (Tim Hockin)
106
107 version 1.0.13:
108 * crc cleanup (Matt Domsch <Matt_Domsch@dell.com>)
109
110 version 1.0.14:
111 * Cleanup some messages and autoneg in ethtool (Tim Hockin)
112
113 version 1.0.15:
114 * Get rid of cable_magic flag
115 * use new (National provided) solution for cable magic issue
116
117 version 1.0.16:
118 * call netdev_rx() for RxErrors (Manfred Spraul)
119 * formatting and cleanups
120 * change options and full_duplex arrays to be zero
121 initialized
122 * enable only the WoL and PHY interrupts in wol mode
123
124 version 1.0.17:
125 * only do cable_magic on 83815 and early 83816 (Tim Hockin)
126 * create a function for rx refill (Manfred Spraul)
127 * combine drain_ring and init_ring (Manfred Spraul)
128 * oom handling (Manfred Spraul)
129 * hands_off instead of playing with netif_device_{de,a}ttach
130 (Manfred Spraul)
131 * be sure to write the MAC back to the chip (Manfred Spraul)
132 * lengthen EEPROM timeout, and always warn about timeouts
133 (Manfred Spraul)
134 * comments update (Manfred)
135 * do the right thing on a phy-reset (Manfred and Tim)
136
137 TODO: 26 TODO:
138 * big endian support with CFG:BEM instead of cpu_to_le32 27 * big endian support with CFG:BEM instead of cpu_to_le32
139*/ 28*/
140 29
141#include <linux/config.h>
142#include <linux/module.h> 30#include <linux/module.h>
143#include <linux/kernel.h> 31#include <linux/kernel.h>
144#include <linux/string.h> 32#include <linux/string.h>
@@ -166,8 +54,8 @@
166#include <asm/uaccess.h> 54#include <asm/uaccess.h>
167 55
168#define DRV_NAME "natsemi" 56#define DRV_NAME "natsemi"
169#define DRV_VERSION "1.07+LK1.0.17" 57#define DRV_VERSION "2.0"
170#define DRV_RELDATE "Sep 27, 2002" 58#define DRV_RELDATE "June 27, 2006"
171 59
172#define RX_OFFSET 2 60#define RX_OFFSET 2
173 61
@@ -226,7 +114,6 @@ static int full_duplex[MAX_UNITS];
226 NATSEMI_PG1_NREGS) 114 NATSEMI_PG1_NREGS)
227#define NATSEMI_REGS_VER 1 /* v1 added RFDR registers */ 115#define NATSEMI_REGS_VER 1 /* v1 added RFDR registers */
228#define NATSEMI_REGS_SIZE (NATSEMI_NREGS * sizeof(u32)) 116#define NATSEMI_REGS_SIZE (NATSEMI_NREGS * sizeof(u32))
229#define NATSEMI_DEF_EEPROM_SIZE 24 /* 12 16-bit values */
230 117
231/* Buffer sizes: 118/* Buffer sizes:
232 * The nic writes 32-bit values, even if the upper bytes of 119 * The nic writes 32-bit values, even if the upper bytes of
@@ -344,18 +231,6 @@ None characterised.
344 231
345 232
346 233
347enum pcistuff {
348 PCI_USES_IO = 0x01,
349 PCI_USES_MEM = 0x02,
350 PCI_USES_MASTER = 0x04,
351 PCI_ADDR0 = 0x08,
352 PCI_ADDR1 = 0x10,
353};
354
355/* MMIO operations required */
356#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_MEM | PCI_ADDR1)
357
358
359/* 234/*
360 * Support for fibre connections on Am79C874: 235 * Support for fibre connections on Am79C874:
361 * This phy needs a special setup when connected to a fibre cable. 236 * This phy needs a special setup when connected to a fibre cable.
@@ -363,22 +238,25 @@ enum pcistuff {
363 */ 238 */
364#define PHYID_AM79C874 0x0022561b 239#define PHYID_AM79C874 0x0022561b
365 240
366#define MII_MCTRL 0x15 /* mode control register */ 241enum {
367#define MII_FX_SEL 0x0001 /* 100BASE-FX (fiber) */ 242 MII_MCTRL = 0x15, /* mode control register */
368#define MII_EN_SCRM 0x0004 /* enable scrambler (tp) */ 243 MII_FX_SEL = 0x0001, /* 100BASE-FX (fiber) */
244 MII_EN_SCRM = 0x0004, /* enable scrambler (tp) */
245};
369 246
370 247
371/* array of board data directly indexed by pci_tbl[x].driver_data */ 248/* array of board data directly indexed by pci_tbl[x].driver_data */
372static const struct { 249static const struct {
373 const char *name; 250 const char *name;
374 unsigned long flags; 251 unsigned long flags;
252 unsigned int eeprom_size;
375} natsemi_pci_info[] __devinitdata = { 253} natsemi_pci_info[] __devinitdata = {
376 { "NatSemi DP8381[56]", PCI_IOTYPE }, 254 { "NatSemi DP8381[56]", 0, 24 },
377}; 255};
378 256
379static struct pci_device_id natsemi_pci_tbl[] = { 257static const struct pci_device_id natsemi_pci_tbl[] __devinitdata = {
380 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_83815, PCI_ANY_ID, PCI_ANY_ID, }, 258 { PCI_VENDOR_ID_NS, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
381 { 0, }, 259 { } /* terminate list */
382}; 260};
383MODULE_DEVICE_TABLE(pci, natsemi_pci_tbl); 261MODULE_DEVICE_TABLE(pci, natsemi_pci_tbl);
384 262
@@ -813,6 +691,42 @@ static void move_int_phy(struct net_device *dev, int addr)
813 udelay(1); 691 udelay(1);
814} 692}
815 693
694static void __devinit natsemi_init_media (struct net_device *dev)
695{
696 struct netdev_private *np = netdev_priv(dev);
697 u32 tmp;
698
699 netif_carrier_off(dev);
700
701 /* get the initial settings from hardware */
702 tmp = mdio_read(dev, MII_BMCR);
703 np->speed = (tmp & BMCR_SPEED100)? SPEED_100 : SPEED_10;
704 np->duplex = (tmp & BMCR_FULLDPLX)? DUPLEX_FULL : DUPLEX_HALF;
705 np->autoneg = (tmp & BMCR_ANENABLE)? AUTONEG_ENABLE: AUTONEG_DISABLE;
706 np->advertising= mdio_read(dev, MII_ADVERTISE);
707
708 if ((np->advertising & ADVERTISE_ALL) != ADVERTISE_ALL
709 && netif_msg_probe(np)) {
710 printk(KERN_INFO "natsemi %s: Transceiver default autonegotiation %s "
711 "10%s %s duplex.\n",
712 pci_name(np->pci_dev),
713 (mdio_read(dev, MII_BMCR) & BMCR_ANENABLE)?
714 "enabled, advertise" : "disabled, force",
715 (np->advertising &
716 (ADVERTISE_100FULL|ADVERTISE_100HALF))?
717 "0" : "",
718 (np->advertising &
719 (ADVERTISE_100FULL|ADVERTISE_10FULL))?
720 "full" : "half");
721 }
722 if (netif_msg_probe(np))
723 printk(KERN_INFO
724 "natsemi %s: Transceiver status %#04x advertising %#04x.\n",
725 pci_name(np->pci_dev), mdio_read(dev, MII_BMSR),
726 np->advertising);
727
728}
729
816static int __devinit natsemi_probe1 (struct pci_dev *pdev, 730static int __devinit natsemi_probe1 (struct pci_dev *pdev,
817 const struct pci_device_id *ent) 731 const struct pci_device_id *ent)
818{ 732{
@@ -852,8 +766,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
852 iosize = pci_resource_len(pdev, pcibar); 766 iosize = pci_resource_len(pdev, pcibar);
853 irq = pdev->irq; 767 irq = pdev->irq;
854 768
855 if (natsemi_pci_info[chip_idx].flags & PCI_USES_MASTER) 769 pci_set_master(pdev);
856 pci_set_master(pdev);
857 770
858 dev = alloc_etherdev(sizeof (struct netdev_private)); 771 dev = alloc_etherdev(sizeof (struct netdev_private));
859 if (!dev) 772 if (!dev)
@@ -892,7 +805,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
892 np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG; 805 np->msg_enable = (debug >= 0) ? (1<<debug)-1 : NATSEMI_DEF_MSG;
893 np->hands_off = 0; 806 np->hands_off = 0;
894 np->intr_status = 0; 807 np->intr_status = 0;
895 np->eeprom_size = NATSEMI_DEF_EEPROM_SIZE; 808 np->eeprom_size = natsemi_pci_info[chip_idx].eeprom_size;
896 809
897 /* Initial port: 810 /* Initial port:
898 * - If the nic was configured to use an external phy and if find_mii 811 * - If the nic was configured to use an external phy and if find_mii
@@ -957,34 +870,7 @@ static int __devinit natsemi_probe1 (struct pci_dev *pdev,
957 if (mtu) 870 if (mtu)
958 dev->mtu = mtu; 871 dev->mtu = mtu;
959 872
960 netif_carrier_off(dev); 873 natsemi_init_media(dev);
961
962 /* get the initial settings from hardware */
963 tmp = mdio_read(dev, MII_BMCR);
964 np->speed = (tmp & BMCR_SPEED100)? SPEED_100 : SPEED_10;
965 np->duplex = (tmp & BMCR_FULLDPLX)? DUPLEX_FULL : DUPLEX_HALF;
966 np->autoneg = (tmp & BMCR_ANENABLE)? AUTONEG_ENABLE: AUTONEG_DISABLE;
967 np->advertising= mdio_read(dev, MII_ADVERTISE);
968
969 if ((np->advertising & ADVERTISE_ALL) != ADVERTISE_ALL
970 && netif_msg_probe(np)) {
971 printk(KERN_INFO "natsemi %s: Transceiver default autonegotiation %s "
972 "10%s %s duplex.\n",
973 pci_name(np->pci_dev),
974 (mdio_read(dev, MII_BMCR) & BMCR_ANENABLE)?
975 "enabled, advertise" : "disabled, force",
976 (np->advertising &
977 (ADVERTISE_100FULL|ADVERTISE_100HALF))?
978 "0" : "",
979 (np->advertising &
980 (ADVERTISE_100FULL|ADVERTISE_10FULL))?
981 "full" : "half");
982 }
983 if (netif_msg_probe(np))
984 printk(KERN_INFO
985 "natsemi %s: Transceiver status %#04x advertising %#04x.\n",
986 pci_name(np->pci_dev), mdio_read(dev, MII_BMSR),
987 np->advertising);
988 874
989 /* save the silicon revision for later querying */ 875 /* save the silicon revision for later querying */
990 np->srr = readl(ioaddr + SiliconRev); 876 np->srr = readl(ioaddr + SiliconRev);
@@ -1577,7 +1463,7 @@ static int netdev_open(struct net_device *dev)
1577 /* Reset the chip, just in case. */ 1463 /* Reset the chip, just in case. */
1578 natsemi_reset(dev); 1464 natsemi_reset(dev);
1579 1465
1580 i = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev); 1466 i = request_irq(dev->irq, &intr_handler, IRQF_SHARED, dev->name, dev);
1581 if (i) return i; 1467 if (i) return i;
1582 1468
1583 if (netif_msg_ifup(np)) 1469 if (netif_msg_ifup(np))
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index ced9fdb8335c..34bdba9eec79 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -231,12 +231,12 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
231 irq = pdev->irq; 231 irq = pdev->irq;
232 232
233 if (!ioaddr || ((pci_resource_flags (pdev, 0) & IORESOURCE_IO) == 0)) { 233 if (!ioaddr || ((pci_resource_flags (pdev, 0) & IORESOURCE_IO) == 0)) {
234 printk (KERN_ERR PFX "no I/O resource at PCI BAR #0\n"); 234 dev_err(&pdev->dev, "no I/O resource at PCI BAR #0\n");
235 return -ENODEV; 235 return -ENODEV;
236 } 236 }
237 237
238 if (request_region (ioaddr, NE_IO_EXTENT, DRV_NAME) == NULL) { 238 if (request_region (ioaddr, NE_IO_EXTENT, DRV_NAME) == NULL) {
239 printk (KERN_ERR PFX "I/O resource 0x%x @ 0x%lx busy\n", 239 dev_err(&pdev->dev, "I/O resource 0x%x @ 0x%lx busy\n",
240 NE_IO_EXTENT, ioaddr); 240 NE_IO_EXTENT, ioaddr);
241 return -EBUSY; 241 return -EBUSY;
242 } 242 }
@@ -263,7 +263,7 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
263 /* Allocate net_device, dev->priv; fill in 8390 specific dev fields. */ 263 /* Allocate net_device, dev->priv; fill in 8390 specific dev fields. */
264 dev = alloc_ei_netdev(); 264 dev = alloc_ei_netdev();
265 if (!dev) { 265 if (!dev) {
266 printk (KERN_ERR PFX "cannot allocate ethernet device\n"); 266 dev_err(&pdev->dev, "cannot allocate ethernet device\n");
267 goto err_out_free_res; 267 goto err_out_free_res;
268 } 268 }
269 SET_MODULE_OWNER(dev); 269 SET_MODULE_OWNER(dev);
@@ -281,7 +281,8 @@ static int __devinit ne2k_pci_init_one (struct pci_dev *pdev,
281 while ((inb(ioaddr + EN0_ISR) & ENISR_RESET) == 0) 281 while ((inb(ioaddr + EN0_ISR) & ENISR_RESET) == 0)
282 /* Limit wait: '2' avoids jiffy roll-over. */ 282 /* Limit wait: '2' avoids jiffy roll-over. */
283 if (jiffies - reset_start_time > 2) { 283 if (jiffies - reset_start_time > 2) {
284 printk(KERN_ERR PFX "Card failure (no reset ack).\n"); 284 dev_err(&pdev->dev,
285 "Card failure (no reset ack).\n");
285 goto err_out_free_netdev; 286 goto err_out_free_netdev;
286 } 287 }
287 288
@@ -420,7 +421,7 @@ static int ne2k_pci_set_fdx(struct net_device *dev)
420 421
421static int ne2k_pci_open(struct net_device *dev) 422static int ne2k_pci_open(struct net_device *dev)
422{ 423{
423 int ret = request_irq(dev->irq, ei_interrupt, SA_SHIRQ, dev->name, dev); 424 int ret = request_irq(dev->irq, ei_interrupt, IRQF_SHARED, dev->name, dev);
424 if (ret) 425 if (ret)
425 return ret; 426 return ret;
426 427
diff --git a/drivers/net/netx-eth.c b/drivers/net/netx-eth.c
new file mode 100644
index 000000000000..b1311ae82675
--- /dev/null
+++ b/drivers/net/netx-eth.c
@@ -0,0 +1,516 @@
1/*
2 * drivers/net/netx-eth.c
3 *
4 * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/config.h>
21#include <linux/init.h>
22#include <linux/module.h>
23#include <linux/kernel.h>
24#include <linux/delay.h>
25
26#include <linux/netdevice.h>
27#include <linux/platform_device.h>
28#include <linux/etherdevice.h>
29#include <linux/skbuff.h>
30#include <linux/mii.h>
31
32#include <asm/io.h>
33#include <asm/hardware.h>
34#include <asm/arch/hardware.h>
35#include <asm/arch/netx-regs.h>
36#include <asm/arch/pfifo.h>
37#include <asm/arch/xc.h>
38#include <asm/arch/eth.h>
39
40/* XC Fifo Offsets */
41#define EMPTY_PTR_FIFO(xcno) (0 + ((xcno) << 3)) /* Index of the empty pointer FIFO */
42#define IND_FIFO_PORT_HI(xcno) (1 + ((xcno) << 3)) /* Index of the FIFO where received */
43 /* Data packages are indicated by XC */
44#define IND_FIFO_PORT_LO(xcno) (2 + ((xcno) << 3)) /* Index of the FIFO where received */
45 /* Data packages are indicated by XC */
46#define REQ_FIFO_PORT_HI(xcno) (3 + ((xcno) << 3)) /* Index of the FIFO where Data packages */
47 /* have to be indicated by ARM which */
48 /* shall be sent */
49#define REQ_FIFO_PORT_LO(xcno) (4 + ((xcno) << 3)) /* Index of the FIFO where Data packages */
50 /* have to be indicated by ARM which shall */
51 /* be sent */
52#define CON_FIFO_PORT_HI(xcno) (5 + ((xcno) << 3)) /* Index of the FIFO where sent Data packages */
53 /* are confirmed */
54#define CON_FIFO_PORT_LO(xcno) (6 + ((xcno) << 3)) /* Index of the FIFO where sent Data */
55 /* packages are confirmed */
56#define PFIFO_MASK(xcno) (0x7f << (xcno*8))
57
58#define FIFO_PTR_FRAMELEN_SHIFT 0
59#define FIFO_PTR_FRAMELEN_MASK (0x7ff << 0)
60#define FIFO_PTR_FRAMELEN(len) (((len) << 0) & FIFO_PTR_FRAMELEN_MASK)
61#define FIFO_PTR_TIMETRIG (1<<11)
62#define FIFO_PTR_MULTI_REQ
63#define FIFO_PTR_ORIGIN (1<<14)
64#define FIFO_PTR_VLAN (1<<15)
65#define FIFO_PTR_FRAMENO_SHIFT 16
66#define FIFO_PTR_FRAMENO_MASK (0x3f << 16)
67#define FIFO_PTR_FRAMENO(no) (((no) << 16) & FIFO_PTR_FRAMENO_MASK)
68#define FIFO_PTR_SEGMENT_SHIFT 22
69#define FIFO_PTR_SEGMENT_MASK (0xf << 22)
70#define FIFO_PTR_SEGMENT(seg) (((seg) & 0xf) << 22)
71#define FIFO_PTR_ERROR_SHIFT 28
72#define FIFO_PTR_ERROR_MASK (0xf << 28)
73
74#define ISR_LINK_STATUS_CHANGE (1<<4)
75#define ISR_IND_LO (1<<3)
76#define ISR_CON_LO (1<<2)
77#define ISR_IND_HI (1<<1)
78#define ISR_CON_HI (1<<0)
79
80#define ETH_MAC_LOCAL_CONFIG 0x1560
81#define ETH_MAC_4321 0x1564
82#define ETH_MAC_65 0x1568
83
84#define MAC_TRAFFIC_CLASS_ARRANGEMENT_SHIFT 16
85#define MAC_TRAFFIC_CLASS_ARRANGEMENT_MASK (0xf<<MAC_TRAFFIC_CLASS_ARRANGEMENT_SHIFT)
86#define MAC_TRAFFIC_CLASS_ARRANGEMENT(x) (((x)<<MAC_TRAFFIC_CLASS_ARRANGEMENT_SHIFT) & MAC_TRAFFIC_CLASS_ARRANGEMENT_MASK)
87#define LOCAL_CONFIG_LINK_STATUS_IRQ_EN (1<<24)
88#define LOCAL_CONFIG_CON_LO_IRQ_EN (1<<23)
89#define LOCAL_CONFIG_CON_HI_IRQ_EN (1<<22)
90#define LOCAL_CONFIG_IND_LO_IRQ_EN (1<<21)
91#define LOCAL_CONFIG_IND_HI_IRQ_EN (1<<20)
92
93#define CARDNAME "netx-eth"
94
95/* LSB must be zero */
96#define INTERNAL_PHY_ADR 0x1c
97
98struct netx_eth_priv {
99 void __iomem *sram_base, *xpec_base, *xmac_base;
100 int id;
101 struct net_device_stats stats;
102 struct mii_if_info mii;
103 u32 msg_enable;
104 struct xc *xc;
105 spinlock_t lock;
106};
107
108static void netx_eth_set_multicast_list(struct net_device *ndev)
109{
110 /* implement me */
111}
112
113static int
114netx_eth_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
115{
116 struct netx_eth_priv *priv = netdev_priv(ndev);
117 unsigned char *buf = skb->data;
118 unsigned int len = skb->len;
119
120 spin_lock_irq(&priv->lock);
121 memcpy_toio(priv->sram_base + 1560, (void *)buf, len);
122 if (len < 60) {
123 memset_io(priv->sram_base + 1560 + len, 0, 60 - len);
124 len = 60;
125 }
126
127 pfifo_push(REQ_FIFO_PORT_LO(priv->id),
128 FIFO_PTR_SEGMENT(priv->id) |
129 FIFO_PTR_FRAMENO(1) |
130 FIFO_PTR_FRAMELEN(len));
131
132 ndev->trans_start = jiffies;
133 priv->stats.tx_packets++;
134 priv->stats.tx_bytes += skb->len;
135
136 netif_stop_queue(ndev);
137 spin_unlock_irq(&priv->lock);
138 dev_kfree_skb(skb);
139
140 return 0;
141}
142
143static void netx_eth_receive(struct net_device *ndev)
144{
145 struct netx_eth_priv *priv = netdev_priv(ndev);
146 unsigned int val, frameno, seg, len;
147 unsigned char *data;
148 struct sk_buff *skb;
149
150 val = pfifo_pop(IND_FIFO_PORT_LO(priv->id));
151
152 frameno = (val & FIFO_PTR_FRAMENO_MASK) >> FIFO_PTR_FRAMENO_SHIFT;
153 seg = (val & FIFO_PTR_SEGMENT_MASK) >> FIFO_PTR_SEGMENT_SHIFT;
154 len = (val & FIFO_PTR_FRAMELEN_MASK) >> FIFO_PTR_FRAMELEN_SHIFT;
155
156 skb = dev_alloc_skb(len);
157 if (unlikely(skb == NULL)) {
158 printk(KERN_NOTICE "%s: Low memory, packet dropped.\n",
159 ndev->name);
160 priv->stats.rx_dropped++;
161 return;
162 }
163
164 data = skb_put(skb, len);
165
166 memcpy_fromio(data, priv->sram_base + frameno * 1560, len);
167
168 pfifo_push(EMPTY_PTR_FIFO(priv->id),
169 FIFO_PTR_SEGMENT(seg) | FIFO_PTR_FRAMENO(frameno));
170
171 ndev->last_rx = jiffies;
172 skb->dev = ndev;
173 skb->protocol = eth_type_trans(skb, ndev);
174 netif_rx(skb);
175 priv->stats.rx_packets++;
176 priv->stats.rx_bytes += len;
177}
178
179static irqreturn_t
180netx_eth_interrupt(int irq, void *dev_id, struct pt_regs *regs)
181{
182 struct net_device *ndev = dev_id;
183 struct netx_eth_priv *priv = netdev_priv(ndev);
184 int status;
185 unsigned long flags;
186
187 spin_lock_irqsave(&priv->lock, flags);
188
189 status = readl(NETX_PFIFO_XPEC_ISR(priv->id));
190 while (status) {
191 int fill_level;
192 writel(status, NETX_PFIFO_XPEC_ISR(priv->id));
193
194 if ((status & ISR_CON_HI) || (status & ISR_IND_HI))
195 printk("%s: unexpected status: 0x%08x\n",
196 __FUNCTION__, status);
197
198 fill_level =
199 readl(NETX_PFIFO_FILL_LEVEL(IND_FIFO_PORT_LO(priv->id)));
200 while (fill_level--)
201 netx_eth_receive(ndev);
202
203 if (status & ISR_CON_LO)
204 netif_wake_queue(ndev);
205
206 if (status & ISR_LINK_STATUS_CHANGE)
207 mii_check_media(&priv->mii, netif_msg_link(priv), 1);
208
209 status = readl(NETX_PFIFO_XPEC_ISR(priv->id));
210 }
211 spin_unlock_irqrestore(&priv->lock, flags);
212 return IRQ_HANDLED;
213}
214
215static struct net_device_stats *netx_eth_query_statistics(struct net_device *ndev)
216{
217 struct netx_eth_priv *priv = netdev_priv(ndev);
218 return &priv->stats;
219}
220
221static int netx_eth_open(struct net_device *ndev)
222{
223 struct netx_eth_priv *priv = netdev_priv(ndev);
224
225 if (request_irq
226 (ndev->irq, &netx_eth_interrupt, IRQF_SHARED, ndev->name, ndev))
227 return -EAGAIN;
228
229 writel(ndev->dev_addr[0] |
230 ndev->dev_addr[1]<<8 |
231 ndev->dev_addr[2]<<16 |
232 ndev->dev_addr[3]<<24,
233 priv->xpec_base + NETX_XPEC_RAM_START_OFS + ETH_MAC_4321);
234 writel(ndev->dev_addr[4] |
235 ndev->dev_addr[5]<<8,
236 priv->xpec_base + NETX_XPEC_RAM_START_OFS + ETH_MAC_65);
237
238 writel(LOCAL_CONFIG_LINK_STATUS_IRQ_EN |
239 LOCAL_CONFIG_CON_LO_IRQ_EN |
240 LOCAL_CONFIG_CON_HI_IRQ_EN |
241 LOCAL_CONFIG_IND_LO_IRQ_EN |
242 LOCAL_CONFIG_IND_HI_IRQ_EN,
243 priv->xpec_base + NETX_XPEC_RAM_START_OFS +
244 ETH_MAC_LOCAL_CONFIG);
245
246 mii_check_media(&priv->mii, netif_msg_link(priv), 1);
247 netif_start_queue(ndev);
248
249 return 0;
250}
251
252static int netx_eth_close(struct net_device *ndev)
253{
254 struct netx_eth_priv *priv = netdev_priv(ndev);
255
256 netif_stop_queue(ndev);
257
258 writel(0,
259 priv->xpec_base + NETX_XPEC_RAM_START_OFS + ETH_MAC_LOCAL_CONFIG);
260
261 free_irq(ndev->irq, ndev);
262
263 return 0;
264}
265
266static void netx_eth_timeout(struct net_device *ndev)
267{
268 struct netx_eth_priv *priv = netdev_priv(ndev);
269 int i;
270
271 printk(KERN_ERR "%s: transmit timed out, resetting\n", ndev->name);
272
273 spin_lock_irq(&priv->lock);
274
275 xc_reset(priv->xc);
276 xc_start(priv->xc);
277
278 for (i=2; i<=18; i++)
279 pfifo_push(EMPTY_PTR_FIFO(priv->id),
280 FIFO_PTR_FRAMENO(i) | FIFO_PTR_SEGMENT(priv->id));
281
282 spin_unlock_irq(&priv->lock);
283
284 netif_wake_queue(ndev);
285}
286
287static int
288netx_eth_phy_read(struct net_device *ndev, int phy_id, int reg)
289{
290 unsigned int val;
291
292 val = MIIMU_SNRDY | MIIMU_PREAMBLE | MIIMU_PHYADDR(phy_id) |
293 MIIMU_REGADDR(reg) | MIIMU_PHY_NRES;
294
295 writel(val, NETX_MIIMU);
296 while (readl(NETX_MIIMU) & MIIMU_SNRDY);
297
298 return readl(NETX_MIIMU) >> 16;
299
300}
301
302static void
303netx_eth_phy_write(struct net_device *ndev, int phy_id, int reg, int value)
304{
305 unsigned int val;
306
307 val = MIIMU_SNRDY | MIIMU_PREAMBLE | MIIMU_PHYADDR(phy_id) |
308 MIIMU_REGADDR(reg) | MIIMU_PHY_NRES | MIIMU_OPMODE_WRITE |
309 MIIMU_DATA(value);
310
311 writel(val, NETX_MIIMU);
312 while (readl(NETX_MIIMU) & MIIMU_SNRDY);
313}
314
315static int netx_eth_enable(struct net_device *ndev)
316{
317 struct netx_eth_priv *priv = netdev_priv(ndev);
318 unsigned int mac4321, mac65;
319 int running, i;
320
321 ether_setup(ndev);
322
323 ndev->open = netx_eth_open;
324 ndev->stop = netx_eth_close;
325 ndev->hard_start_xmit = netx_eth_hard_start_xmit;
326 ndev->tx_timeout = netx_eth_timeout;
327 ndev->watchdog_timeo = msecs_to_jiffies(5000);
328 ndev->get_stats = netx_eth_query_statistics;
329 ndev->set_multicast_list = netx_eth_set_multicast_list;
330
331 priv->msg_enable = NETIF_MSG_LINK;
332 priv->mii.phy_id_mask = 0x1f;
333 priv->mii.reg_num_mask = 0x1f;
334 priv->mii.force_media = 0;
335 priv->mii.full_duplex = 0;
336 priv->mii.dev = ndev;
337 priv->mii.mdio_read = netx_eth_phy_read;
338 priv->mii.mdio_write = netx_eth_phy_write;
339 priv->mii.phy_id = INTERNAL_PHY_ADR + priv->id;
340
341 running = xc_running(priv->xc);
342 xc_stop(priv->xc);
343
344 /* if the xc engine is already running, assume the bootloader has
345 * loaded the firmware for us
346 */
347 if (running) {
348 /* get Node Address from hardware */
349 mac4321 = readl(priv->xpec_base +
350 NETX_XPEC_RAM_START_OFS + ETH_MAC_4321);
351 mac65 = readl(priv->xpec_base +
352 NETX_XPEC_RAM_START_OFS + ETH_MAC_65);
353
354 ndev->dev_addr[0] = mac4321 & 0xff;
355 ndev->dev_addr[1] = (mac4321 >> 8) & 0xff;
356 ndev->dev_addr[2] = (mac4321 >> 16) & 0xff;
357 ndev->dev_addr[3] = (mac4321 >> 24) & 0xff;
358 ndev->dev_addr[4] = mac65 & 0xff;
359 ndev->dev_addr[5] = (mac65 >> 8) & 0xff;
360 } else {
361 if (xc_request_firmware(priv->xc)) {
362 printk(CARDNAME ": requesting firmware failed\n");
363 return -ENODEV;
364 }
365 }
366
367 xc_reset(priv->xc);
368 xc_start(priv->xc);
369
370 if (!is_valid_ether_addr(ndev->dev_addr))
371 printk("%s: Invalid ethernet MAC address. Please "
372 "set using ifconfig\n", ndev->name);
373
374 for (i=2; i<=18; i++)
375 pfifo_push(EMPTY_PTR_FIFO(priv->id),
376 FIFO_PTR_FRAMENO(i) | FIFO_PTR_SEGMENT(priv->id));
377
378 return register_netdev(ndev);
379
380}
381
382static int netx_eth_drv_probe(struct platform_device *pdev)
383{
384 struct netx_eth_priv *priv;
385 struct net_device *ndev;
386 struct netxeth_platform_data *pdata;
387 int ret;
388
389 ndev = alloc_etherdev(sizeof (struct netx_eth_priv));
390 if (!ndev) {
391 printk("%s: could not allocate device.\n", CARDNAME);
392 ret = -ENOMEM;
393 goto exit;
394 }
395 SET_MODULE_OWNER(ndev);
396 SET_NETDEV_DEV(ndev, &pdev->dev);
397
398 platform_set_drvdata(pdev, ndev);
399
400 priv = netdev_priv(ndev);
401
402 pdata = (struct netxeth_platform_data *)pdev->dev.platform_data;
403 priv->xc = request_xc(pdata->xcno, &pdev->dev);
404 if (!priv->xc) {
405 dev_err(&pdev->dev, "unable to request xc engine\n");
406 ret = -ENODEV;
407 goto exit_free_netdev;
408 }
409
410 ndev->irq = priv->xc->irq;
411 priv->id = pdev->id;
412 priv->xpec_base = priv->xc->xpec_base;
413 priv->xmac_base = priv->xc->xmac_base;
414 priv->sram_base = priv->xc->sram_base;
415
416 ret = pfifo_request(PFIFO_MASK(priv->id));
417 if (ret) {
418 printk("unable to request PFIFO\n");
419 goto exit_free_xc;
420 }
421
422 ret = netx_eth_enable(ndev);
423 if (ret)
424 goto exit_free_pfifo;
425
426 return 0;
427exit_free_pfifo:
428 pfifo_free(PFIFO_MASK(priv->id));
429exit_free_xc:
430 free_xc(priv->xc);
431exit_free_netdev:
432 platform_set_drvdata(pdev, NULL);
433 free_netdev(ndev);
434exit:
435 return ret;
436}
437
438static int netx_eth_drv_remove(struct platform_device *pdev)
439{
440 struct net_device *ndev = dev_get_drvdata(&pdev->dev);
441 struct netx_eth_priv *priv = netdev_priv(ndev);
442
443 platform_set_drvdata(pdev, NULL);
444
445 unregister_netdev(ndev);
446 xc_stop(priv->xc);
447 free_xc(priv->xc);
448 free_netdev(ndev);
449 pfifo_free(PFIFO_MASK(priv->id));
450
451 return 0;
452}
453
454static int netx_eth_drv_suspend(struct platform_device *pdev, pm_message_t state)
455{
456 dev_err(&pdev->dev, "suspend not implemented\n");
457 return 0;
458}
459
460static int netx_eth_drv_resume(struct platform_device *pdev)
461{
462 dev_err(&pdev->dev, "resume not implemented\n");
463 return 0;
464}
465
466static struct platform_driver netx_eth_driver = {
467 .probe = netx_eth_drv_probe,
468 .remove = netx_eth_drv_remove,
469 .suspend = netx_eth_drv_suspend,
470 .resume = netx_eth_drv_resume,
471 .driver = {
472 .name = CARDNAME,
473 .owner = THIS_MODULE,
474 },
475};
476
477static int __init netx_eth_init(void)
478{
479 unsigned int phy_control, val;
480
481 printk("NetX Ethernet driver\n");
482
483 phy_control = PHY_CONTROL_PHY_ADDRESS(INTERNAL_PHY_ADR>>1) |
484 PHY_CONTROL_PHY1_MODE(PHY_MODE_ALL) |
485 PHY_CONTROL_PHY1_AUTOMDIX |
486 PHY_CONTROL_PHY1_EN |
487 PHY_CONTROL_PHY0_MODE(PHY_MODE_ALL) |
488 PHY_CONTROL_PHY0_AUTOMDIX |
489 PHY_CONTROL_PHY0_EN |
490 PHY_CONTROL_CLK_XLATIN;
491
492 val = readl(NETX_SYSTEM_IOC_ACCESS_KEY);
493 writel(val, NETX_SYSTEM_IOC_ACCESS_KEY);
494
495 writel(phy_control | PHY_CONTROL_RESET, NETX_SYSTEM_PHY_CONTROL);
496 udelay(100);
497
498 val = readl(NETX_SYSTEM_IOC_ACCESS_KEY);
499 writel(val, NETX_SYSTEM_IOC_ACCESS_KEY);
500
501 writel(phy_control, NETX_SYSTEM_PHY_CONTROL);
502
503 return platform_driver_register(&netx_eth_driver);
504}
505
506static void __exit netx_eth_cleanup(void)
507{
508 platform_driver_unregister(&netx_eth_driver);
509}
510
511module_init(netx_eth_init);
512module_exit(netx_eth_cleanup);
513
514MODULE_AUTHOR("Sascha Hauer, Pengutronix");
515MODULE_LICENSE("GPL");
516
diff --git a/drivers/net/ni5010.c b/drivers/net/ni5010.c
index a68bf474f6ed..d4be207d321a 100644
--- a/drivers/net/ni5010.c
+++ b/drivers/net/ni5010.c
@@ -1,17 +1,12 @@
1/* ni5010.c: A network driver for the MiCom-Interlan NI5010 ethercard. 1/* ni5010.c: A network driver for the MiCom-Interlan NI5010 ethercard.
2 * 2 *
3 * Copyright 1996,1997 Jan-Pascal van Best and Andreas Mohr. 3 * Copyright 1996,1997,2006 Jan-Pascal van Best and Andreas Mohr.
4 * 4 *
5 * This software may be used and distributed according to the terms 5 * This software may be used and distributed according to the terms
6 * of the GNU General Public License, incorporated herein by reference. 6 * of the GNU General Public License, incorporated herein by reference.
7 * 7 *
8 * The authors may be reached as: 8 * The authors may be reached as:
9 * jvbest@wi.leidenuniv.nl a.mohr@mailto.de 9 * janpascal@vanbest.org andi@lisas.de
10 * or by snail mail as
11 * Jan-Pascal van Best Andreas Mohr
12 * Klikspaanweg 58-4 Stauferstr. 6
13 * 2324 LZ Leiden D-71272 Renningen
14 * The Netherlands Germany
15 * 10 *
16 * Sources: 11 * Sources:
17 * Donald Becker's "skeleton.c" 12 * Donald Becker's "skeleton.c"
@@ -27,8 +22,9 @@
27 * 970503 v0.93: Fixed auto-irq failure on warm reboot (JB) 22 * 970503 v0.93: Fixed auto-irq failure on warm reboot (JB)
28 * 970623 v1.00: First kernel version (AM) 23 * 970623 v1.00: First kernel version (AM)
29 * 970814 v1.01: Added detection of onboard receive buffer size (AM) 24 * 970814 v1.01: Added detection of onboard receive buffer size (AM)
25 * 060611 v1.02: slight cleanup: email addresses, driver modernization.
30 * Bugs: 26 * Bugs:
31 * - None known... 27 * - not SMP-safe (no locking of I/O accesses)
32 * - Note that you have to patch ifconfig for the new /proc/net/dev 28 * - Note that you have to patch ifconfig for the new /proc/net/dev
33 * format. It gives incorrect stats otherwise. 29 * format. It gives incorrect stats otherwise.
34 * 30 *
@@ -39,7 +35,7 @@
39 * Complete merge with Andreas' driver 35 * Complete merge with Andreas' driver
40 * Implement ring buffers (Is this useful? You can't squeeze 36 * Implement ring buffers (Is this useful? You can't squeeze
41 * too many packet in a 2k buffer!) 37 * too many packet in a 2k buffer!)
42 * Implement DMA (Again, is this useful? Some docs says DMA is 38 * Implement DMA (Again, is this useful? Some docs say DMA is
43 * slower than programmed I/O) 39 * slower than programmed I/O)
44 * 40 *
45 * Compile with: 41 * Compile with:
@@ -47,7 +43,7 @@
47 * -DMODULE -c ni5010.c 43 * -DMODULE -c ni5010.c
48 * 44 *
49 * Insert with e.g.: 45 * Insert with e.g.:
50 * insmod ni5010.o io=0x300 irq=5 46 * insmod ni5010.ko io=0x300 irq=5
51 */ 47 */
52 48
53#include <linux/module.h> 49#include <linux/module.h>
@@ -69,15 +65,15 @@
69 65
70#include "ni5010.h" 66#include "ni5010.h"
71 67
72static const char *boardname = "NI5010"; 68static const char boardname[] = "NI5010";
73static char *version = 69static char version[] __initdata =
74 "ni5010.c: v1.00 06/23/97 Jan-Pascal van Best and Andreas Mohr\n"; 70 "ni5010.c: v1.02 20060611 Jan-Pascal van Best and Andreas Mohr\n";
75 71
76/* bufsize_rcv == 0 means autoprobing */ 72/* bufsize_rcv == 0 means autoprobing */
77static unsigned int bufsize_rcv; 73static unsigned int bufsize_rcv;
78 74
79#define jumpered_interrupts /* IRQ line jumpered on board */ 75#define JUMPERED_INTERRUPTS /* IRQ line jumpered on board */
80#undef jumpered_dma /* No DMA used */ 76#undef JUMPERED_DMA /* No DMA used */
81#undef FULL_IODETECT /* Only detect in portlist */ 77#undef FULL_IODETECT /* Only detect in portlist */
82 78
83#ifndef FULL_IODETECT 79#ifndef FULL_IODETECT
@@ -281,7 +277,7 @@ static int __init ni5010_probe1(struct net_device *dev, int ioaddr)
281 277
282 PRINTK2((KERN_DEBUG "%s: I/O #4 passed!\n", dev->name)); 278 PRINTK2((KERN_DEBUG "%s: I/O #4 passed!\n", dev->name));
283 279
284#ifdef jumpered_interrupts 280#ifdef JUMPERED_INTERRUPTS
285 if (dev->irq == 0xff) 281 if (dev->irq == 0xff)
286 ; 282 ;
287 else if (dev->irq < 2) { 283 else if (dev->irq < 2) {
@@ -305,7 +301,7 @@ static int __init ni5010_probe1(struct net_device *dev, int ioaddr)
305 } else if (dev->irq == 2) { 301 } else if (dev->irq == 2) {
306 dev->irq = 9; 302 dev->irq = 9;
307 } 303 }
308#endif /* jumpered_irq */ 304#endif /* JUMPERED_INTERRUPTS */
309 PRINTK2((KERN_DEBUG "%s: I/O #9 passed!\n", dev->name)); 305 PRINTK2((KERN_DEBUG "%s: I/O #9 passed!\n", dev->name));
310 306
311 /* DMA is not supported (yet?), so no use detecting it */ 307 /* DMA is not supported (yet?), so no use detecting it */
@@ -334,7 +330,7 @@ static int __init ni5010_probe1(struct net_device *dev, int ioaddr)
334 outw(0, IE_GP); /* Point GP at start of packet */ 330 outw(0, IE_GP); /* Point GP at start of packet */
335 outb(0, IE_RBUF); /* set buffer byte 0 to 0 again */ 331 outb(0, IE_RBUF); /* set buffer byte 0 to 0 again */
336 } 332 }
337 printk("// bufsize rcv/xmt=%d/%d\n", bufsize_rcv, NI5010_BUFSIZE); 333 printk("-> bufsize rcv/xmt=%d/%d\n", bufsize_rcv, NI5010_BUFSIZE);
338 memset(dev->priv, 0, sizeof(struct ni5010_local)); 334 memset(dev->priv, 0, sizeof(struct ni5010_local));
339 335
340 dev->open = ni5010_open; 336 dev->open = ni5010_open;
@@ -354,11 +350,9 @@ static int __init ni5010_probe1(struct net_device *dev, int ioaddr)
354 outb(0xff, EDLC_XCLR); /* Kill all pending xmt interrupts */ 350 outb(0xff, EDLC_XCLR); /* Kill all pending xmt interrupts */
355 351
356 printk(KERN_INFO "%s: NI5010 found at 0x%x, using IRQ %d", dev->name, ioaddr, dev->irq); 352 printk(KERN_INFO "%s: NI5010 found at 0x%x, using IRQ %d", dev->name, ioaddr, dev->irq);
357 if (dev->dma) printk(" & DMA %d", dev->dma); 353 if (dev->dma)
354 printk(" & DMA %d", dev->dma);
358 printk(".\n"); 355 printk(".\n");
359
360 printk(KERN_INFO "Join the NI5010 driver development team!\n");
361 printk(KERN_INFO "Mail to a.mohr@mailto.de or jvbest@wi.leidenuniv.nl\n");
362 return 0; 356 return 0;
363out: 357out:
364 release_region(dev->base_addr, NI5010_IO_EXTENT); 358 release_region(dev->base_addr, NI5010_IO_EXTENT);
@@ -371,7 +365,7 @@ out:
371 * 365 *
372 * This routine should set everything up anew at each open, even 366 * This routine should set everything up anew at each open, even
373 * registers that "should" only need to be set once at boot, so that 367 * registers that "should" only need to be set once at boot, so that
374 * there is non-reboot way to recover if something goes wrong. 368 * there is a non-reboot way to recover if something goes wrong.
375 */ 369 */
376 370
377static int ni5010_open(struct net_device *dev) 371static int ni5010_open(struct net_device *dev)
@@ -390,13 +384,13 @@ static int ni5010_open(struct net_device *dev)
390 * Always allocate the DMA channel after the IRQ, 384 * Always allocate the DMA channel after the IRQ,
391 * and clean up on failure. 385 * and clean up on failure.
392 */ 386 */
393#ifdef jumpered_dma 387#ifdef JUMPERED_DMA
394 if (request_dma(dev->dma, cardname)) { 388 if (request_dma(dev->dma, cardname)) {
395 printk(KERN_WARNING "%s: Cannot get dma %#2x\n", dev->name, dev->dma); 389 printk(KERN_WARNING "%s: Cannot get dma %#2x\n", dev->name, dev->dma);
396 free_irq(dev->irq, NULL); 390 free_irq(dev->irq, NULL);
397 return -EAGAIN; 391 return -EAGAIN;
398 } 392 }
399#endif /* jumpered_dma */ 393#endif /* JUMPERED_DMA */
400 394
401 PRINTK3((KERN_DEBUG "%s: passed open() #2\n", dev->name)); 395 PRINTK3((KERN_DEBUG "%s: passed open() #2\n", dev->name));
402 /* Reset the hardware here. Don't forget to set the station address. */ 396 /* Reset the hardware here. Don't forget to set the station address. */
@@ -633,7 +627,7 @@ static int ni5010_close(struct net_device *dev)
633 int ioaddr = dev->base_addr; 627 int ioaddr = dev->base_addr;
634 628
635 PRINTK2((KERN_DEBUG "%s: entering ni5010_close\n", dev->name)); 629 PRINTK2((KERN_DEBUG "%s: entering ni5010_close\n", dev->name));
636#ifdef jumpered_interrupts 630#ifdef JUMPERED_INTERRUPTS
637 free_irq(dev->irq, NULL); 631 free_irq(dev->irq, NULL);
638#endif 632#endif
639 /* Put card in held-RESET state */ 633 /* Put card in held-RESET state */
@@ -771,7 +765,7 @@ module_param(irq, int, 0);
771MODULE_PARM_DESC(io, "ni5010 I/O base address"); 765MODULE_PARM_DESC(io, "ni5010 I/O base address");
772MODULE_PARM_DESC(irq, "ni5010 IRQ number"); 766MODULE_PARM_DESC(irq, "ni5010 IRQ number");
773 767
774int init_module(void) 768static int __init ni5010_init_module(void)
775{ 769{
776 PRINTK2((KERN_DEBUG "%s: entering init_module\n", boardname)); 770 PRINTK2((KERN_DEBUG "%s: entering init_module\n", boardname));
777 /* 771 /*
@@ -792,13 +786,15 @@ int init_module(void)
792 return 0; 786 return 0;
793} 787}
794 788
795void cleanup_module(void) 789static void __exit ni5010_cleanup_module(void)
796{ 790{
797 PRINTK2((KERN_DEBUG "%s: entering cleanup_module\n", boardname)); 791 PRINTK2((KERN_DEBUG "%s: entering cleanup_module\n", boardname));
798 unregister_netdev(dev_ni5010); 792 unregister_netdev(dev_ni5010);
799 release_region(dev_ni5010->base_addr, NI5010_IO_EXTENT); 793 release_region(dev_ni5010->base_addr, NI5010_IO_EXTENT);
800 free_netdev(dev_ni5010); 794 free_netdev(dev_ni5010);
801} 795}
796module_init(ni5010_init_module);
797module_exit(ni5010_cleanup_module);
802#endif /* MODULE */ 798#endif /* MODULE */
803MODULE_LICENSE("GPL"); 799MODULE_LICENSE("GPL");
804 800
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index 706aed7d717f..0e76859c90a2 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -96,7 +96,6 @@
96//#define dprintk printk 96//#define dprintk printk
97#define dprintk(x...) do { } while (0) 97#define dprintk(x...) do { } while (0)
98 98
99#include <linux/config.h>
100#include <linux/module.h> 99#include <linux/module.h>
101#include <linux/moduleparam.h> 100#include <linux/moduleparam.h>
102#include <linux/types.h> 101#include <linux/types.h>
@@ -804,7 +803,7 @@ static int ns83820_setup_rx(struct net_device *ndev)
804 803
805 writel(dev->IMR_cache, dev->base + IMR); 804 writel(dev->IMR_cache, dev->base + IMR);
806 writel(1, dev->base + IER); 805 writel(1, dev->base + IER);
807 spin_unlock_irq(&dev->misc_lock); 806 spin_unlock(&dev->misc_lock);
808 807
809 kick_rx(ndev); 808 kick_rx(ndev);
810 809
@@ -1013,8 +1012,6 @@ static void do_tx_done(struct net_device *ndev)
1013 struct ns83820 *dev = PRIV(ndev); 1012 struct ns83820 *dev = PRIV(ndev);
1014 u32 cmdsts, tx_done_idx, *desc; 1013 u32 cmdsts, tx_done_idx, *desc;
1015 1014
1016 spin_lock_irq(&dev->tx_lock);
1017
1018 dprintk("do_tx_done(%p)\n", ndev); 1015 dprintk("do_tx_done(%p)\n", ndev);
1019 tx_done_idx = dev->tx_done_idx; 1016 tx_done_idx = dev->tx_done_idx;
1020 desc = dev->tx_descs + (tx_done_idx * DESC_SIZE); 1017 desc = dev->tx_descs + (tx_done_idx * DESC_SIZE);
@@ -1070,7 +1067,6 @@ static void do_tx_done(struct net_device *ndev)
1070 netif_start_queue(ndev); 1067 netif_start_queue(ndev);
1071 netif_wake_queue(ndev); 1068 netif_wake_queue(ndev);
1072 } 1069 }
1073 spin_unlock_irq(&dev->tx_lock);
1074} 1070}
1075 1071
1076static void ns83820_cleanup_tx(struct ns83820 *dev) 1072static void ns83820_cleanup_tx(struct ns83820 *dev)
@@ -1282,11 +1278,13 @@ static struct ethtool_ops ops = {
1282 .get_link = ns83820_get_link 1278 .get_link = ns83820_get_link
1283}; 1279};
1284 1280
1281/* this function is called in irq context from the ISR */
1285static void ns83820_mib_isr(struct ns83820 *dev) 1282static void ns83820_mib_isr(struct ns83820 *dev)
1286{ 1283{
1287 spin_lock(&dev->misc_lock); 1284 unsigned long flags;
1285 spin_lock_irqsave(&dev->misc_lock, flags);
1288 ns83820_update_stats(dev); 1286 ns83820_update_stats(dev);
1289 spin_unlock(&dev->misc_lock); 1287 spin_unlock_irqrestore(&dev->misc_lock, flags);
1290} 1288}
1291 1289
1292static void ns83820_do_isr(struct net_device *ndev, u32 isr); 1290static void ns83820_do_isr(struct net_device *ndev, u32 isr);
@@ -1308,6 +1306,8 @@ static irqreturn_t ns83820_irq(int foo, void *data, struct pt_regs *regs)
1308static void ns83820_do_isr(struct net_device *ndev, u32 isr) 1306static void ns83820_do_isr(struct net_device *ndev, u32 isr)
1309{ 1307{
1310 struct ns83820 *dev = PRIV(ndev); 1308 struct ns83820 *dev = PRIV(ndev);
1309 unsigned long flags;
1310
1311#ifdef DEBUG 1311#ifdef DEBUG
1312 if (isr & ~(ISR_PHY | ISR_RXDESC | ISR_RXEARLY | ISR_RXOK | ISR_RXERR | ISR_TXIDLE | ISR_TXOK | ISR_TXDESC)) 1312 if (isr & ~(ISR_PHY | ISR_RXDESC | ISR_RXEARLY | ISR_RXOK | ISR_RXERR | ISR_TXIDLE | ISR_TXOK | ISR_TXDESC))
1313 Dprintk("odd isr? 0x%08x\n", isr); 1313 Dprintk("odd isr? 0x%08x\n", isr);
@@ -1322,10 +1322,10 @@ static void ns83820_do_isr(struct net_device *ndev, u32 isr)
1322 if ((ISR_RXDESC | ISR_RXOK) & isr) { 1322 if ((ISR_RXDESC | ISR_RXOK) & isr) {
1323 prefetch(dev->rx_info.next_rx_desc); 1323 prefetch(dev->rx_info.next_rx_desc);
1324 1324
1325 spin_lock_irq(&dev->misc_lock); 1325 spin_lock_irqsave(&dev->misc_lock, flags);
1326 dev->IMR_cache &= ~(ISR_RXDESC | ISR_RXOK); 1326 dev->IMR_cache &= ~(ISR_RXDESC | ISR_RXOK);
1327 writel(dev->IMR_cache, dev->base + IMR); 1327 writel(dev->IMR_cache, dev->base + IMR);
1328 spin_unlock_irq(&dev->misc_lock); 1328 spin_unlock_irqrestore(&dev->misc_lock, flags);
1329 1329
1330 tasklet_schedule(&dev->rx_tasklet); 1330 tasklet_schedule(&dev->rx_tasklet);
1331 //rx_irq(ndev); 1331 //rx_irq(ndev);
@@ -1371,16 +1371,18 @@ static void ns83820_do_isr(struct net_device *ndev, u32 isr)
1371 * work has accumulated 1371 * work has accumulated
1372 */ 1372 */
1373 if ((ISR_TXDESC | ISR_TXIDLE | ISR_TXOK | ISR_TXERR) & isr) { 1373 if ((ISR_TXDESC | ISR_TXIDLE | ISR_TXOK | ISR_TXERR) & isr) {
1374 spin_lock_irqsave(&dev->tx_lock, flags);
1374 do_tx_done(ndev); 1375 do_tx_done(ndev);
1376 spin_unlock_irqrestore(&dev->tx_lock, flags);
1375 1377
1376 /* Disable TxOk if there are no outstanding tx packets. 1378 /* Disable TxOk if there are no outstanding tx packets.
1377 */ 1379 */
1378 if ((dev->tx_done_idx == dev->tx_free_idx) && 1380 if ((dev->tx_done_idx == dev->tx_free_idx) &&
1379 (dev->IMR_cache & ISR_TXOK)) { 1381 (dev->IMR_cache & ISR_TXOK)) {
1380 spin_lock_irq(&dev->misc_lock); 1382 spin_lock_irqsave(&dev->misc_lock, flags);
1381 dev->IMR_cache &= ~ISR_TXOK; 1383 dev->IMR_cache &= ~ISR_TXOK;
1382 writel(dev->IMR_cache, dev->base + IMR); 1384 writel(dev->IMR_cache, dev->base + IMR);
1383 spin_unlock_irq(&dev->misc_lock); 1385 spin_unlock_irqrestore(&dev->misc_lock, flags);
1384 } 1386 }
1385 } 1387 }
1386 1388
@@ -1391,10 +1393,10 @@ static void ns83820_do_isr(struct net_device *ndev, u32 isr)
1391 * nature are expected, we must enable TxOk. 1393 * nature are expected, we must enable TxOk.
1392 */ 1394 */
1393 if ((ISR_TXIDLE & isr) && (dev->tx_done_idx != dev->tx_free_idx)) { 1395 if ((ISR_TXIDLE & isr) && (dev->tx_done_idx != dev->tx_free_idx)) {
1394 spin_lock_irq(&dev->misc_lock); 1396 spin_lock_irqsave(&dev->misc_lock, flags);
1395 dev->IMR_cache |= ISR_TXOK; 1397 dev->IMR_cache |= ISR_TXOK;
1396 writel(dev->IMR_cache, dev->base + IMR); 1398 writel(dev->IMR_cache, dev->base + IMR);
1397 spin_unlock_irq(&dev->misc_lock); 1399 spin_unlock_irqrestore(&dev->misc_lock, flags);
1398 } 1400 }
1399 1401
1400 /* MIB interrupt: one of the statistics counters is about to overflow */ 1402 /* MIB interrupt: one of the statistics counters is about to overflow */
@@ -1456,7 +1458,7 @@ static void ns83820_tx_timeout(struct net_device *ndev)
1456 u32 tx_done_idx, *desc; 1458 u32 tx_done_idx, *desc;
1457 unsigned long flags; 1459 unsigned long flags;
1458 1460
1459 local_irq_save(flags); 1461 spin_lock_irqsave(&dev->tx_lock, flags);
1460 1462
1461 tx_done_idx = dev->tx_done_idx; 1463 tx_done_idx = dev->tx_done_idx;
1462 desc = dev->tx_descs + (tx_done_idx * DESC_SIZE); 1464 desc = dev->tx_descs + (tx_done_idx * DESC_SIZE);
@@ -1483,7 +1485,7 @@ static void ns83820_tx_timeout(struct net_device *ndev)
1483 ndev->name, 1485 ndev->name,
1484 tx_done_idx, dev->tx_free_idx, le32_to_cpu(desc[DESC_CMDSTS])); 1486 tx_done_idx, dev->tx_free_idx, le32_to_cpu(desc[DESC_CMDSTS]));
1485 1487
1486 local_irq_restore(flags); 1488 spin_unlock_irqrestore(&dev->tx_lock, flags);
1487} 1489}
1488 1490
1489static void ns83820_tx_watch(unsigned long data) 1491static void ns83820_tx_watch(unsigned long data)
@@ -1833,7 +1835,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1833 } else if (!pci_set_dma_mask(pci_dev, DMA_32BIT_MASK)) { 1835 } else if (!pci_set_dma_mask(pci_dev, DMA_32BIT_MASK)) {
1834 using_dac = 0; 1836 using_dac = 0;
1835 } else { 1837 } else {
1836 printk(KERN_WARNING "ns83820.c: pci_set_dma_mask failed!\n"); 1838 dev_warn(&pci_dev->dev, "pci_set_dma_mask failed!\n");
1837 return -ENODEV; 1839 return -ENODEV;
1838 } 1840 }
1839 1841
@@ -1856,7 +1858,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1856 1858
1857 err = pci_enable_device(pci_dev); 1859 err = pci_enable_device(pci_dev);
1858 if (err) { 1860 if (err) {
1859 printk(KERN_INFO "ns83820: pci_enable_dev failed: %d\n", err); 1861 dev_info(&pci_dev->dev, "pci_enable_dev failed: %d\n", err);
1860 goto out_free; 1862 goto out_free;
1861 } 1863 }
1862 1864
@@ -1882,11 +1884,11 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1882 1884
1883 dev->IMR_cache = 0; 1885 dev->IMR_cache = 0;
1884 1886
1885 err = request_irq(pci_dev->irq, ns83820_irq, SA_SHIRQ, 1887 err = request_irq(pci_dev->irq, ns83820_irq, IRQF_SHARED,
1886 DRV_NAME, ndev); 1888 DRV_NAME, ndev);
1887 if (err) { 1889 if (err) {
1888 printk(KERN_INFO "ns83820: unable to register irq %d\n", 1890 dev_info(&pci_dev->dev, "unable to register irq %d, err %d\n",
1889 pci_dev->irq); 1891 pci_dev->irq, err);
1890 goto out_disable; 1892 goto out_disable;
1891 } 1893 }
1892 1894
@@ -1900,7 +1902,7 @@ static int __devinit ns83820_init_one(struct pci_dev *pci_dev, const struct pci_
1900 rtnl_lock(); 1902 rtnl_lock();
1901 err = dev_alloc_name(ndev, ndev->name); 1903 err = dev_alloc_name(ndev, ndev->name);
1902 if (err < 0) { 1904 if (err < 0) {
1903 printk(KERN_INFO "ns83820: unable to get netdev name: %d\n", err); 1905 dev_info(&pci_dev->dev, "unable to get netdev name: %d\n", err);
1904 goto out_free_irq; 1906 goto out_free_irq;
1905 } 1907 }
1906 1908
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c
index a7bb54df75a8..e0e293964042 100644
--- a/drivers/net/pci-skeleton.c
+++ b/drivers/net/pci-skeleton.c
@@ -85,7 +85,6 @@ IVc. Errata
85 85
86*/ 86*/
87 87
88#include <linux/config.h>
89#include <linux/module.h> 88#include <linux/module.h>
90#include <linux/kernel.h> 89#include <linux/kernel.h>
91#include <linux/pci.h> 90#include <linux/pci.h>
@@ -602,7 +601,7 @@ static int __devinit netdrv_init_board (struct pci_dev *pdev,
602 /* dev zeroed in alloc_etherdev */ 601 /* dev zeroed in alloc_etherdev */
603 dev = alloc_etherdev (sizeof (*tp)); 602 dev = alloc_etherdev (sizeof (*tp));
604 if (dev == NULL) { 603 if (dev == NULL) {
605 printk (KERN_ERR PFX "unable to alloc new ethernet\n"); 604 dev_err(&pdev->dev, "unable to alloc new ethernet\n");
606 DPRINTK ("EXIT, returning -ENOMEM\n"); 605 DPRINTK ("EXIT, returning -ENOMEM\n");
607 return -ENOMEM; 606 return -ENOMEM;
608 } 607 }
@@ -632,14 +631,14 @@ static int __devinit netdrv_init_board (struct pci_dev *pdev,
632 631
633 /* make sure PCI base addr 0 is PIO */ 632 /* make sure PCI base addr 0 is PIO */
634 if (!(pio_flags & IORESOURCE_IO)) { 633 if (!(pio_flags & IORESOURCE_IO)) {
635 printk (KERN_ERR PFX "region #0 not a PIO resource, aborting\n"); 634 dev_err(&pdev->dev, "region #0 not a PIO resource, aborting\n");
636 rc = -ENODEV; 635 rc = -ENODEV;
637 goto err_out; 636 goto err_out;
638 } 637 }
639 638
640 /* make sure PCI base addr 1 is MMIO */ 639 /* make sure PCI base addr 1 is MMIO */
641 if (!(mmio_flags & IORESOURCE_MEM)) { 640 if (!(mmio_flags & IORESOURCE_MEM)) {
642 printk (KERN_ERR PFX "region #1 not an MMIO resource, aborting\n"); 641 dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n");
643 rc = -ENODEV; 642 rc = -ENODEV;
644 goto err_out; 643 goto err_out;
645 } 644 }
@@ -647,12 +646,12 @@ static int __devinit netdrv_init_board (struct pci_dev *pdev,
647 /* check for weird/broken PCI region reporting */ 646 /* check for weird/broken PCI region reporting */
648 if ((pio_len < NETDRV_MIN_IO_SIZE) || 647 if ((pio_len < NETDRV_MIN_IO_SIZE) ||
649 (mmio_len < NETDRV_MIN_IO_SIZE)) { 648 (mmio_len < NETDRV_MIN_IO_SIZE)) {
650 printk (KERN_ERR PFX "Invalid PCI region size(s), aborting\n"); 649 dev_err(&pdev->dev, "Invalid PCI region size(s), aborting\n");
651 rc = -ENODEV; 650 rc = -ENODEV;
652 goto err_out; 651 goto err_out;
653 } 652 }
654 653
655 rc = pci_request_regions (pdev, "pci-skeleton"); 654 rc = pci_request_regions (pdev, MODNAME);
656 if (rc) 655 if (rc)
657 goto err_out; 656 goto err_out;
658 657
@@ -664,7 +663,7 @@ static int __devinit netdrv_init_board (struct pci_dev *pdev,
664 /* ioremap MMIO region */ 663 /* ioremap MMIO region */
665 ioaddr = ioremap (mmio_start, mmio_len); 664 ioaddr = ioremap (mmio_start, mmio_len);
666 if (ioaddr == NULL) { 665 if (ioaddr == NULL) {
667 printk (KERN_ERR PFX "cannot remap MMIO, aborting\n"); 666 dev_err(&pdev->dev, "cannot remap MMIO, aborting\n");
668 rc = -EIO; 667 rc = -EIO;
669 goto err_out_free_res; 668 goto err_out_free_res;
670 } 669 }
@@ -700,9 +699,10 @@ static int __devinit netdrv_init_board (struct pci_dev *pdev,
700 } 699 }
701 700
702 /* if unknown chip, assume array element #0, original RTL-8139 in this case */ 701 /* if unknown chip, assume array element #0, original RTL-8139 in this case */
703 printk (KERN_DEBUG PFX "PCI device %s: unknown chip version, assuming RTL-8139\n", 702 dev_printk (KERN_DEBUG, &pdev->dev,
704 pci_name(pdev)); 703 "unknown chip version, assuming RTL-8139\n");
705 printk (KERN_DEBUG PFX "PCI device %s: TxConfig = 0x%lx\n", pci_name(pdev), NETDRV_R32 (TxConfig)); 704 dev_printk (KERN_DEBUG, &pdev->dev, "TxConfig = 0x%lx\n",
705 NETDRV_R32 (TxConfig));
706 tp->chipset = 0; 706 tp->chipset = 0;
707 707
708match: 708match:
@@ -1076,7 +1076,7 @@ static int netdrv_open (struct net_device *dev)
1076 1076
1077 DPRINTK ("ENTER\n"); 1077 DPRINTK ("ENTER\n");
1078 1078
1079 retval = request_irq (dev->irq, netdrv_interrupt, SA_SHIRQ, dev->name, dev); 1079 retval = request_irq (dev->irq, netdrv_interrupt, IRQF_SHARED, dev->name, dev);
1080 if (retval) { 1080 if (retval) {
1081 DPRINTK ("EXIT, returning %d\n", retval); 1081 DPRINTK ("EXIT, returning %d\n", retval);
1082 return retval; 1082 return retval;
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 2ea66aca648b..297e9f805366 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -535,7 +535,7 @@ static int axnet_open(struct net_device *dev)
535 535
536 link->open++; 536 link->open++;
537 537
538 request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, "axnet_cs", dev); 538 request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, "axnet_cs", dev);
539 539
540 info->link_status = 0x00; 540 info->link_status = 0x00;
541 init_timer(&info->watchdog); 541 init_timer(&info->watchdog);
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 441de824ab6b..48434d7924eb 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -387,7 +387,10 @@ static int com20020_resume(struct pcmcia_device *link)
387} 387}
388 388
389static struct pcmcia_device_id com20020_ids[] = { 389static struct pcmcia_device_id com20020_ids[] = {
390 PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf), 390 PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.",
391 "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf),
392 PCMCIA_DEVICE_PROD_ID12("SoHard AG",
393 "SH ARC PCMCIA", 0xf8991729, 0x69dff0c7),
391 PCMCIA_DEVICE_NULL 394 PCMCIA_DEVICE_NULL
392}; 395};
393MODULE_DEVICE_TABLE(pcmcia, com20020_ids); 396MODULE_DEVICE_TABLE(pcmcia, com20020_ids);
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 09b11761cdfa..ea93b8f18605 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -831,8 +831,7 @@ static int fjn_start_xmit(struct sk_buff *skb, struct net_device *dev)
831 831
832 if (length < ETH_ZLEN) 832 if (length < ETH_ZLEN)
833 { 833 {
834 skb = skb_padto(skb, ETH_ZLEN); 834 if (skb_padto(skb, ETH_ZLEN))
835 if (skb == NULL)
836 return 0; 835 return 0;
837 length = ETH_ZLEN; 836 length = ETH_ZLEN;
838 } 837 }
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 661bfe54ff5d..0ecebfc31f07 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -998,7 +998,7 @@ static int pcnet_open(struct net_device *dev)
998 link->open++; 998 link->open++;
999 999
1000 set_misc_reg(dev); 1000 set_misc_reg(dev);
1001 request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, dev_info, dev); 1001 request_irq(dev->irq, ei_irq_wrapper, IRQF_SHARED, dev_info, dev);
1002 1002
1003 info->phy_id = info->eth_phy; 1003 info->phy_id = info->eth_phy;
1004 info->link_status = 0x00; 1004 info->link_status = 0x00;
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index e74bf5014ef6..a73d54553030 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -1883,7 +1883,7 @@ static void smc_reset(struct net_device *dev)
1883 /* Set the Window 1 control, configuration and station addr registers. 1883 /* Set the Window 1 control, configuration and station addr registers.
1884 No point in writing the I/O base register ;-> */ 1884 No point in writing the I/O base register ;-> */
1885 SMC_SELECT_BANK(1); 1885 SMC_SELECT_BANK(1);
1886 /* Automatically release succesfully transmitted packets, 1886 /* Automatically release successfully transmitted packets,
1887 Accept link errors, counter and Tx error interrupts. */ 1887 Accept link errors, counter and Tx error interrupts. */
1888 outw(CTL_AUTO_RELEASE | CTL_TE_ENABLE | CTL_CR_ENABLE, 1888 outw(CTL_AUTO_RELEASE | CTL_TE_ENABLE | CTL_CR_ENABLE,
1889 ioaddr + CONTROL); 1889 ioaddr + CONTROL);
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 71f45056a70c..9bae77ce1314 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -1359,7 +1359,7 @@ do_start_xmit(struct sk_buff *skb, struct net_device *dev)
1359 kio_addr_t ioaddr = dev->base_addr; 1359 kio_addr_t ioaddr = dev->base_addr;
1360 int okay; 1360 int okay;
1361 unsigned freespace; 1361 unsigned freespace;
1362 unsigned pktlen = skb? skb->len : 0; 1362 unsigned pktlen = skb->len;
1363 1363
1364 DEBUG(1, "do_start_xmit(skb=%p, dev=%p) len=%u\n", 1364 DEBUG(1, "do_start_xmit(skb=%p, dev=%p) len=%u\n",
1365 skb, dev, pktlen); 1365 skb, dev, pktlen);
@@ -1374,8 +1374,7 @@ do_start_xmit(struct sk_buff *skb, struct net_device *dev)
1374 */ 1374 */
1375 if (pktlen < ETH_ZLEN) 1375 if (pktlen < ETH_ZLEN)
1376 { 1376 {
1377 skb = skb_padto(skb, ETH_ZLEN); 1377 if (skb_padto(skb, ETH_ZLEN))
1378 if (skb == NULL)
1379 return 0; 1378 return 0;
1380 pktlen = ETH_ZLEN; 1379 pktlen = ETH_ZLEN;
1381 } 1380 }
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index fc08c4af506c..4daafe303358 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -58,18 +58,15 @@ static const char *const version =
58 * PCI device identifiers for "new style" Linux PCI Device Drivers 58 * PCI device identifiers for "new style" Linux PCI Device Drivers
59 */ 59 */
60static struct pci_device_id pcnet32_pci_tbl[] = { 60static struct pci_device_id pcnet32_pci_tbl[] = {
61 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE_HOME, 61 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE_HOME), },
62 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 62 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE), },
63 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE,
64 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
65 63
66 /* 64 /*
67 * Adapters that were sold with IBM's RS/6000 or pSeries hardware have 65 * Adapters that were sold with IBM's RS/6000 or pSeries hardware have
68 * the incorrect vendor id. 66 * the incorrect vendor id.
69 */ 67 */
70 { PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_AMD_LANCE, 68 { PCI_DEVICE(PCI_VENDOR_ID_TRIDENT, PCI_DEVICE_ID_AMD_LANCE),
71 PCI_ANY_ID, PCI_ANY_ID, 69 .class = (PCI_CLASS_NETWORK_ETHERNET << 8), .class_mask = 0xffff00, },
72 PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, 0},
73 70
74 { } /* terminate list */ 71 { } /* terminate list */
75}; 72};
@@ -188,6 +185,23 @@ static int homepna[MAX_UNITS];
188 185
189#define PCNET32_TOTAL_SIZE 0x20 186#define PCNET32_TOTAL_SIZE 0x20
190 187
188#define CSR0 0
189#define CSR0_INIT 0x1
190#define CSR0_START 0x2
191#define CSR0_STOP 0x4
192#define CSR0_TXPOLL 0x8
193#define CSR0_INTEN 0x40
194#define CSR0_IDON 0x0100
195#define CSR0_NORMAL (CSR0_START | CSR0_INTEN)
196#define PCNET32_INIT_LOW 1
197#define PCNET32_INIT_HIGH 2
198#define CSR3 3
199#define CSR4 4
200#define CSR5 5
201#define CSR5_SUSPEND 0x0001
202#define CSR15 15
203#define PCNET32_MC_FILTER 8
204
191/* The PCNET32 Rx and Tx ring descriptors. */ 205/* The PCNET32 Rx and Tx ring descriptors. */
192struct pcnet32_rx_head { 206struct pcnet32_rx_head {
193 u32 base; 207 u32 base;
@@ -277,7 +291,6 @@ struct pcnet32_private {
277 u32 phymask; 291 u32 phymask;
278}; 292};
279 293
280static void pcnet32_probe_vlbus(void);
281static int pcnet32_probe_pci(struct pci_dev *, const struct pci_device_id *); 294static int pcnet32_probe_pci(struct pci_dev *, const struct pci_device_id *);
282static int pcnet32_probe1(unsigned long, int, struct pci_dev *); 295static int pcnet32_probe1(unsigned long, int, struct pci_dev *);
283static int pcnet32_open(struct net_device *); 296static int pcnet32_open(struct net_device *);
@@ -309,12 +322,6 @@ static int pcnet32_alloc_ring(struct net_device *dev, char *name);
309static void pcnet32_free_ring(struct net_device *dev); 322static void pcnet32_free_ring(struct net_device *dev);
310static void pcnet32_check_media(struct net_device *dev, int verbose); 323static void pcnet32_check_media(struct net_device *dev, int verbose);
311 324
312enum pci_flags_bit {
313 PCI_USES_IO = 1, PCI_USES_MEM = 2, PCI_USES_MASTER = 4,
314 PCI_ADDR0 = 0x10 << 0, PCI_ADDR1 = 0x10 << 1, PCI_ADDR2 =
315 0x10 << 2, PCI_ADDR3 = 0x10 << 3,
316};
317
318static u16 pcnet32_wio_read_csr(unsigned long addr, int index) 325static u16 pcnet32_wio_read_csr(unsigned long addr, int index)
319{ 326{
320 outw(index, addr + PCNET32_WIO_RAP); 327 outw(index, addr + PCNET32_WIO_RAP);
@@ -425,6 +432,238 @@ static struct pcnet32_access pcnet32_dwio = {
425 .reset = pcnet32_dwio_reset 432 .reset = pcnet32_dwio_reset
426}; 433};
427 434
435static void pcnet32_netif_stop(struct net_device *dev)
436{
437 dev->trans_start = jiffies;
438 netif_poll_disable(dev);
439 netif_tx_disable(dev);
440}
441
442static void pcnet32_netif_start(struct net_device *dev)
443{
444 netif_wake_queue(dev);
445 netif_poll_enable(dev);
446}
447
448/*
449 * Allocate space for the new sized tx ring.
450 * Free old resources
451 * Save new resources.
452 * Any failure keeps old resources.
453 * Must be called with lp->lock held.
454 */
455static void pcnet32_realloc_tx_ring(struct net_device *dev,
456 struct pcnet32_private *lp,
457 unsigned int size)
458{
459 dma_addr_t new_ring_dma_addr;
460 dma_addr_t *new_dma_addr_list;
461 struct pcnet32_tx_head *new_tx_ring;
462 struct sk_buff **new_skb_list;
463
464 pcnet32_purge_tx_ring(dev);
465
466 new_tx_ring = pci_alloc_consistent(lp->pci_dev,
467 sizeof(struct pcnet32_tx_head) *
468 (1 << size),
469 &new_ring_dma_addr);
470 if (new_tx_ring == NULL) {
471 if (netif_msg_drv(lp))
472 printk("\n" KERN_ERR
473 "%s: Consistent memory allocation failed.\n",
474 dev->name);
475 return;
476 }
477 memset(new_tx_ring, 0, sizeof(struct pcnet32_tx_head) * (1 << size));
478
479 new_dma_addr_list = kcalloc((1 << size), sizeof(dma_addr_t),
480 GFP_ATOMIC);
481 if (!new_dma_addr_list) {
482 if (netif_msg_drv(lp))
483 printk("\n" KERN_ERR
484 "%s: Memory allocation failed.\n", dev->name);
485 goto free_new_tx_ring;
486 }
487
488 new_skb_list = kcalloc((1 << size), sizeof(struct sk_buff *),
489 GFP_ATOMIC);
490 if (!new_skb_list) {
491 if (netif_msg_drv(lp))
492 printk("\n" KERN_ERR
493 "%s: Memory allocation failed.\n", dev->name);
494 goto free_new_lists;
495 }
496
497 kfree(lp->tx_skbuff);
498 kfree(lp->tx_dma_addr);
499 pci_free_consistent(lp->pci_dev,
500 sizeof(struct pcnet32_tx_head) *
501 lp->tx_ring_size, lp->tx_ring,
502 lp->tx_ring_dma_addr);
503
504 lp->tx_ring_size = (1 << size);
505 lp->tx_mod_mask = lp->tx_ring_size - 1;
506 lp->tx_len_bits = (size << 12);
507 lp->tx_ring = new_tx_ring;
508 lp->tx_ring_dma_addr = new_ring_dma_addr;
509 lp->tx_dma_addr = new_dma_addr_list;
510 lp->tx_skbuff = new_skb_list;
511 return;
512
513 free_new_lists:
514 kfree(new_dma_addr_list);
515 free_new_tx_ring:
516 pci_free_consistent(lp->pci_dev,
517 sizeof(struct pcnet32_tx_head) *
518 (1 << size),
519 new_tx_ring,
520 new_ring_dma_addr);
521 return;
522}
523
524/*
525 * Allocate space for the new sized rx ring.
526 * Re-use old receive buffers.
527 * alloc extra buffers
528 * free unneeded buffers
529 * free unneeded buffers
530 * Save new resources.
531 * Any failure keeps old resources.
532 * Must be called with lp->lock held.
533 */
534static void pcnet32_realloc_rx_ring(struct net_device *dev,
535 struct pcnet32_private *lp,
536 unsigned int size)
537{
538 dma_addr_t new_ring_dma_addr;
539 dma_addr_t *new_dma_addr_list;
540 struct pcnet32_rx_head *new_rx_ring;
541 struct sk_buff **new_skb_list;
542 int new, overlap;
543
544 new_rx_ring = pci_alloc_consistent(lp->pci_dev,
545 sizeof(struct pcnet32_rx_head) *
546 (1 << size),
547 &new_ring_dma_addr);
548 if (new_rx_ring == NULL) {
549 if (netif_msg_drv(lp))
550 printk("\n" KERN_ERR
551 "%s: Consistent memory allocation failed.\n",
552 dev->name);
553 return;
554 }
555 memset(new_rx_ring, 0, sizeof(struct pcnet32_rx_head) * (1 << size));
556
557 new_dma_addr_list = kcalloc((1 << size), sizeof(dma_addr_t),
558 GFP_ATOMIC);
559 if (!new_dma_addr_list) {
560 if (netif_msg_drv(lp))
561 printk("\n" KERN_ERR
562 "%s: Memory allocation failed.\n", dev->name);
563 goto free_new_rx_ring;
564 }
565
566 new_skb_list = kcalloc((1 << size), sizeof(struct sk_buff *),
567 GFP_ATOMIC);
568 if (!new_skb_list) {
569 if (netif_msg_drv(lp))
570 printk("\n" KERN_ERR
571 "%s: Memory allocation failed.\n", dev->name);
572 goto free_new_lists;
573 }
574
575 /* first copy the current receive buffers */
576 overlap = min(size, lp->rx_ring_size);
577 for (new = 0; new < overlap; new++) {
578 new_rx_ring[new] = lp->rx_ring[new];
579 new_dma_addr_list[new] = lp->rx_dma_addr[new];
580 new_skb_list[new] = lp->rx_skbuff[new];
581 }
582 /* now allocate any new buffers needed */
583 for (; new < size; new++ ) {
584 struct sk_buff *rx_skbuff;
585 new_skb_list[new] = dev_alloc_skb(PKT_BUF_SZ);
586 if (!(rx_skbuff = new_skb_list[new])) {
587 /* keep the original lists and buffers */
588 if (netif_msg_drv(lp))
589 printk(KERN_ERR
590 "%s: pcnet32_realloc_rx_ring dev_alloc_skb failed.\n",
591 dev->name);
592 goto free_all_new;
593 }
594 skb_reserve(rx_skbuff, 2);
595
596 new_dma_addr_list[new] =
597 pci_map_single(lp->pci_dev, rx_skbuff->data,
598 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE);
599 new_rx_ring[new].base = (u32) le32_to_cpu(new_dma_addr_list[new]);
600 new_rx_ring[new].buf_length = le16_to_cpu(2 - PKT_BUF_SZ);
601 new_rx_ring[new].status = le16_to_cpu(0x8000);
602 }
603 /* and free any unneeded buffers */
604 for (; new < lp->rx_ring_size; new++) {
605 if (lp->rx_skbuff[new]) {
606 pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[new],
607 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE);
608 dev_kfree_skb(lp->rx_skbuff[new]);
609 }
610 }
611
612 kfree(lp->rx_skbuff);
613 kfree(lp->rx_dma_addr);
614 pci_free_consistent(lp->pci_dev,
615 sizeof(struct pcnet32_rx_head) *
616 lp->rx_ring_size, lp->rx_ring,
617 lp->rx_ring_dma_addr);
618
619 lp->rx_ring_size = (1 << size);
620 lp->rx_mod_mask = lp->rx_ring_size - 1;
621 lp->rx_len_bits = (size << 4);
622 lp->rx_ring = new_rx_ring;
623 lp->rx_ring_dma_addr = new_ring_dma_addr;
624 lp->rx_dma_addr = new_dma_addr_list;
625 lp->rx_skbuff = new_skb_list;
626 return;
627
628 free_all_new:
629 for (; --new >= lp->rx_ring_size; ) {
630 if (new_skb_list[new]) {
631 pci_unmap_single(lp->pci_dev, new_dma_addr_list[new],
632 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE);
633 dev_kfree_skb(new_skb_list[new]);
634 }
635 }
636 kfree(new_skb_list);
637 free_new_lists:
638 kfree(new_dma_addr_list);
639 free_new_rx_ring:
640 pci_free_consistent(lp->pci_dev,
641 sizeof(struct pcnet32_rx_head) *
642 (1 << size),
643 new_rx_ring,
644 new_ring_dma_addr);
645 return;
646}
647
648static void pcnet32_purge_rx_ring(struct net_device *dev)
649{
650 struct pcnet32_private *lp = dev->priv;
651 int i;
652
653 /* free all allocated skbuffs */
654 for (i = 0; i < lp->rx_ring_size; i++) {
655 lp->rx_ring[i].status = 0; /* CPU owns buffer */
656 wmb(); /* Make sure adapter sees owner change */
657 if (lp->rx_skbuff[i]) {
658 pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[i],
659 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE);
660 dev_kfree_skb_any(lp->rx_skbuff[i]);
661 }
662 lp->rx_skbuff[i] = NULL;
663 lp->rx_dma_addr[i] = 0;
664 }
665}
666
428#ifdef CONFIG_NET_POLL_CONTROLLER 667#ifdef CONFIG_NET_POLL_CONTROLLER
429static void pcnet32_poll_controller(struct net_device *dev) 668static void pcnet32_poll_controller(struct net_device *dev)
430{ 669{
@@ -525,10 +764,10 @@ static void pcnet32_get_ringparam(struct net_device *dev,
525{ 764{
526 struct pcnet32_private *lp = dev->priv; 765 struct pcnet32_private *lp = dev->priv;
527 766
528 ering->tx_max_pending = TX_MAX_RING_SIZE - 1; 767 ering->tx_max_pending = TX_MAX_RING_SIZE;
529 ering->tx_pending = lp->tx_ring_size - 1; 768 ering->tx_pending = lp->tx_ring_size;
530 ering->rx_max_pending = RX_MAX_RING_SIZE - 1; 769 ering->rx_max_pending = RX_MAX_RING_SIZE;
531 ering->rx_pending = lp->rx_ring_size - 1; 770 ering->rx_pending = lp->rx_ring_size;
532} 771}
533 772
534static int pcnet32_set_ringparam(struct net_device *dev, 773static int pcnet32_set_ringparam(struct net_device *dev,
@@ -536,56 +775,53 @@ static int pcnet32_set_ringparam(struct net_device *dev,
536{ 775{
537 struct pcnet32_private *lp = dev->priv; 776 struct pcnet32_private *lp = dev->priv;
538 unsigned long flags; 777 unsigned long flags;
778 unsigned int size;
779 ulong ioaddr = dev->base_addr;
539 int i; 780 int i;
540 781
541 if (ering->rx_mini_pending || ering->rx_jumbo_pending) 782 if (ering->rx_mini_pending || ering->rx_jumbo_pending)
542 return -EINVAL; 783 return -EINVAL;
543 784
544 if (netif_running(dev)) 785 if (netif_running(dev))
545 pcnet32_close(dev); 786 pcnet32_netif_stop(dev);
546 787
547 spin_lock_irqsave(&lp->lock, flags); 788 spin_lock_irqsave(&lp->lock, flags);
548 pcnet32_free_ring(dev); 789 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); /* stop the chip */
549 lp->tx_ring_size = 790
550 min(ering->tx_pending, (unsigned int)TX_MAX_RING_SIZE); 791 size = min(ering->tx_pending, (unsigned int)TX_MAX_RING_SIZE);
551 lp->rx_ring_size =
552 min(ering->rx_pending, (unsigned int)RX_MAX_RING_SIZE);
553 792
554 /* set the minimum ring size to 4, to allow the loopback test to work 793 /* set the minimum ring size to 4, to allow the loopback test to work
555 * unchanged. 794 * unchanged.
556 */ 795 */
557 for (i = 2; i <= PCNET32_LOG_MAX_TX_BUFFERS; i++) { 796 for (i = 2; i <= PCNET32_LOG_MAX_TX_BUFFERS; i++) {
558 if (lp->tx_ring_size <= (1 << i)) 797 if (size <= (1 << i))
559 break; 798 break;
560 } 799 }
561 lp->tx_ring_size = (1 << i); 800 if ((1 << i) != lp->tx_ring_size)
562 lp->tx_mod_mask = lp->tx_ring_size - 1; 801 pcnet32_realloc_tx_ring(dev, lp, i);
563 lp->tx_len_bits = (i << 12); 802
564 803 size = min(ering->rx_pending, (unsigned int)RX_MAX_RING_SIZE);
565 for (i = 2; i <= PCNET32_LOG_MAX_RX_BUFFERS; i++) { 804 for (i = 2; i <= PCNET32_LOG_MAX_RX_BUFFERS; i++) {
566 if (lp->rx_ring_size <= (1 << i)) 805 if (size <= (1 << i))
567 break; 806 break;
568 } 807 }
569 lp->rx_ring_size = (1 << i); 808 if ((1 << i) != lp->rx_ring_size)
570 lp->rx_mod_mask = lp->rx_ring_size - 1; 809 pcnet32_realloc_rx_ring(dev, lp, i);
571 lp->rx_len_bits = (i << 4); 810
811 dev->weight = lp->rx_ring_size / 2;
572 812
573 if (pcnet32_alloc_ring(dev, dev->name)) { 813 if (netif_running(dev)) {
574 pcnet32_free_ring(dev); 814 pcnet32_netif_start(dev);
575 spin_unlock_irqrestore(&lp->lock, flags); 815 pcnet32_restart(dev, CSR0_NORMAL);
576 return -ENOMEM;
577 } 816 }
578 817
579 spin_unlock_irqrestore(&lp->lock, flags); 818 spin_unlock_irqrestore(&lp->lock, flags);
580 819
581 if (pcnet32_debug & NETIF_MSG_DRV) 820 if (netif_msg_drv(lp))
582 printk(KERN_INFO PFX 821 printk(KERN_INFO
583 "%s: Ring Param Settings: RX: %d, TX: %d\n", dev->name, 822 "%s: Ring Param Settings: RX: %d, TX: %d\n", dev->name,
584 lp->rx_ring_size, lp->tx_ring_size); 823 lp->rx_ring_size, lp->tx_ring_size);
585 824
586 if (netif_running(dev))
587 pcnet32_open(dev);
588
589 return 0; 825 return 0;
590} 826}
591 827
@@ -639,29 +875,27 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
639 unsigned long flags; 875 unsigned long flags;
640 unsigned long ticks; 876 unsigned long ticks;
641 877
642 *data1 = 1; /* status of test, default to fail */
643 rc = 1; /* default to fail */ 878 rc = 1; /* default to fail */
644 879
645 if (netif_running(dev)) 880 if (netif_running(dev))
646 pcnet32_close(dev); 881 pcnet32_close(dev);
647 882
648 spin_lock_irqsave(&lp->lock, flags); 883 spin_lock_irqsave(&lp->lock, flags);
884 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); /* stop the chip */
885
886 numbuffs = min(numbuffs, (int)min(lp->rx_ring_size, lp->tx_ring_size));
649 887
650 /* Reset the PCNET32 */ 888 /* Reset the PCNET32 */
651 lp->a.reset(ioaddr); 889 lp->a.reset(ioaddr);
890 lp->a.write_csr(ioaddr, CSR4, 0x0915);
652 891
653 /* switch pcnet32 to 32bit mode */ 892 /* switch pcnet32 to 32bit mode */
654 lp->a.write_bcr(ioaddr, 20, 2); 893 lp->a.write_bcr(ioaddr, 20, 2);
655 894
656 lp->init_block.mode =
657 le16_to_cpu((lp->options & PCNET32_PORT_PORTSEL) << 7);
658 lp->init_block.filter[0] = 0;
659 lp->init_block.filter[1] = 0;
660
661 /* purge & init rings but don't actually restart */ 895 /* purge & init rings but don't actually restart */
662 pcnet32_restart(dev, 0x0000); 896 pcnet32_restart(dev, 0x0000);
663 897
664 lp->a.write_csr(ioaddr, 0, 0x0004); /* Set STOP bit */ 898 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); /* Set STOP bit */
665 899
666 /* Initialize Transmit buffers. */ 900 /* Initialize Transmit buffers. */
667 size = data_len + 15; 901 size = data_len + 15;
@@ -703,14 +937,15 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
703 } 937 }
704 } 938 }
705 939
706 x = a->read_bcr(ioaddr, 32); /* set internal loopback in BSR32 */ 940 x = a->read_bcr(ioaddr, 32); /* set internal loopback in BCR32 */
707 x = x | 0x0002; 941 a->write_bcr(ioaddr, 32, x | 0x0002);
708 a->write_bcr(ioaddr, 32, x);
709 942
710 lp->a.write_csr(ioaddr, 15, 0x0044); /* set int loopback in CSR15 */ 943 /* set int loopback in CSR15 */
944 x = a->read_csr(ioaddr, CSR15) & 0xfffc;
945 lp->a.write_csr(ioaddr, CSR15, x | 0x0044);
711 946
712 teststatus = le16_to_cpu(0x8000); 947 teststatus = le16_to_cpu(0x8000);
713 lp->a.write_csr(ioaddr, 0, 0x0002); /* Set STRT bit */ 948 lp->a.write_csr(ioaddr, CSR0, CSR0_START); /* Set STRT bit */
714 949
715 /* Check status of descriptors */ 950 /* Check status of descriptors */
716 for (x = 0; x < numbuffs; x++) { 951 for (x = 0; x < numbuffs; x++) {
@@ -718,7 +953,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
718 rmb(); 953 rmb();
719 while ((lp->rx_ring[x].status & teststatus) && (ticks < 200)) { 954 while ((lp->rx_ring[x].status & teststatus) && (ticks < 200)) {
720 spin_unlock_irqrestore(&lp->lock, flags); 955 spin_unlock_irqrestore(&lp->lock, flags);
721 mdelay(1); 956 msleep(1);
722 spin_lock_irqsave(&lp->lock, flags); 957 spin_lock_irqsave(&lp->lock, flags);
723 rmb(); 958 rmb();
724 ticks++; 959 ticks++;
@@ -731,7 +966,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
731 } 966 }
732 } 967 }
733 968
734 lp->a.write_csr(ioaddr, 0, 0x0004); /* Set STOP bit */ 969 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); /* Set STOP bit */
735 wmb(); 970 wmb();
736 if (netif_msg_hw(lp) && netif_msg_pktdata(lp)) { 971 if (netif_msg_hw(lp) && netif_msg_pktdata(lp)) {
737 printk(KERN_DEBUG "%s: RX loopback packets:\n", dev->name); 972 printk(KERN_DEBUG "%s: RX loopback packets:\n", dev->name);
@@ -764,25 +999,24 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
764 } 999 }
765 x++; 1000 x++;
766 } 1001 }
767 if (!rc) {
768 *data1 = 0;
769 }
770 1002
771 clean_up: 1003 clean_up:
1004 *data1 = rc;
772 pcnet32_purge_tx_ring(dev); 1005 pcnet32_purge_tx_ring(dev);
773 x = a->read_csr(ioaddr, 15) & 0xFFFF;
774 a->write_csr(ioaddr, 15, (x & ~0x0044)); /* reset bits 6 and 2 */
775 1006
776 x = a->read_bcr(ioaddr, 32); /* reset internal loopback */ 1007 x = a->read_csr(ioaddr, CSR15);
777 x = x & ~0x0002; 1008 a->write_csr(ioaddr, CSR15, (x & ~0x0044)); /* reset bits 6 and 2 */
778 a->write_bcr(ioaddr, 32, x);
779 1009
780 spin_unlock_irqrestore(&lp->lock, flags); 1010 x = a->read_bcr(ioaddr, 32); /* reset internal loopback */
1011 a->write_bcr(ioaddr, 32, (x & ~0x0002));
781 1012
782 if (netif_running(dev)) { 1013 if (netif_running(dev)) {
1014 spin_unlock_irqrestore(&lp->lock, flags);
783 pcnet32_open(dev); 1015 pcnet32_open(dev);
784 } else { 1016 } else {
1017 pcnet32_purge_rx_ring(dev);
785 lp->a.write_bcr(ioaddr, 20, 4); /* return to 16bit mode */ 1018 lp->a.write_bcr(ioaddr, 20, 4); /* return to 16bit mode */
1019 spin_unlock_irqrestore(&lp->lock, flags);
786 } 1020 }
787 1021
788 return (rc); 1022 return (rc);
@@ -845,6 +1079,43 @@ static int pcnet32_phys_id(struct net_device *dev, u32 data)
845 return 0; 1079 return 0;
846} 1080}
847 1081
1082/*
1083 * lp->lock must be held.
1084 */
1085static int pcnet32_suspend(struct net_device *dev, unsigned long *flags,
1086 int can_sleep)
1087{
1088 int csr5;
1089 struct pcnet32_private *lp = dev->priv;
1090 struct pcnet32_access *a = &lp->a;
1091 ulong ioaddr = dev->base_addr;
1092 int ticks;
1093
1094 /* set SUSPEND (SPND) - CSR5 bit 0 */
1095 csr5 = a->read_csr(ioaddr, CSR5);
1096 a->write_csr(ioaddr, CSR5, csr5 | CSR5_SUSPEND);
1097
1098 /* poll waiting for bit to be set */
1099 ticks = 0;
1100 while (!(a->read_csr(ioaddr, CSR5) & CSR5_SUSPEND)) {
1101 spin_unlock_irqrestore(&lp->lock, *flags);
1102 if (can_sleep)
1103 msleep(1);
1104 else
1105 mdelay(1);
1106 spin_lock_irqsave(&lp->lock, *flags);
1107 ticks++;
1108 if (ticks > 200) {
1109 if (netif_msg_hw(lp))
1110 printk(KERN_DEBUG
1111 "%s: Error getting into suspend!\n",
1112 dev->name);
1113 return 0;
1114 }
1115 }
1116 return 1;
1117}
1118
848#define PCNET32_REGS_PER_PHY 32 1119#define PCNET32_REGS_PER_PHY 32
849#define PCNET32_MAX_PHYS 32 1120#define PCNET32_MAX_PHYS 32
850static int pcnet32_get_regs_len(struct net_device *dev) 1121static int pcnet32_get_regs_len(struct net_device *dev)
@@ -863,32 +1134,13 @@ static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs,
863 struct pcnet32_private *lp = dev->priv; 1134 struct pcnet32_private *lp = dev->priv;
864 struct pcnet32_access *a = &lp->a; 1135 struct pcnet32_access *a = &lp->a;
865 ulong ioaddr = dev->base_addr; 1136 ulong ioaddr = dev->base_addr;
866 int ticks;
867 unsigned long flags; 1137 unsigned long flags;
868 1138
869 spin_lock_irqsave(&lp->lock, flags); 1139 spin_lock_irqsave(&lp->lock, flags);
870 1140
871 csr0 = a->read_csr(ioaddr, 0); 1141 csr0 = a->read_csr(ioaddr, CSR0);
872 if (!(csr0 & 0x0004)) { /* If not stopped */ 1142 if (!(csr0 & CSR0_STOP)) /* If not stopped */
873 /* set SUSPEND (SPND) - CSR5 bit 0 */ 1143 pcnet32_suspend(dev, &flags, 1);
874 a->write_csr(ioaddr, 5, 0x0001);
875
876 /* poll waiting for bit to be set */
877 ticks = 0;
878 while (!(a->read_csr(ioaddr, 5) & 0x0001)) {
879 spin_unlock_irqrestore(&lp->lock, flags);
880 mdelay(1);
881 spin_lock_irqsave(&lp->lock, flags);
882 ticks++;
883 if (ticks > 200) {
884 if (netif_msg_hw(lp))
885 printk(KERN_DEBUG
886 "%s: Error getting into suspend!\n",
887 dev->name);
888 break;
889 }
890 }
891 }
892 1144
893 /* read address PROM */ 1145 /* read address PROM */
894 for (i = 0; i < 16; i += 2) 1146 for (i = 0; i < 16; i += 2)
@@ -925,9 +1177,12 @@ static void pcnet32_get_regs(struct net_device *dev, struct ethtool_regs *regs,
925 } 1177 }
926 } 1178 }
927 1179
928 if (!(csr0 & 0x0004)) { /* If not stopped */ 1180 if (!(csr0 & CSR0_STOP)) { /* If not stopped */
1181 int csr5;
1182
929 /* clear SUSPEND (SPND) - CSR5 bit 0 */ 1183 /* clear SUSPEND (SPND) - CSR5 bit 0 */
930 a->write_csr(ioaddr, 5, 0x0000); 1184 csr5 = a->read_csr(ioaddr, CSR5);
1185 a->write_csr(ioaddr, CSR5, csr5 & (~CSR5_SUSPEND));
931 } 1186 }
932 1187
933 spin_unlock_irqrestore(&lp->lock, flags); 1188 spin_unlock_irqrestore(&lp->lock, flags);
@@ -958,7 +1213,7 @@ static struct ethtool_ops pcnet32_ethtool_ops = {
958/* only probes for non-PCI devices, the rest are handled by 1213/* only probes for non-PCI devices, the rest are handled by
959 * pci_register_driver via pcnet32_probe_pci */ 1214 * pci_register_driver via pcnet32_probe_pci */
960 1215
961static void __devinit pcnet32_probe_vlbus(void) 1216static void __devinit pcnet32_probe_vlbus(unsigned int *pcnet32_portlist)
962{ 1217{
963 unsigned int *port, ioaddr; 1218 unsigned int *port, ioaddr;
964 1219
@@ -1442,7 +1697,7 @@ static int pcnet32_alloc_ring(struct net_device *dev, char *name)
1442 lp->tx_ring_size, 1697 lp->tx_ring_size,
1443 &lp->tx_ring_dma_addr); 1698 &lp->tx_ring_dma_addr);
1444 if (lp->tx_ring == NULL) { 1699 if (lp->tx_ring == NULL) {
1445 if (pcnet32_debug & NETIF_MSG_DRV) 1700 if (netif_msg_drv(lp))
1446 printk("\n" KERN_ERR PFX 1701 printk("\n" KERN_ERR PFX
1447 "%s: Consistent memory allocation failed.\n", 1702 "%s: Consistent memory allocation failed.\n",
1448 name); 1703 name);
@@ -1454,52 +1709,48 @@ static int pcnet32_alloc_ring(struct net_device *dev, char *name)
1454 lp->rx_ring_size, 1709 lp->rx_ring_size,
1455 &lp->rx_ring_dma_addr); 1710 &lp->rx_ring_dma_addr);
1456 if (lp->rx_ring == NULL) { 1711 if (lp->rx_ring == NULL) {
1457 if (pcnet32_debug & NETIF_MSG_DRV) 1712 if (netif_msg_drv(lp))
1458 printk("\n" KERN_ERR PFX 1713 printk("\n" KERN_ERR PFX
1459 "%s: Consistent memory allocation failed.\n", 1714 "%s: Consistent memory allocation failed.\n",
1460 name); 1715 name);
1461 return -ENOMEM; 1716 return -ENOMEM;
1462 } 1717 }
1463 1718
1464 lp->tx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->tx_ring_size, 1719 lp->tx_dma_addr = kcalloc(lp->tx_ring_size, sizeof(dma_addr_t),
1465 GFP_ATOMIC); 1720 GFP_ATOMIC);
1466 if (!lp->tx_dma_addr) { 1721 if (!lp->tx_dma_addr) {
1467 if (pcnet32_debug & NETIF_MSG_DRV) 1722 if (netif_msg_drv(lp))
1468 printk("\n" KERN_ERR PFX 1723 printk("\n" KERN_ERR PFX
1469 "%s: Memory allocation failed.\n", name); 1724 "%s: Memory allocation failed.\n", name);
1470 return -ENOMEM; 1725 return -ENOMEM;
1471 } 1726 }
1472 memset(lp->tx_dma_addr, 0, sizeof(dma_addr_t) * lp->tx_ring_size);
1473 1727
1474 lp->rx_dma_addr = kmalloc(sizeof(dma_addr_t) * lp->rx_ring_size, 1728 lp->rx_dma_addr = kcalloc(lp->rx_ring_size, sizeof(dma_addr_t),
1475 GFP_ATOMIC); 1729 GFP_ATOMIC);
1476 if (!lp->rx_dma_addr) { 1730 if (!lp->rx_dma_addr) {
1477 if (pcnet32_debug & NETIF_MSG_DRV) 1731 if (netif_msg_drv(lp))
1478 printk("\n" KERN_ERR PFX 1732 printk("\n" KERN_ERR PFX
1479 "%s: Memory allocation failed.\n", name); 1733 "%s: Memory allocation failed.\n", name);
1480 return -ENOMEM; 1734 return -ENOMEM;
1481 } 1735 }
1482 memset(lp->rx_dma_addr, 0, sizeof(dma_addr_t) * lp->rx_ring_size);
1483 1736
1484 lp->tx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->tx_ring_size, 1737 lp->tx_skbuff = kcalloc(lp->tx_ring_size, sizeof(struct sk_buff *),
1485 GFP_ATOMIC); 1738 GFP_ATOMIC);
1486 if (!lp->tx_skbuff) { 1739 if (!lp->tx_skbuff) {
1487 if (pcnet32_debug & NETIF_MSG_DRV) 1740 if (netif_msg_drv(lp))
1488 printk("\n" KERN_ERR PFX 1741 printk("\n" KERN_ERR PFX
1489 "%s: Memory allocation failed.\n", name); 1742 "%s: Memory allocation failed.\n", name);
1490 return -ENOMEM; 1743 return -ENOMEM;
1491 } 1744 }
1492 memset(lp->tx_skbuff, 0, sizeof(struct sk_buff *) * lp->tx_ring_size);
1493 1745
1494 lp->rx_skbuff = kmalloc(sizeof(struct sk_buff *) * lp->rx_ring_size, 1746 lp->rx_skbuff = kcalloc(lp->rx_ring_size, sizeof(struct sk_buff *),
1495 GFP_ATOMIC); 1747 GFP_ATOMIC);
1496 if (!lp->rx_skbuff) { 1748 if (!lp->rx_skbuff) {
1497 if (pcnet32_debug & NETIF_MSG_DRV) 1749 if (netif_msg_drv(lp))
1498 printk("\n" KERN_ERR PFX 1750 printk("\n" KERN_ERR PFX
1499 "%s: Memory allocation failed.\n", name); 1751 "%s: Memory allocation failed.\n", name);
1500 return -ENOMEM; 1752 return -ENOMEM;
1501 } 1753 }
1502 memset(lp->rx_skbuff, 0, sizeof(struct sk_buff *) * lp->rx_ring_size);
1503 1754
1504 return 0; 1755 return 0;
1505} 1756}
@@ -1547,7 +1798,7 @@ static int pcnet32_open(struct net_device *dev)
1547 unsigned long flags; 1798 unsigned long flags;
1548 1799
1549 if (request_irq(dev->irq, &pcnet32_interrupt, 1800 if (request_irq(dev->irq, &pcnet32_interrupt,
1550 lp->shared_irq ? SA_SHIRQ : 0, dev->name, 1801 lp->shared_irq ? IRQF_SHARED : 0, dev->name,
1551 (void *)dev)) { 1802 (void *)dev)) {
1552 return -EAGAIN; 1803 return -EAGAIN;
1553 } 1804 }
@@ -1763,16 +2014,7 @@ static int pcnet32_open(struct net_device *dev)
1763 2014
1764 err_free_ring: 2015 err_free_ring:
1765 /* free any allocated skbuffs */ 2016 /* free any allocated skbuffs */
1766 for (i = 0; i < lp->rx_ring_size; i++) { 2017 pcnet32_purge_rx_ring(dev);
1767 lp->rx_ring[i].status = 0;
1768 if (lp->rx_skbuff[i]) {
1769 pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[i],
1770 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE);
1771 dev_kfree_skb(lp->rx_skbuff[i]);
1772 }
1773 lp->rx_skbuff[i] = NULL;
1774 lp->rx_dma_addr[i] = 0;
1775 }
1776 2018
1777 /* 2019 /*
1778 * Switch back to 16bit mode to avoid problems with dumb 2020 * Switch back to 16bit mode to avoid problems with dumb
@@ -2354,7 +2596,6 @@ static int pcnet32_close(struct net_device *dev)
2354{ 2596{
2355 unsigned long ioaddr = dev->base_addr; 2597 unsigned long ioaddr = dev->base_addr;
2356 struct pcnet32_private *lp = dev->priv; 2598 struct pcnet32_private *lp = dev->priv;
2357 int i;
2358 unsigned long flags; 2599 unsigned long flags;
2359 2600
2360 del_timer_sync(&lp->watchdog_timer); 2601 del_timer_sync(&lp->watchdog_timer);
@@ -2385,31 +2626,8 @@ static int pcnet32_close(struct net_device *dev)
2385 2626
2386 spin_lock_irqsave(&lp->lock, flags); 2627 spin_lock_irqsave(&lp->lock, flags);
2387 2628
2388 /* free all allocated skbuffs */ 2629 pcnet32_purge_rx_ring(dev);
2389 for (i = 0; i < lp->rx_ring_size; i++) { 2630 pcnet32_purge_tx_ring(dev);
2390 lp->rx_ring[i].status = 0;
2391 wmb(); /* Make sure adapter sees owner change */
2392 if (lp->rx_skbuff[i]) {
2393 pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[i],
2394 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE);
2395 dev_kfree_skb(lp->rx_skbuff[i]);
2396 }
2397 lp->rx_skbuff[i] = NULL;
2398 lp->rx_dma_addr[i] = 0;
2399 }
2400
2401 for (i = 0; i < lp->tx_ring_size; i++) {
2402 lp->tx_ring[i].status = 0; /* CPU owns buffer */
2403 wmb(); /* Make sure adapter sees owner change */
2404 if (lp->tx_skbuff[i]) {
2405 pci_unmap_single(lp->pci_dev, lp->tx_dma_addr[i],
2406 lp->tx_skbuff[i]->len,
2407 PCI_DMA_TODEVICE);
2408 dev_kfree_skb(lp->tx_skbuff[i]);
2409 }
2410 lp->tx_skbuff[i] = NULL;
2411 lp->tx_dma_addr[i] = 0;
2412 }
2413 2631
2414 spin_unlock_irqrestore(&lp->lock, flags); 2632 spin_unlock_irqrestore(&lp->lock, flags);
2415 2633
@@ -2439,6 +2657,7 @@ static void pcnet32_load_multicast(struct net_device *dev)
2439 volatile struct pcnet32_init_block *ib = &lp->init_block; 2657 volatile struct pcnet32_init_block *ib = &lp->init_block;
2440 volatile u16 *mcast_table = (u16 *) & ib->filter; 2658 volatile u16 *mcast_table = (u16 *) & ib->filter;
2441 struct dev_mc_list *dmi = dev->mc_list; 2659 struct dev_mc_list *dmi = dev->mc_list;
2660 unsigned long ioaddr = dev->base_addr;
2442 char *addrs; 2661 char *addrs;
2443 int i; 2662 int i;
2444 u32 crc; 2663 u32 crc;
@@ -2447,6 +2666,10 @@ static void pcnet32_load_multicast(struct net_device *dev)
2447 if (dev->flags & IFF_ALLMULTI) { 2666 if (dev->flags & IFF_ALLMULTI) {
2448 ib->filter[0] = 0xffffffff; 2667 ib->filter[0] = 0xffffffff;
2449 ib->filter[1] = 0xffffffff; 2668 ib->filter[1] = 0xffffffff;
2669 lp->a.write_csr(ioaddr, PCNET32_MC_FILTER, 0xffff);
2670 lp->a.write_csr(ioaddr, PCNET32_MC_FILTER+1, 0xffff);
2671 lp->a.write_csr(ioaddr, PCNET32_MC_FILTER+2, 0xffff);
2672 lp->a.write_csr(ioaddr, PCNET32_MC_FILTER+3, 0xffff);
2450 return; 2673 return;
2451 } 2674 }
2452 /* clear the multicast filter */ 2675 /* clear the multicast filter */
@@ -2468,6 +2691,9 @@ static void pcnet32_load_multicast(struct net_device *dev)
2468 le16_to_cpu(le16_to_cpu(mcast_table[crc >> 4]) | 2691 le16_to_cpu(le16_to_cpu(mcast_table[crc >> 4]) |
2469 (1 << (crc & 0xf))); 2692 (1 << (crc & 0xf)));
2470 } 2693 }
2694 for (i = 0; i < 4; i++)
2695 lp->a.write_csr(ioaddr, PCNET32_MC_FILTER + i,
2696 le16_to_cpu(mcast_table[i]));
2471 return; 2697 return;
2472} 2698}
2473 2699
@@ -2478,8 +2704,11 @@ static void pcnet32_set_multicast_list(struct net_device *dev)
2478{ 2704{
2479 unsigned long ioaddr = dev->base_addr, flags; 2705 unsigned long ioaddr = dev->base_addr, flags;
2480 struct pcnet32_private *lp = dev->priv; 2706 struct pcnet32_private *lp = dev->priv;
2707 int csr15, suspended;
2481 2708
2482 spin_lock_irqsave(&lp->lock, flags); 2709 spin_lock_irqsave(&lp->lock, flags);
2710 suspended = pcnet32_suspend(dev, &flags, 0);
2711 csr15 = lp->a.read_csr(ioaddr, CSR15);
2483 if (dev->flags & IFF_PROMISC) { 2712 if (dev->flags & IFF_PROMISC) {
2484 /* Log any net taps. */ 2713 /* Log any net taps. */
2485 if (netif_msg_hw(lp)) 2714 if (netif_msg_hw(lp))
@@ -2488,15 +2717,24 @@ static void pcnet32_set_multicast_list(struct net_device *dev)
2488 lp->init_block.mode = 2717 lp->init_block.mode =
2489 le16_to_cpu(0x8000 | (lp->options & PCNET32_PORT_PORTSEL) << 2718 le16_to_cpu(0x8000 | (lp->options & PCNET32_PORT_PORTSEL) <<
2490 7); 2719 7);
2720 lp->a.write_csr(ioaddr, CSR15, csr15 | 0x8000);
2491 } else { 2721 } else {
2492 lp->init_block.mode = 2722 lp->init_block.mode =
2493 le16_to_cpu((lp->options & PCNET32_PORT_PORTSEL) << 7); 2723 le16_to_cpu((lp->options & PCNET32_PORT_PORTSEL) << 7);
2724 lp->a.write_csr(ioaddr, CSR15, csr15 & 0x7fff);
2494 pcnet32_load_multicast(dev); 2725 pcnet32_load_multicast(dev);
2495 } 2726 }
2496 2727
2497 lp->a.write_csr(ioaddr, 0, 0x0004); /* Temporarily stop the lance. */ 2728 if (suspended) {
2498 pcnet32_restart(dev, 0x0042); /* Resume normal operation */ 2729 int csr5;
2499 netif_wake_queue(dev); 2730 /* clear SUSPEND (SPND) - CSR5 bit 0 */
2731 csr5 = lp->a.read_csr(ioaddr, CSR5);
2732 lp->a.write_csr(ioaddr, CSR5, csr5 & (~CSR5_SUSPEND));
2733 } else {
2734 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP);
2735 pcnet32_restart(dev, CSR0_NORMAL);
2736 netif_wake_queue(dev);
2737 }
2500 2738
2501 spin_unlock_irqrestore(&lp->lock, flags); 2739 spin_unlock_irqrestore(&lp->lock, flags);
2502} 2740}
@@ -2736,7 +2974,7 @@ static int __init pcnet32_init_module(void)
2736 2974
2737 /* should we find any remaining VLbus devices ? */ 2975 /* should we find any remaining VLbus devices ? */
2738 if (pcnet32vlb) 2976 if (pcnet32vlb)
2739 pcnet32_probe_vlbus(); 2977 pcnet32_probe_vlbus(pcnet32_portlist);
2740 2978
2741 if (cards_found && (pcnet32_debug & NETIF_MSG_PROBE)) 2979 if (cards_found && (pcnet32_debug & NETIF_MSG_PROBE))
2742 printk(KERN_INFO PFX "%d cards_found.\n", cards_found); 2980 printk(KERN_INFO PFX "%d cards_found.\n", cards_found);
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index cda3e53d6917..2ba6d3a40e2e 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -44,6 +44,11 @@ config CICADA_PHY
44 depends on PHYLIB 44 depends on PHYLIB
45 ---help--- 45 ---help---
46 Currently supports the cis8204 46 Currently supports the cis8204
47config VITESSE_PHY
48 tristate "Drivers for the Vitesse PHYs"
49 depends on PHYLIB
50 ---help---
51 Currently supports the vsc8244
47 52
48config SMSC_PHY 53config SMSC_PHY
49 tristate "Drivers for SMSC PHYs" 54 tristate "Drivers for SMSC PHYs"
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index d9614134cc06..a00e61942525 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -9,3 +9,4 @@ obj-$(CONFIG_CICADA_PHY) += cicada.o
9obj-$(CONFIG_LXT_PHY) += lxt.o 9obj-$(CONFIG_LXT_PHY) += lxt.o
10obj-$(CONFIG_QSEMI_PHY) += qsemi.o 10obj-$(CONFIG_QSEMI_PHY) += qsemi.o
11obj-$(CONFIG_SMSC_PHY) += smsc.o 11obj-$(CONFIG_SMSC_PHY) += smsc.o
12obj-$(CONFIG_VITESSE_PHY) += vitesse.o
diff --git a/drivers/net/phy/cicada.c b/drivers/net/phy/cicada.c
index 7d8d534255c0..ae60e6e4107c 100644
--- a/drivers/net/phy/cicada.c
+++ b/drivers/net/phy/cicada.c
@@ -13,7 +13,6 @@
13 * option) any later version. 13 * option) any later version.
14 * 14 *
15 */ 15 */
16#include <linux/config.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/sched.h> 17#include <linux/sched.h>
19#include <linux/string.h> 18#include <linux/string.h>
@@ -104,7 +103,22 @@ static int cis820x_config_intr(struct phy_device *phydev)
104 return err; 103 return err;
105} 104}
106 105
107/* Cicada 820x */ 106/* Cicada 8201, a.k.a Vitesse VSC8201 */
107static struct phy_driver cis8201_driver = {
108 .phy_id = 0x000fc410,
109 .name = "Cicada Cis8201",
110 .phy_id_mask = 0x000ffff0,
111 .features = PHY_GBIT_FEATURES,
112 .flags = PHY_HAS_INTERRUPT,
113 .config_init = &cis820x_config_init,
114 .config_aneg = &genphy_config_aneg,
115 .read_status = &genphy_read_status,
116 .ack_interrupt = &cis820x_ack_interrupt,
117 .config_intr = &cis820x_config_intr,
118 .driver = { .owner = THIS_MODULE,},
119};
120
121/* Cicada 8204 */
108static struct phy_driver cis8204_driver = { 122static struct phy_driver cis8204_driver = {
109 .phy_id = 0x000fc440, 123 .phy_id = 0x000fc440,
110 .name = "Cicada Cis8204", 124 .name = "Cicada Cis8204",
@@ -119,15 +133,30 @@ static struct phy_driver cis8204_driver = {
119 .driver = { .owner = THIS_MODULE,}, 133 .driver = { .owner = THIS_MODULE,},
120}; 134};
121 135
122static int __init cis8204_init(void) 136static int __init cicada_init(void)
123{ 137{
124 return phy_driver_register(&cis8204_driver); 138 int ret;
139
140 ret = phy_driver_register(&cis8204_driver);
141 if (ret)
142 goto err1;
143
144 ret = phy_driver_register(&cis8201_driver);
145 if (ret)
146 goto err2;
147 return 0;
148
149err2:
150 phy_driver_unregister(&cis8204_driver);
151err1:
152 return ret;
125} 153}
126 154
127static void __exit cis8204_exit(void) 155static void __exit cicada_exit(void)
128{ 156{
129 phy_driver_unregister(&cis8204_driver); 157 phy_driver_unregister(&cis8204_driver);
158 phy_driver_unregister(&cis8201_driver);
130} 159}
131 160
132module_init(cis8204_init); 161module_init(cicada_init);
133module_exit(cis8204_exit); 162module_exit(cicada_exit);
diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c
index 5e9002e444c5..aa7983f55838 100644
--- a/drivers/net/phy/davicom.c
+++ b/drivers/net/phy/davicom.c
@@ -13,7 +13,6 @@
13 * option) any later version. 13 * option) any later version.
14 * 14 *
15 */ 15 */
16#include <linux/config.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/sched.h> 17#include <linux/sched.h>
19#include <linux/string.h> 18#include <linux/string.h>
diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c
index bef79e454c33..69d2325f848c 100644
--- a/drivers/net/phy/lxt.c
+++ b/drivers/net/phy/lxt.c
@@ -13,7 +13,6 @@
13 * option) any later version. 13 * option) any later version.
14 * 14 *
15 */ 15 */
16#include <linux/config.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/sched.h> 17#include <linux/sched.h>
19#include <linux/string.h> 18#include <linux/string.h>
@@ -123,9 +122,9 @@ static int lxt971_config_intr(struct phy_device *phydev)
123} 122}
124 123
125static struct phy_driver lxt970_driver = { 124static struct phy_driver lxt970_driver = {
126 .phy_id = 0x07810000, 125 .phy_id = 0x78100000,
127 .name = "LXT970", 126 .name = "LXT970",
128 .phy_id_mask = 0x0fffffff, 127 .phy_id_mask = 0xfffffff0,
129 .features = PHY_BASIC_FEATURES, 128 .features = PHY_BASIC_FEATURES,
130 .flags = PHY_HAS_INTERRUPT, 129 .flags = PHY_HAS_INTERRUPT,
131 .config_init = lxt970_config_init, 130 .config_init = lxt970_config_init,
@@ -137,9 +136,9 @@ static struct phy_driver lxt970_driver = {
137}; 136};
138 137
139static struct phy_driver lxt971_driver = { 138static struct phy_driver lxt971_driver = {
140 .phy_id = 0x0001378e, 139 .phy_id = 0x001378e0,
141 .name = "LXT971", 140 .name = "LXT971",
142 .phy_id_mask = 0x0fffffff, 141 .phy_id_mask = 0xfffffff0,
143 .features = PHY_BASIC_FEATURES, 142 .features = PHY_BASIC_FEATURES,
144 .flags = PHY_HAS_INTERRUPT, 143 .flags = PHY_HAS_INTERRUPT,
145 .config_aneg = genphy_config_aneg, 144 .config_aneg = genphy_config_aneg,
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
index a2d6386d13bc..0ad253282d0d 100644
--- a/drivers/net/phy/marvell.c
+++ b/drivers/net/phy/marvell.c
@@ -13,7 +13,6 @@
13 * option) any later version. 13 * option) any later version.
14 * 14 *
15 */ 15 */
16#include <linux/config.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/sched.h> 17#include <linux/sched.h>
19#include <linux/string.h> 18#include <linux/string.h>
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 1b236bdf6b92..1dde390c164d 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -13,7 +13,6 @@
13 * option) any later version. 13 * option) any later version.
14 * 14 *
15 */ 15 */
16#include <linux/config.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/sched.h> 17#include <linux/sched.h>
19#include <linux/string.h> 18#include <linux/string.h>
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 33cec2dab942..7d5c2233c252 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -14,7 +14,6 @@
14 * option) any later version. 14 * option) any later version.
15 * 15 *
16 */ 16 */
17#include <linux/config.h>
18#include <linux/kernel.h> 17#include <linux/kernel.h>
19#include <linux/sched.h> 18#include <linux/sched.h>
20#include <linux/string.h> 19#include <linux/string.h>
@@ -557,7 +556,7 @@ int phy_start_interrupts(struct phy_device *phydev)
557 INIT_WORK(&phydev->phy_queue, phy_change, phydev); 556 INIT_WORK(&phydev->phy_queue, phy_change, phydev);
558 557
559 if (request_irq(phydev->irq, phy_interrupt, 558 if (request_irq(phydev->irq, phy_interrupt,
560 SA_SHIRQ, 559 IRQF_SHARED,
561 "phy_interrupt", 560 "phy_interrupt",
562 phydev) < 0) { 561 phydev) < 0) {
563 printk(KERN_WARNING "%s: Can't get IRQ %d (PHY)\n", 562 printk(KERN_WARNING "%s: Can't get IRQ %d (PHY)\n",
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 7da0e3dd5fe3..1bc1e032c5d6 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -14,7 +14,6 @@
14 * option) any later version. 14 * option) any later version.
15 * 15 *
16 */ 16 */
17#include <linux/config.h>
18#include <linux/kernel.h> 17#include <linux/kernel.h>
19#include <linux/sched.h> 18#include <linux/sched.h>
20#include <linux/string.h> 19#include <linux/string.h>
diff --git a/drivers/net/phy/qsemi.c b/drivers/net/phy/qsemi.c
index 65d995b02b25..2b50e1739aa5 100644
--- a/drivers/net/phy/qsemi.c
+++ b/drivers/net/phy/qsemi.c
@@ -13,7 +13,6 @@
13 * option) any later version. 13 * option) any later version.
14 * 14 *
15 */ 15 */
16#include <linux/config.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/sched.h> 17#include <linux/sched.h>
19#include <linux/string.h> 18#include <linux/string.h>
diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
new file mode 100644
index 000000000000..ffd215d9a9be
--- /dev/null
+++ b/drivers/net/phy/vitesse.c
@@ -0,0 +1,112 @@
1/*
2 * Driver for Vitesse PHYs
3 *
4 * Author: Kriston Carson
5 *
6 * Copyright (c) 2005 Freescale Semiconductor, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#include <linux/config.h>
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/mii.h>
19#include <linux/ethtool.h>
20#include <linux/phy.h>
21
22/* Vitesse Extended Control Register 1 */
23#define MII_VSC8244_EXT_CON1 0x17
24#define MII_VSC8244_EXTCON1_INIT 0x0000
25
26/* Vitesse Interrupt Mask Register */
27#define MII_VSC8244_IMASK 0x19
28#define MII_VSC8244_IMASK_IEN 0x8000
29#define MII_VSC8244_IMASK_SPEED 0x4000
30#define MII_VSC8244_IMASK_LINK 0x2000
31#define MII_VSC8244_IMASK_DUPLEX 0x1000
32#define MII_VSC8244_IMASK_MASK 0xf000
33
34/* Vitesse Interrupt Status Register */
35#define MII_VSC8244_ISTAT 0x1a
36#define MII_VSC8244_ISTAT_STATUS 0x8000
37#define MII_VSC8244_ISTAT_SPEED 0x4000
38#define MII_VSC8244_ISTAT_LINK 0x2000
39#define MII_VSC8244_ISTAT_DUPLEX 0x1000
40
41/* Vitesse Auxiliary Control/Status Register */
42#define MII_VSC8244_AUX_CONSTAT 0x1c
43#define MII_VSC8244_AUXCONSTAT_INIT 0x0004
44#define MII_VSC8244_AUXCONSTAT_DUPLEX 0x0020
45#define MII_VSC8244_AUXCONSTAT_SPEED 0x0018
46#define MII_VSC8244_AUXCONSTAT_GBIT 0x0010
47#define MII_VSC8244_AUXCONSTAT_100 0x0008
48
49MODULE_DESCRIPTION("Vitesse PHY driver");
50MODULE_AUTHOR("Kriston Carson");
51MODULE_LICENSE("GPL");
52
53static int vsc824x_config_init(struct phy_device *phydev)
54{
55 int err;
56
57 err = phy_write(phydev, MII_VSC8244_AUX_CONSTAT,
58 MII_VSC8244_AUXCONSTAT_INIT);
59 if (err < 0)
60 return err;
61
62 err = phy_write(phydev, MII_VSC8244_EXT_CON1,
63 MII_VSC8244_EXTCON1_INIT);
64 return err;
65}
66
67static int vsc824x_ack_interrupt(struct phy_device *phydev)
68{
69 int err = phy_read(phydev, MII_VSC8244_ISTAT);
70
71 return (err < 0) ? err : 0;
72}
73
74static int vsc824x_config_intr(struct phy_device *phydev)
75{
76 int err;
77
78 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
79 err = phy_write(phydev, MII_VSC8244_IMASK,
80 MII_VSC8244_IMASK_MASK);
81 else
82 err = phy_write(phydev, MII_VSC8244_IMASK, 0);
83 return err;
84}
85
86/* Vitesse 824x */
87static struct phy_driver vsc8244_driver = {
88 .phy_id = 0x000fc6c2,
89 .name = "Vitesse VSC8244",
90 .phy_id_mask = 0x000fffc0,
91 .features = PHY_GBIT_FEATURES,
92 .flags = PHY_HAS_INTERRUPT,
93 .config_init = &vsc824x_config_init,
94 .config_aneg = &genphy_config_aneg,
95 .read_status = &genphy_read_status,
96 .ack_interrupt = &vsc824x_ack_interrupt,
97 .config_intr = &vsc824x_config_intr,
98 .driver = { .owner = THIS_MODULE,},
99};
100
101static int __init vsc8244_init(void)
102{
103 return phy_driver_register(&vsc8244_driver);
104}
105
106static void __exit vsc8244_exit(void)
107{
108 phy_driver_unregister(&vsc8244_driver);
109}
110
111module_init(vsc8244_init);
112module_exit(vsc8244_exit);
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 01cd8ec751ea..0ec6e9d57b94 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -22,13 +22,11 @@
22 * ==FILEVERSION 20041108== 22 * ==FILEVERSION 20041108==
23 */ 23 */
24 24
25#include <linux/config.h>
26#include <linux/module.h> 25#include <linux/module.h>
27#include <linux/kernel.h> 26#include <linux/kernel.h>
28#include <linux/kmod.h> 27#include <linux/kmod.h>
29#include <linux/init.h> 28#include <linux/init.h>
30#include <linux/list.h> 29#include <linux/list.h>
31#include <linux/devfs_fs_kernel.h>
32#include <linux/netdevice.h> 30#include <linux/netdevice.h>
33#include <linux/poll.h> 31#include <linux/poll.h>
34#include <linux/ppp_defs.h> 32#include <linux/ppp_defs.h>
@@ -863,10 +861,6 @@ static int __init ppp_init(void)
863 goto out_chrdev; 861 goto out_chrdev;
864 } 862 }
865 class_device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp"); 863 class_device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
866 err = devfs_mk_cdev(MKDEV(PPP_MAJOR, 0),
867 S_IFCHR|S_IRUSR|S_IWUSR, "ppp");
868 if (err)
869 goto out_class;
870 } 864 }
871 865
872out: 866out:
@@ -874,9 +868,6 @@ out:
874 printk(KERN_ERR "failed to register PPP device (%d)\n", err); 868 printk(KERN_ERR "failed to register PPP device (%d)\n", err);
875 return err; 869 return err;
876 870
877out_class:
878 class_device_destroy(ppp_class, MKDEV(PPP_MAJOR,0));
879 class_destroy(ppp_class);
880out_chrdev: 871out_chrdev:
881 unregister_chrdev(PPP_MAJOR, "ppp"); 872 unregister_chrdev(PPP_MAJOR, "ppp");
882 goto out; 873 goto out;
@@ -2578,8 +2569,7 @@ ppp_find_channel(int unit)
2578 2569
2579 list_for_each_entry(pch, &new_channels, list) { 2570 list_for_each_entry(pch, &new_channels, list) {
2580 if (pch->file.index == unit) { 2571 if (pch->file.index == unit) {
2581 list_del(&pch->list); 2572 list_move(&pch->list, &all_channels);
2582 list_add(&pch->list, &all_channels);
2583 return pch; 2573 return pch;
2584 } 2574 }
2585 } 2575 }
@@ -2682,7 +2672,6 @@ static void __exit ppp_cleanup(void)
2682 cardmap_destroy(&all_ppp_units); 2672 cardmap_destroy(&all_ppp_units);
2683 if (unregister_chrdev(PPP_MAJOR, "ppp") != 0) 2673 if (unregister_chrdev(PPP_MAJOR, "ppp") != 0)
2684 printk(KERN_ERR "PPP: failed to unregister PPP device\n"); 2674 printk(KERN_ERR "PPP: failed to unregister PPP device\n");
2685 devfs_remove("ppp");
2686 class_device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0)); 2675 class_device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0));
2687 class_destroy(ppp_class); 2676 class_destroy(ppp_class);
2688} 2677}
diff --git a/drivers/net/ppp_mppe.c b/drivers/net/ppp_mppe.c
index 1985d1b57c45..51ff9a9d1bb5 100644
--- a/drivers/net/ppp_mppe.c
+++ b/drivers/net/ppp_mppe.c
@@ -43,7 +43,6 @@
43 * deprecated in 2.6 43 * deprecated in 2.6
44 */ 44 */
45 45
46#include <linux/config.h>
47#include <linux/module.h> 46#include <linux/module.h>
48#include <linux/kernel.h> 47#include <linux/kernel.h>
49#include <linux/version.h> 48#include <linux/version.h>
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 9945cc6b8d90..4c2f575faad7 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1406,7 +1406,7 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
1406 dev = alloc_etherdev(sizeof (*tp)); 1406 dev = alloc_etherdev(sizeof (*tp));
1407 if (dev == NULL) { 1407 if (dev == NULL) {
1408 if (netif_msg_drv(&debug)) 1408 if (netif_msg_drv(&debug))
1409 printk(KERN_ERR PFX "unable to alloc new ethernet\n"); 1409 dev_err(&pdev->dev, "unable to alloc new ethernet\n");
1410 goto err_out; 1410 goto err_out;
1411 } 1411 }
1412 1412
@@ -1418,10 +1418,8 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
1418 /* enable device (incl. PCI PM wakeup and hotplug setup) */ 1418 /* enable device (incl. PCI PM wakeup and hotplug setup) */
1419 rc = pci_enable_device(pdev); 1419 rc = pci_enable_device(pdev);
1420 if (rc < 0) { 1420 if (rc < 0) {
1421 if (netif_msg_probe(tp)) { 1421 if (netif_msg_probe(tp))
1422 printk(KERN_ERR PFX "%s: enable failure\n", 1422 dev_err(&pdev->dev, "enable failure\n");
1423 pci_name(pdev));
1424 }
1425 goto err_out_free_dev; 1423 goto err_out_free_dev;
1426 } 1424 }
1427 1425
@@ -1437,37 +1435,32 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
1437 pci_read_config_word(pdev, pm_cap + PCI_PM_CTRL, &pwr_command); 1435 pci_read_config_word(pdev, pm_cap + PCI_PM_CTRL, &pwr_command);
1438 acpi_idle_state = pwr_command & PCI_PM_CTRL_STATE_MASK; 1436 acpi_idle_state = pwr_command & PCI_PM_CTRL_STATE_MASK;
1439 } else { 1437 } else {
1440 if (netif_msg_probe(tp)) { 1438 if (netif_msg_probe(tp))
1441 printk(KERN_ERR PFX 1439 dev_err(&pdev->dev,
1442 "PowerManagement capability not found.\n"); 1440 "PowerManagement capability not found.\n");
1443 }
1444 } 1441 }
1445 1442
1446 /* make sure PCI base addr 1 is MMIO */ 1443 /* make sure PCI base addr 1 is MMIO */
1447 if (!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { 1444 if (!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
1448 if (netif_msg_probe(tp)) { 1445 if (netif_msg_probe(tp))
1449 printk(KERN_ERR PFX 1446 dev_err(&pdev->dev,
1450 "region #1 not an MMIO resource, aborting\n"); 1447 "region #1 not an MMIO resource, aborting\n");
1451 }
1452 rc = -ENODEV; 1448 rc = -ENODEV;
1453 goto err_out_mwi; 1449 goto err_out_mwi;
1454 } 1450 }
1455 /* check for weird/broken PCI region reporting */ 1451 /* check for weird/broken PCI region reporting */
1456 if (pci_resource_len(pdev, 1) < R8169_REGS_SIZE) { 1452 if (pci_resource_len(pdev, 1) < R8169_REGS_SIZE) {
1457 if (netif_msg_probe(tp)) { 1453 if (netif_msg_probe(tp))
1458 printk(KERN_ERR PFX 1454 dev_err(&pdev->dev,
1459 "Invalid PCI region size(s), aborting\n"); 1455 "Invalid PCI region size(s), aborting\n");
1460 }
1461 rc = -ENODEV; 1456 rc = -ENODEV;
1462 goto err_out_mwi; 1457 goto err_out_mwi;
1463 } 1458 }
1464 1459
1465 rc = pci_request_regions(pdev, MODULENAME); 1460 rc = pci_request_regions(pdev, MODULENAME);
1466 if (rc < 0) { 1461 if (rc < 0) {
1467 if (netif_msg_probe(tp)) { 1462 if (netif_msg_probe(tp))
1468 printk(KERN_ERR PFX "%s: could not request regions.\n", 1463 dev_err(&pdev->dev, "could not request regions.\n");
1469 pci_name(pdev));
1470 }
1471 goto err_out_mwi; 1464 goto err_out_mwi;
1472 } 1465 }
1473 1466
@@ -1480,10 +1473,9 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
1480 } else { 1473 } else {
1481 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 1474 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
1482 if (rc < 0) { 1475 if (rc < 0) {
1483 if (netif_msg_probe(tp)) { 1476 if (netif_msg_probe(tp))
1484 printk(KERN_ERR PFX 1477 dev_err(&pdev->dev,
1485 "DMA configuration failed.\n"); 1478 "DMA configuration failed.\n");
1486 }
1487 goto err_out_free_res; 1479 goto err_out_free_res;
1488 } 1480 }
1489 } 1481 }
@@ -1494,7 +1486,7 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
1494 ioaddr = ioremap(pci_resource_start(pdev, 1), R8169_REGS_SIZE); 1486 ioaddr = ioremap(pci_resource_start(pdev, 1), R8169_REGS_SIZE);
1495 if (ioaddr == NULL) { 1487 if (ioaddr == NULL) {
1496 if (netif_msg_probe(tp)) 1488 if (netif_msg_probe(tp))
1497 printk(KERN_ERR PFX "cannot remap MMIO, aborting\n"); 1489 dev_err(&pdev->dev, "cannot remap MMIO, aborting\n");
1498 rc = -EIO; 1490 rc = -EIO;
1499 goto err_out_free_res; 1491 goto err_out_free_res;
1500 } 1492 }
@@ -1526,9 +1518,9 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
1526 if (i < 0) { 1518 if (i < 0) {
1527 /* Unknown chip: assume array element #0, original RTL-8169 */ 1519 /* Unknown chip: assume array element #0, original RTL-8169 */
1528 if (netif_msg_probe(tp)) { 1520 if (netif_msg_probe(tp)) {
1529 printk(KERN_DEBUG PFX "PCI device %s: " 1521 dev_printk(KERN_DEBUG, &pdev->dev,
1530 "unknown chip version, assuming %s\n", 1522 "unknown chip version, assuming %s\n",
1531 pci_name(pdev), rtl_chip_info[0].name); 1523 rtl_chip_info[0].name);
1532 } 1524 }
1533 i++; 1525 i++;
1534 } 1526 }
@@ -1726,7 +1718,7 @@ static int rtl8169_open(struct net_device *dev)
1726 rtl8169_set_rxbufsize(tp, dev); 1718 rtl8169_set_rxbufsize(tp, dev);
1727 1719
1728 retval = 1720 retval =
1729 request_irq(dev->irq, rtl8169_interrupt, SA_SHIRQ, dev->name, dev); 1721 request_irq(dev->irq, rtl8169_interrupt, IRQF_SHARED, dev->name, dev);
1730 if (retval < 0) 1722 if (retval < 0)
1731 goto out; 1723 goto out;
1732 1724
@@ -2172,7 +2164,7 @@ static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb,
2172static inline u32 rtl8169_tso_csum(struct sk_buff *skb, struct net_device *dev) 2164static inline u32 rtl8169_tso_csum(struct sk_buff *skb, struct net_device *dev)
2173{ 2165{
2174 if (dev->features & NETIF_F_TSO) { 2166 if (dev->features & NETIF_F_TSO) {
2175 u32 mss = skb_shinfo(skb)->tso_size; 2167 u32 mss = skb_shinfo(skb)->gso_size;
2176 2168
2177 if (mss) 2169 if (mss)
2178 return LargeSend | ((mss & MSSMask) << MSSShift); 2170 return LargeSend | ((mss & MSSMask) << MSSShift);
@@ -2222,8 +2214,7 @@ static int rtl8169_start_xmit(struct sk_buff *skb, struct net_device *dev)
2222 len = skb->len; 2214 len = skb->len;
2223 2215
2224 if (unlikely(len < ETH_ZLEN)) { 2216 if (unlikely(len < ETH_ZLEN)) {
2225 skb = skb_padto(skb, ETH_ZLEN); 2217 if (skb_padto(skb, ETH_ZLEN))
2226 if (!skb)
2227 goto err_update_stats; 2218 goto err_update_stats;
2228 len = ETH_ZLEN; 2219 len = ETH_ZLEN;
2229 } 2220 }
diff --git a/drivers/net/rrunner.c b/drivers/net/rrunner.c
index 19c2df9c86fe..c3ed734cbe39 100644
--- a/drivers/net/rrunner.c
+++ b/drivers/net/rrunner.c
@@ -28,7 +28,6 @@
28#define RX_DMA_SKBUFF 1 28#define RX_DMA_SKBUFF 1
29#define PKT_COPY_THRESHOLD 512 29#define PKT_COPY_THRESHOLD 512
30 30
31#include <linux/config.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/errno.h> 33#include <linux/errno.h>
@@ -1253,7 +1252,7 @@ static int rr_open(struct net_device *dev)
1253 readl(&regs->HostCtrl); 1252 readl(&regs->HostCtrl);
1254 spin_unlock_irqrestore(&rrpriv->lock, flags); 1253 spin_unlock_irqrestore(&rrpriv->lock, flags);
1255 1254
1256 if (request_irq(dev->irq, rr_interrupt, SA_SHIRQ, dev->name, dev)) { 1255 if (request_irq(dev->irq, rr_interrupt, IRQF_SHARED, dev->name, dev)) {
1257 printk(KERN_WARNING "%s: Requested IRQ %d is busy\n", 1256 printk(KERN_WARNING "%s: Requested IRQ %d is busy\n",
1258 dev->name, dev->irq); 1257 dev->name, dev->irq);
1259 ecode = -EAGAIN; 1258 ecode = -EAGAIN;
diff --git a/drivers/net/rrunner.h b/drivers/net/rrunner.h
index 10baae55953a..2c3c91ebd99f 100644
--- a/drivers/net/rrunner.h
+++ b/drivers/net/rrunner.h
@@ -1,7 +1,6 @@
1#ifndef _RRUNNER_H_ 1#ifndef _RRUNNER_H_
2#define _RRUNNER_H_ 2#define _RRUNNER_H_
3 3
4#include <linux/config.h>
5#include <linux/interrupt.h> 4#include <linux/interrupt.h>
6 5
7#if ((BITS_PER_LONG != 32) && (BITS_PER_LONG != 64)) 6#if ((BITS_PER_LONG != 32) && (BITS_PER_LONG != 64))
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 11daed495b97..c6b77acb35ef 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -44,7 +44,6 @@
44 * aggregated as a single large packet 44 * aggregated as a single large packet
45 ************************************************************************/ 45 ************************************************************************/
46 46
47#include <linux/config.h>
48#include <linux/module.h> 47#include <linux/module.h>
49#include <linux/types.h> 48#include <linux/types.h>
50#include <linux/errno.h> 49#include <linux/errno.h>
@@ -3762,7 +3761,7 @@ static int s2io_open(struct net_device *dev)
3762 /* After proper initialization of H/W, register ISR */ 3761 /* After proper initialization of H/W, register ISR */
3763 if (sp->intr_type == MSI) { 3762 if (sp->intr_type == MSI) {
3764 err = request_irq((int) sp->pdev->irq, s2io_msi_handle, 3763 err = request_irq((int) sp->pdev->irq, s2io_msi_handle,
3765 SA_SHIRQ, sp->name, dev); 3764 IRQF_SHARED, sp->name, dev);
3766 if (err) { 3765 if (err) {
3767 DBG_PRINT(ERR_DBG, "%s: MSI registration \ 3766 DBG_PRINT(ERR_DBG, "%s: MSI registration \
3768failed\n", dev->name); 3767failed\n", dev->name);
@@ -3800,7 +3799,7 @@ failed\n", dev->name, i);
3800 } 3799 }
3801 } 3800 }
3802 if (sp->intr_type == INTA) { 3801 if (sp->intr_type == INTA) {
3803 err = request_irq((int) sp->pdev->irq, s2io_isr, SA_SHIRQ, 3802 err = request_irq((int) sp->pdev->irq, s2io_isr, IRQF_SHARED,
3804 sp->name, dev); 3803 sp->name, dev);
3805 if (err) { 3804 if (err) {
3806 DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n", 3805 DBG_PRINT(ERR_DBG, "%s: ISR registration failed\n",
@@ -3959,8 +3958,8 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3959 txdp->Control_1 = 0; 3958 txdp->Control_1 = 0;
3960 txdp->Control_2 = 0; 3959 txdp->Control_2 = 0;
3961#ifdef NETIF_F_TSO 3960#ifdef NETIF_F_TSO
3962 mss = skb_shinfo(skb)->tso_size; 3961 mss = skb_shinfo(skb)->gso_size;
3963 if (mss) { 3962 if (skb_shinfo(skb)->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)) {
3964 txdp->Control_1 |= TXD_TCP_LSO_EN; 3963 txdp->Control_1 |= TXD_TCP_LSO_EN;
3965 txdp->Control_1 |= TXD_TCP_LSO_MSS(mss); 3964 txdp->Control_1 |= TXD_TCP_LSO_MSS(mss);
3966 } 3965 }
@@ -3980,10 +3979,10 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3980 } 3979 }
3981 3980
3982 frg_len = skb->len - skb->data_len; 3981 frg_len = skb->len - skb->data_len;
3983 if (skb_shinfo(skb)->ufo_size) { 3982 if (skb_shinfo(skb)->gso_type == SKB_GSO_UDP) {
3984 int ufo_size; 3983 int ufo_size;
3985 3984
3986 ufo_size = skb_shinfo(skb)->ufo_size; 3985 ufo_size = skb_shinfo(skb)->gso_size;
3987 ufo_size &= ~7; 3986 ufo_size &= ~7;
3988 txdp->Control_1 |= TXD_UFO_EN; 3987 txdp->Control_1 |= TXD_UFO_EN;
3989 txdp->Control_1 |= TXD_UFO_MSS(ufo_size); 3988 txdp->Control_1 |= TXD_UFO_MSS(ufo_size);
@@ -4009,7 +4008,7 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4009 txdp->Host_Control = (unsigned long) skb; 4008 txdp->Host_Control = (unsigned long) skb;
4010 txdp->Control_1 |= TXD_BUFFER0_SIZE(frg_len); 4009 txdp->Control_1 |= TXD_BUFFER0_SIZE(frg_len);
4011 4010
4012 if (skb_shinfo(skb)->ufo_size) 4011 if (skb_shinfo(skb)->gso_type == SKB_GSO_UDP)
4013 txdp->Control_1 |= TXD_UFO_EN; 4012 txdp->Control_1 |= TXD_UFO_EN;
4014 4013
4015 frg_cnt = skb_shinfo(skb)->nr_frags; 4014 frg_cnt = skb_shinfo(skb)->nr_frags;
@@ -4024,12 +4023,12 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4024 (sp->pdev, frag->page, frag->page_offset, 4023 (sp->pdev, frag->page, frag->page_offset,
4025 frag->size, PCI_DMA_TODEVICE); 4024 frag->size, PCI_DMA_TODEVICE);
4026 txdp->Control_1 = TXD_BUFFER0_SIZE(frag->size); 4025 txdp->Control_1 = TXD_BUFFER0_SIZE(frag->size);
4027 if (skb_shinfo(skb)->ufo_size) 4026 if (skb_shinfo(skb)->gso_type == SKB_GSO_UDP)
4028 txdp->Control_1 |= TXD_UFO_EN; 4027 txdp->Control_1 |= TXD_UFO_EN;
4029 } 4028 }
4030 txdp->Control_1 |= TXD_GATHER_CODE_LAST; 4029 txdp->Control_1 |= TXD_GATHER_CODE_LAST;
4031 4030
4032 if (skb_shinfo(skb)->ufo_size) 4031 if (skb_shinfo(skb)->gso_type == SKB_GSO_UDP)
4033 frg_cnt++; /* as Txd0 was used for inband header */ 4032 frg_cnt++; /* as Txd0 was used for inband header */
4034 4033
4035 tx_fifo = mac_control->tx_FIFO_start[queue]; 4034 tx_fifo = mac_control->tx_FIFO_start[queue];
@@ -4043,7 +4042,7 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
4043 if (mss) 4042 if (mss)
4044 val64 |= TX_FIFO_SPECIAL_FUNC; 4043 val64 |= TX_FIFO_SPECIAL_FUNC;
4045#endif 4044#endif
4046 if (skb_shinfo(skb)->ufo_size) 4045 if (skb_shinfo(skb)->gso_type == SKB_GSO_UDP)
4047 val64 |= TX_FIFO_SPECIAL_FUNC; 4046 val64 |= TX_FIFO_SPECIAL_FUNC;
4048 writeq(val64, &tx_fifo->List_Control); 4047 writeq(val64, &tx_fifo->List_Control);
4049 4048
@@ -7021,6 +7020,9 @@ s2io_init_nic(struct pci_dev *pdev, const struct pci_device_id *pre)
7021#ifdef NETIF_F_TSO 7020#ifdef NETIF_F_TSO
7022 dev->features |= NETIF_F_TSO; 7021 dev->features |= NETIF_F_TSO;
7023#endif 7022#endif
7023#ifdef NETIF_F_TSO6
7024 dev->features |= NETIF_F_TSO6;
7025#endif
7024 if (sp->device_type & XFRAME_II_DEVICE) { 7026 if (sp->device_type & XFRAME_II_DEVICE) {
7025 dev->features |= NETIF_F_UFO; 7027 dev->features |= NETIF_F_UFO;
7026 dev->features |= NETIF_F_HW_CSUM; 7028 dev->features |= NETIF_F_HW_CSUM;
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 3203732a668d..c43f52179708 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -652,7 +652,7 @@ typedef struct fifo_info {
652 nic_t *nic; 652 nic_t *nic;
653}fifo_info_t; 653}fifo_info_t;
654 654
655/* Infomation related to the Tx and Rx FIFOs and Rings of Xena 655/* Information related to the Tx and Rx FIFOs and Rings of Xena
656 * is maintained in this structure. 656 * is maintained in this structure.
657 */ 657 */
658typedef struct mac_info { 658typedef struct mac_info {
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c
index f2be9f83f091..9ab1618e82a4 100644
--- a/drivers/net/sb1250-mac.c
+++ b/drivers/net/sb1250-mac.c
@@ -31,7 +31,6 @@
31#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
32#include <linux/skbuff.h> 32#include <linux/skbuff.h>
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/config.h>
35#include <linux/bitops.h> 34#include <linux/bitops.h>
36#include <asm/processor.h> /* Processor type for cache alignment. */ 35#include <asm/processor.h> /* Processor type for cache alignment. */
37#include <asm/io.h> 36#include <asm/io.h>
@@ -2451,7 +2450,7 @@ static int sbmac_open(struct net_device *dev)
2451 */ 2450 */
2452 2451
2453 __raw_readq(sc->sbm_isr); 2452 __raw_readq(sc->sbm_isr);
2454 if (request_irq(dev->irq, &sbmac_intr, SA_SHIRQ, dev->name, dev)) 2453 if (request_irq(dev->irq, &sbmac_intr, IRQF_SHARED, dev->name, dev))
2455 return -EBUSY; 2454 return -EBUSY;
2456 2455
2457 /* 2456 /*
diff --git a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c
index bcef03feb2fc..efd0f235020f 100644
--- a/drivers/net/seeq8005.c
+++ b/drivers/net/seeq8005.c
@@ -396,8 +396,7 @@ static int seeq8005_send_packet(struct sk_buff *skb, struct net_device *dev)
396 unsigned char *buf; 396 unsigned char *buf;
397 397
398 if (length < ETH_ZLEN) { 398 if (length < ETH_ZLEN) {
399 skb = skb_padto(skb, ETH_ZLEN); 399 if (skb_padto(skb, ETH_ZLEN))
400 if (skb == NULL)
401 return 0; 400 return 0;
402 length = ETH_ZLEN; 401 length = ETH_ZLEN;
403 } 402 }
diff --git a/drivers/net/shaper.c b/drivers/net/shaper.c
index 88e212043a43..c7832e69f177 100644
--- a/drivers/net/shaper.c
+++ b/drivers/net/shaper.c
@@ -69,7 +69,6 @@
69 * 2000/03 Andi Kleen 69 * 2000/03 Andi Kleen
70 */ 70 */
71 71
72#include <linux/config.h>
73#include <linux/module.h> 72#include <linux/module.h>
74#include <linux/kernel.h> 73#include <linux/kernel.h>
75#include <linux/fcntl.h> 74#include <linux/fcntl.h>
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index 31dd3f036fa8..df0cbebb3277 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -1054,7 +1054,7 @@ static int sis190_open(struct net_device *dev)
1054 1054
1055 sis190_request_timer(dev); 1055 sis190_request_timer(dev);
1056 1056
1057 rc = request_irq(dev->irq, sis190_interrupt, SA_SHIRQ, dev->name, dev); 1057 rc = request_irq(dev->irq, sis190_interrupt, IRQF_SHARED, dev->name, dev);
1058 if (rc < 0) 1058 if (rc < 0)
1059 goto err_release_timer_2; 1059 goto err_release_timer_2;
1060 1060
@@ -1156,8 +1156,7 @@ static int sis190_start_xmit(struct sk_buff *skb, struct net_device *dev)
1156 dma_addr_t mapping; 1156 dma_addr_t mapping;
1157 1157
1158 if (unlikely(skb->len < ETH_ZLEN)) { 1158 if (unlikely(skb->len < ETH_ZLEN)) {
1159 skb = skb_padto(skb, ETH_ZLEN); 1159 if (skb_padto(skb, ETH_ZLEN)) {
1160 if (!skb) {
1161 tp->stats.tx_dropped++; 1160 tp->stats.tx_dropped++;
1162 goto out; 1161 goto out;
1163 } 1162 }
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index d05874172209..29ee7ffedfff 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -1013,7 +1013,7 @@ sis900_open(struct net_device *net_dev)
1013 /* Equalizer workaround Rule */ 1013 /* Equalizer workaround Rule */
1014 sis630_set_eq(net_dev, sis_priv->chipset_rev); 1014 sis630_set_eq(net_dev, sis_priv->chipset_rev);
1015 1015
1016 ret = request_irq(net_dev->irq, &sis900_interrupt, SA_SHIRQ, 1016 ret = request_irq(net_dev->irq, &sis900_interrupt, IRQF_SHARED,
1017 net_dev->name, net_dev); 1017 net_dev->name, net_dev);
1018 if (ret) 1018 if (ret)
1019 return ret; 1019 return ret;
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index 38a26df4095f..ee62845d3ac9 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -570,9 +570,9 @@ SK_BOOL DualNet;
570 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); 570 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
571 571
572 if (pAC->GIni.GIMacsFound == 2) { 572 if (pAC->GIni.GIMacsFound == 2) {
573 Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev); 573 Ret = request_irq(dev->irq, SkGeIsr, IRQF_SHARED, "sk98lin", dev);
574 } else if (pAC->GIni.GIMacsFound == 1) { 574 } else if (pAC->GIni.GIMacsFound == 1) {
575 Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, 575 Ret = request_irq(dev->irq, SkGeIsrOnePort, IRQF_SHARED,
576 "sk98lin", dev); 576 "sk98lin", dev);
577 } else { 577 } else {
578 printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n", 578 printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n",
@@ -1525,7 +1525,7 @@ struct sk_buff *pMessage) /* pointer to send-message */
1525 ** This is to resolve faulty padding by the HW with 0xaa bytes. 1525 ** This is to resolve faulty padding by the HW with 0xaa bytes.
1526 */ 1526 */
1527 if (BytesSend < C_LEN_ETHERNET_MINSIZE) { 1527 if (BytesSend < C_LEN_ETHERNET_MINSIZE) {
1528 if ((pMessage = skb_padto(pMessage, C_LEN_ETHERNET_MINSIZE)) == NULL) { 1528 if (skb_padto(pMessage, C_LEN_ETHERNET_MINSIZE)) {
1529 spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags); 1529 spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
1530 return 0; 1530 return 0;
1531 } 1531 }
@@ -5073,9 +5073,9 @@ static int skge_resume(struct pci_dev *pdev)
5073 pci_enable_device(pdev); 5073 pci_enable_device(pdev);
5074 pci_set_master(pdev); 5074 pci_set_master(pdev);
5075 if (pAC->GIni.GIMacsFound == 2) 5075 if (pAC->GIni.GIMacsFound == 2)
5076 ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev); 5076 ret = request_irq(dev->irq, SkGeIsr, IRQF_SHARED, "sk98lin", dev);
5077 else 5077 else
5078 ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, "sk98lin", dev); 5078 ret = request_irq(dev->irq, SkGeIsrOnePort, IRQF_SHARED, "sk98lin", dev);
5079 if (ret) { 5079 if (ret) {
5080 printk(KERN_WARNING "sk98lin: unable to acquire IRQ %d\n", dev->irq); 5080 printk(KERN_WARNING "sk98lin: unable to acquire IRQ %d\n", dev->irq);
5081 pAC->AllocFlag &= ~SK_ALLOC_IRQ; 5081 pAC->AllocFlag &= ~SK_ALLOC_IRQ;
diff --git a/drivers/net/sk98lin/skvpd.c b/drivers/net/sk98lin/skvpd.c
index 17786056c66a..1e662aaebf84 100644
--- a/drivers/net/sk98lin/skvpd.c
+++ b/drivers/net/sk98lin/skvpd.c
@@ -22,7 +22,7 @@
22 ******************************************************************************/ 22 ******************************************************************************/
23 23
24/* 24/*
25 Please refer skvpd.txt for infomation how to include this module 25 Please refer skvpd.txt for information how to include this module
26 */ 26 */
27static const char SysKonnectFileId[] = 27static const char SysKonnectFileId[] =
28 "@(#)$Id: skvpd.c,v 1.37 2003/01/13 10:42:45 rschmidt Exp $ (C) SK"; 28 "@(#)$Id: skvpd.c,v 1.37 2003/01/13 10:42:45 rschmidt Exp $ (C) SK";
diff --git a/drivers/net/sk_mca.c b/drivers/net/sk_mca.c
index e5d6d95960c7..799e09801934 100644
--- a/drivers/net/sk_mca.c
+++ b/drivers/net/sk_mca.c
@@ -824,7 +824,7 @@ static int skmca_open(struct net_device *dev)
824 /* register resources - only necessary for IRQ */ 824 /* register resources - only necessary for IRQ */
825 result = 825 result =
826 request_irq(priv->realirq, irq_handler, 826 request_irq(priv->realirq, irq_handler,
827 SA_SHIRQ | SA_SAMPLE_RANDOM, "sk_mca", dev); 827 IRQF_SHARED | IRQF_SAMPLE_RANDOM, "sk_mca", dev);
828 if (result != 0) { 828 if (result != 0) {
829 printk("%s: failed to register irq %d\n", dev->name, 829 printk("%s: failed to register irq %d\n", dev->name,
830 dev->irq); 830 dev->irq);
diff --git a/drivers/net/skfp/h/sba.h b/drivers/net/skfp/h/sba.h
index df716cd5784a..638cf0283bc4 100644
--- a/drivers/net/skfp/h/sba.h
+++ b/drivers/net/skfp/h/sba.h
@@ -13,7 +13,7 @@
13 ******************************************************************************/ 13 ******************************************************************************/
14 14
15/* 15/*
16 * Synchronous Bandwith Allocation (SBA) structs 16 * Synchronous Bandwidth Allocation (SBA) structs
17 */ 17 */
18 18
19#ifndef _SBA_ 19#ifndef _SBA_
diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
index c7fb6133047e..b5714a60237d 100644
--- a/drivers/net/skfp/skfddi.c
+++ b/drivers/net/skfp/skfddi.c
@@ -497,7 +497,7 @@ static int skfp_open(struct net_device *dev)
497 497
498 PRINTK(KERN_INFO "entering skfp_open\n"); 498 PRINTK(KERN_INFO "entering skfp_open\n");
499 /* Register IRQ - support shared interrupts by passing device ptr */ 499 /* Register IRQ - support shared interrupts by passing device ptr */
500 err = request_irq(dev->irq, (void *) skfp_interrupt, SA_SHIRQ, 500 err = request_irq(dev->irq, (void *) skfp_interrupt, IRQF_SHARED,
501 dev->name, dev); 501 dev->name, dev);
502 if (err) 502 if (err)
503 return err; 503 return err;
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 536dd1cf7f79..82200bfaa8ed 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -24,7 +24,6 @@
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include <linux/config.h>
28#include <linux/in.h> 27#include <linux/in.h>
29#include <linux/kernel.h> 28#include <linux/kernel.h>
30#include <linux/module.h> 29#include <linux/module.h>
@@ -2310,8 +2309,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2310 u64 map; 2309 u64 map;
2311 unsigned long flags; 2310 unsigned long flags;
2312 2311
2313 skb = skb_padto(skb, ETH_ZLEN); 2312 if (skb_padto(skb, ETH_ZLEN))
2314 if (!skb)
2315 return NETDEV_TX_OK; 2313 return NETDEV_TX_OK;
2316 2314
2317 if (!spin_trylock_irqsave(&skge->tx_lock, flags)) 2315 if (!spin_trylock_irqsave(&skge->tx_lock, flags))
@@ -3343,7 +3341,7 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3343 goto err_out_free_hw; 3341 goto err_out_free_hw;
3344 } 3342 }
3345 3343
3346 err = request_irq(pdev->irq, skge_intr, SA_SHIRQ, DRV_NAME, hw); 3344 err = request_irq(pdev->irq, skge_intr, IRQF_SHARED, DRV_NAME, hw);
3347 if (err) { 3345 if (err) {
3348 printk(KERN_ERR PFX "%s: cannot assign irq %d\n", 3346 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3349 pci_name(pdev), pdev->irq); 3347 pci_name(pdev), pdev->irq);
@@ -3355,8 +3353,8 @@ static int __devinit skge_probe(struct pci_dev *pdev,
3355 if (err) 3353 if (err)
3356 goto err_out_free_irq; 3354 goto err_out_free_irq;
3357 3355
3358 printk(KERN_INFO PFX DRV_VERSION " addr 0x%lx irq %d chip %s rev %d\n", 3356 printk(KERN_INFO PFX DRV_VERSION " addr 0x%llx irq %d chip %s rev %d\n",
3359 pci_resource_start(pdev, 0), pdev->irq, 3357 (unsigned long long)pci_resource_start(pdev, 0), pdev->irq,
3360 skge_board_name(hw), hw->chip_rev); 3358 skge_board_name(hw), hw->chip_rev);
3361 3359
3362 if ((dev = skge_devinit(hw, 0, using_dac)) == NULL) 3360 if ((dev = skge_devinit(hw, 0, using_dac)) == NULL)
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index fba1e4d4d83d..418f169a6a31 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -23,7 +23,6 @@
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25 25
26#include <linux/config.h>
27#include <linux/crc32.h> 26#include <linux/crc32.h>
28#include <linux/kernel.h> 27#include <linux/kernel.h>
29#include <linux/version.h> 28#include <linux/version.h>
@@ -1160,7 +1159,7 @@ static unsigned tx_le_req(const struct sk_buff *skb)
1160 count = sizeof(dma_addr_t) / sizeof(u32); 1159 count = sizeof(dma_addr_t) / sizeof(u32);
1161 count += skb_shinfo(skb)->nr_frags * count; 1160 count += skb_shinfo(skb)->nr_frags * count;
1162 1161
1163 if (skb_shinfo(skb)->tso_size) 1162 if (skb_shinfo(skb)->gso_size)
1164 ++count; 1163 ++count;
1165 1164
1166 if (skb->ip_summed == CHECKSUM_HW) 1165 if (skb->ip_summed == CHECKSUM_HW)
@@ -1232,7 +1231,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
1232 } 1231 }
1233 1232
1234 /* Check for TCP Segmentation Offload */ 1233 /* Check for TCP Segmentation Offload */
1235 mss = skb_shinfo(skb)->tso_size; 1234 mss = skb_shinfo(skb)->gso_size;
1236 if (mss != 0) { 1235 if (mss != 0) {
1237 /* just drop the packet if non-linear expansion fails */ 1236 /* just drop the packet if non-linear expansion fails */
1238 if (skb_header_cloned(skb) && 1237 if (skb_header_cloned(skb) &&
@@ -3189,7 +3188,7 @@ static int __devinit sky2_test_msi(struct sky2_hw *hw)
3189 3188
3190 sky2_write32(hw, B0_IMSK, Y2_IS_IRQ_SW); 3189 sky2_write32(hw, B0_IMSK, Y2_IS_IRQ_SW);
3191 3190
3192 err = request_irq(pdev->irq, sky2_test_intr, SA_SHIRQ, DRV_NAME, hw); 3191 err = request_irq(pdev->irq, sky2_test_intr, IRQF_SHARED, DRV_NAME, hw);
3193 if (err) { 3192 if (err) {
3194 printk(KERN_ERR PFX "%s: cannot assign irq %d\n", 3193 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3195 pci_name(pdev), pdev->irq); 3194 pci_name(pdev), pdev->irq);
@@ -3311,9 +3310,9 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3311 if (err) 3310 if (err)
3312 goto err_out_iounmap; 3311 goto err_out_iounmap;
3313 3312
3314 printk(KERN_INFO PFX "v%s addr 0x%lx irq %d Yukon-%s (0x%x) rev %d\n", 3313 printk(KERN_INFO PFX "v%s addr 0x%llx irq %d Yukon-%s (0x%x) rev %d\n",
3315 DRV_VERSION, pci_resource_start(pdev, 0), pdev->irq, 3314 DRV_VERSION, (unsigned long long)pci_resource_start(pdev, 0),
3316 yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL], 3315 pdev->irq, yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL],
3317 hw->chip_id, hw->chip_rev); 3316 hw->chip_id, hw->chip_rev);
3318 3317
3319 dev = sky2_init_netdev(hw, 0, using_dac); 3318 dev = sky2_init_netdev(hw, 0, using_dac);
@@ -3349,7 +3348,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3349 goto err_out_unregister; 3348 goto err_out_unregister;
3350 } 3349 }
3351 3350
3352 err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ, DRV_NAME, hw); 3351 err = request_irq(pdev->irq, sky2_intr, IRQF_SHARED, DRV_NAME, hw);
3353 if (err) { 3352 if (err) {
3354 printk(KERN_ERR PFX "%s: cannot assign irq %d\n", 3353 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3355 pci_name(pdev), pdev->irq); 3354 pci_name(pdev), pdev->irq);
diff --git a/drivers/net/slhc.c b/drivers/net/slhc.c
index c6fbb1ede0ed..3a1b7131681c 100644
--- a/drivers/net/slhc.c
+++ b/drivers/net/slhc.c
@@ -50,7 +50,6 @@
50 * driver code belonging close to PPP and SLIP 50 * driver code belonging close to PPP and SLIP
51 */ 51 */
52 52
53#include <linux/config.h>
54#include <linux/module.h> 53#include <linux/module.h>
55#include <linux/types.h> 54#include <linux/types.h>
56#include <linux/string.h> 55#include <linux/string.h>
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index b2e18d28850d..1588cb7f6c83 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -55,7 +55,6 @@
55 */ 55 */
56 56
57#define SL_CHECK_TRANSMIT 57#define SL_CHECK_TRANSMIT
58#include <linux/config.h>
59#include <linux/module.h> 58#include <linux/module.h>
60#include <linux/moduleparam.h> 59#include <linux/moduleparam.h>
61 60
diff --git a/drivers/net/slip.h b/drivers/net/slip.h
index ab3efe66a642..29d87dd45a24 100644
--- a/drivers/net/slip.h
+++ b/drivers/net/slip.h
@@ -22,7 +22,6 @@
22#ifndef _LINUX_SLIP_H 22#ifndef _LINUX_SLIP_H
23#define _LINUX_SLIP_H 23#define _LINUX_SLIP_H
24 24
25#include <linux/config.h>
26 25
27#if defined(CONFIG_INET) && defined(CONFIG_SLIP_COMPRESSED) 26#if defined(CONFIG_INET) && defined(CONFIG_SLIP_COMPRESSED)
28# define SL_INCLUDE_CSLIP 27# define SL_INCLUDE_CSLIP
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
index 5b4e8529d4ab..45449353a958 100644
--- a/drivers/net/smc-ultra.c
+++ b/drivers/net/smc-ultra.c
@@ -57,7 +57,6 @@
57static const char version[] = 57static const char version[] =
58 "smc-ultra.c:v2.02 2/3/98 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; 58 "smc-ultra.c:v2.02 2/3/98 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
59 59
60#include <linux/config.h>
61#include <linux/module.h> 60#include <linux/module.h>
62#include <linux/kernel.h> 61#include <linux/kernel.h>
63#include <linux/errno.h> 62#include <linux/errno.h>
diff --git a/drivers/net/smc-ultra32.c b/drivers/net/smc-ultra32.c
index ff9bd97746dc..85be22a05973 100644
--- a/drivers/net/smc-ultra32.c
+++ b/drivers/net/smc-ultra32.c
@@ -290,7 +290,7 @@ out:
290static int ultra32_open(struct net_device *dev) 290static int ultra32_open(struct net_device *dev)
291{ 291{
292 int ioaddr = dev->base_addr - ULTRA32_NIC_OFFSET; /* ASIC addr */ 292 int ioaddr = dev->base_addr - ULTRA32_NIC_OFFSET; /* ASIC addr */
293 int irq_flags = (inb(ioaddr + ULTRA32_CFG5) & 0x08) ? 0 : SA_SHIRQ; 293 int irq_flags = (inb(ioaddr + ULTRA32_CFG5) & 0x08) ? 0 : IRQF_SHARED;
294 int retval; 294 int retval;
295 295
296 retval = request_irq(dev->irq, ei_interrupt, irq_flags, dev->name, dev); 296 retval = request_irq(dev->irq, ei_interrupt, irq_flags, dev->name, dev);
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index bdd8702ead54..d37bd860b336 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -2081,7 +2081,7 @@ static int __init smc911x_probe(struct net_device *dev, unsigned long ioaddr)
2081 lp->ctl_rspeed = 100; 2081 lp->ctl_rspeed = 100;
2082 2082
2083 /* Grab the IRQ */ 2083 /* Grab the IRQ */
2084 retval = request_irq(dev->irq, &smc911x_interrupt, SA_SHIRQ, dev->name, dev); 2084 retval = request_irq(dev->irq, &smc911x_interrupt, IRQF_SHARED, dev->name, dev);
2085 if (retval) 2085 if (retval)
2086 goto err_out; 2086 goto err_out;
2087 2087
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c
index 6cf16f322ad5..8b0321f1976c 100644
--- a/drivers/net/smc9194.c
+++ b/drivers/net/smc9194.c
@@ -523,8 +523,7 @@ static int smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * de
523 length = skb->len; 523 length = skb->len;
524 524
525 if (length < ETH_ZLEN) { 525 if (length < ETH_ZLEN) {
526 skb = skb_padto(skb, ETH_ZLEN); 526 if (skb_padto(skb, ETH_ZLEN)) {
527 if (skb == NULL) {
528 netif_wake_queue(dev); 527 netif_wake_queue(dev);
529 return 0; 528 return 0;
530 } 529 }
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 0e9833adf9fe..3d8dcb6c8758 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -66,7 +66,6 @@ static const char version[] =
66#endif 66#endif
67 67
68 68
69#include <linux/config.h>
70#include <linux/init.h> 69#include <linux/init.h>
71#include <linux/module.h> 70#include <linux/module.h>
72#include <linux/kernel.h> 71#include <linux/kernel.h>
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index f72a4f57905a..b4028049ed76 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -207,7 +207,7 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
207 machine_is_omap_h2() \ 207 machine_is_omap_h2() \
208 || machine_is_omap_h3() \ 208 || machine_is_omap_h3() \
209 || (machine_is_omap_innovator() && !cpu_is_omap1510()) \ 209 || (machine_is_omap_innovator() && !cpu_is_omap1510()) \
210 ) ? SA_TRIGGER_FALLING : SA_TRIGGER_RISING) 210 ) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING)
211 211
212 212
213#elif defined(CONFIG_SH_SH4202_MICRODEV) 213#elif defined(CONFIG_SH_SH4202_MICRODEV)
@@ -260,15 +260,17 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
260#define RPC_LSA_DEFAULT RPC_LED_TX_RX 260#define RPC_LSA_DEFAULT RPC_LED_TX_RX
261#define RPC_LSB_DEFAULT RPC_LED_100_10 261#define RPC_LSB_DEFAULT RPC_LED_100_10
262 262
263#elif defined(CONFIG_MACH_LPD7A400) || defined(CONFIG_MACH_LPD7A404) 263#elif defined(CONFIG_MACH_LPD79520) \
264 || defined(CONFIG_MACH_LPD7A400) \
265 || defined(CONFIG_MACH_LPD7A404)
264 266
265/* The LPD7A40X_IOBARRIER is necessary to overcome a mismatch between 267/* The LPD7X_IOBARRIER is necessary to overcome a mismatch between the
266 * the way that the CPU handles chip selects and the way that the SMC 268 * way that the CPU handles chip selects and the way that the SMC chip
267 * chip expects the chip select to operate. Refer to 269 * expects the chip select to operate. Refer to
268 * Documentation/arm/Sharp-LH/IOBarrier for details. The read from 270 * Documentation/arm/Sharp-LH/IOBarrier for details. The read from
269 * IOBARRIER is a byte as a least-common denominator of possible 271 * IOBARRIER is a byte, in order that we read the least-common
270 * regions to use as the barrier. It would be wasteful to read 32 272 * denominator. It would be wasteful to read 32 bits from an 8-bit
271 * bits from a byte oriented region. 273 * accessible region.
272 * 274 *
273 * There is no explicit protection against interrupts intervening 275 * There is no explicit protection against interrupts intervening
274 * between the writew and the IOBARRIER. In SMC ISR there is a 276 * between the writew and the IOBARRIER. In SMC ISR there is a
@@ -287,25 +289,35 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
287#define SMC_CAN_USE_16BIT 1 289#define SMC_CAN_USE_16BIT 1
288#define SMC_CAN_USE_32BIT 0 290#define SMC_CAN_USE_32BIT 0
289#define SMC_NOWAIT 0 291#define SMC_NOWAIT 0
290#define LPD7A40X_IOBARRIER readb (IOBARRIER_VIRT) 292#define LPD7X_IOBARRIER readb (IOBARRIER_VIRT)
291 293
292#define SMC_inw(a,r) readw ((void*) ((a) + (r))) 294#define SMC_inw(a,r)\
293#define SMC_insw(a,r,p,l) readsw ((void*) ((a) + (r)), p, l) 295 ({ unsigned short v = readw ((void*) ((a) + (r))); LPD7X_IOBARRIER; v; })
294#define SMC_outw(v,a,r) ({ writew ((v), (a) + (r)); LPD7A40X_IOBARRIER; }) 296#define SMC_outw(v,a,r) ({ writew ((v), (a) + (r)); LPD7X_IOBARRIER; })
295 297
296#define SMC_outsw LPD7A40X_SMC_outsw 298#define SMC_insw LPD7_SMC_insw
299static inline void LPD7_SMC_insw (unsigned char* a, int r,
300 unsigned char* p, int l)
301{
302 unsigned short* ps = (unsigned short*) p;
303 while (l-- > 0) {
304 *ps++ = readw (a + r);
305 LPD7X_IOBARRIER;
306 }
307}
297 308
298static inline void LPD7A40X_SMC_outsw(unsigned long a, int r, 309#define SMC_outsw LPD7_SMC_outsw
299 unsigned char* p, int l) 310static inline void LPD7_SMC_outsw (unsigned char* a, int r,
311 unsigned char* p, int l)
300{ 312{
301 unsigned short* ps = (unsigned short*) p; 313 unsigned short* ps = (unsigned short*) p;
302 while (l-- > 0) { 314 while (l-- > 0) {
303 writew (*ps++, a + r); 315 writew (*ps++, a + r);
304 LPD7A40X_IOBARRIER; 316 LPD7X_IOBARRIER;
305 } 317 }
306} 318}
307 319
308#define SMC_INTERRUPT_PREAMBLE LPD7A40X_IOBARRIER 320#define SMC_INTERRUPT_PREAMBLE LPD7X_IOBARRIER
309 321
310#define RPC_LSA_DEFAULT RPC_LED_TX_RX 322#define RPC_LSA_DEFAULT RPC_LED_TX_RX
311#define RPC_LSB_DEFAULT RPC_LED_100_10 323#define RPC_LSB_DEFAULT RPC_LED_100_10
@@ -528,7 +540,7 @@ smc_pxa_dma_irq(int dma, void *dummy, struct pt_regs *regs)
528#endif 540#endif
529 541
530#ifndef SMC_IRQ_FLAGS 542#ifndef SMC_IRQ_FLAGS
531#define SMC_IRQ_FLAGS SA_TRIGGER_RISING 543#define SMC_IRQ_FLAGS IRQF_TRIGGER_RISING
532#endif 544#endif
533 545
534#ifndef SMC_INTERRUPT_PREAMBLE 546#ifndef SMC_INTERRUPT_PREAMBLE
diff --git a/drivers/net/sonic.c b/drivers/net/sonic.c
index 90b818a8de6e..cab0dd958492 100644
--- a/drivers/net/sonic.c
+++ b/drivers/net/sonic.c
@@ -231,8 +231,7 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev)
231 231
232 length = skb->len; 232 length = skb->len;
233 if (length < ETH_ZLEN) { 233 if (length < ETH_ZLEN) {
234 skb = skb_padto(skb, ETH_ZLEN); 234 if (skb_padto(skb, ETH_ZLEN))
235 if (skb == NULL)
236 return 0; 235 return 0;
237 length = ETH_ZLEN; 236 length = ETH_ZLEN;
238 } 237 }
diff --git a/drivers/net/sonic.h b/drivers/net/sonic.h
index cede969a8baa..7f5c4ebcc17a 100644
--- a/drivers/net/sonic.h
+++ b/drivers/net/sonic.h
@@ -22,7 +22,6 @@
22#ifndef SONIC_H 22#ifndef SONIC_H
23#define SONIC_H 23#define SONIC_H
24 24
25#include <linux/config.h>
26 25
27/* 26/*
28 * SONIC register offsets 27 * SONIC register offsets
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 394339d5e87c..fb1d5a8a45cf 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -21,7 +21,6 @@
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */ 22 */
23 23
24#include <linux/config.h>
25#include <linux/compiler.h> 24#include <linux/compiler.h>
26#include <linux/crc32.h> 25#include <linux/crc32.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
@@ -1745,7 +1744,7 @@ spider_net_open(struct net_device *netdev)
1745 1744
1746 result = -EBUSY; 1745 result = -EBUSY;
1747 if (request_irq(netdev->irq, spider_net_interrupt, 1746 if (request_irq(netdev->irq, spider_net_interrupt,
1748 SA_SHIRQ, netdev->name, netdev)) 1747 IRQF_SHARED, netdev->name, netdev))
1749 goto register_int_failed; 1748 goto register_int_failed;
1750 1749
1751 spider_net_enable_card(card); 1750 spider_net_enable_card(card);
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 9b7805be21da..c0a62b00ffc8 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -22,131 +22,14 @@
22 22
23 Support and updates available at 23 Support and updates available at
24 http://www.scyld.com/network/starfire.html 24 http://www.scyld.com/network/starfire.html
25 [link no longer provides useful info -jgarzik]
25 26
26 -----------------------------------------------------------
27
28 Linux kernel-specific changes:
29
30 LK1.1.1 (jgarzik):
31 - Use PCI driver interface
32 - Fix MOD_xxx races
33 - softnet fixups
34
35 LK1.1.2 (jgarzik):
36 - Merge Becker version 0.15
37
38 LK1.1.3 (Andrew Morton)
39 - Timer cleanups
40
41 LK1.1.4 (jgarzik):
42 - Merge Becker version 1.03
43
44 LK1.2.1 (Ion Badulescu <ionut@cs.columbia.edu>)
45 - Support hardware Rx/Tx checksumming
46 - Use the GFP firmware taken from Adaptec's Netware driver
47
48 LK1.2.2 (Ion Badulescu)
49 - Backported to 2.2.x
50
51 LK1.2.3 (Ion Badulescu)
52 - Fix the flaky mdio interface
53 - More compat clean-ups
54
55 LK1.2.4 (Ion Badulescu)
56 - More 2.2.x initialization fixes
57
58 LK1.2.5 (Ion Badulescu)
59 - Several fixes from Manfred Spraul
60
61 LK1.2.6 (Ion Badulescu)
62 - Fixed ifup/ifdown/ifup problem in 2.4.x
63
64 LK1.2.7 (Ion Badulescu)
65 - Removed unused code
66 - Made more functions static and __init
67
68 LK1.2.8 (Ion Badulescu)
69 - Quell bogus error messages, inform about the Tx threshold
70 - Removed #ifdef CONFIG_PCI, this driver is PCI only
71
72 LK1.2.9 (Ion Badulescu)
73 - Merged Jeff Garzik's changes from 2.4.4-pre5
74 - Added 2.2.x compatibility stuff required by the above changes
75
76 LK1.2.9a (Ion Badulescu)
77 - More updates from Jeff Garzik
78
79 LK1.3.0 (Ion Badulescu)
80 - Merged zerocopy support
81
82 LK1.3.1 (Ion Badulescu)
83 - Added ethtool support
84 - Added GPIO (media change) interrupt support
85
86 LK1.3.2 (Ion Badulescu)
87 - Fixed 2.2.x compatibility issues introduced in 1.3.1
88 - Fixed ethtool ioctl returning uninitialized memory
89
90 LK1.3.3 (Ion Badulescu)
91 - Initialize the TxMode register properly
92 - Don't dereference dev->priv after freeing it
93
94 LK1.3.4 (Ion Badulescu)
95 - Fixed initialization timing problems
96 - Fixed interrupt mask definitions
97
98 LK1.3.5 (jgarzik)
99 - ethtool NWAY_RST, GLINK, [GS]MSGLVL support
100
101 LK1.3.6:
102 - Sparc64 support and fixes (Ion Badulescu)
103 - Better stats and error handling (Ion Badulescu)
104 - Use new pci_set_mwi() PCI API function (jgarzik)
105
106 LK1.3.7 (Ion Badulescu)
107 - minimal implementation of tx_timeout()
108 - correctly shutdown the Rx/Tx engines in netdev_close()
109 - added calls to netif_carrier_on/off
110 (patch from Stefan Rompf <srompf@isg.de>)
111 - VLAN support
112
113 LK1.3.8 (Ion Badulescu)
114 - adjust DMA burst size on sparc64
115 - 64-bit support
116 - reworked zerocopy support for 64-bit buffers
117 - working and usable interrupt mitigation/latency
118 - reduced Tx interrupt frequency for lower interrupt overhead
119
120 LK1.3.9 (Ion Badulescu)
121 - bugfix for mcast filter
122 - enable the right kind of Tx interrupts (TxDMADone, not TxDone)
123
124 LK1.4.0 (Ion Badulescu)
125 - NAPI support
126
127 LK1.4.1 (Ion Badulescu)
128 - flush PCI posting buffers after disabling Rx interrupts
129 - put the chip to a D3 slumber on driver unload
130 - added config option to enable/disable NAPI
131
132 LK1.4.2 (Ion Badulescu)
133 - finally added firmware (GPL'ed by Adaptec)
134 - removed compatibility code for 2.2.x
135
136 LK1.4.2.1 (Ion Badulescu)
137 - fixed 32/64 bit issues on i386 + CONFIG_HIGHMEM
138 - added 32-bit padding to outgoing skb's, removed previous workaround
139
140TODO: - fix forced speed/duplexing code (broken a long time ago, when
141 somebody converted the driver to use the generic MII code)
142 - fix VLAN support
143*/ 27*/
144 28
145#define DRV_NAME "starfire" 29#define DRV_NAME "starfire"
146#define DRV_VERSION "1.03+LK1.4.2.1" 30#define DRV_VERSION "2.0"
147#define DRV_RELDATE "October 3, 2005" 31#define DRV_RELDATE "June 27, 2006"
148 32
149#include <linux/config.h>
150#include <linux/module.h> 33#include <linux/module.h>
151#include <linux/kernel.h> 34#include <linux/kernel.h>
152#include <linux/pci.h> 35#include <linux/pci.h>
@@ -847,7 +730,6 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
847 goto err_out_free_netdev; 730 goto err_out_free_netdev;
848 } 731 }
849 732
850 /* ioremap is borken in Linux-2.2.x/sparc64 */
851 base = ioremap(ioaddr, io_size); 733 base = ioremap(ioaddr, io_size);
852 if (!base) { 734 if (!base) {
853 printk(KERN_ERR DRV_NAME " %d: cannot remap %#x @ %#lx, aborting\n", 735 printk(KERN_ERR DRV_NAME " %d: cannot remap %#x @ %#lx, aborting\n",
@@ -1071,7 +953,7 @@ static int netdev_open(struct net_device *dev)
1071 953
1072 /* Do we ever need to reset the chip??? */ 954 /* Do we ever need to reset the chip??? */
1073 955
1074 retval = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev); 956 retval = request_irq(dev->irq, &intr_handler, IRQF_SHARED, dev->name, dev);
1075 if (retval) 957 if (retval)
1076 return retval; 958 return retval;
1077 959
@@ -1349,8 +1231,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
1349 1231
1350#if defined(ZEROCOPY) && defined(HAS_BROKEN_FIRMWARE) 1232#if defined(ZEROCOPY) && defined(HAS_BROKEN_FIRMWARE)
1351 if (skb->ip_summed == CHECKSUM_HW) { 1233 if (skb->ip_summed == CHECKSUM_HW) {
1352 skb = skb_padto(skb, (skb->len + PADDING_MASK) & ~PADDING_MASK); 1234 if (skb_padto(skb, (skb->len + PADDING_MASK) & ~PADDING_MASK))
1353 if (skb == NULL)
1354 return NETDEV_TX_OK; 1235 return NETDEV_TX_OK;
1355 } 1236 }
1356#endif /* ZEROCOPY && HAS_BROKEN_FIRMWARE */ 1237#endif /* ZEROCOPY && HAS_BROKEN_FIRMWARE */
diff --git a/drivers/net/stnic.c b/drivers/net/stnic.c
index b6dfdf8f44da..74228348995d 100644
--- a/drivers/net/stnic.c
+++ b/drivers/net/stnic.c
@@ -7,7 +7,6 @@
7 * Copyright (C) 1999 kaz Kojima 7 * Copyright (C) 1999 kaz Kojima
8 */ 8 */
9 9
10#include <linux/config.h>
11#include <linux/module.h> 10#include <linux/module.h>
12#include <linux/kernel.h> 11#include <linux/kernel.h>
13#include <linux/errno.h> 12#include <linux/errno.h>
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index d4c0002b43db..2dcadb169a22 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -55,7 +55,7 @@ static char *version = "sun3lance.c: v1.2 1/12/2001 Sam Creasey (sammy@sammy.ne
55/* sun3/60 addr/irq for the lance chip. If your sun is different, 55/* sun3/60 addr/irq for the lance chip. If your sun is different,
56 change this. */ 56 change this. */
57#define LANCE_OBIO 0x120000 57#define LANCE_OBIO 0x120000
58#define LANCE_IRQ IRQ3 58#define LANCE_IRQ IRQ_AUTO_3
59 59
60/* Debug level: 60/* Debug level:
61 * 0 = silent, print only serious errors 61 * 0 = silent, print only serious errors
@@ -341,7 +341,7 @@ static int __init lance_probe( struct net_device *dev)
341 341
342 REGA(CSR0) = CSR0_STOP; 342 REGA(CSR0) = CSR0_STOP;
343 343
344 request_irq(LANCE_IRQ, lance_interrupt, SA_INTERRUPT, "SUN3 Lance", dev); 344 request_irq(LANCE_IRQ, lance_interrupt, IRQF_DISABLED, "SUN3 Lance", dev);
345 dev->irq = (unsigned short)LANCE_IRQ; 345 dev->irq = (unsigned short)LANCE_IRQ;
346 346
347 347
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c
index cfaf47c63c58..d46891510767 100644
--- a/drivers/net/sunbmac.c
+++ b/drivers/net/sunbmac.c
@@ -72,8 +72,6 @@ MODULE_LICENSE("GPL");
72#define DIRQ(x) 72#define DIRQ(x)
73#endif 73#endif
74 74
75static struct bigmac *root_bigmac_dev;
76
77#define DEFAULT_JAMSIZE 4 /* Toe jam */ 75#define DEFAULT_JAMSIZE 4 /* Toe jam */
78 76
79#define QEC_RESET_TRIES 200 77#define QEC_RESET_TRIES 200
@@ -491,7 +489,7 @@ static void bigmac_tcvr_init(struct bigmac *bp)
491 } 489 }
492} 490}
493 491
494static int bigmac_init(struct bigmac *, int); 492static int bigmac_init_hw(struct bigmac *, int);
495 493
496static int try_next_permutation(struct bigmac *bp, void __iomem *tregs) 494static int try_next_permutation(struct bigmac *bp, void __iomem *tregs)
497{ 495{
@@ -551,7 +549,7 @@ static void bigmac_timer(unsigned long data)
551 if (ret == -1) { 549 if (ret == -1) {
552 printk(KERN_ERR "%s: Link down, cable problem?\n", 550 printk(KERN_ERR "%s: Link down, cable problem?\n",
553 bp->dev->name); 551 bp->dev->name);
554 ret = bigmac_init(bp, 0); 552 ret = bigmac_init_hw(bp, 0);
555 if (ret) { 553 if (ret) {
556 printk(KERN_ERR "%s: Error, cannot re-init the " 554 printk(KERN_ERR "%s: Error, cannot re-init the "
557 "BigMAC.\n", bp->dev->name); 555 "BigMAC.\n", bp->dev->name);
@@ -621,7 +619,7 @@ static void bigmac_begin_auto_negotiation(struct bigmac *bp)
621 add_timer(&bp->bigmac_timer); 619 add_timer(&bp->bigmac_timer);
622} 620}
623 621
624static int bigmac_init(struct bigmac *bp, int from_irq) 622static int bigmac_init_hw(struct bigmac *bp, int from_irq)
625{ 623{
626 void __iomem *gregs = bp->gregs; 624 void __iomem *gregs = bp->gregs;
627 void __iomem *cregs = bp->creg; 625 void __iomem *cregs = bp->creg;
@@ -752,7 +750,7 @@ static void bigmac_is_medium_rare(struct bigmac *bp, u32 qec_status, u32 bmac_st
752 } 750 }
753 751
754 printk(" RESET\n"); 752 printk(" RESET\n");
755 bigmac_init(bp, 1); 753 bigmac_init_hw(bp, 1);
756} 754}
757 755
758/* BigMAC transmit complete service routines. */ 756/* BigMAC transmit complete service routines. */
@@ -920,13 +918,13 @@ static int bigmac_open(struct net_device *dev)
920 struct bigmac *bp = (struct bigmac *) dev->priv; 918 struct bigmac *bp = (struct bigmac *) dev->priv;
921 int ret; 919 int ret;
922 920
923 ret = request_irq(dev->irq, &bigmac_interrupt, SA_SHIRQ, dev->name, bp); 921 ret = request_irq(dev->irq, &bigmac_interrupt, IRQF_SHARED, dev->name, bp);
924 if (ret) { 922 if (ret) {
925 printk(KERN_ERR "BIGMAC: Can't order irq %d to go.\n", dev->irq); 923 printk(KERN_ERR "BIGMAC: Can't order irq %d to go.\n", dev->irq);
926 return ret; 924 return ret;
927 } 925 }
928 init_timer(&bp->bigmac_timer); 926 init_timer(&bp->bigmac_timer);
929 ret = bigmac_init(bp, 0); 927 ret = bigmac_init_hw(bp, 0);
930 if (ret) 928 if (ret)
931 free_irq(dev->irq, bp); 929 free_irq(dev->irq, bp);
932 return ret; 930 return ret;
@@ -950,7 +948,7 @@ static void bigmac_tx_timeout(struct net_device *dev)
950{ 948{
951 struct bigmac *bp = (struct bigmac *) dev->priv; 949 struct bigmac *bp = (struct bigmac *) dev->priv;
952 950
953 bigmac_init(bp, 0); 951 bigmac_init_hw(bp, 0);
954 netif_wake_queue(dev); 952 netif_wake_queue(dev);
955} 953}
956 954
@@ -1104,6 +1102,8 @@ static int __init bigmac_ether_init(struct sbus_dev *qec_sdev)
1104 bp->qec_sdev = qec_sdev; 1102 bp->qec_sdev = qec_sdev;
1105 bp->bigmac_sdev = qec_sdev->child; 1103 bp->bigmac_sdev = qec_sdev->child;
1106 1104
1105 SET_NETDEV_DEV(dev, &bp->bigmac_sdev->ofdev.dev);
1106
1107 spin_lock_init(&bp->lock); 1107 spin_lock_init(&bp->lock);
1108 1108
1109 /* Verify the registers we expect, are actually there. */ 1109 /* Verify the registers we expect, are actually there. */
@@ -1226,11 +1226,7 @@ static int __init bigmac_ether_init(struct sbus_dev *qec_sdev)
1226 goto fail_and_cleanup; 1226 goto fail_and_cleanup;
1227 } 1227 }
1228 1228
1229 /* Put us into the list of instances attached for later driver 1229 dev_set_drvdata(&bp->bigmac_sdev->ofdev.dev, bp);
1230 * exit.
1231 */
1232 bp->next_module = root_bigmac_dev;
1233 root_bigmac_dev = bp;
1234 1230
1235 printk(KERN_INFO "%s: BigMAC 100baseT Ethernet ", dev->name); 1231 printk(KERN_INFO "%s: BigMAC 100baseT Ethernet ", dev->name);
1236 for (i = 0; i < 6; i++) 1232 for (i = 0; i < 6; i++)
@@ -1266,69 +1262,68 @@ fail_and_cleanup:
1266/* QEC can be the parent of either QuadEthernet or 1262/* QEC can be the parent of either QuadEthernet or
1267 * a BigMAC. We want the latter. 1263 * a BigMAC. We want the latter.
1268 */ 1264 */
1269static int __init bigmac_match(struct sbus_dev *sdev) 1265static int __devinit bigmac_sbus_probe(struct of_device *dev, const struct of_device_id *match)
1270{ 1266{
1271 struct sbus_dev *child = sdev->child; 1267 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
1268 struct device_node *dp = dev->node;
1272 1269
1273 if (strcmp(sdev->prom_name, "qec") != 0) 1270 if (!strcmp(dp->name, "be"))
1274 return 0; 1271 sdev = sdev->parent;
1275 1272
1276 if (child == NULL) 1273 return bigmac_ether_init(sdev);
1277 return 0;
1278
1279 if (strcmp(child->prom_name, "be") != 0)
1280 return 0;
1281
1282 return 1;
1283} 1274}
1284 1275
1285static int __init bigmac_probe(void) 1276static int __devexit bigmac_sbus_remove(struct of_device *dev)
1286{ 1277{
1287 struct sbus_bus *sbus; 1278 struct bigmac *bp = dev_get_drvdata(&dev->dev);
1288 struct sbus_dev *sdev = NULL; 1279 struct net_device *net_dev = bp->dev;
1289 static int called; 1280
1290 int cards = 0, v; 1281 unregister_netdevice(net_dev);
1291 1282
1292 root_bigmac_dev = NULL; 1283 sbus_iounmap(bp->gregs, GLOB_REG_SIZE);
1293 1284 sbus_iounmap(bp->creg, CREG_REG_SIZE);
1294 if (called) 1285 sbus_iounmap(bp->bregs, BMAC_REG_SIZE);
1295 return -ENODEV; 1286 sbus_iounmap(bp->tregs, TCVR_REG_SIZE);
1296 called++; 1287 sbus_free_consistent(bp->bigmac_sdev,
1297 1288 PAGE_SIZE,
1298 for_each_sbus(sbus) { 1289 bp->bmac_block,
1299 for_each_sbusdev(sdev, sbus) { 1290 bp->bblock_dvma);
1300 if (bigmac_match(sdev)) { 1291
1301 cards++; 1292 free_netdev(net_dev);
1302 if ((v = bigmac_ether_init(sdev))) 1293
1303 return v; 1294 dev_set_drvdata(&dev->dev, NULL);
1304 } 1295
1305 }
1306 }
1307 if (!cards)
1308 return -ENODEV;
1309 return 0; 1296 return 0;
1310} 1297}
1311 1298
1312static void __exit bigmac_cleanup(void) 1299static struct of_device_id bigmac_sbus_match[] = {
1313{ 1300 {
1314 while (root_bigmac_dev) { 1301 .name = "qec",
1315 struct bigmac *bp = root_bigmac_dev; 1302 },
1316 struct bigmac *bp_nxt = root_bigmac_dev->next_module; 1303 {
1304 .name = "be",
1305 },
1306 {},
1307};
1317 1308
1318 sbus_iounmap(bp->gregs, GLOB_REG_SIZE); 1309MODULE_DEVICE_TABLE(of, bigmac_sbus_match);
1319 sbus_iounmap(bp->creg, CREG_REG_SIZE);
1320 sbus_iounmap(bp->bregs, BMAC_REG_SIZE);
1321 sbus_iounmap(bp->tregs, TCVR_REG_SIZE);
1322 sbus_free_consistent(bp->bigmac_sdev,
1323 PAGE_SIZE,
1324 bp->bmac_block,
1325 bp->bblock_dvma);
1326 1310
1327 unregister_netdev(bp->dev); 1311static struct of_platform_driver bigmac_sbus_driver = {
1328 free_netdev(bp->dev); 1312 .name = "sunbmac",
1329 root_bigmac_dev = bp_nxt; 1313 .match_table = bigmac_sbus_match,
1330 } 1314 .probe = bigmac_sbus_probe,
1315 .remove = __devexit_p(bigmac_sbus_remove),
1316};
1317
1318static int __init bigmac_init(void)
1319{
1320 return of_register_driver(&bigmac_sbus_driver, &sbus_bus_type);
1321}
1322
1323static void __exit bigmac_exit(void)
1324{
1325 of_unregister_driver(&bigmac_sbus_driver);
1331} 1326}
1332 1327
1333module_init(bigmac_probe); 1328module_init(bigmac_init);
1334module_exit(bigmac_cleanup); 1329module_exit(bigmac_exit);
diff --git a/drivers/net/sunbmac.h b/drivers/net/sunbmac.h
index b0dbc5187143..b563d3c2993e 100644
--- a/drivers/net/sunbmac.h
+++ b/drivers/net/sunbmac.h
@@ -332,7 +332,6 @@ struct bigmac {
332 struct sbus_dev *qec_sdev; 332 struct sbus_dev *qec_sdev;
333 struct sbus_dev *bigmac_sdev; 333 struct sbus_dev *bigmac_sdev;
334 struct net_device *dev; 334 struct net_device *dev;
335 struct bigmac *next_module;
336}; 335};
337 336
338/* We use this to acquire receive skb's that we can DMA directly into. */ 337/* We use this to acquire receive skb's that we can DMA directly into. */
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index f13b2a195c70..ac17377b3e9f 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -16,91 +16,13 @@
16 16
17 Support and updates available at 17 Support and updates available at
18 http://www.scyld.com/network/sundance.html 18 http://www.scyld.com/network/sundance.html
19 [link no longer provides useful info -jgarzik]
19 20
20
21 Version LK1.01a (jgarzik):
22 - Replace some MII-related magic numbers with constants
23
24 Version LK1.02 (D-Link):
25 - Add new board to PCI ID list
26 - Fix multicast bug
27
28 Version LK1.03 (D-Link):
29 - New Rx scheme, reduce Rx congestion
30 - Option to disable flow control
31
32 Version LK1.04 (D-Link):
33 - Tx timeout recovery
34 - More support for ethtool.
35
36 Version LK1.04a:
37 - Remove unused/constant members from struct pci_id_info
38 (which then allows removal of 'drv_flags' from private struct)
39 (jgarzik)
40 - If no phy is found, fail to load that board (jgarzik)
41 - Always start phy id scan at id 1 to avoid problems (Donald Becker)
42 - Autodetect where mii_preable_required is needed,
43 default to not needed. (Donald Becker)
44
45 Version LK1.04b:
46 - Remove mii_preamble_required module parameter (Donald Becker)
47 - Add per-interface mii_preamble_required (setting is autodetected)
48 (Donald Becker)
49 - Remove unnecessary cast from void pointer (jgarzik)
50 - Re-align comments in private struct (jgarzik)
51
52 Version LK1.04c (jgarzik):
53 - Support bitmapped message levels (NETIF_MSG_xxx), and the
54 two ethtool ioctls that get/set them
55 - Don't hand-code MII ethtool support, use standard API/lib
56
57 Version LK1.04d:
58 - Merge from Donald Becker's sundance.c: (Jason Lunz)
59 * proper support for variably-sized MTUs
60 * default to PIO, to fix chip bugs
61 - Add missing unregister_netdev (Jason Lunz)
62 - Add CONFIG_SUNDANCE_MMIO config option (jgarzik)
63 - Better rx buf size calculation (Donald Becker)
64
65 Version LK1.05 (D-Link):
66 - Fix DFE-580TX packet drop issue (for DL10050C)
67 - Fix reset_tx logic
68
69 Version LK1.06 (D-Link):
70 - Fix crash while unloading driver
71
72 Versin LK1.06b (D-Link):
73 - New tx scheme, adaptive tx_coalesce
74
75 Version LK1.07 (D-Link):
76 - Fix tx bugs in big-endian machines
77 - Remove unused max_interrupt_work module parameter, the new
78 NAPI-like rx scheme doesn't need it.
79 - Remove redundancy get_stats() in intr_handler(), those
80 I/O access could affect performance in ARM-based system
81 - Add Linux software VLAN support
82
83 Version LK1.08 (Philippe De Muyter phdm@macqel.be):
84 - Fix bug of custom mac address
85 (StationAddr register only accept word write)
86
87 Version LK1.09 (D-Link):
88 - Fix the flowctrl bug.
89 - Set Pause bit in MII ANAR if flow control enabled.
90
91 Version LK1.09a (ICPlus):
92 - Add the delay time in reading the contents of EEPROM
93
94 Version LK1.10 (Philippe De Muyter phdm@macqel.be):
95 - Make 'unblock interface after Tx underrun' work
96
97 Version LK1.11 (Pedro Alejandro Lopez-Valencia palopezv at gmail.com):
98 - Add support for IC Plus Corporation IP100A chipset
99*/ 21*/
100 22
101#define DRV_NAME "sundance" 23#define DRV_NAME "sundance"
102#define DRV_VERSION "1.01+LK1.11" 24#define DRV_VERSION "1.1"
103#define DRV_RELDATE "14-Jun-2006" 25#define DRV_RELDATE "27-Jun-2006"
104 26
105 27
106/* The user-configurable values. 28/* The user-configurable values.
@@ -282,15 +204,15 @@ IVc. Errata
282#define USE_IO_OPS 1 204#define USE_IO_OPS 1
283#endif 205#endif
284 206
285static struct pci_device_id sundance_pci_tbl[] = { 207static const struct pci_device_id sundance_pci_tbl[] = {
286 {0x1186, 0x1002, 0x1186, 0x1002, 0, 0, 0}, 208 { 0x1186, 0x1002, 0x1186, 0x1002, 0, 0, 0 },
287 {0x1186, 0x1002, 0x1186, 0x1003, 0, 0, 1}, 209 { 0x1186, 0x1002, 0x1186, 0x1003, 0, 0, 1 },
288 {0x1186, 0x1002, 0x1186, 0x1012, 0, 0, 2}, 210 { 0x1186, 0x1002, 0x1186, 0x1012, 0, 0, 2 },
289 {0x1186, 0x1002, 0x1186, 0x1040, 0, 0, 3}, 211 { 0x1186, 0x1002, 0x1186, 0x1040, 0, 0, 3 },
290 {0x1186, 0x1002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, 212 { 0x1186, 0x1002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 },
291 {0x13F0, 0x0201, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5}, 213 { 0x13F0, 0x0201, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 },
292 {0x13F0, 0x0200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6}, 214 { 0x13F0, 0x0200, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 },
293 {0,} 215 { }
294}; 216};
295MODULE_DEVICE_TABLE(pci, sundance_pci_tbl); 217MODULE_DEVICE_TABLE(pci, sundance_pci_tbl);
296 218
@@ -301,7 +223,7 @@ enum {
301struct pci_id_info { 223struct pci_id_info {
302 const char *name; 224 const char *name;
303}; 225};
304static const struct pci_id_info pci_id_tbl[] = { 226static const struct pci_id_info pci_id_tbl[] __devinitdata = {
305 {"D-Link DFE-550TX FAST Ethernet Adapter"}, 227 {"D-Link DFE-550TX FAST Ethernet Adapter"},
306 {"D-Link DFE-550FX 100Mbps Fiber-optics Adapter"}, 228 {"D-Link DFE-550FX 100Mbps Fiber-optics Adapter"},
307 {"D-Link DFE-580TX 4 port Server Adapter"}, 229 {"D-Link DFE-580TX 4 port Server Adapter"},
@@ -309,7 +231,7 @@ static const struct pci_id_info pci_id_tbl[] = {
309 {"D-Link DL10050-based FAST Ethernet Adapter"}, 231 {"D-Link DL10050-based FAST Ethernet Adapter"},
310 {"Sundance Technology Alta"}, 232 {"Sundance Technology Alta"},
311 {"IC Plus Corporation IP100A FAST Ethernet Adapter"}, 233 {"IC Plus Corporation IP100A FAST Ethernet Adapter"},
312 {NULL,}, /* 0 terminated list. */ 234 { } /* terminate list. */
313}; 235};
314 236
315/* This driver was written to use PCI memory space, however x86-oriented 237/* This driver was written to use PCI memory space, however x86-oriented
@@ -870,7 +792,7 @@ static int netdev_open(struct net_device *dev)
870 792
871 /* Do we need to reset the chip??? */ 793 /* Do we need to reset the chip??? */
872 794
873 i = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev); 795 i = request_irq(dev->irq, &intr_handler, IRQF_SHARED, dev->name, dev);
874 if (i) 796 if (i)
875 return i; 797 return i;
876 798
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 38cd30cb7c75..b70bbd748978 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2220,7 +2220,7 @@ static int gem_do_start(struct net_device *dev)
2220 spin_unlock_irqrestore(&gp->lock, flags); 2220 spin_unlock_irqrestore(&gp->lock, flags);
2221 2221
2222 if (request_irq(gp->pdev->irq, gem_interrupt, 2222 if (request_irq(gp->pdev->irq, gem_interrupt,
2223 SA_SHIRQ, dev->name, (void *)dev)) { 2223 IRQF_SHARED, dev->name, (void *)dev)) {
2224 printk(KERN_ERR "%s: failed to request irq !\n", gp->dev->name); 2224 printk(KERN_ERR "%s: failed to request irq !\n", gp->dev->name);
2225 2225
2226 spin_lock_irqsave(&gp->lock, flags); 2226 spin_lock_irqsave(&gp->lock, flags);
@@ -2880,17 +2880,20 @@ static int __devinit gem_get_device_address(struct gem *gp)
2880#if defined(__sparc__) 2880#if defined(__sparc__)
2881 struct pci_dev *pdev = gp->pdev; 2881 struct pci_dev *pdev = gp->pdev;
2882 struct pcidev_cookie *pcp = pdev->sysdata; 2882 struct pcidev_cookie *pcp = pdev->sysdata;
2883 int node = -1; 2883 int use_idprom = 1;
2884 2884
2885 if (pcp != NULL) { 2885 if (pcp != NULL) {
2886 node = pcp->prom_node; 2886 unsigned char *addr;
2887 if (prom_getproplen(node, "local-mac-address") == 6) 2887 int len;
2888 prom_getproperty(node, "local-mac-address", 2888
2889 dev->dev_addr, 6); 2889 addr = of_get_property(pcp->prom_node, "local-mac-address",
2890 else 2890 &len);
2891 node = -1; 2891 if (addr && len == 6) {
2892 use_idprom = 0;
2893 memcpy(dev->dev_addr, addr, 6);
2894 }
2892 } 2895 }
2893 if (node == -1) 2896 if (use_idprom)
2894 memcpy(dev->dev_addr, idprom->id_ethaddr, 6); 2897 memcpy(dev->dev_addr, idprom->id_ethaddr, 6);
2895#elif defined(CONFIG_PPC_PMAC) 2898#elif defined(CONFIG_PPC_PMAC)
2896 unsigned char *addr; 2899 unsigned char *addr;
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
index 9282b4b0c022..278c7cb22216 100644
--- a/drivers/net/sungem_phy.c
+++ b/drivers/net/sungem_phy.c
@@ -19,7 +19,6 @@
19 * of darwin, still need to reverse engineer that 19 * of darwin, still need to reverse engineer that
20 */ 20 */
21 21
22#include <linux/config.h>
23 22
24#include <linux/module.h> 23#include <linux/module.h>
25 24
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index 9f046cae2f71..8673fd4c08c7 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -1,9 +1,9 @@
1/* $Id: sunhme.c,v 1.124 2002/01/15 06:25:51 davem Exp $ 1/* sunhme.c: Sparc HME/BigMac 10/100baseT half/full duplex auto switching,
2 * sunhme.c: Sparc HME/BigMac 10/100baseT half/full duplex auto switching,
3 * auto carrier detecting ethernet driver. Also known as the 2 * auto carrier detecting ethernet driver. Also known as the
4 * "Happy Meal Ethernet" found on SunSwift SBUS cards. 3 * "Happy Meal Ethernet" found on SunSwift SBUS cards.
5 * 4 *
6 * Copyright (C) 1996, 1998, 1999, 2002, 2003 David S. Miller (davem@redhat.com) 5 * Copyright (C) 1996, 1998, 1999, 2002, 2003,
6 2006 David S. Miller (davem@davemloft.net)
7 * 7 *
8 * Changes : 8 * Changes :
9 * 2000/11/11 Willy Tarreau <willy AT meta-x.org> 9 * 2000/11/11 Willy Tarreau <willy AT meta-x.org>
@@ -13,7 +13,6 @@
13 * argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50 13 * argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50
14 */ 14 */
15 15
16#include <linux/config.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/kernel.h> 17#include <linux/kernel.h>
19#include <linux/types.h> 18#include <linux/types.h>
@@ -40,15 +39,13 @@
40#include <asm/dma.h> 39#include <asm/dma.h>
41#include <asm/byteorder.h> 40#include <asm/byteorder.h>
42 41
43#ifdef __sparc__ 42#ifdef CONFIG_SPARC
44#include <asm/idprom.h> 43#include <asm/idprom.h>
45#include <asm/sbus.h> 44#include <asm/sbus.h>
46#include <asm/openprom.h> 45#include <asm/openprom.h>
47#include <asm/oplib.h> 46#include <asm/oplib.h>
47#include <asm/prom.h>
48#include <asm/auxio.h> 48#include <asm/auxio.h>
49#ifndef __sparc_v9__
50#include <asm/io-unit.h>
51#endif
52#endif 49#endif
53#include <asm/uaccess.h> 50#include <asm/uaccess.h>
54 51
@@ -57,7 +54,7 @@
57 54
58#ifdef CONFIG_PCI 55#ifdef CONFIG_PCI
59#include <linux/pci.h> 56#include <linux/pci.h>
60#ifdef __sparc__ 57#ifdef CONFIG_SPARC
61#include <asm/pbm.h> 58#include <asm/pbm.h>
62#endif 59#endif
63#endif 60#endif
@@ -65,9 +62,9 @@
65#include "sunhme.h" 62#include "sunhme.h"
66 63
67#define DRV_NAME "sunhme" 64#define DRV_NAME "sunhme"
68#define DRV_VERSION "2.02" 65#define DRV_VERSION "3.00"
69#define DRV_RELDATE "8/24/03" 66#define DRV_RELDATE "June 23, 2006"
70#define DRV_AUTHOR "David S. Miller (davem@redhat.com)" 67#define DRV_AUTHOR "David S. Miller (davem@davemloft.net)"
71 68
72static char version[] = 69static char version[] =
73 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; 70 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
@@ -83,8 +80,6 @@ static int macaddr[6];
83module_param_array(macaddr, int, NULL, 0); 80module_param_array(macaddr, int, NULL, 0);
84MODULE_PARM_DESC(macaddr, "Happy Meal MAC address to set"); 81MODULE_PARM_DESC(macaddr, "Happy Meal MAC address to set");
85 82
86static struct happy_meal *root_happy_dev;
87
88#ifdef CONFIG_SBUS 83#ifdef CONFIG_SBUS
89static struct quattro *qfe_sbus_list; 84static struct quattro *qfe_sbus_list;
90#endif 85#endif
@@ -181,26 +176,6 @@ static __inline__ void tx_dump_ring(struct happy_meal *hp)
181#define DEFAULT_IPG2 4 /* For all modes */ 176#define DEFAULT_IPG2 4 /* For all modes */
182#define DEFAULT_JAMSIZE 4 /* Toe jam */ 177#define DEFAULT_JAMSIZE 4 /* Toe jam */
183 178
184#if defined(CONFIG_PCI) && defined(MODULE)
185/* This happy_pci_ids is declared __initdata because it is only used
186 as an advisory to depmod. If this is ported to the new PCI interface
187 where it could be referenced at any time due to hot plugging,
188 the __initdata reference should be removed. */
189
190static struct pci_device_id happymeal_pci_ids[] = {
191 {
192 .vendor = PCI_VENDOR_ID_SUN,
193 .device = PCI_DEVICE_ID_SUN_HAPPYMEAL,
194 .subvendor = PCI_ANY_ID,
195 .subdevice = PCI_ANY_ID,
196 },
197 { } /* Terminating entry */
198};
199
200MODULE_DEVICE_TABLE(pci, happymeal_pci_ids);
201
202#endif
203
204/* NOTE: In the descriptor writes one _must_ write the address 179/* NOTE: In the descriptor writes one _must_ write the address
205 * member _first_. The card must not be allowed to see 180 * member _first_. The card must not be allowed to see
206 * the updated descriptor flags until the address is 181 * the updated descriptor flags until the address is
@@ -1610,7 +1585,7 @@ static int happy_meal_init(struct happy_meal *hp)
1610 HMD(("happy_meal_init: old[%08x] bursts<", 1585 HMD(("happy_meal_init: old[%08x] bursts<",
1611 hme_read32(hp, gregs + GREG_CFG))); 1586 hme_read32(hp, gregs + GREG_CFG)));
1612 1587
1613#ifndef __sparc__ 1588#ifndef CONFIG_SPARC
1614 /* It is always PCI and can handle 64byte bursts. */ 1589 /* It is always PCI and can handle 64byte bursts. */
1615 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST64); 1590 hme_write32(hp, gregs + GREG_CFG, GREG_CFG_BURST64);
1616#else 1591#else
@@ -1647,7 +1622,7 @@ static int happy_meal_init(struct happy_meal *hp)
1647 HMD(("XXX>")); 1622 HMD(("XXX>"));
1648 hme_write32(hp, gregs + GREG_CFG, 0); 1623 hme_write32(hp, gregs + GREG_CFG, 0);
1649 } 1624 }
1650#endif /* __sparc__ */ 1625#endif /* CONFIG_SPARC */
1651 1626
1652 /* Turn off interrupts we do not want to hear. */ 1627 /* Turn off interrupts we do not want to hear. */
1653 HMD((", enable global interrupts, ")); 1628 HMD((", enable global interrupts, "));
@@ -2219,15 +2194,10 @@ static int happy_meal_open(struct net_device *dev)
2219 */ 2194 */
2220 if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) { 2195 if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) {
2221 if (request_irq(dev->irq, &happy_meal_interrupt, 2196 if (request_irq(dev->irq, &happy_meal_interrupt,
2222 SA_SHIRQ, dev->name, (void *)dev)) { 2197 IRQF_SHARED, dev->name, (void *)dev)) {
2223 HMD(("EAGAIN\n")); 2198 HMD(("EAGAIN\n"));
2224#ifdef __sparc__
2225 printk(KERN_ERR "happy_meal(SBUS): Can't order irq %s to go.\n",
2226 __irq_itoa(dev->irq));
2227#else
2228 printk(KERN_ERR "happy_meal(SBUS): Can't order irq %d to go.\n", 2199 printk(KERN_ERR "happy_meal(SBUS): Can't order irq %d to go.\n",
2229 dev->irq); 2200 dev->irq);
2230#endif
2231 2201
2232 return -EAGAIN; 2202 return -EAGAIN;
2233 } 2203 }
@@ -2552,7 +2522,7 @@ static struct ethtool_ops hme_ethtool_ops = {
2552static int hme_version_printed; 2522static int hme_version_printed;
2553 2523
2554#ifdef CONFIG_SBUS 2524#ifdef CONFIG_SBUS
2555void __init quattro_get_ranges(struct quattro *qp) 2525void __devinit quattro_get_ranges(struct quattro *qp)
2556{ 2526{
2557 struct sbus_dev *sdev = qp->quattro_dev; 2527 struct sbus_dev *sdev = qp->quattro_dev;
2558 int err; 2528 int err;
@@ -2568,7 +2538,7 @@ void __init quattro_get_ranges(struct quattro *qp)
2568 qp->nranges = (err / sizeof(struct linux_prom_ranges)); 2538 qp->nranges = (err / sizeof(struct linux_prom_ranges));
2569} 2539}
2570 2540
2571static void __init quattro_apply_ranges(struct quattro *qp, struct happy_meal *hp) 2541static void __devinit quattro_apply_ranges(struct quattro *qp, struct happy_meal *hp)
2572{ 2542{
2573 struct sbus_dev *sdev = hp->happy_dev; 2543 struct sbus_dev *sdev = hp->happy_dev;
2574 int rng; 2544 int rng;
@@ -2595,16 +2565,12 @@ static void __init quattro_apply_ranges(struct quattro *qp, struct happy_meal *h
2595 * 2565 *
2596 * Return NULL on failure. 2566 * Return NULL on failure.
2597 */ 2567 */
2598static struct quattro * __init quattro_sbus_find(struct sbus_dev *goal_sdev) 2568static struct quattro * __devinit quattro_sbus_find(struct sbus_dev *goal_sdev)
2599{ 2569{
2600 struct sbus_bus *sbus;
2601 struct sbus_dev *sdev; 2570 struct sbus_dev *sdev;
2602 struct quattro *qp; 2571 struct quattro *qp;
2603 int i; 2572 int i;
2604 2573
2605 if (qfe_sbus_list == NULL)
2606 goto found;
2607
2608 for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { 2574 for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) {
2609 for (i = 0, sdev = qp->quattro_dev; 2575 for (i = 0, sdev = qp->quattro_dev;
2610 (sdev != NULL) && (i < 4); 2576 (sdev != NULL) && (i < 4);
@@ -2613,17 +2579,7 @@ static struct quattro * __init quattro_sbus_find(struct sbus_dev *goal_sdev)
2613 return qp; 2579 return qp;
2614 } 2580 }
2615 } 2581 }
2616 for_each_sbus(sbus) {
2617 for_each_sbusdev(sdev, sbus) {
2618 if (sdev == goal_sdev)
2619 goto found;
2620 }
2621 }
2622 2582
2623 /* Cannot find quattro parent, fail. */
2624 return NULL;
2625
2626found:
2627 qp = kmalloc(sizeof(struct quattro), GFP_KERNEL); 2583 qp = kmalloc(sizeof(struct quattro), GFP_KERNEL);
2628 if (qp != NULL) { 2584 if (qp != NULL) {
2629 int i; 2585 int i;
@@ -2652,7 +2608,7 @@ static void __init quattro_sbus_register_irqs(void)
2652 2608
2653 err = request_irq(sdev->irqs[0], 2609 err = request_irq(sdev->irqs[0],
2654 quattro_sbus_interrupt, 2610 quattro_sbus_interrupt,
2655 SA_SHIRQ, "Quattro", 2611 IRQF_SHARED, "Quattro",
2656 qp); 2612 qp);
2657 if (err != 0) { 2613 if (err != 0) {
2658 printk(KERN_ERR "Quattro: Fatal IRQ registery error %d.\n", err); 2614 printk(KERN_ERR "Quattro: Fatal IRQ registery error %d.\n", err);
@@ -2660,6 +2616,17 @@ static void __init quattro_sbus_register_irqs(void)
2660 } 2616 }
2661 } 2617 }
2662} 2618}
2619
2620static void quattro_sbus_free_irqs(void)
2621{
2622 struct quattro *qp;
2623
2624 for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) {
2625 struct sbus_dev *sdev = qp->quattro_dev;
2626
2627 free_irq(sdev->irqs[0], qp);
2628 }
2629}
2663#endif /* CONFIG_SBUS */ 2630#endif /* CONFIG_SBUS */
2664 2631
2665#ifdef CONFIG_PCI 2632#ifdef CONFIG_PCI
@@ -2694,8 +2661,9 @@ static struct quattro * __init quattro_pci_find(struct pci_dev *pdev)
2694#endif /* CONFIG_PCI */ 2661#endif /* CONFIG_PCI */
2695 2662
2696#ifdef CONFIG_SBUS 2663#ifdef CONFIG_SBUS
2697static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe) 2664static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe)
2698{ 2665{
2666 struct device_node *dp = sdev->ofdev.node;
2699 struct quattro *qp = NULL; 2667 struct quattro *qp = NULL;
2700 struct happy_meal *hp; 2668 struct happy_meal *hp;
2701 struct net_device *dev; 2669 struct net_device *dev;
@@ -2718,6 +2686,7 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe)
2718 if (!dev) 2686 if (!dev)
2719 goto err_out; 2687 goto err_out;
2720 SET_MODULE_OWNER(dev); 2688 SET_MODULE_OWNER(dev);
2689 SET_NETDEV_DEV(dev, &sdev->ofdev.dev);
2721 2690
2722 if (hme_version_printed++ == 0) 2691 if (hme_version_printed++ == 0)
2723 printk(KERN_INFO "%s", version); 2692 printk(KERN_INFO "%s", version);
@@ -2733,13 +2702,16 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe)
2733 for (i = 0; i < 6; i++) 2702 for (i = 0; i < 6; i++)
2734 dev->dev_addr[i] = macaddr[i]; 2703 dev->dev_addr[i] = macaddr[i];
2735 macaddr[5]++; 2704 macaddr[5]++;
2736 } else if (qfe_slot != -1 &&
2737 prom_getproplen(sdev->prom_node,
2738 "local-mac-address") == 6) {
2739 prom_getproperty(sdev->prom_node, "local-mac-address",
2740 dev->dev_addr, 6);
2741 } else { 2705 } else {
2742 memcpy(dev->dev_addr, idprom->id_ethaddr, 6); 2706 unsigned char *addr;
2707 int len;
2708
2709 addr = of_get_property(dp, "local-mac-address", &len);
2710
2711 if (qfe_slot != -1 && addr && len == 6)
2712 memcpy(dev->dev_addr, addr, 6);
2713 else
2714 memcpy(dev->dev_addr, idprom->id_ethaddr, 6);
2743 } 2715 }
2744 2716
2745 hp = dev->priv; 2717 hp = dev->priv;
@@ -2750,9 +2722,8 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe)
2750 2722
2751 err = -ENODEV; 2723 err = -ENODEV;
2752 if (sdev->num_registers != 5) { 2724 if (sdev->num_registers != 5) {
2753 printk(KERN_ERR "happymeal: Device does not have 5 regs, it has %d.\n", 2725 printk(KERN_ERR "happymeal: Device needs 5 regs, has %d.\n",
2754 sdev->num_registers); 2726 sdev->num_registers);
2755 printk(KERN_ERR "happymeal: Would you like that for here or to go?\n");
2756 goto err_out_free_netdev; 2727 goto err_out_free_netdev;
2757 } 2728 }
2758 2729
@@ -2766,39 +2737,39 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe)
2766 hp->gregs = sbus_ioremap(&sdev->resource[0], 0, 2737 hp->gregs = sbus_ioremap(&sdev->resource[0], 0,
2767 GREG_REG_SIZE, "HME Global Regs"); 2738 GREG_REG_SIZE, "HME Global Regs");
2768 if (!hp->gregs) { 2739 if (!hp->gregs) {
2769 printk(KERN_ERR "happymeal: Cannot map Happy Meal global registers.\n"); 2740 printk(KERN_ERR "happymeal: Cannot map global registers.\n");
2770 goto err_out_free_netdev; 2741 goto err_out_free_netdev;
2771 } 2742 }
2772 2743
2773 hp->etxregs = sbus_ioremap(&sdev->resource[1], 0, 2744 hp->etxregs = sbus_ioremap(&sdev->resource[1], 0,
2774 ETX_REG_SIZE, "HME TX Regs"); 2745 ETX_REG_SIZE, "HME TX Regs");
2775 if (!hp->etxregs) { 2746 if (!hp->etxregs) {
2776 printk(KERN_ERR "happymeal: Cannot map Happy Meal MAC Transmit registers.\n"); 2747 printk(KERN_ERR "happymeal: Cannot map MAC TX registers.\n");
2777 goto err_out_iounmap; 2748 goto err_out_iounmap;
2778 } 2749 }
2779 2750
2780 hp->erxregs = sbus_ioremap(&sdev->resource[2], 0, 2751 hp->erxregs = sbus_ioremap(&sdev->resource[2], 0,
2781 ERX_REG_SIZE, "HME RX Regs"); 2752 ERX_REG_SIZE, "HME RX Regs");
2782 if (!hp->erxregs) { 2753 if (!hp->erxregs) {
2783 printk(KERN_ERR "happymeal: Cannot map Happy Meal MAC Receive registers.\n"); 2754 printk(KERN_ERR "happymeal: Cannot map MAC RX registers.\n");
2784 goto err_out_iounmap; 2755 goto err_out_iounmap;
2785 } 2756 }
2786 2757
2787 hp->bigmacregs = sbus_ioremap(&sdev->resource[3], 0, 2758 hp->bigmacregs = sbus_ioremap(&sdev->resource[3], 0,
2788 BMAC_REG_SIZE, "HME BIGMAC Regs"); 2759 BMAC_REG_SIZE, "HME BIGMAC Regs");
2789 if (!hp->bigmacregs) { 2760 if (!hp->bigmacregs) {
2790 printk(KERN_ERR "happymeal: Cannot map Happy Meal BIGMAC registers.\n"); 2761 printk(KERN_ERR "happymeal: Cannot map BIGMAC registers.\n");
2791 goto err_out_iounmap; 2762 goto err_out_iounmap;
2792 } 2763 }
2793 2764
2794 hp->tcvregs = sbus_ioremap(&sdev->resource[4], 0, 2765 hp->tcvregs = sbus_ioremap(&sdev->resource[4], 0,
2795 TCVR_REG_SIZE, "HME Tranceiver Regs"); 2766 TCVR_REG_SIZE, "HME Tranceiver Regs");
2796 if (!hp->tcvregs) { 2767 if (!hp->tcvregs) {
2797 printk(KERN_ERR "happymeal: Cannot map Happy Meal Tranceiver registers.\n"); 2768 printk(KERN_ERR "happymeal: Cannot map TCVR registers.\n");
2798 goto err_out_iounmap; 2769 goto err_out_iounmap;
2799 } 2770 }
2800 2771
2801 hp->hm_revision = prom_getintdefault(sdev->prom_node, "hm-rev", 0xff); 2772 hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff);
2802 if (hp->hm_revision == 0xff) 2773 if (hp->hm_revision == 0xff)
2803 hp->hm_revision = 0xa0; 2774 hp->hm_revision = 0xa0;
2804 2775
@@ -2812,8 +2783,8 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe)
2812 hp->happy_flags |= HFLAG_QUATTRO; 2783 hp->happy_flags |= HFLAG_QUATTRO;
2813 2784
2814 /* Get the supported DVMA burst sizes from our Happy SBUS. */ 2785 /* Get the supported DVMA burst sizes from our Happy SBUS. */
2815 hp->happy_bursts = prom_getintdefault(sdev->bus->prom_node, 2786 hp->happy_bursts = of_getintprop_default(sdev->bus->ofdev.node,
2816 "burst-sizes", 0x00); 2787 "burst-sizes", 0x00);
2817 2788
2818 hp->happy_block = sbus_alloc_consistent(hp->happy_dev, 2789 hp->happy_block = sbus_alloc_consistent(hp->happy_dev,
2819 PAGE_SIZE, 2790 PAGE_SIZE,
@@ -2876,6 +2847,8 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe)
2876 goto err_out_free_consistent; 2847 goto err_out_free_consistent;
2877 } 2848 }
2878 2849
2850 dev_set_drvdata(&sdev->ofdev.dev, hp);
2851
2879 if (qfe_slot != -1) 2852 if (qfe_slot != -1)
2880 printk(KERN_INFO "%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ", 2853 printk(KERN_INFO "%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ",
2881 dev->name, qfe_slot); 2854 dev->name, qfe_slot);
@@ -2888,12 +2861,6 @@ static int __init happy_meal_sbus_init(struct sbus_dev *sdev, int is_qfe)
2888 dev->dev_addr[i], i == 5 ? ' ' : ':'); 2861 dev->dev_addr[i], i == 5 ? ' ' : ':');
2889 printk("\n"); 2862 printk("\n");
2890 2863
2891 /* We are home free at this point, link us in to the happy
2892 * device list.
2893 */
2894 hp->next_module = root_happy_dev;
2895 root_happy_dev = hp;
2896
2897 return 0; 2864 return 0;
2898 2865
2899err_out_free_consistent: 2866err_out_free_consistent:
@@ -2923,7 +2890,7 @@ err_out:
2923#endif 2890#endif
2924 2891
2925#ifdef CONFIG_PCI 2892#ifdef CONFIG_PCI
2926#ifndef __sparc__ 2893#ifndef CONFIG_SPARC
2927static int is_quattro_p(struct pci_dev *pdev) 2894static int is_quattro_p(struct pci_dev *pdev)
2928{ 2895{
2929 struct pci_dev *busdev = pdev->bus->self; 2896 struct pci_dev *busdev = pdev->bus->self;
@@ -3011,14 +2978,14 @@ static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr)
3011 get_random_bytes(&dev_addr[3], 3); 2978 get_random_bytes(&dev_addr[3], 3);
3012 return; 2979 return;
3013} 2980}
3014#endif /* !(__sparc__) */ 2981#endif /* !(CONFIG_SPARC) */
3015 2982
3016static int __init happy_meal_pci_init(struct pci_dev *pdev) 2983static int __devinit happy_meal_pci_probe(struct pci_dev *pdev,
2984 const struct pci_device_id *ent)
3017{ 2985{
3018 struct quattro *qp = NULL; 2986 struct quattro *qp = NULL;
3019#ifdef __sparc__ 2987#ifdef CONFIG_SPARC
3020 struct pcidev_cookie *pcp; 2988 struct pcidev_cookie *pcp;
3021 int node;
3022#endif 2989#endif
3023 struct happy_meal *hp; 2990 struct happy_meal *hp;
3024 struct net_device *dev; 2991 struct net_device *dev;
@@ -3029,15 +2996,14 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
3029 int err; 2996 int err;
3030 2997
3031 /* Now make sure pci_dev cookie is there. */ 2998 /* Now make sure pci_dev cookie is there. */
3032#ifdef __sparc__ 2999#ifdef CONFIG_SPARC
3033 pcp = pdev->sysdata; 3000 pcp = pdev->sysdata;
3034 if (pcp == NULL || pcp->prom_node == -1) { 3001 if (pcp == NULL) {
3035 printk(KERN_ERR "happymeal(PCI): Some PCI device info missing\n"); 3002 printk(KERN_ERR "happymeal(PCI): Some PCI device info missing\n");
3036 return -ENODEV; 3003 return -ENODEV;
3037 } 3004 }
3038 node = pcp->prom_node;
3039 3005
3040 prom_getstring(node, "name", prom_name, sizeof(prom_name)); 3006 strcpy(prom_name, pcp->prom_node->name);
3041#else 3007#else
3042 if (is_quattro_p(pdev)) 3008 if (is_quattro_p(pdev))
3043 strcpy(prom_name, "SUNW,qfe"); 3009 strcpy(prom_name, "SUNW,qfe");
@@ -3108,11 +3074,15 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
3108 dev->dev_addr[i] = macaddr[i]; 3074 dev->dev_addr[i] = macaddr[i];
3109 macaddr[5]++; 3075 macaddr[5]++;
3110 } else { 3076 } else {
3111#ifdef __sparc__ 3077#ifdef CONFIG_SPARC
3078 unsigned char *addr;
3079 int len;
3080
3112 if (qfe_slot != -1 && 3081 if (qfe_slot != -1 &&
3113 prom_getproplen(node, "local-mac-address") == 6) { 3082 (addr = of_get_property(pcp->prom_node,
3114 prom_getproperty(node, "local-mac-address", 3083 "local-mac-address", &len)) != NULL
3115 dev->dev_addr, 6); 3084 && len == 6) {
3085 memcpy(dev->dev_addr, addr, 6);
3116 } else { 3086 } else {
3117 memcpy(dev->dev_addr, idprom->id_ethaddr, 6); 3087 memcpy(dev->dev_addr, idprom->id_ethaddr, 6);
3118 } 3088 }
@@ -3128,8 +3098,8 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
3128 hp->bigmacregs = (hpreg_base + 0x6000UL); 3098 hp->bigmacregs = (hpreg_base + 0x6000UL);
3129 hp->tcvregs = (hpreg_base + 0x7000UL); 3099 hp->tcvregs = (hpreg_base + 0x7000UL);
3130 3100
3131#ifdef __sparc__ 3101#ifdef CONFIG_SPARC
3132 hp->hm_revision = prom_getintdefault(node, "hm-rev", 0xff); 3102 hp->hm_revision = of_getintprop_default(pcp->prom_node, "hm-rev", 0xff);
3133 if (hp->hm_revision == 0xff) { 3103 if (hp->hm_revision == 0xff) {
3134 unsigned char prev; 3104 unsigned char prev;
3135 3105
@@ -3153,7 +3123,7 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
3153 /* And of course, indicate this is PCI. */ 3123 /* And of course, indicate this is PCI. */
3154 hp->happy_flags |= HFLAG_PCI; 3124 hp->happy_flags |= HFLAG_PCI;
3155 3125
3156#ifdef __sparc__ 3126#ifdef CONFIG_SPARC
3157 /* Assume PCI happy meals can handle all burst sizes. */ 3127 /* Assume PCI happy meals can handle all burst sizes. */
3158 hp->happy_bursts = DMA_BURSTBITS; 3128 hp->happy_bursts = DMA_BURSTBITS;
3159#endif 3129#endif
@@ -3216,6 +3186,8 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
3216 goto err_out_iounmap; 3186 goto err_out_iounmap;
3217 } 3187 }
3218 3188
3189 dev_set_drvdata(&pdev->dev, hp);
3190
3219 if (!qfe_slot) { 3191 if (!qfe_slot) {
3220 struct pci_dev *qpdev = qp->quattro_dev; 3192 struct pci_dev *qpdev = qp->quattro_dev;
3221 3193
@@ -3245,12 +3217,6 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
3245 3217
3246 printk("\n"); 3218 printk("\n");
3247 3219
3248 /* We are home free at this point, link us in to the happy
3249 * device list.
3250 */
3251 hp->next_module = root_happy_dev;
3252 root_happy_dev = hp;
3253
3254 return 0; 3220 return 0;
3255 3221
3256err_out_iounmap: 3222err_out_iounmap:
@@ -3268,136 +3234,146 @@ err_out_clear_quattro:
3268err_out: 3234err_out:
3269 return err; 3235 return err;
3270} 3236}
3271#endif
3272 3237
3273#ifdef CONFIG_SBUS 3238static void __devexit happy_meal_pci_remove(struct pci_dev *pdev)
3274static int __init happy_meal_sbus_probe(void)
3275{ 3239{
3276 struct sbus_bus *sbus; 3240 struct happy_meal *hp = dev_get_drvdata(&pdev->dev);
3277 struct sbus_dev *sdev; 3241 struct net_device *net_dev = hp->dev;
3278 int cards = 0; 3242
3279 char model[128]; 3243 unregister_netdev(net_dev);
3280 3244
3281 for_each_sbus(sbus) { 3245 pci_free_consistent(hp->happy_dev,
3282 for_each_sbusdev(sdev, sbus) { 3246 PAGE_SIZE,
3283 char *name = sdev->prom_name; 3247 hp->happy_block,
3284 3248 hp->hblock_dvma);
3285 if (!strcmp(name, "SUNW,hme")) { 3249 iounmap(hp->gregs);
3286 cards++; 3250 pci_release_regions(hp->happy_dev);
3287 prom_getstring(sdev->prom_node, "model", 3251
3288 model, sizeof(model)); 3252 free_netdev(net_dev);
3289 if (!strcmp(model, "SUNW,sbus-qfe")) 3253
3290 happy_meal_sbus_init(sdev, 1); 3254 dev_set_drvdata(&pdev->dev, NULL);
3291 else
3292 happy_meal_sbus_init(sdev, 0);
3293 } else if (!strcmp(name, "qfe") ||
3294 !strcmp(name, "SUNW,qfe")) {
3295 cards++;
3296 happy_meal_sbus_init(sdev, 1);
3297 }
3298 }
3299 }
3300 if (cards != 0)
3301 quattro_sbus_register_irqs();
3302 return cards;
3303} 3255}
3304#endif
3305 3256
3306#ifdef CONFIG_PCI 3257static struct pci_device_id happymeal_pci_ids[] = {
3307static int __init happy_meal_pci_probe(void) 3258 {
3259 .vendor = PCI_VENDOR_ID_SUN,
3260 .device = PCI_DEVICE_ID_SUN_HAPPYMEAL,
3261 .subvendor = PCI_ANY_ID,
3262 .subdevice = PCI_ANY_ID,
3263 },
3264 { } /* Terminating entry */
3265};
3266
3267MODULE_DEVICE_TABLE(pci, happymeal_pci_ids);
3268
3269static struct pci_driver hme_pci_driver = {
3270 .name = "hme",
3271 .id_table = happymeal_pci_ids,
3272 .probe = happy_meal_pci_probe,
3273 .remove = __devexit_p(happy_meal_pci_remove),
3274};
3275
3276static int __init happy_meal_pci_init(void)
3308{ 3277{
3309 struct pci_dev *pdev = NULL; 3278 return pci_module_init(&hme_pci_driver);
3310 int cards = 0; 3279}
3311 3280
3312 while ((pdev = pci_find_device(PCI_VENDOR_ID_SUN, 3281static void happy_meal_pci_exit(void)
3313 PCI_DEVICE_ID_SUN_HAPPYMEAL, pdev)) != NULL) { 3282{
3314 if (pci_enable_device(pdev)) 3283 pci_unregister_driver(&hme_pci_driver);
3315 continue; 3284
3316 pci_set_master(pdev); 3285 while (qfe_pci_list) {
3317 cards++; 3286 struct quattro *qfe = qfe_pci_list;
3318 happy_meal_pci_init(pdev); 3287 struct quattro *next = qfe->next;
3288
3289 kfree(qfe);
3290
3291 qfe_pci_list = next;
3319 } 3292 }
3320 return cards;
3321} 3293}
3294
3322#endif 3295#endif
3323 3296
3324static int __init happy_meal_probe(void) 3297#ifdef CONFIG_SBUS
3298static int __devinit hme_sbus_probe(struct of_device *dev, const struct of_device_id *match)
3325{ 3299{
3326 static int called = 0; 3300 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
3327 int cards; 3301 struct device_node *dp = dev->node;
3302 char *model = of_get_property(dp, "model", NULL);
3303 int is_qfe = (match->data != NULL);
3328 3304
3329 root_happy_dev = NULL; 3305 if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe"))
3306 is_qfe = 1;
3330 3307
3331 if (called) 3308 return happy_meal_sbus_probe_one(sdev, is_qfe);
3332 return -ENODEV; 3309}
3333 called++; 3310
3311static int __devexit hme_sbus_remove(struct of_device *dev)
3312{
3313 struct happy_meal *hp = dev_get_drvdata(&dev->dev);
3314 struct net_device *net_dev = hp->dev;
3315
3316 unregister_netdevice(net_dev);
3317
3318 /* XXX qfe parent interrupt... */
3319
3320 sbus_iounmap(hp->gregs, GREG_REG_SIZE);
3321 sbus_iounmap(hp->etxregs, ETX_REG_SIZE);
3322 sbus_iounmap(hp->erxregs, ERX_REG_SIZE);
3323 sbus_iounmap(hp->bigmacregs, BMAC_REG_SIZE);
3324 sbus_iounmap(hp->tcvregs, TCVR_REG_SIZE);
3325 sbus_free_consistent(hp->happy_dev,
3326 PAGE_SIZE,
3327 hp->happy_block,
3328 hp->hblock_dvma);
3329
3330 free_netdev(net_dev);
3331
3332 dev_set_drvdata(&dev->dev, NULL);
3334 3333
3335 cards = 0;
3336#ifdef CONFIG_SBUS
3337 cards += happy_meal_sbus_probe();
3338#endif
3339#ifdef CONFIG_PCI
3340 cards += happy_meal_pci_probe();
3341#endif
3342 if (!cards)
3343 return -ENODEV;
3344 return 0; 3334 return 0;
3345} 3335}
3346 3336
3337static struct of_device_id hme_sbus_match[] = {
3338 {
3339 .name = "SUNW,hme",
3340 },
3341 {
3342 .name = "SUNW,qfe",
3343 .data = (void *) 1,
3344 },
3345 {
3346 .name = "qfe",
3347 .data = (void *) 1,
3348 },
3349 {},
3350};
3347 3351
3348static void __exit happy_meal_cleanup_module(void) 3352MODULE_DEVICE_TABLE(of, hme_sbus_match);
3349{
3350#ifdef CONFIG_SBUS
3351 struct quattro *last_seen_qfe = NULL;
3352#endif
3353 3353
3354 while (root_happy_dev) { 3354static struct of_platform_driver hme_sbus_driver = {
3355 struct happy_meal *hp = root_happy_dev; 3355 .name = "hme",
3356 struct happy_meal *next = root_happy_dev->next_module; 3356 .match_table = hme_sbus_match,
3357 struct net_device *dev = hp->dev; 3357 .probe = hme_sbus_probe,
3358 .remove = __devexit_p(hme_sbus_remove),
3359};
3358 3360
3359 /* Unregister netdev before unmapping registers as this 3361static int __init happy_meal_sbus_init(void)
3360 * call can end up trying to access those registers. 3362{
3361 */ 3363 int err;
3362 unregister_netdev(dev);
3363 3364
3364#ifdef CONFIG_SBUS 3365 err = of_register_driver(&hme_sbus_driver, &sbus_bus_type);
3365 if (!(hp->happy_flags & HFLAG_PCI)) { 3366 if (!err)
3366 if (hp->happy_flags & HFLAG_QUATTRO) { 3367 quattro_sbus_register_irqs();
3367 if (hp->qfe_parent != last_seen_qfe) {
3368 free_irq(dev->irq, hp->qfe_parent);
3369 last_seen_qfe = hp->qfe_parent;
3370 }
3371 }
3372 3368
3373 sbus_iounmap(hp->gregs, GREG_REG_SIZE); 3369 return err;
3374 sbus_iounmap(hp->etxregs, ETX_REG_SIZE); 3370}
3375 sbus_iounmap(hp->erxregs, ERX_REG_SIZE);
3376 sbus_iounmap(hp->bigmacregs, BMAC_REG_SIZE);
3377 sbus_iounmap(hp->tcvregs, TCVR_REG_SIZE);
3378 sbus_free_consistent(hp->happy_dev,
3379 PAGE_SIZE,
3380 hp->happy_block,
3381 hp->hblock_dvma);
3382 }
3383#endif
3384#ifdef CONFIG_PCI
3385 if ((hp->happy_flags & HFLAG_PCI)) {
3386 pci_free_consistent(hp->happy_dev,
3387 PAGE_SIZE,
3388 hp->happy_block,
3389 hp->hblock_dvma);
3390 iounmap(hp->gregs);
3391 pci_release_regions(hp->happy_dev);
3392 }
3393#endif
3394 free_netdev(dev);
3395 3371
3396 root_happy_dev = next; 3372static void happy_meal_sbus_exit(void)
3397 } 3373{
3374 of_unregister_driver(&hme_sbus_driver);
3375 quattro_sbus_free_irqs();
3398 3376
3399 /* Now cleanup the quattro lists. */
3400#ifdef CONFIG_SBUS
3401 while (qfe_sbus_list) { 3377 while (qfe_sbus_list) {
3402 struct quattro *qfe = qfe_sbus_list; 3378 struct quattro *qfe = qfe_sbus_list;
3403 struct quattro *next = qfe->next; 3379 struct quattro *next = qfe->next;
@@ -3406,18 +3382,39 @@ static void __exit happy_meal_cleanup_module(void)
3406 3382
3407 qfe_sbus_list = next; 3383 qfe_sbus_list = next;
3408 } 3384 }
3385}
3409#endif 3386#endif
3410#ifdef CONFIG_PCI
3411 while (qfe_pci_list) {
3412 struct quattro *qfe = qfe_pci_list;
3413 struct quattro *next = qfe->next;
3414 3387
3415 kfree(qfe); 3388static int __init happy_meal_probe(void)
3389{
3390 int err = 0;
3416 3391
3417 qfe_pci_list = next; 3392#ifdef CONFIG_SBUS
3393 err = happy_meal_sbus_init();
3394#endif
3395#ifdef CONFIG_PCI
3396 if (!err) {
3397 err = happy_meal_pci_init();
3398#ifdef CONFIG_SBUS
3399 if (err)
3400 happy_meal_sbus_exit();
3401#endif
3418 } 3402 }
3419#endif 3403#endif
3404
3405 return err;
3406}
3407
3408
3409static void __exit happy_meal_exit(void)
3410{
3411#ifdef CONFIG_SBUS
3412 happy_meal_sbus_exit();
3413#endif
3414#ifdef CONFIG_PCI
3415 happy_meal_pci_exit();
3416#endif
3420} 3417}
3421 3418
3422module_init(happy_meal_probe); 3419module_init(happy_meal_probe);
3423module_exit(happy_meal_cleanup_module); 3420module_exit(happy_meal_exit);
diff --git a/drivers/net/sunhme.h b/drivers/net/sunhme.h
index 34e9f953cea4..90f446db9ba2 100644
--- a/drivers/net/sunhme.h
+++ b/drivers/net/sunhme.h
@@ -8,7 +8,6 @@
8#ifndef _SUNHME_H 8#ifndef _SUNHME_H
9#define _SUNHME_H 9#define _SUNHME_H
10 10
11#include <linux/config.h>
12#include <linux/pci.h> 11#include <linux/pci.h>
13 12
14/* Happy Meal global registers. */ 13/* Happy Meal global registers. */
@@ -461,7 +460,6 @@ struct happy_meal {
461 struct net_device *dev; /* Backpointer */ 460 struct net_device *dev; /* Backpointer */
462 struct quattro *qfe_parent; /* For Quattro cards */ 461 struct quattro *qfe_parent; /* For Quattro cards */
463 int qfe_ent; /* Which instance on quattro */ 462 int qfe_ent; /* Which instance on quattro */
464 struct happy_meal *next_module;
465}; 463};
466 464
467/* Here are the happy flags. */ 465/* Here are the happy flags. */
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c
index b7d87d4690b4..1ef9fd39a79a 100644
--- a/drivers/net/sunlance.c
+++ b/drivers/net/sunlance.c
@@ -71,7 +71,6 @@
71 71
72static char lancestr[] = "LANCE"; 72static char lancestr[] = "LANCE";
73 73
74#include <linux/config.h>
75#include <linux/module.h> 74#include <linux/module.h>
76#include <linux/kernel.h> 75#include <linux/kernel.h>
77#include <linux/types.h> 76#include <linux/types.h>
@@ -266,7 +265,6 @@ struct lance_private {
266 char *name; 265 char *name;
267 dma_addr_t init_block_dvma; 266 dma_addr_t init_block_dvma;
268 struct net_device *dev; /* Backpointer */ 267 struct net_device *dev; /* Backpointer */
269 struct lance_private *next_module;
270 struct sbus_dev *sdev; 268 struct sbus_dev *sdev;
271 struct timer_list multicast_timer; 269 struct timer_list multicast_timer;
272}; 270};
@@ -298,8 +296,6 @@ int sparc_lance_debug = 2;
298 296
299#define LANCE_ADDR(x) ((long)(x) & ~0xff000000) 297#define LANCE_ADDR(x) ((long)(x) & ~0xff000000)
300 298
301static struct lance_private *root_lance_dev;
302
303/* Load the CSR registers */ 299/* Load the CSR registers */
304static void load_csrs(struct lance_private *lp) 300static void load_csrs(struct lance_private *lp)
305{ 301{
@@ -934,9 +930,9 @@ static int lance_open(struct net_device *dev)
934 930
935 STOP_LANCE(lp); 931 STOP_LANCE(lp);
936 932
937 if (request_irq(dev->irq, &lance_interrupt, SA_SHIRQ, 933 if (request_irq(dev->irq, &lance_interrupt, IRQF_SHARED,
938 lancestr, (void *) dev)) { 934 lancestr, (void *) dev)) {
939 printk(KERN_ERR "Lance: Can't get irq %s\n", __irq_itoa(dev->irq)); 935 printk(KERN_ERR "Lance: Can't get irq %d\n", dev->irq);
940 return -EAGAIN; 936 return -EAGAIN;
941 } 937 }
942 938
@@ -1327,9 +1323,9 @@ static struct ethtool_ops sparc_lance_ethtool_ops = {
1327 .get_link = sparc_lance_get_link, 1323 .get_link = sparc_lance_get_link,
1328}; 1324};
1329 1325
1330static int __init sparc_lance_init(struct sbus_dev *sdev, 1326static int __init sparc_lance_probe_one(struct sbus_dev *sdev,
1331 struct sbus_dma *ledma, 1327 struct sbus_dma *ledma,
1332 struct sbus_dev *lebuffer) 1328 struct sbus_dev *lebuffer)
1333{ 1329{
1334 static unsigned version_printed; 1330 static unsigned version_printed;
1335 struct net_device *dev; 1331 struct net_device *dev;
@@ -1473,6 +1469,7 @@ no_link_test:
1473 1469
1474 lp->dev = dev; 1470 lp->dev = dev;
1475 SET_MODULE_OWNER(dev); 1471 SET_MODULE_OWNER(dev);
1472 SET_NETDEV_DEV(dev, &sdev->ofdev.dev);
1476 dev->open = &lance_open; 1473 dev->open = &lance_open;
1477 dev->stop = &lance_close; 1474 dev->stop = &lance_close;
1478 dev->hard_start_xmit = &lance_start_xmit; 1475 dev->hard_start_xmit = &lance_start_xmit;
@@ -1500,8 +1497,7 @@ no_link_test:
1500 goto fail; 1497 goto fail;
1501 } 1498 }
1502 1499
1503 lp->next_module = root_lance_dev; 1500 dev_set_drvdata(&sdev->ofdev.dev, lp);
1504 root_lance_dev = lp;
1505 1501
1506 printk(KERN_INFO "%s: LANCE ", dev->name); 1502 printk(KERN_INFO "%s: LANCE ", dev->name);
1507 1503
@@ -1536,88 +1532,112 @@ static inline struct sbus_dma *find_ledma(struct sbus_dev *sdev)
1536#include <asm/machines.h> 1532#include <asm/machines.h>
1537 1533
1538/* Find all the lance cards on the system and initialize them */ 1534/* Find all the lance cards on the system and initialize them */
1539static int __init sparc_lance_probe(void) 1535static struct sbus_dev sun4_sdev;
1536static int __init sparc_lance_init(void)
1540{ 1537{
1541 static struct sbus_dev sdev;
1542 static int called;
1543
1544 root_lance_dev = NULL;
1545
1546 if (called)
1547 return -ENODEV;
1548 called++;
1549
1550 if ((idprom->id_machtype == (SM_SUN4|SM_4_330)) || 1538 if ((idprom->id_machtype == (SM_SUN4|SM_4_330)) ||
1551 (idprom->id_machtype == (SM_SUN4|SM_4_470))) { 1539 (idprom->id_machtype == (SM_SUN4|SM_4_470))) {
1552 memset(&sdev, 0, sizeof(sdev)); 1540 memset(&sun4_sdev, 0, sizeof(sdev));
1553 sdev.reg_addrs[0].phys_addr = sun4_eth_physaddr; 1541 sun4_sdev.reg_addrs[0].phys_addr = sun4_eth_physaddr;
1554 sdev.irqs[0] = 6; 1542 sun4_sdev.irqs[0] = 6;
1555 return sparc_lance_init(&sdev, NULL, NULL); 1543 return sparc_lance_probe_one(&sun4_sdev, NULL, NULL);
1556 } 1544 }
1557 return -ENODEV; 1545 return -ENODEV;
1558} 1546}
1559 1547
1560#else /* !CONFIG_SUN4 */ 1548static int __exit sunlance_sun4_remove(void)
1561
1562/* Find all the lance cards on the system and initialize them */
1563static int __init sparc_lance_probe(void)
1564{ 1549{
1565 struct sbus_bus *bus; 1550 struct lance_private *lp = dev_get_drvdata(&sun4_sdev->dev);
1566 struct sbus_dev *sdev = NULL; 1551 struct net_device *net_dev = lp->dev;
1567 struct sbus_dma *ledma = NULL; 1552
1568 static int called; 1553 unregister_netdevice(net_dev);
1569 int cards = 0, v; 1554
1570 1555 lance_free_hwresources(root_lance_dev);
1571 root_lance_dev = NULL; 1556
1572 1557 free_netdev(net_dev);
1573 if (called) 1558
1574 return -ENODEV; 1559 dev_set_drvdata(&sun4_sdev->dev, NULL);
1575 called++; 1560
1576
1577 for_each_sbus (bus) {
1578 for_each_sbusdev (sdev, bus) {
1579 if (strcmp(sdev->prom_name, "le") == 0) {
1580 cards++;
1581 if ((v = sparc_lance_init(sdev, NULL, NULL)))
1582 return v;
1583 continue;
1584 }
1585 if (strcmp(sdev->prom_name, "ledma") == 0) {
1586 cards++;
1587 ledma = find_ledma(sdev);
1588 if ((v = sparc_lance_init(sdev->child,
1589 ledma, NULL)))
1590 return v;
1591 continue;
1592 }
1593 if (strcmp(sdev->prom_name, "lebuffer") == 0){
1594 cards++;
1595 if ((v = sparc_lance_init(sdev->child,
1596 NULL, sdev)))
1597 return v;
1598 continue;
1599 }
1600 } /* for each sbusdev */
1601 } /* for each sbus */
1602 if (!cards)
1603 return -ENODEV;
1604 return 0; 1561 return 0;
1605} 1562}
1606#endif /* !CONFIG_SUN4 */
1607 1563
1608static void __exit sparc_lance_cleanup(void) 1564#else /* !CONFIG_SUN4 */
1565
1566static int __devinit sunlance_sbus_probe(struct of_device *dev, const struct of_device_id *match)
1609{ 1567{
1610 struct lance_private *lp; 1568 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
1569 struct device_node *dp = dev->node;
1570 int err;
1571
1572 if (!strcmp(dp->name, "le")) {
1573 err = sparc_lance_probe_one(sdev, NULL, NULL);
1574 } else if (!strcmp(dp->name, "ledma")) {
1575 struct sbus_dma *ledma = find_ledma(sdev);
1611 1576
1612 while (root_lance_dev) { 1577 err = sparc_lance_probe_one(sdev->child, ledma, NULL);
1613 lp = root_lance_dev->next_module; 1578 } else {
1579 BUG_ON(strcmp(dp->name, "lebuffer"));
1614 1580
1615 unregister_netdev(root_lance_dev->dev); 1581 err = sparc_lance_probe_one(sdev->child, NULL, sdev);
1616 lance_free_hwresources(root_lance_dev);
1617 free_netdev(root_lance_dev->dev);
1618 root_lance_dev = lp;
1619 } 1582 }
1583
1584 return err;
1585}
1586
1587static int __devexit sunlance_sbus_remove(struct of_device *dev)
1588{
1589 struct lance_private *lp = dev_get_drvdata(&dev->dev);
1590 struct net_device *net_dev = lp->dev;
1591
1592 unregister_netdevice(net_dev);
1593
1594 lance_free_hwresources(lp);
1595
1596 free_netdev(net_dev);
1597
1598 dev_set_drvdata(&dev->dev, NULL);
1599
1600 return 0;
1601}
1602
1603static struct of_device_id sunlance_sbus_match[] = {
1604 {
1605 .name = "le",
1606 },
1607 {
1608 .name = "ledma",
1609 },
1610 {
1611 .name = "lebuffer",
1612 },
1613 {},
1614};
1615
1616MODULE_DEVICE_TABLE(of, sunlance_sbus_match);
1617
1618static struct of_platform_driver sunlance_sbus_driver = {
1619 .name = "sunlance",
1620 .match_table = sunlance_sbus_match,
1621 .probe = sunlance_sbus_probe,
1622 .remove = __devexit_p(sunlance_sbus_remove),
1623};
1624
1625
1626/* Find all the lance cards on the system and initialize them */
1627static int __init sparc_lance_init(void)
1628{
1629 return of_register_driver(&sunlance_sbus_driver, &sbus_bus_type);
1630}
1631#endif /* !CONFIG_SUN4 */
1632
1633static void __exit sparc_lance_exit(void)
1634{
1635#ifdef CONFIG_SUN4
1636 sunlance_sun4_remove();
1637#else
1638 of_unregister_driver(&sunlance_sbus_driver);
1639#endif
1620} 1640}
1621 1641
1622module_init(sparc_lance_probe); 1642module_init(sparc_lance_init);
1623module_exit(sparc_lance_cleanup); 1643module_exit(sparc_lance_exit);
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c
index 1f2323be60d4..817a40b66638 100644
--- a/drivers/net/sunqe.c
+++ b/drivers/net/sunqe.c
@@ -1,10 +1,9 @@
1/* $Id: sunqe.c,v 1.55 2002/01/15 06:48:55 davem Exp $ 1/* sunqe.c: Sparc QuadEthernet 10baseT SBUS card driver.
2 * sunqe.c: Sparc QuadEthernet 10baseT SBUS card driver.
3 * Once again I am out to prove that every ethernet 2 * Once again I am out to prove that every ethernet
4 * controller out there can be most efficiently programmed 3 * controller out there can be most efficiently programmed
5 * if you make it look like a LANCE. 4 * if you make it look like a LANCE.
6 * 5 *
7 * Copyright (C) 1996, 1999, 2003 David S. Miller (davem@redhat.com) 6 * Copyright (C) 1996, 1999, 2003, 2006 David S. Miller (davem@davemloft.net)
8 */ 7 */
9 8
10#include <linux/module.h> 9#include <linux/module.h>
@@ -41,9 +40,9 @@
41#include "sunqe.h" 40#include "sunqe.h"
42 41
43#define DRV_NAME "sunqe" 42#define DRV_NAME "sunqe"
44#define DRV_VERSION "3.0" 43#define DRV_VERSION "4.0"
45#define DRV_RELDATE "8/24/03" 44#define DRV_RELDATE "June 23, 2006"
46#define DRV_AUTHOR "David S. Miller (davem@redhat.com)" 45#define DRV_AUTHOR "David S. Miller (davem@davemloft.net)"
47 46
48static char version[] = 47static char version[] =
49 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; 48 DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
@@ -755,298 +754,269 @@ static inline void qec_init_once(struct sunqec *qecp, struct sbus_dev *qsdev)
755 qecp->gregs + GLOB_RSIZE); 754 qecp->gregs + GLOB_RSIZE);
756} 755}
757 756
758/* Four QE's per QEC card. */ 757static u8 __init qec_get_burst(struct device_node *dp)
759static int __init qec_ether_init(struct net_device *dev, struct sbus_dev *sdev)
760{ 758{
761 static unsigned version_printed;
762 struct net_device *qe_devs[4];
763 struct sunqe *qeps[4];
764 struct sbus_dev *qesdevs[4];
765 struct sbus_dev *child;
766 struct sunqec *qecp = NULL;
767 u8 bsizes, bsizes_more; 759 u8 bsizes, bsizes_more;
768 int i, j, res = -ENOMEM;
769 760
770 for (i = 0; i < 4; i++) { 761 /* Find and set the burst sizes for the QEC, since it
771 qe_devs[i] = alloc_etherdev(sizeof(struct sunqe)); 762 * does the actual dma for all 4 channels.
772 if (!qe_devs[i]) 763 */
773 goto out; 764 bsizes = of_getintprop_default(dp, "burst-sizes", 0xff);
774 } 765 bsizes &= 0xff;
766 bsizes_more = of_getintprop_default(dp->parent, "burst-sizes", 0xff);
775 767
776 if (version_printed++ == 0) 768 if (bsizes_more != 0xff)
777 printk(KERN_INFO "%s", version); 769 bsizes &= bsizes_more;
770 if (bsizes == 0xff || (bsizes & DMA_BURST16) == 0 ||
771 (bsizes & DMA_BURST32)==0)
772 bsizes = (DMA_BURST32 - 1);
778 773
779 for (i = 0; i < 4; i++) { 774 return bsizes;
780 qeps[i] = (struct sunqe *) qe_devs[i]->priv; 775}
781 for (j = 0; j < 6; j++)
782 qe_devs[i]->dev_addr[j] = idprom->id_ethaddr[j];
783 qeps[i]->channel = i;
784 spin_lock_init(&qeps[i]->lock);
785 }
786 776
787 qecp = kmalloc(sizeof(struct sunqec), GFP_KERNEL); 777static struct sunqec * __init get_qec(struct sbus_dev *child_sdev)
788 if (qecp == NULL) 778{
789 goto out1; 779 struct sbus_dev *qec_sdev = child_sdev->parent;
790 qecp->qec_sdev = sdev; 780 struct sunqec *qecp;
791 781
792 for (i = 0; i < 4; i++) { 782 for (qecp = root_qec_dev; qecp; qecp = qecp->next_module) {
793 qecp->qes[i] = qeps[i]; 783 if (qecp->qec_sdev == qec_sdev)
794 qeps[i]->dev = qe_devs[i]; 784 break;
795 qeps[i]->parent = qecp;
796 } 785 }
786 if (!qecp) {
787 qecp = kzalloc(sizeof(struct sunqec), GFP_KERNEL);
788 if (qecp) {
789 u32 ctrl;
790
791 qecp->qec_sdev = qec_sdev;
792 qecp->gregs = sbus_ioremap(&qec_sdev->resource[0], 0,
793 GLOB_REG_SIZE,
794 "QEC Global Registers");
795 if (!qecp->gregs)
796 goto fail;
797
798 /* Make sure the QEC is in MACE mode. */
799 ctrl = sbus_readl(qecp->gregs + GLOB_CTRL);
800 ctrl &= 0xf0000000;
801 if (ctrl != GLOB_CTRL_MMODE) {
802 printk(KERN_ERR "qec: Not in MACE mode!\n");
803 goto fail;
804 }
797 805
798 res = -ENODEV; 806 if (qec_global_reset(qecp->gregs))
807 goto fail;
799 808
800 for (i = 0, child = sdev->child; i < 4; i++, child = child->next) { 809 qecp->qec_bursts = qec_get_burst(qec_sdev->ofdev.node);
801 /* Link in channel */
802 j = prom_getintdefault(child->prom_node, "channel#", -1);
803 if (j == -1)
804 goto out2;
805 qesdevs[j] = child;
806 }
807 810
808 for (i = 0; i < 4; i++) 811 qec_init_once(qecp, qec_sdev);
809 qeps[i]->qe_sdev = qesdevs[i];
810 812
811 /* Now map in the registers, QEC globals first. */ 813 if (request_irq(qec_sdev->irqs[0], &qec_interrupt,
812 qecp->gregs = sbus_ioremap(&sdev->resource[0], 0, 814 IRQF_SHARED, "qec", (void *) qecp)) {
813 GLOB_REG_SIZE, "QEC Global Registers"); 815 printk(KERN_ERR "qec: Can't register irq.\n");
814 if (!qecp->gregs) { 816 goto fail;
815 printk(KERN_ERR "QuadEther: Cannot map QEC global registers.\n"); 817 }
816 goto out2;
817 }
818 818
819 /* Make sure the QEC is in MACE mode. */ 819 qecp->next_module = root_qec_dev;
820 if ((sbus_readl(qecp->gregs + GLOB_CTRL) & 0xf0000000) != GLOB_CTRL_MMODE) { 820 root_qec_dev = qecp;
821 printk(KERN_ERR "QuadEther: AIEEE, QEC is not in MACE mode!\n"); 821 }
822 goto out3;
823 } 822 }
824 823
825 /* Reset the QEC. */ 824 return qecp;
826 if (qec_global_reset(qecp->gregs))
827 goto out3;
828 825
829 /* Find and set the burst sizes for the QEC, since it does 826fail:
830 * the actual dma for all 4 channels. 827 if (qecp->gregs)
831 */ 828 sbus_iounmap(qecp->gregs, GLOB_REG_SIZE);
832 bsizes = prom_getintdefault(sdev->prom_node, "burst-sizes", 0xff); 829 kfree(qecp);
833 bsizes &= 0xff; 830 return NULL;
834 bsizes_more = prom_getintdefault(sdev->bus->prom_node, "burst-sizes", 0xff); 831}
835 832
836 if (bsizes_more != 0xff) 833static int __init qec_ether_init(struct sbus_dev *sdev)
837 bsizes &= bsizes_more; 834{
838 if (bsizes == 0xff || (bsizes & DMA_BURST16) == 0 || 835 static unsigned version_printed;
839 (bsizes & DMA_BURST32)==0) 836 struct net_device *dev;
840 bsizes = (DMA_BURST32 - 1); 837 struct sunqe *qe;
838 struct sunqec *qecp;
839 int i, res;
841 840
842 qecp->qec_bursts = bsizes; 841 if (version_printed++ == 0)
842 printk(KERN_INFO "%s", version);
843 843
844 /* Perform one time QEC initialization, we never touch the QEC 844 dev = alloc_etherdev(sizeof(struct sunqe));
845 * globals again after this. 845 if (!dev)
846 */ 846 return -ENOMEM;
847 qec_init_once(qecp, sdev);
848
849 for (i = 0; i < 4; i++) {
850 struct sunqe *qe = qeps[i];
851 /* Map in QEC per-channel control registers. */
852 qe->qcregs = sbus_ioremap(&qe->qe_sdev->resource[0], 0,
853 CREG_REG_SIZE, "QEC Channel Registers");
854 if (!qe->qcregs) {
855 printk(KERN_ERR "QuadEther: Cannot map QE %d's channel registers.\n", i);
856 goto out4;
857 }
858 847
859 /* Map in per-channel AMD MACE registers. */ 848 qe = netdev_priv(dev);
860 qe->mregs = sbus_ioremap(&qe->qe_sdev->resource[1], 0,
861 MREGS_REG_SIZE, "QE MACE Registers");
862 if (!qe->mregs) {
863 printk(KERN_ERR "QuadEther: Cannot map QE %d's MACE registers.\n", i);
864 goto out4;
865 }
866 849
867 qe->qe_block = sbus_alloc_consistent(qe->qe_sdev, 850 i = of_getintprop_default(sdev->ofdev.node, "channel#", -1);
868 PAGE_SIZE, 851 if (i == -1) {
869 &qe->qblock_dvma); 852 struct sbus_dev *td = sdev->parent->child;
870 qe->buffers = sbus_alloc_consistent(qe->qe_sdev, 853 i = 0;
871 sizeof(struct sunqe_buffers), 854 while (td != sdev) {
872 &qe->buffers_dvma); 855 td = td->next;
873 if (qe->qe_block == NULL || qe->qblock_dvma == 0 || 856 i++;
874 qe->buffers == NULL || qe->buffers_dvma == 0) {
875 goto out4;
876 } 857 }
877
878 /* Stop this QE. */
879 qe_stop(qe);
880 } 858 }
859 qe->channel = i;
860 spin_lock_init(&qe->lock);
861
862 res = -ENODEV;
863 qecp = get_qec(sdev);
864 if (!qecp)
865 goto fail;
881 866
882 for (i = 0; i < 4; i++) { 867 qecp->qes[qe->channel] = qe;
883 SET_MODULE_OWNER(qe_devs[i]); 868 qe->dev = dev;
884 qe_devs[i]->open = qe_open; 869 qe->parent = qecp;
885 qe_devs[i]->stop = qe_close; 870 qe->qe_sdev = sdev;
886 qe_devs[i]->hard_start_xmit = qe_start_xmit;
887 qe_devs[i]->get_stats = qe_get_stats;
888 qe_devs[i]->set_multicast_list = qe_set_multicast;
889 qe_devs[i]->tx_timeout = qe_tx_timeout;
890 qe_devs[i]->watchdog_timeo = 5*HZ;
891 qe_devs[i]->irq = sdev->irqs[0];
892 qe_devs[i]->dma = 0;
893 qe_devs[i]->ethtool_ops = &qe_ethtool_ops;
894 }
895 871
896 /* QEC receives interrupts from each QE, then it sends the actual 872 res = -ENOMEM;
897 * IRQ to the cpu itself. Since QEC is the single point of 873 qe->qcregs = sbus_ioremap(&qe->qe_sdev->resource[0], 0,
898 * interrupt for all QE channels we register the IRQ handler 874 CREG_REG_SIZE, "QEC Channel Registers");
899 * for it now. 875 if (!qe->qcregs) {
900 */ 876 printk(KERN_ERR "qe: Cannot map channel registers.\n");
901 if (request_irq(sdev->irqs[0], &qec_interrupt, 877 goto fail;
902 SA_SHIRQ, "QuadEther", (void *) qecp)) {
903 printk(KERN_ERR "QuadEther: Can't register QEC master irq handler.\n");
904 res = -EAGAIN;
905 goto out4;
906 } 878 }
907 879
908 for (i = 0; i < 4; i++) { 880 qe->mregs = sbus_ioremap(&qe->qe_sdev->resource[1], 0,
909 if (register_netdev(qe_devs[i]) != 0) 881 MREGS_REG_SIZE, "QE MACE Registers");
910 goto out5; 882 if (!qe->mregs) {
883 printk(KERN_ERR "qe: Cannot map MACE registers.\n");
884 goto fail;
911 } 885 }
912 886
913 /* Report the QE channels. */ 887 qe->qe_block = sbus_alloc_consistent(qe->qe_sdev,
914 for (i = 0; i < 4; i++) { 888 PAGE_SIZE,
915 printk(KERN_INFO "%s: QuadEthernet channel[%d] ", qe_devs[i]->name, i); 889 &qe->qblock_dvma);
916 for (j = 0; j < 6; j++) 890 qe->buffers = sbus_alloc_consistent(qe->qe_sdev,
917 printk ("%2.2x%c", 891 sizeof(struct sunqe_buffers),
918 qe_devs[i]->dev_addr[j], 892 &qe->buffers_dvma);
919 j == 5 ? ' ': ':'); 893 if (qe->qe_block == NULL || qe->qblock_dvma == 0 ||
920 printk("\n"); 894 qe->buffers == NULL || qe->buffers_dvma == 0)
921 } 895 goto fail;
896
897 /* Stop this QE. */
898 qe_stop(qe);
899
900 SET_MODULE_OWNER(dev);
901 SET_NETDEV_DEV(dev, &sdev->ofdev.dev);
902
903 dev->open = qe_open;
904 dev->stop = qe_close;
905 dev->hard_start_xmit = qe_start_xmit;
906 dev->get_stats = qe_get_stats;
907 dev->set_multicast_list = qe_set_multicast;
908 dev->tx_timeout = qe_tx_timeout;
909 dev->watchdog_timeo = 5*HZ;
910 dev->irq = sdev->irqs[0];
911 dev->dma = 0;
912 dev->ethtool_ops = &qe_ethtool_ops;
913
914 res = register_netdev(dev);
915 if (res)
916 goto fail;
917
918 dev_set_drvdata(&sdev->ofdev.dev, qe);
919
920 printk(KERN_INFO "%s: qe channel[%d] ", dev->name, qe->channel);
921 for (i = 0; i < 6; i++)
922 printk ("%2.2x%c",
923 dev->dev_addr[i],
924 i == 5 ? ' ': ':');
925 printk("\n");
922 926
923 /* We are home free at this point, link the qe's into
924 * the master list for later driver exit.
925 */
926 qecp->next_module = root_qec_dev;
927 root_qec_dev = qecp;
928 927
929 return 0; 928 return 0;
930 929
931out5: 930fail:
932 while (i--) 931 if (qe->qcregs)
933 unregister_netdev(qe_devs[i]); 932 sbus_iounmap(qe->qcregs, CREG_REG_SIZE);
934 free_irq(sdev->irqs[0], (void *)qecp); 933 if (qe->mregs)
935out4: 934 sbus_iounmap(qe->mregs, MREGS_REG_SIZE);
936 for (i = 0; i < 4; i++) { 935 if (qe->qe_block)
937 struct sunqe *qe = (struct sunqe *)qe_devs[i]->priv; 936 sbus_free_consistent(qe->qe_sdev,
938 937 PAGE_SIZE,
939 if (qe->qcregs) 938 qe->qe_block,
940 sbus_iounmap(qe->qcregs, CREG_REG_SIZE); 939 qe->qblock_dvma);
941 if (qe->mregs) 940 if (qe->buffers)
942 sbus_iounmap(qe->mregs, MREGS_REG_SIZE); 941 sbus_free_consistent(qe->qe_sdev,
943 if (qe->qe_block) 942 sizeof(struct sunqe_buffers),
944 sbus_free_consistent(qe->qe_sdev, 943 qe->buffers,
945 PAGE_SIZE, 944 qe->buffers_dvma);
946 qe->qe_block, 945
947 qe->qblock_dvma); 946 free_netdev(dev);
948 if (qe->buffers) 947
949 sbus_free_consistent(qe->qe_sdev,
950 sizeof(struct sunqe_buffers),
951 qe->buffers,
952 qe->buffers_dvma);
953 }
954out3:
955 sbus_iounmap(qecp->gregs, GLOB_REG_SIZE);
956out2:
957 kfree(qecp);
958out1:
959 i = 4;
960out:
961 while (i--)
962 free_netdev(qe_devs[i]);
963 return res; 948 return res;
964} 949}
965 950
966static int __init qec_match(struct sbus_dev *sdev) 951static int __devinit qec_sbus_probe(struct of_device *dev, const struct of_device_id *match)
967{ 952{
968 struct sbus_dev *sibling; 953 struct sbus_dev *sdev = to_sbus_device(&dev->dev);
969 int i;
970
971 if (strcmp(sdev->prom_name, "qec") != 0)
972 return 0;
973 954
974 /* QEC can be parent of either QuadEthernet or BigMAC 955 return qec_ether_init(sdev);
975 * children. Do not confuse this with qfe/SUNW,qfe
976 * which is a quad-happymeal card and handled by
977 * a different driver.
978 */
979 sibling = sdev->child;
980 for (i = 0; i < 4; i++) {
981 if (sibling == NULL)
982 return 0;
983 if (strcmp(sibling->prom_name, "qe") != 0)
984 return 0;
985 sibling = sibling->next;
986 }
987 return 1;
988} 956}
989 957
990static int __init qec_probe(void) 958static int __devexit qec_sbus_remove(struct of_device *dev)
991{ 959{
992 struct net_device *dev = NULL; 960 struct sunqe *qp = dev_get_drvdata(&dev->dev);
993 struct sbus_bus *bus; 961 struct net_device *net_dev = qp->dev;
994 struct sbus_dev *sdev = NULL; 962
995 static int called; 963 unregister_netdevice(net_dev);
996 int cards = 0, v; 964
997 965 sbus_iounmap(qp->qcregs, CREG_REG_SIZE);
998 root_qec_dev = NULL; 966 sbus_iounmap(qp->mregs, MREGS_REG_SIZE);
999 967 sbus_free_consistent(qp->qe_sdev,
1000 if (called) 968 PAGE_SIZE,
1001 return -ENODEV; 969 qp->qe_block,
1002 called++; 970 qp->qblock_dvma);
1003 971 sbus_free_consistent(qp->qe_sdev,
1004 for_each_sbus(bus) { 972 sizeof(struct sunqe_buffers),
1005 for_each_sbusdev(sdev, bus) { 973 qp->buffers,
1006 if (cards) 974 qp->buffers_dvma);
1007 dev = NULL; 975
1008 976 free_netdev(net_dev);
1009 if (qec_match(sdev)) { 977
1010 cards++; 978 dev_set_drvdata(&dev->dev, NULL);
1011 if ((v = qec_ether_init(dev, sdev))) 979
1012 return v;
1013 }
1014 }
1015 }
1016 if (!cards)
1017 return -ENODEV;
1018 return 0; 980 return 0;
1019} 981}
1020 982
1021static void __exit qec_cleanup(void) 983static struct of_device_id qec_sbus_match[] = {
984 {
985 .name = "qe",
986 },
987 {},
988};
989
990MODULE_DEVICE_TABLE(of, qec_sbus_match);
991
992static struct of_platform_driver qec_sbus_driver = {
993 .name = "qec",
994 .match_table = qec_sbus_match,
995 .probe = qec_sbus_probe,
996 .remove = __devexit_p(qec_sbus_remove),
997};
998
999static int __init qec_init(void)
1000{
1001 return of_register_driver(&qec_sbus_driver, &sbus_bus_type);
1002}
1003
1004static void __exit qec_exit(void)
1022{ 1005{
1023 struct sunqec *next_qec; 1006 of_unregister_driver(&qec_sbus_driver);
1024 int i;
1025 1007
1026 while (root_qec_dev) { 1008 while (root_qec_dev) {
1027 next_qec = root_qec_dev->next_module; 1009 struct sunqec *next = root_qec_dev->next_module;
1028 1010
1029 /* Release all four QE channels, then the QEC itself. */ 1011 free_irq(root_qec_dev->qec_sdev->irqs[0],
1030 for (i = 0; i < 4; i++) { 1012 (void *) root_qec_dev);
1031 unregister_netdev(root_qec_dev->qes[i]->dev);
1032 sbus_iounmap(root_qec_dev->qes[i]->qcregs, CREG_REG_SIZE);
1033 sbus_iounmap(root_qec_dev->qes[i]->mregs, MREGS_REG_SIZE);
1034 sbus_free_consistent(root_qec_dev->qes[i]->qe_sdev,
1035 PAGE_SIZE,
1036 root_qec_dev->qes[i]->qe_block,
1037 root_qec_dev->qes[i]->qblock_dvma);
1038 sbus_free_consistent(root_qec_dev->qes[i]->qe_sdev,
1039 sizeof(struct sunqe_buffers),
1040 root_qec_dev->qes[i]->buffers,
1041 root_qec_dev->qes[i]->buffers_dvma);
1042 free_netdev(root_qec_dev->qes[i]->dev);
1043 }
1044 free_irq(root_qec_dev->qec_sdev->irqs[0], (void *)root_qec_dev);
1045 sbus_iounmap(root_qec_dev->gregs, GLOB_REG_SIZE); 1013 sbus_iounmap(root_qec_dev->gregs, GLOB_REG_SIZE);
1014
1046 kfree(root_qec_dev); 1015 kfree(root_qec_dev);
1047 root_qec_dev = next_qec; 1016
1017 root_qec_dev = next;
1048 } 1018 }
1049} 1019}
1050 1020
1051module_init(qec_probe); 1021module_init(qec_init);
1052module_exit(qec_cleanup); 1022module_exit(qec_exit);
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c
index c2ec9fd8c31d..8b53ded66d37 100644
--- a/drivers/net/tc35815.c
+++ b/drivers/net/tc35815.c
@@ -880,7 +880,7 @@ tc35815_open(struct net_device *dev)
880 */ 880 */
881 881
882 if (dev->irq == 0 || 882 if (dev->irq == 0 ||
883 request_irq(dev->irq, &tc35815_interrupt, SA_SHIRQ, cardname, dev)) { 883 request_irq(dev->irq, &tc35815_interrupt, IRQF_SHARED, cardname, dev)) {
884 return -EAGAIN; 884 return -EAGAIN;
885 } 885 }
886 886
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index b2ddd4522a87..f645921aff8b 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -15,7 +15,6 @@
15 * notice is accompanying it. 15 * notice is accompanying it.
16 */ 16 */
17 17
18#include <linux/config.h>
19 18
20#include <linux/module.h> 19#include <linux/module.h>
21#include <linux/moduleparam.h> 20#include <linux/moduleparam.h>
@@ -69,8 +68,8 @@
69 68
70#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
71#define PFX DRV_MODULE_NAME ": " 70#define PFX DRV_MODULE_NAME ": "
72#define DRV_MODULE_VERSION "3.60" 71#define DRV_MODULE_VERSION "3.62"
73#define DRV_MODULE_RELDATE "June 17, 2006" 72#define DRV_MODULE_RELDATE "June 30, 2006"
74 73
75#define TG3_DEF_MAC_MODE 0 74#define TG3_DEF_MAC_MODE 0
76#define TG3_DEF_RX_MODE 0 75#define TG3_DEF_RX_MODE 0
@@ -3195,7 +3194,7 @@ static int tg3_vlan_rx(struct tg3 *tp, struct sk_buff *skb, u16 vlan_tag)
3195 */ 3194 */
3196static int tg3_rx(struct tg3 *tp, int budget) 3195static int tg3_rx(struct tg3 *tp, int budget)
3197{ 3196{
3198 u32 work_mask; 3197 u32 work_mask, rx_std_posted = 0;
3199 u32 sw_idx = tp->rx_rcb_ptr; 3198 u32 sw_idx = tp->rx_rcb_ptr;
3200 u16 hw_idx; 3199 u16 hw_idx;
3201 int received; 3200 int received;
@@ -3222,6 +3221,7 @@ static int tg3_rx(struct tg3 *tp, int budget)
3222 mapping); 3221 mapping);
3223 skb = tp->rx_std_buffers[desc_idx].skb; 3222 skb = tp->rx_std_buffers[desc_idx].skb;
3224 post_ptr = &tp->rx_std_ptr; 3223 post_ptr = &tp->rx_std_ptr;
3224 rx_std_posted++;
3225 } else if (opaque_key == RXD_OPAQUE_RING_JUMBO) { 3225 } else if (opaque_key == RXD_OPAQUE_RING_JUMBO) {
3226 dma_addr = pci_unmap_addr(&tp->rx_jumbo_buffers[desc_idx], 3226 dma_addr = pci_unmap_addr(&tp->rx_jumbo_buffers[desc_idx],
3227 mapping); 3227 mapping);
@@ -3309,6 +3309,15 @@ static int tg3_rx(struct tg3 *tp, int budget)
3309 3309
3310next_pkt: 3310next_pkt:
3311 (*post_ptr)++; 3311 (*post_ptr)++;
3312
3313 if (unlikely(rx_std_posted >= tp->rx_std_max_post)) {
3314 u32 idx = *post_ptr % TG3_RX_RING_SIZE;
3315
3316 tw32_rx_mbox(MAILBOX_RCV_STD_PROD_IDX +
3317 TG3_64BIT_REG_LOW, idx);
3318 work_mask &= ~RXD_OPAQUE_RING_STD;
3319 rx_std_posted = 0;
3320 }
3312next_pkt_nopost: 3321next_pkt_nopost:
3313 sw_idx++; 3322 sw_idx++;
3314 sw_idx %= TG3_RX_RCB_RING_SIZE(tp); 3323 sw_idx %= TG3_RX_RCB_RING_SIZE(tp);
@@ -3780,7 +3789,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3780#if TG3_TSO_SUPPORT != 0 3789#if TG3_TSO_SUPPORT != 0
3781 mss = 0; 3790 mss = 0;
3782 if (skb->len > (tp->dev->mtu + ETH_HLEN) && 3791 if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
3783 (mss = skb_shinfo(skb)->tso_size) != 0) { 3792 (mss = skb_shinfo(skb)->gso_size) != 0) {
3784 int tcp_opt_len, ip_tcp_len; 3793 int tcp_opt_len, ip_tcp_len;
3785 3794
3786 if (skb_header_cloned(skb) && 3795 if (skb_header_cloned(skb) &&
@@ -3789,18 +3798,24 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3789 goto out_unlock; 3798 goto out_unlock;
3790 } 3799 }
3791 3800
3792 tcp_opt_len = ((skb->h.th->doff - 5) * 4); 3801 if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
3793 ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr); 3802 mss |= (skb_headlen(skb) - ETH_HLEN) << 9;
3803 else {
3804 tcp_opt_len = ((skb->h.th->doff - 5) * 4);
3805 ip_tcp_len = (skb->nh.iph->ihl * 4) +
3806 sizeof(struct tcphdr);
3807
3808 skb->nh.iph->check = 0;
3809 skb->nh.iph->tot_len = htons(mss + ip_tcp_len +
3810 tcp_opt_len);
3811 mss |= (ip_tcp_len + tcp_opt_len) << 9;
3812 }
3794 3813
3795 base_flags |= (TXD_FLAG_CPU_PRE_DMA | 3814 base_flags |= (TXD_FLAG_CPU_PRE_DMA |
3796 TXD_FLAG_CPU_POST_DMA); 3815 TXD_FLAG_CPU_POST_DMA);
3797 3816
3798 skb->nh.iph->check = 0;
3799 skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
3800
3801 skb->h.th->check = 0; 3817 skb->h.th->check = 0;
3802 3818
3803 mss |= (ip_tcp_len + tcp_opt_len) << 9;
3804 } 3819 }
3805 else if (skb->ip_summed == CHECKSUM_HW) 3820 else if (skb->ip_summed == CHECKSUM_HW)
3806 base_flags |= TXD_FLAG_TCPUDP_CSUM; 3821 base_flags |= TXD_FLAG_TCPUDP_CSUM;
@@ -3870,6 +3885,40 @@ out_unlock:
3870 return NETDEV_TX_OK; 3885 return NETDEV_TX_OK;
3871} 3886}
3872 3887
3888#if TG3_TSO_SUPPORT != 0
3889static int tg3_start_xmit_dma_bug(struct sk_buff *, struct net_device *);
3890
3891/* Use GSO to workaround a rare TSO bug that may be triggered when the
3892 * TSO header is greater than 80 bytes.
3893 */
3894static int tg3_tso_bug(struct tg3 *tp, struct sk_buff *skb)
3895{
3896 struct sk_buff *segs, *nskb;
3897
3898 /* Estimate the number of fragments in the worst case */
3899 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->gso_segs * 3))) {
3900 netif_stop_queue(tp->dev);
3901 return NETDEV_TX_BUSY;
3902 }
3903
3904 segs = skb_gso_segment(skb, tp->dev->features & ~NETIF_F_TSO);
3905 if (unlikely(IS_ERR(segs)))
3906 goto tg3_tso_bug_end;
3907
3908 do {
3909 nskb = segs;
3910 segs = segs->next;
3911 nskb->next = NULL;
3912 tg3_start_xmit_dma_bug(nskb, tp->dev);
3913 } while (segs);
3914
3915tg3_tso_bug_end:
3916 dev_kfree_skb(skb);
3917
3918 return NETDEV_TX_OK;
3919}
3920#endif
3921
3873/* hard_start_xmit for devices that have the 4G bug and/or 40-bit bug and 3922/* hard_start_xmit for devices that have the 4G bug and/or 40-bit bug and
3874 * support TG3_FLG2_HW_TSO_1 or firmware TSO only. 3923 * support TG3_FLG2_HW_TSO_1 or firmware TSO only.
3875 */ 3924 */
@@ -3905,8 +3954,8 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
3905#if TG3_TSO_SUPPORT != 0 3954#if TG3_TSO_SUPPORT != 0
3906 mss = 0; 3955 mss = 0;
3907 if (skb->len > (tp->dev->mtu + ETH_HLEN) && 3956 if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
3908 (mss = skb_shinfo(skb)->tso_size) != 0) { 3957 (mss = skb_shinfo(skb)->gso_size) != 0) {
3909 int tcp_opt_len, ip_tcp_len; 3958 int tcp_opt_len, ip_tcp_len, hdr_len;
3910 3959
3911 if (skb_header_cloned(skb) && 3960 if (skb_header_cloned(skb) &&
3912 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) { 3961 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
@@ -3917,11 +3966,16 @@ static int tg3_start_xmit_dma_bug(struct sk_buff *skb, struct net_device *dev)
3917 tcp_opt_len = ((skb->h.th->doff - 5) * 4); 3966 tcp_opt_len = ((skb->h.th->doff - 5) * 4);
3918 ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr); 3967 ip_tcp_len = (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
3919 3968
3969 hdr_len = ip_tcp_len + tcp_opt_len;
3970 if (unlikely((ETH_HLEN + hdr_len) > 80) &&
3971 (tp->tg3_flags2 & TG3_FLG2_HW_TSO_1_BUG))
3972 return (tg3_tso_bug(tp, skb));
3973
3920 base_flags |= (TXD_FLAG_CPU_PRE_DMA | 3974 base_flags |= (TXD_FLAG_CPU_PRE_DMA |
3921 TXD_FLAG_CPU_POST_DMA); 3975 TXD_FLAG_CPU_POST_DMA);
3922 3976
3923 skb->nh.iph->check = 0; 3977 skb->nh.iph->check = 0;
3924 skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len); 3978 skb->nh.iph->tot_len = htons(mss + hdr_len);
3925 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) { 3979 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
3926 skb->h.th->check = 0; 3980 skb->h.th->check = 0;
3927 base_flags &= ~TXD_FLAG_TCPUDP_CSUM; 3981 base_flags &= ~TXD_FLAG_TCPUDP_CSUM;
@@ -5981,7 +6035,13 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
5981 } 6035 }
5982 6036
5983 /* Setup replenish threshold. */ 6037 /* Setup replenish threshold. */
5984 tw32(RCVBDI_STD_THRESH, tp->rx_pending / 8); 6038 val = tp->rx_pending / 8;
6039 if (val == 0)
6040 val = 1;
6041 else if (val > tp->rx_std_max_post)
6042 val = tp->rx_std_max_post;
6043
6044 tw32(RCVBDI_STD_THRESH, val);
5985 6045
5986 /* Initialize TG3_BDINFO's at: 6046 /* Initialize TG3_BDINFO's at:
5987 * RCVDBDI_STD_BD: standard eth size rx ring 6047 * RCVDBDI_STD_BD: standard eth size rx ring
@@ -6141,8 +6201,12 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6141#endif 6201#endif
6142 6202
6143 /* Receive/send statistics. */ 6203 /* Receive/send statistics. */
6144 if ((rdmac_mode & RDMAC_MODE_FIFO_SIZE_128) && 6204 if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) {
6145 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)) { 6205 val = tr32(RCVLPC_STATS_ENABLE);
6206 val &= ~RCVLPC_STATSENAB_DACK_FIX;
6207 tw32(RCVLPC_STATS_ENABLE, val);
6208 } else if ((rdmac_mode & RDMAC_MODE_FIFO_SIZE_128) &&
6209 (tp->tg3_flags2 & TG3_FLG2_TSO_CAPABLE)) {
6146 val = tr32(RCVLPC_STATS_ENABLE); 6210 val = tr32(RCVLPC_STATS_ENABLE);
6147 val &= ~RCVLPC_STATSENAB_LNGBRST_RFIX; 6211 val &= ~RCVLPC_STATSENAB_LNGBRST_RFIX;
6148 tw32(RCVLPC_STATS_ENABLE, val); 6212 tw32(RCVLPC_STATS_ENABLE, val);
@@ -6644,12 +6708,12 @@ static int tg3_request_irq(struct tg3 *tp)
6644 fn = tg3_msi; 6708 fn = tg3_msi;
6645 if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI) 6709 if (tp->tg3_flags2 & TG3_FLG2_1SHOT_MSI)
6646 fn = tg3_msi_1shot; 6710 fn = tg3_msi_1shot;
6647 flags = SA_SAMPLE_RANDOM; 6711 flags = IRQF_SAMPLE_RANDOM;
6648 } else { 6712 } else {
6649 fn = tg3_interrupt; 6713 fn = tg3_interrupt;
6650 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS) 6714 if (tp->tg3_flags & TG3_FLAG_TAGGED_STATUS)
6651 fn = tg3_interrupt_tagged; 6715 fn = tg3_interrupt_tagged;
6652 flags = SA_SHIRQ | SA_SAMPLE_RANDOM; 6716 flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
6653 } 6717 }
6654 return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev)); 6718 return (request_irq(tp->pdev->irq, fn, flags, dev->name, dev));
6655} 6719}
@@ -6668,7 +6732,7 @@ static int tg3_test_interrupt(struct tg3 *tp)
6668 free_irq(tp->pdev->irq, dev); 6732 free_irq(tp->pdev->irq, dev);
6669 6733
6670 err = request_irq(tp->pdev->irq, tg3_test_isr, 6734 err = request_irq(tp->pdev->irq, tg3_test_isr,
6671 SA_SHIRQ | SA_SAMPLE_RANDOM, dev->name, dev); 6735 IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
6672 if (err) 6736 if (err)
6673 return err; 6737 return err;
6674 6738
@@ -7829,6 +7893,12 @@ static int tg3_set_tso(struct net_device *dev, u32 value)
7829 return -EINVAL; 7893 return -EINVAL;
7830 return 0; 7894 return 0;
7831 } 7895 }
7896 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO_2) {
7897 if (value)
7898 dev->features |= NETIF_F_TSO6;
7899 else
7900 dev->features &= ~NETIF_F_TSO6;
7901 }
7832 return ethtool_op_set_tso(dev, value); 7902 return ethtool_op_set_tso(dev, value);
7833} 7903}
7834#endif 7904#endif
@@ -8738,6 +8808,9 @@ static void tg3_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
8738{ 8808{
8739 struct tg3 *tp = netdev_priv(dev); 8809 struct tg3 *tp = netdev_priv(dev);
8740 8810
8811 if (netif_running(dev))
8812 tg3_netif_stop(tp);
8813
8741 tg3_full_lock(tp, 0); 8814 tg3_full_lock(tp, 0);
8742 8815
8743 tp->vlgrp = grp; 8816 tp->vlgrp = grp;
@@ -8746,16 +8819,25 @@ static void tg3_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
8746 __tg3_set_rx_mode(dev); 8819 __tg3_set_rx_mode(dev);
8747 8820
8748 tg3_full_unlock(tp); 8821 tg3_full_unlock(tp);
8822
8823 if (netif_running(dev))
8824 tg3_netif_start(tp);
8749} 8825}
8750 8826
8751static void tg3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) 8827static void tg3_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
8752{ 8828{
8753 struct tg3 *tp = netdev_priv(dev); 8829 struct tg3 *tp = netdev_priv(dev);
8754 8830
8831 if (netif_running(dev))
8832 tg3_netif_stop(tp);
8833
8755 tg3_full_lock(tp, 0); 8834 tg3_full_lock(tp, 0);
8756 if (tp->vlgrp) 8835 if (tp->vlgrp)
8757 tp->vlgrp->vlan_devices[vid] = NULL; 8836 tp->vlgrp->vlan_devices[vid] = NULL;
8758 tg3_full_unlock(tp); 8837 tg3_full_unlock(tp);
8838
8839 if (netif_running(dev))
8840 tg3_netif_start(tp);
8759} 8841}
8760#endif 8842#endif
8761 8843
@@ -10160,8 +10242,14 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10160 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) { 10242 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) {
10161 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2; 10243 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2;
10162 tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI; 10244 tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI;
10163 } else 10245 } else {
10164 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_1; 10246 tp->tg3_flags2 |= TG3_FLG2_HW_TSO_1 |
10247 TG3_FLG2_HW_TSO_1_BUG;
10248 if (GET_ASIC_REV(tp->pci_chip_rev_id) ==
10249 ASIC_REV_5750 &&
10250 tp->pci_chip_rev_id >= CHIPREV_ID_5750_C2)
10251 tp->tg3_flags2 &= ~TG3_FLG2_HW_TSO_1_BUG;
10252 }
10165 } 10253 }
10166 10254
10167 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 && 10255 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
@@ -10533,6 +10621,16 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10533 (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) 10621 (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0)
10534 tp->rx_offset = 0; 10622 tp->rx_offset = 0;
10535 10623
10624 tp->rx_std_max_post = TG3_RX_RING_SIZE;
10625
10626 /* Increment the rx prod index on the rx std ring by at most
10627 * 8 for these chips to workaround hw errata.
10628 */
10629 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 ||
10630 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
10631 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
10632 tp->rx_std_max_post = 8;
10633
10536 /* By default, disable wake-on-lan. User can change this 10634 /* By default, disable wake-on-lan. User can change this
10537 * using ETHTOOL_SWOL. 10635 * using ETHTOOL_SWOL.
10538 */ 10636 */
@@ -10549,11 +10647,13 @@ static int __devinit tg3_get_macaddr_sparc(struct tg3 *tp)
10549 struct pcidev_cookie *pcp = pdev->sysdata; 10647 struct pcidev_cookie *pcp = pdev->sysdata;
10550 10648
10551 if (pcp != NULL) { 10649 if (pcp != NULL) {
10552 int node = pcp->prom_node; 10650 unsigned char *addr;
10651 int len;
10553 10652
10554 if (prom_getproplen(node, "local-mac-address") == 6) { 10653 addr = of_get_property(pcp->prom_node, "local-mac-address",
10555 prom_getproperty(node, "local-mac-address", 10654 &len);
10556 dev->dev_addr, 6); 10655 if (addr && len == 6) {
10656 memcpy(dev->dev_addr, addr, 6);
10557 memcpy(dev->perm_addr, dev->dev_addr, 6); 10657 memcpy(dev->perm_addr, dev->dev_addr, 6);
10558 return 0; 10658 return 0;
10559 } 10659 }
@@ -11419,8 +11519,11 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11419 * Firmware TSO on older chips gives lower performance, so it 11519 * Firmware TSO on older chips gives lower performance, so it
11420 * is off by default, but can be enabled using ethtool. 11520 * is off by default, but can be enabled using ethtool.
11421 */ 11521 */
11422 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) 11522 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
11423 dev->features |= NETIF_F_TSO; 11523 dev->features |= NETIF_F_TSO;
11524 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO_2)
11525 dev->features |= NETIF_F_TSO6;
11526 }
11424 11527
11425#endif 11528#endif
11426 11529
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 8209da5dd15f..ba2c98711c88 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -125,6 +125,7 @@
125#define CHIPREV_ID_5750_A0 0x4000 125#define CHIPREV_ID_5750_A0 0x4000
126#define CHIPREV_ID_5750_A1 0x4001 126#define CHIPREV_ID_5750_A1 0x4001
127#define CHIPREV_ID_5750_A3 0x4003 127#define CHIPREV_ID_5750_A3 0x4003
128#define CHIPREV_ID_5750_C2 0x4202
128#define CHIPREV_ID_5752_A0_HW 0x5000 129#define CHIPREV_ID_5752_A0_HW 0x5000
129#define CHIPREV_ID_5752_A0 0x6000 130#define CHIPREV_ID_5752_A0 0x6000
130#define CHIPREV_ID_5752_A1 0x6001 131#define CHIPREV_ID_5752_A1 0x6001
@@ -760,6 +761,7 @@
760#define RCVLPC_STATSCTRL_ENABLE 0x00000001 761#define RCVLPC_STATSCTRL_ENABLE 0x00000001
761#define RCVLPC_STATSCTRL_FASTUPD 0x00000002 762#define RCVLPC_STATSCTRL_FASTUPD 0x00000002
762#define RCVLPC_STATS_ENABLE 0x00002018 763#define RCVLPC_STATS_ENABLE 0x00002018
764#define RCVLPC_STATSENAB_DACK_FIX 0x00040000
763#define RCVLPC_STATSENAB_LNGBRST_RFIX 0x00400000 765#define RCVLPC_STATSENAB_LNGBRST_RFIX 0x00400000
764#define RCVLPC_STATS_INCMASK 0x0000201c 766#define RCVLPC_STATS_INCMASK 0x0000201c
765/* 0x2020 --> 0x2100 unused */ 767/* 0x2020 --> 0x2100 unused */
@@ -2137,6 +2139,7 @@ struct tg3 {
2137 struct tg3_rx_buffer_desc *rx_std; 2139 struct tg3_rx_buffer_desc *rx_std;
2138 struct ring_info *rx_std_buffers; 2140 struct ring_info *rx_std_buffers;
2139 dma_addr_t rx_std_mapping; 2141 dma_addr_t rx_std_mapping;
2142 u32 rx_std_max_post;
2140 2143
2141 struct tg3_rx_buffer_desc *rx_jumbo; 2144 struct tg3_rx_buffer_desc *rx_jumbo;
2142 struct ring_info *rx_jumbo_buffers; 2145 struct ring_info *rx_jumbo_buffers;
@@ -2191,7 +2194,7 @@ struct tg3 {
2191#define TG3_FLAG_INIT_COMPLETE 0x80000000 2194#define TG3_FLAG_INIT_COMPLETE 0x80000000
2192 u32 tg3_flags2; 2195 u32 tg3_flags2;
2193#define TG3_FLG2_RESTART_TIMER 0x00000001 2196#define TG3_FLG2_RESTART_TIMER 0x00000001
2194/* 0x00000002 available */ 2197#define TG3_FLG2_HW_TSO_1_BUG 0x00000002
2195#define TG3_FLG2_NO_ETH_WIRE_SPEED 0x00000004 2198#define TG3_FLG2_NO_ETH_WIRE_SPEED 0x00000004
2196#define TG3_FLG2_IS_5788 0x00000008 2199#define TG3_FLG2_IS_5788 0x00000008
2197#define TG3_FLG2_MAX_RXPEND_64 0x00000010 2200#define TG3_FLG2_MAX_RXPEND_64 0x00000010
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index 12076f8f942c..23c0017f25a9 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -943,7 +943,7 @@ static int TLan_Open( struct net_device *dev )
943 int err; 943 int err;
944 944
945 priv->tlanRev = TLan_DioRead8( dev->base_addr, TLAN_DEF_REVISION ); 945 priv->tlanRev = TLan_DioRead8( dev->base_addr, TLAN_DEF_REVISION );
946 err = request_irq( dev->irq, TLan_HandleInterrupt, SA_SHIRQ, TLanSignature, dev ); 946 err = request_irq( dev->irq, TLan_HandleInterrupt, IRQF_SHARED, TLanSignature, dev );
947 947
948 if ( err ) { 948 if ( err ) {
949 printk(KERN_ERR "TLAN: Cannot open %s because IRQ %d is already in use.\n", dev->name, dev->irq ); 949 printk(KERN_ERR "TLAN: Cannot open %s because IRQ %d is already in use.\n", dev->name, dev->irq );
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c
index 41e0cd8f4786..465921e3874c 100644
--- a/drivers/net/tokenring/3c359.c
+++ b/drivers/net/tokenring/3c359.c
@@ -42,7 +42,6 @@
42 42
43#define XL_DEBUG 0 43#define XL_DEBUG 0
44 44
45#include <linux/config.h>
46#include <linux/module.h> 45#include <linux/module.h>
47#include <linux/kernel.h> 46#include <linux/kernel.h>
48#include <linux/errno.h> 47#include <linux/errno.h>
@@ -577,7 +576,7 @@ static int xl_open(struct net_device *dev)
577 576
578 u16 switchsettings, switchsettings_eeprom ; 577 u16 switchsettings, switchsettings_eeprom ;
579 578
580 if(request_irq(dev->irq, &xl_interrupt, SA_SHIRQ , "3c359", dev)) { 579 if(request_irq(dev->irq, &xl_interrupt, IRQF_SHARED , "3c359", dev)) {
581 return -EAGAIN; 580 return -EAGAIN;
582 } 581 }
583 582
diff --git a/drivers/net/tokenring/abyss.c b/drivers/net/tokenring/abyss.c
index 649d8ea354f5..1bdd3beefbe5 100644
--- a/drivers/net/tokenring/abyss.c
+++ b/drivers/net/tokenring/abyss.c
@@ -123,7 +123,7 @@ static int __devinit abyss_attach(struct pci_dev *pdev, const struct pci_device_
123 goto err_out_trdev; 123 goto err_out_trdev;
124 } 124 }
125 125
126 ret = request_irq(pdev->irq, tms380tr_interrupt, SA_SHIRQ, 126 ret = request_irq(pdev->irq, tms380tr_interrupt, IRQF_SHARED,
127 dev->name, dev); 127 dev->name, dev);
128 if (ret) 128 if (ret)
129 goto err_out_region; 129 goto err_out_region;
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index c58a4c31d0dd..28d968ffd5d0 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -100,7 +100,6 @@
100 100
101#define STREAMER_IOCTL 0 101#define STREAMER_IOCTL 0
102 102
103#include <linux/config.h>
104#include <linux/module.h> 103#include <linux/module.h>
105#include <linux/kernel.h> 104#include <linux/kernel.h>
106#include <linux/errno.h> 105#include <linux/errno.h>
@@ -602,7 +601,7 @@ static int streamer_open(struct net_device *dev)
602 rc=streamer_reset(dev); 601 rc=streamer_reset(dev);
603 } 602 }
604 603
605 if (request_irq(dev->irq, &streamer_interrupt, SA_SHIRQ, "lanstreamer", dev)) { 604 if (request_irq(dev->irq, &streamer_interrupt, IRQF_SHARED, "lanstreamer", dev)) {
606 return -EAGAIN; 605 return -EAGAIN;
607 } 606 }
608#if STREAMER_DEBUG 607#if STREAMER_DEBUG
diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
index 19e6f4dfd69c..666bbaaae82f 100644
--- a/drivers/net/tokenring/madgemc.c
+++ b/drivers/net/tokenring/madgemc.c
@@ -311,7 +311,7 @@ static int __devinit madgemc_probe(struct device *device)
311 */ 311 */
312 outb(0, dev->base_addr + MC_CONTROL_REG0); /* sanity */ 312 outb(0, dev->base_addr + MC_CONTROL_REG0); /* sanity */
313 madgemc_setsifsel(dev, 1); 313 madgemc_setsifsel(dev, 1);
314 if (request_irq(dev->irq, madgemc_interrupt, SA_SHIRQ, 314 if (request_irq(dev->irq, madgemc_interrupt, IRQF_SHARED,
315 "madgemc", dev)) { 315 "madgemc", dev)) {
316 ret = -EBUSY; 316 ret = -EBUSY;
317 goto getout3; 317 goto getout3;
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c
index 23032a7bc0a9..85831484bc40 100644
--- a/drivers/net/tokenring/olympic.c
+++ b/drivers/net/tokenring/olympic.c
@@ -80,7 +80,6 @@
80#define OLYMPIC_DEBUG 0 80#define OLYMPIC_DEBUG 0
81 81
82 82
83#include <linux/config.h>
84#include <linux/module.h> 83#include <linux/module.h>
85#include <linux/kernel.h> 84#include <linux/kernel.h>
86#include <linux/errno.h> 85#include <linux/errno.h>
@@ -217,7 +216,7 @@ static int __devinit olympic_probe(struct pci_dev *pdev, const struct pci_device
217 dev = alloc_trdev(sizeof(struct olympic_private)) ; 216 dev = alloc_trdev(sizeof(struct olympic_private)) ;
218 if (!dev) { 217 if (!dev) {
219 i = -ENOMEM; 218 i = -ENOMEM;
220 goto op_free_dev; 219 goto op_release_dev;
221 } 220 }
222 221
223 olympic_priv = dev->priv ; 222 olympic_priv = dev->priv ;
@@ -282,8 +281,8 @@ op_free_iomap:
282 if (olympic_priv->olympic_lap) 281 if (olympic_priv->olympic_lap)
283 iounmap(olympic_priv->olympic_lap); 282 iounmap(olympic_priv->olympic_lap);
284 283
285op_free_dev:
286 free_netdev(dev); 284 free_netdev(dev);
285op_release_dev:
287 pci_release_regions(pdev); 286 pci_release_regions(pdev);
288 287
289op_disable_dev: 288op_disable_dev:
@@ -446,7 +445,7 @@ static int olympic_open(struct net_device *dev)
446 445
447 olympic_init(dev); 446 olympic_init(dev);
448 447
449 if(request_irq(dev->irq, &olympic_interrupt, SA_SHIRQ , "olympic", dev)) { 448 if(request_irq(dev->irq, &olympic_interrupt, IRQF_SHARED , "olympic", dev)) {
450 return -EAGAIN; 449 return -EAGAIN;
451 } 450 }
452 451
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index 67d2b596ce22..cd2e0251e2bc 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -29,7 +29,6 @@
29 */ 29 */
30 30
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/config.h>
33#include <linux/kernel.h> 32#include <linux/kernel.h>
34#include <linux/types.h> 33#include <linux/types.h>
35#include <linux/fcntl.h> 34#include <linux/fcntl.h>
@@ -532,7 +531,7 @@ static int __init smctr_chk_mca(struct net_device *dev)
532 dev->irq = 15; 531 dev->irq = 15;
533 break; 532 break;
534 } 533 }
535 if (request_irq(dev->irq, smctr_interrupt, SA_SHIRQ, smctr_name, dev)) { 534 if (request_irq(dev->irq, smctr_interrupt, IRQF_SHARED, smctr_name, dev)) {
536 release_region(dev->base_addr, SMCTR_IO_EXTENT); 535 release_region(dev->base_addr, SMCTR_IO_EXTENT);
537 return -ENODEV; 536 return -ENODEV;
538 } 537 }
@@ -1062,7 +1061,7 @@ static int __init smctr_chk_isa(struct net_device *dev)
1062 goto out2; 1061 goto out2;
1063 } 1062 }
1064 1063
1065 if (request_irq(dev->irq, smctr_interrupt, SA_SHIRQ, smctr_name, dev)) 1064 if (request_irq(dev->irq, smctr_interrupt, IRQF_SHARED, smctr_name, dev))
1066 goto out2; 1065 goto out2;
1067 1066
1068 /* Get 58x Rom Base */ 1067 /* Get 58x Rom Base */
diff --git a/drivers/net/tokenring/smctr_firmware.h b/drivers/net/tokenring/smctr_firmware.h
index 48994b043b7c..292e50ddf01a 100644
--- a/drivers/net/tokenring/smctr_firmware.h
+++ b/drivers/net/tokenring/smctr_firmware.h
@@ -17,7 +17,6 @@
17 * - Jay Schulist <jschlst@samba.org> 17 * - Jay Schulist <jschlst@samba.org>
18 */ 18 */
19 19
20#include <linux/config.h>
21 20
22#if defined(CONFIG_SMCTR) || defined(CONFIG_SMCTR_MODULE) 21#if defined(CONFIG_SMCTR) || defined(CONFIG_SMCTR_MODULE)
23 22
diff --git a/drivers/net/tokenring/tmspci.c b/drivers/net/tokenring/tmspci.c
index ab47c0547a3b..7d3e270c4f45 100644
--- a/drivers/net/tokenring/tmspci.c
+++ b/drivers/net/tokenring/tmspci.c
@@ -122,7 +122,7 @@ static int __devinit tms_pci_attach(struct pci_dev *pdev, const struct pci_devic
122 goto err_out_trdev; 122 goto err_out_trdev;
123 } 123 }
124 124
125 ret = request_irq(pdev->irq, tms380tr_interrupt, SA_SHIRQ, 125 ret = request_irq(pdev->irq, tms380tr_interrupt, IRQF_SHARED,
126 dev->name, dev); 126 dev->name, dev);
127 if (ret) 127 if (ret)
128 goto err_out_region; 128 goto err_out_region;
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 5f743b972949..d05c5aa254ee 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -31,7 +31,6 @@
31#define DRV_VERSION "0.7" 31#define DRV_VERSION "0.7"
32#define DRV_RELDATE "Mar 17, 2004" 32#define DRV_RELDATE "Mar 17, 2004"
33 33
34#include <linux/config.h>
35#include <linux/module.h> 34#include <linux/module.h>
36#include <linux/kernel.h> 35#include <linux/kernel.h>
37#include <linux/netdevice.h> 36#include <linux/netdevice.h>
@@ -1372,7 +1371,7 @@ static int de_open (struct net_device *dev)
1372 1371
1373 dw32(IntrMask, 0); 1372 dw32(IntrMask, 0);
1374 1373
1375 rc = request_irq(dev->irq, de_interrupt, SA_SHIRQ, dev->name, dev); 1374 rc = request_irq(dev->irq, de_interrupt, IRQF_SHARED, dev->name, dev);
1376 if (rc) { 1375 if (rc) {
1377 printk(KERN_ERR "%s: IRQ %d request failure, err=%d\n", 1376 printk(KERN_ERR "%s: IRQ %d request failure, err=%d\n",
1378 dev->name, dev->irq, rc); 1377 dev->name, dev->irq, rc);
@@ -2007,8 +2006,8 @@ static int __init de_init_one (struct pci_dev *pdev,
2007 } 2006 }
2008 if (pci_resource_len(pdev, 1) < DE_REGS_SIZE) { 2007 if (pci_resource_len(pdev, 1) < DE_REGS_SIZE) {
2009 rc = -EIO; 2008 rc = -EIO;
2010 printk(KERN_ERR PFX "MMIO resource (%lx) too small on pci dev %s\n", 2009 printk(KERN_ERR PFX "MMIO resource (%llx) too small on pci dev %s\n",
2011 pci_resource_len(pdev, 1), pci_name(pdev)); 2010 (unsigned long long)pci_resource_len(pdev, 1), pci_name(pdev));
2012 goto err_out_res; 2011 goto err_out_res;
2013 } 2012 }
2014 2013
@@ -2016,8 +2015,9 @@ static int __init de_init_one (struct pci_dev *pdev,
2016 regs = ioremap_nocache(pciaddr, DE_REGS_SIZE); 2015 regs = ioremap_nocache(pciaddr, DE_REGS_SIZE);
2017 if (!regs) { 2016 if (!regs) {
2018 rc = -EIO; 2017 rc = -EIO;
2019 printk(KERN_ERR PFX "Cannot map PCI MMIO (%lx@%lx) on pci dev %s\n", 2018 printk(KERN_ERR PFX "Cannot map PCI MMIO (%llx@%lx) on pci dev %s\n",
2020 pci_resource_len(pdev, 1), pciaddr, pci_name(pdev)); 2019 (unsigned long long)pci_resource_len(pdev, 1),
2020 pciaddr, pci_name(pdev));
2021 goto err_out_res; 2021 goto err_out_res;
2022 } 2022 }
2023 dev->base_addr = (unsigned long) regs; 2023 dev->base_addr = (unsigned long) regs;
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index da8bd0d62a3f..75ff14a55239 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -292,7 +292,7 @@
292 0.41 21-Mar-96 Don't check for get_hw_addr checksum unless DEC card 292 0.41 21-Mar-96 Don't check for get_hw_addr checksum unless DEC card
293 only <niles@axp745gsfc.nasa.gov> 293 only <niles@axp745gsfc.nasa.gov>
294 Fix for multiple PCI cards reported by <jos@xos.nl> 294 Fix for multiple PCI cards reported by <jos@xos.nl>
295 Duh, put the SA_SHIRQ flag into request_interrupt(). 295 Duh, put the IRQF_SHARED flag into request_interrupt().
296 Fix SMC ethernet address in enet_det[]. 296 Fix SMC ethernet address in enet_det[].
297 Print chip name instead of "UNKNOWN" during boot. 297 Print chip name instead of "UNKNOWN" during boot.
298 0.42 26-Apr-96 Fix MII write TA bit error. 298 0.42 26-Apr-96 Fix MII write TA bit error.
@@ -353,7 +353,7 @@
353 infoblocks. 353 infoblocks.
354 Added DC21142 and DC21143 functions. 354 Added DC21142 and DC21143 functions.
355 Added byte counters from <phil@tazenda.demon.co.uk> 355 Added byte counters from <phil@tazenda.demon.co.uk>
356 Added SA_INTERRUPT temporary fix from 356 Added IRQF_DISABLED temporary fix from
357 <mjacob@feral.com>. 357 <mjacob@feral.com>.
358 0.53 12-Nov-97 Fix the *_probe() to include 'eth??' name during 358 0.53 12-Nov-97 Fix the *_probe() to include 'eth??' name during
359 module load: bug reported by 359 module load: bug reported by
@@ -443,7 +443,6 @@
443 ========================================================================= 443 =========================================================================
444*/ 444*/
445 445
446#include <linux/config.h>
447#include <linux/module.h> 446#include <linux/module.h>
448#include <linux/kernel.h> 447#include <linux/kernel.h>
449#include <linux/string.h> 448#include <linux/string.h>
@@ -1320,10 +1319,10 @@ de4x5_open(struct net_device *dev)
1320 lp->state = OPEN; 1319 lp->state = OPEN;
1321 de4x5_dbg_open(dev); 1320 de4x5_dbg_open(dev);
1322 1321
1323 if (request_irq(dev->irq, (void *)de4x5_interrupt, SA_SHIRQ, 1322 if (request_irq(dev->irq, (void *)de4x5_interrupt, IRQF_SHARED,
1324 lp->adapter_name, dev)) { 1323 lp->adapter_name, dev)) {
1325 printk("de4x5_open(): Requested IRQ%d is busy - attemping FAST/SHARE...", dev->irq); 1324 printk("de4x5_open(): Requested IRQ%d is busy - attemping FAST/SHARE...", dev->irq);
1326 if (request_irq(dev->irq, de4x5_interrupt, SA_INTERRUPT | SA_SHIRQ, 1325 if (request_irq(dev->irq, de4x5_interrupt, IRQF_DISABLED | IRQF_SHARED,
1327 lp->adapter_name, dev)) { 1326 lp->adapter_name, dev)) {
1328 printk("\n Cannot get IRQ- reconfigure your hardware.\n"); 1327 printk("\n Cannot get IRQ- reconfigure your hardware.\n");
1329 disable_ast(dev); 1328 disable_ast(dev);
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index ba5b112093f4..4e5b0f2acc39 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -506,7 +506,7 @@ static int dmfe_open(struct DEVICE *dev)
506 506
507 DMFE_DBUG(0, "dmfe_open", 0); 507 DMFE_DBUG(0, "dmfe_open", 0);
508 508
509 ret = request_irq(dev->irq, &dmfe_interrupt, SA_SHIRQ, dev->name, dev); 509 ret = request_irq(dev->irq, &dmfe_interrupt, IRQF_SHARED, dev->name, dev);
510 if (ret) 510 if (ret)
511 return ret; 511 return ret;
512 512
diff --git a/drivers/net/tulip/interrupt.c b/drivers/net/tulip/interrupt.c
index da4f7593c50f..99ccf2ebb342 100644
--- a/drivers/net/tulip/interrupt.c
+++ b/drivers/net/tulip/interrupt.c
@@ -16,7 +16,6 @@
16 16
17#include <linux/pci.h> 17#include <linux/pci.h>
18#include "tulip.h" 18#include "tulip.h"
19#include <linux/config.h>
20#include <linux/etherdevice.h> 19#include <linux/etherdevice.h>
21 20
22int tulip_rx_copybreak; 21int tulip_rx_copybreak;
diff --git a/drivers/net/tulip/tulip.h b/drivers/net/tulip/tulip.h
index d25020da6798..3bcfbf3d23ed 100644
--- a/drivers/net/tulip/tulip.h
+++ b/drivers/net/tulip/tulip.h
@@ -16,7 +16,6 @@
16#ifndef __NET_TULIP_H__ 16#ifndef __NET_TULIP_H__
17#define __NET_TULIP_H__ 17#define __NET_TULIP_H__
18 18
19#include <linux/config.h>
20#include <linux/kernel.h> 19#include <linux/kernel.h>
21#include <linux/types.h> 20#include <linux/types.h>
22#include <linux/spinlock.h> 21#include <linux/spinlock.h>
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index cabdf894e21e..7351831f57ce 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -14,7 +14,6 @@
14 14
15*/ 15*/
16 16
17#include <linux/config.h>
18 17
19#define DRV_NAME "tulip" 18#define DRV_NAME "tulip"
20#ifdef CONFIG_TULIP_NAPI 19#ifdef CONFIG_TULIP_NAPI
@@ -490,7 +489,7 @@ tulip_open(struct net_device *dev)
490{ 489{
491 int retval; 490 int retval;
492 491
493 if ((retval = request_irq(dev->irq, &tulip_interrupt, SA_SHIRQ, dev->name, dev))) 492 if ((retval = request_irq(dev->irq, &tulip_interrupt, IRQF_SHARED, dev->name, dev)))
494 return retval; 493 return retval;
495 494
496 tulip_init_ring (dev); 495 tulip_init_ring (dev);
@@ -1350,10 +1349,10 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1350 SET_MODULE_OWNER(dev); 1349 SET_MODULE_OWNER(dev);
1351 SET_NETDEV_DEV(dev, &pdev->dev); 1350 SET_NETDEV_DEV(dev, &pdev->dev);
1352 if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) { 1351 if (pci_resource_len (pdev, 0) < tulip_tbl[chip_idx].io_size) {
1353 printk (KERN_ERR PFX "%s: I/O region (0x%lx@0x%lx) too small, " 1352 printk (KERN_ERR PFX "%s: I/O region (0x%llx@0x%llx) too small, "
1354 "aborting\n", pci_name(pdev), 1353 "aborting\n", pci_name(pdev),
1355 pci_resource_len (pdev, 0), 1354 (unsigned long long)pci_resource_len (pdev, 0),
1356 pci_resource_start (pdev, 0)); 1355 (unsigned long long)pci_resource_start (pdev, 0));
1357 goto err_out_free_netdev; 1356 goto err_out_free_netdev;
1358 } 1357 }
1359 1358
@@ -1550,10 +1549,14 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
1550 dev->dev_addr[i] = last_phys_addr[i]; 1549 dev->dev_addr[i] = last_phys_addr[i];
1551 dev->dev_addr[i] = last_phys_addr[i] + 1; 1550 dev->dev_addr[i] = last_phys_addr[i] + 1;
1552#if defined(__sparc__) 1551#if defined(__sparc__)
1553 if ((pcp != NULL) && prom_getproplen(pcp->prom_node, 1552 if (pcp) {
1554 "local-mac-address") == 6) { 1553 unsigned char *addr;
1555 prom_getproperty(pcp->prom_node, "local-mac-address", 1554 int len;
1556 dev->dev_addr, 6); 1555
1556 addr = of_get_property(pcp->prom_node,
1557 "local-mac-address", &len);
1558 if (addr && len == 6)
1559 memcpy(dev->dev_addr, addr, 6);
1557 } 1560 }
1558#endif 1561#endif
1559#if defined(__i386__) || defined(__x86_64__) /* Patch up x86 BIOS bug. */ 1562#if defined(__i386__) || defined(__x86_64__) /* Patch up x86 BIOS bug. */
@@ -1767,7 +1770,7 @@ static int tulip_resume(struct pci_dev *pdev)
1767 1770
1768 pci_enable_device(pdev); 1771 pci_enable_device(pdev);
1769 1772
1770 if ((retval = request_irq(dev->irq, &tulip_interrupt, SA_SHIRQ, dev->name, dev))) { 1773 if ((retval = request_irq(dev->irq, &tulip_interrupt, IRQF_SHARED, dev->name, dev))) {
1771 printk (KERN_ERR "tulip: request_irq failed in resume\n"); 1774 printk (KERN_ERR "tulip: request_irq failed in resume\n");
1772 return retval; 1775 return retval;
1773 } 1776 }
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
index 8b3a28f53c3d..fd64b2b3e99c 100644
--- a/drivers/net/tulip/uli526x.c
+++ b/drivers/net/tulip/uli526x.c
@@ -436,7 +436,7 @@ static int uli526x_open(struct net_device *dev)
436 436
437 ULI526X_DBUG(0, "uli526x_open", 0); 437 ULI526X_DBUG(0, "uli526x_open", 0);
438 438
439 ret = request_irq(dev->irq, &uli526x_interrupt, SA_SHIRQ, dev->name, dev); 439 ret = request_irq(dev->irq, &uli526x_interrupt, IRQF_SHARED, dev->name, dev);
440 if (ret) 440 if (ret)
441 return ret; 441 return ret;
442 442
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 8fea2aa455d4..7f414815cc62 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -212,48 +212,33 @@ Test with 'ping -s 10000' on a fast computer.
212/* 212/*
213 PCI probe table. 213 PCI probe table.
214*/ 214*/
215enum pci_id_flags_bits {
216 /* Set PCI command register bits before calling probe1(). */
217 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
218 /* Read and map the single following PCI BAR. */
219 PCI_ADDR0=0<<4, PCI_ADDR1=1<<4, PCI_ADDR2=2<<4, PCI_ADDR3=3<<4,
220 PCI_ADDR_64BITS=0x100, PCI_NO_ACPI_WAKE=0x200, PCI_NO_MIN_LATENCY=0x400,
221};
222enum chip_capability_flags { 215enum chip_capability_flags {
223 CanHaveMII=1, HasBrokenTx=2, AlwaysFDX=4, FDXOnNoMII=8,}; 216 CanHaveMII=1, HasBrokenTx=2, AlwaysFDX=4, FDXOnNoMII=8,
224#ifdef USE_IO_OPS 217};
225#define W840_FLAGS (PCI_USES_IO | PCI_ADDR0 | PCI_USES_MASTER)
226#else
227#define W840_FLAGS (PCI_USES_MEM | PCI_ADDR1 | PCI_USES_MASTER)
228#endif
229 218
230static struct pci_device_id w840_pci_tbl[] = { 219static const struct pci_device_id w840_pci_tbl[] = {
231 { 0x1050, 0x0840, PCI_ANY_ID, 0x8153, 0, 0, 0 }, 220 { 0x1050, 0x0840, PCI_ANY_ID, 0x8153, 0, 0, 0 },
232 { 0x1050, 0x0840, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 221 { 0x1050, 0x0840, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
233 { 0x11f6, 0x2011, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, 222 { 0x11f6, 0x2011, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
234 { 0, } 223 { }
235}; 224};
236MODULE_DEVICE_TABLE(pci, w840_pci_tbl); 225MODULE_DEVICE_TABLE(pci, w840_pci_tbl);
237 226
227enum {
228 netdev_res_size = 128, /* size of PCI BAR resource */
229};
230
238struct pci_id_info { 231struct pci_id_info {
239 const char *name; 232 const char *name;
240 struct match_info { 233 int drv_flags; /* Driver use, intended as capability flags. */
241 int pci, pci_mask, subsystem, subsystem_mask;
242 int revision, revision_mask; /* Only 8 bits. */
243 } id;
244 enum pci_id_flags_bits pci_flags;
245 int io_size; /* Needed for I/O region check or ioremap(). */
246 int drv_flags; /* Driver use, intended as capability flags. */
247}; 234};
248static struct pci_id_info pci_id_tbl[] = { 235
249 {"Winbond W89c840", /* Sometime a Level-One switch card. */ 236static const struct pci_id_info pci_id_tbl[] __devinitdata = {
250 { 0x08401050, 0xffffffff, 0x81530000, 0xffff0000 }, 237 { /* Sometime a Level-One switch card. */
251 W840_FLAGS, 128, CanHaveMII | HasBrokenTx | FDXOnNoMII}, 238 "Winbond W89c840", CanHaveMII | HasBrokenTx | FDXOnNoMII},
252 {"Winbond W89c840", { 0x08401050, 0xffffffff, }, 239 { "Winbond W89c840", CanHaveMII | HasBrokenTx},
253 W840_FLAGS, 128, CanHaveMII | HasBrokenTx}, 240 { "Compex RL100-ATX", CanHaveMII | HasBrokenTx},
254 {"Compex RL100-ATX", { 0x201111F6, 0xffffffff,}, 241 { } /* terminate list. */
255 W840_FLAGS, 128, CanHaveMII | HasBrokenTx},
256 {NULL,}, /* 0 terminated list. */
257}; 242};
258 243
259/* This driver was written to use PCI memory space, however some x86 systems 244/* This driver was written to use PCI memory space, however some x86 systems
@@ -411,7 +396,7 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
411#ifdef USE_IO_OPS 396#ifdef USE_IO_OPS
412 bar = 0; 397 bar = 0;
413#endif 398#endif
414 ioaddr = pci_iomap(pdev, bar, pci_id_tbl[chip_idx].io_size); 399 ioaddr = pci_iomap(pdev, bar, netdev_res_size);
415 if (!ioaddr) 400 if (!ioaddr)
416 goto err_out_free_res; 401 goto err_out_free_res;
417 402
@@ -670,7 +655,7 @@ static int netdev_open(struct net_device *dev)
670 iowrite32(0x00000001, ioaddr + PCIBusCfg); /* Reset */ 655 iowrite32(0x00000001, ioaddr + PCIBusCfg); /* Reset */
671 656
672 netif_device_detach(dev); 657 netif_device_detach(dev);
673 i = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev); 658 i = request_irq(dev->irq, &intr_handler, IRQF_SHARED, dev->name, dev);
674 if (i) 659 if (i)
675 goto out_err; 660 goto out_err;
676 661
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c
index 63c2175ed138..f874e4f6ccf6 100644
--- a/drivers/net/tulip/xircom_cb.c
+++ b/drivers/net/tulip/xircom_cb.c
@@ -457,7 +457,7 @@ static int xircom_open(struct net_device *dev)
457 int retval; 457 int retval;
458 enter("xircom_open"); 458 enter("xircom_open");
459 printk(KERN_INFO "xircom cardbus adaptor found, registering as %s, using irq %i \n",dev->name,dev->irq); 459 printk(KERN_INFO "xircom cardbus adaptor found, registering as %s, using irq %i \n",dev->name,dev->irq);
460 retval = request_irq(dev->irq, &xircom_interrupt, SA_SHIRQ, dev->name, dev); 460 retval = request_irq(dev->irq, &xircom_interrupt, IRQF_SHARED, dev->name, dev);
461 if (retval) { 461 if (retval) {
462 leave("xircom_open - No IRQ"); 462 leave("xircom_open - No IRQ");
463 return retval; 463 return retval;
diff --git a/drivers/net/tulip/xircom_tulip_cb.c b/drivers/net/tulip/xircom_tulip_cb.c
index 887d7245fe7b..17ca7dc42e6f 100644
--- a/drivers/net/tulip/xircom_tulip_cb.c
+++ b/drivers/net/tulip/xircom_tulip_cb.c
@@ -10,26 +10,11 @@
10 410 Severn Ave., Suite 210 10 410 Severn Ave., Suite 210
11 Annapolis MD 21403 11 Annapolis MD 21403
12 12
13 -----------------------------------------------------------
14
15 Linux kernel-specific changes:
16
17 LK1.0 (Ion Badulescu)
18 - Major cleanup
19 - Use 2.4 PCI API
20 - Support ethtool
21 - Rewrite perfect filter/hash code
22 - Use interrupts for media changes
23
24 LK1.1 (Ion Badulescu)
25 - Disallow negotiation of unsupported full-duplex modes
26*/ 13*/
27 14
28#define DRV_NAME "xircom_tulip_cb" 15#define DRV_NAME "xircom_tulip_cb"
29#define DRV_VERSION "0.91+LK1.1" 16#define DRV_VERSION "0.92"
30#define DRV_RELDATE "October 11, 2001" 17#define DRV_RELDATE "June 27, 2006"
31
32#define CARDBUS 1
33 18
34/* A few user-configurable values. */ 19/* A few user-configurable values. */
35 20
@@ -98,7 +83,6 @@ static int csr0 = 0x00A00000 | 0x4800;
98/* PCI registers */ 83/* PCI registers */
99#define PCI_POWERMGMT 0x40 84#define PCI_POWERMGMT 0x40
100 85
101#include <linux/config.h>
102#include <linux/module.h> 86#include <linux/module.h>
103#include <linux/moduleparam.h> 87#include <linux/moduleparam.h>
104#include <linux/kernel.h> 88#include <linux/kernel.h>
@@ -307,10 +291,10 @@ struct xircom_private {
307 struct xircom_tx_desc tx_ring[TX_RING_SIZE]; 291 struct xircom_tx_desc tx_ring[TX_RING_SIZE];
308 /* The saved address of a sent-in-place packet/buffer, for skfree(). */ 292 /* The saved address of a sent-in-place packet/buffer, for skfree(). */
309 struct sk_buff* tx_skbuff[TX_RING_SIZE]; 293 struct sk_buff* tx_skbuff[TX_RING_SIZE];
310#ifdef CARDBUS 294
311 /* The X3201-3 requires 4-byte aligned tx bufs */ 295 /* The X3201-3 requires 4-byte aligned tx bufs */
312 struct sk_buff* tx_aligned_skbuff[TX_RING_SIZE]; 296 struct sk_buff* tx_aligned_skbuff[TX_RING_SIZE];
313#endif 297
314 /* The addresses of receive-in-place skbuffs. */ 298 /* The addresses of receive-in-place skbuffs. */
315 struct sk_buff* rx_skbuff[RX_RING_SIZE]; 299 struct sk_buff* rx_skbuff[RX_RING_SIZE];
316 u16 setup_frame[PKT_SETUP_SZ / sizeof(u16)]; /* Pseudo-Tx frame to init address table. */ 300 u16 setup_frame[PKT_SETUP_SZ / sizeof(u16)]; /* Pseudo-Tx frame to init address table. */
@@ -808,7 +792,7 @@ xircom_open(struct net_device *dev)
808{ 792{
809 struct xircom_private *tp = netdev_priv(dev); 793 struct xircom_private *tp = netdev_priv(dev);
810 794
811 if (request_irq(dev->irq, &xircom_interrupt, SA_SHIRQ, dev->name, dev)) 795 if (request_irq(dev->irq, &xircom_interrupt, IRQF_SHARED, dev->name, dev))
812 return -EAGAIN; 796 return -EAGAIN;
813 797
814 xircom_up(dev); 798 xircom_up(dev);
@@ -909,10 +893,8 @@ static void xircom_init_ring(struct net_device *dev)
909 tp->tx_skbuff[i] = NULL; 893 tp->tx_skbuff[i] = NULL;
910 tp->tx_ring[i].status = 0; 894 tp->tx_ring[i].status = 0;
911 tp->tx_ring[i].buffer2 = virt_to_bus(&tp->tx_ring[i+1]); 895 tp->tx_ring[i].buffer2 = virt_to_bus(&tp->tx_ring[i+1]);
912#ifdef CARDBUS
913 if (tp->chip_id == X3201_3) 896 if (tp->chip_id == X3201_3)
914 tp->tx_aligned_skbuff[i] = dev_alloc_skb(PKT_BUF_SZ); 897 tp->tx_aligned_skbuff[i] = dev_alloc_skb(PKT_BUF_SZ);
915#endif /* CARDBUS */
916 } 898 }
917 tp->tx_ring[i-1].buffer2 = virt_to_bus(&tp->tx_ring[0]); 899 tp->tx_ring[i-1].buffer2 = virt_to_bus(&tp->tx_ring[0]);
918} 900}
@@ -932,12 +914,10 @@ xircom_start_xmit(struct sk_buff *skb, struct net_device *dev)
932 entry = tp->cur_tx % TX_RING_SIZE; 914 entry = tp->cur_tx % TX_RING_SIZE;
933 915
934 tp->tx_skbuff[entry] = skb; 916 tp->tx_skbuff[entry] = skb;
935#ifdef CARDBUS
936 if (tp->chip_id == X3201_3) { 917 if (tp->chip_id == X3201_3) {
937 memcpy(tp->tx_aligned_skbuff[entry]->data,skb->data,skb->len); 918 memcpy(tp->tx_aligned_skbuff[entry]->data,skb->data,skb->len);
938 tp->tx_ring[entry].buffer1 = virt_to_bus(tp->tx_aligned_skbuff[entry]->data); 919 tp->tx_ring[entry].buffer1 = virt_to_bus(tp->tx_aligned_skbuff[entry]->data);
939 } else 920 } else
940#endif
941 tp->tx_ring[entry].buffer1 = virt_to_bus(skb->data); 921 tp->tx_ring[entry].buffer1 = virt_to_bus(skb->data);
942 922
943 if (tp->cur_tx - tp->dirty_tx < TX_RING_SIZE/2) {/* Typical path */ 923 if (tp->cur_tx - tp->dirty_tx < TX_RING_SIZE/2) {/* Typical path */
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a1ed2d983740..329d9feb9b89 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -39,7 +39,6 @@
39#define DRV_DESCRIPTION "Universal TUN/TAP device driver" 39#define DRV_DESCRIPTION "Universal TUN/TAP device driver"
40#define DRV_COPYRIGHT "(C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>" 40#define DRV_COPYRIGHT "(C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>"
41 41
42#include <linux/config.h>
43#include <linux/module.h> 42#include <linux/module.h>
44#include <linux/errno.h> 43#include <linux/errno.h>
45#include <linux/kernel.h> 44#include <linux/kernel.h>
@@ -490,6 +489,9 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
490 489
491 err = -EINVAL; 490 err = -EINVAL;
492 491
492 if (!capable(CAP_NET_ADMIN))
493 return -EPERM;
494
493 /* Set dev type */ 495 /* Set dev type */
494 if (ifr->ifr_flags & IFF_TUN) { 496 if (ifr->ifr_flags & IFF_TUN) {
495 /* TUN device */ 497 /* TUN device */
@@ -777,7 +779,6 @@ static struct miscdevice tun_miscdev = {
777 .minor = TUN_MINOR, 779 .minor = TUN_MINOR,
778 .name = "tun", 780 .name = "tun",
779 .fops = &tun_fops, 781 .fops = &tun_fops,
780 .devfs_name = "net/tun",
781}; 782};
782 783
783/* ethtool interface */ 784/* ethtool interface */
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index d9258d42090c..063816f2b11e 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -340,7 +340,7 @@ enum state_values {
340#endif 340#endif
341 341
342#if defined(NETIF_F_TSO) 342#if defined(NETIF_F_TSO)
343#define skb_tso_size(x) (skb_shinfo(x)->tso_size) 343#define skb_tso_size(x) (skb_shinfo(x)->gso_size)
344#define TSO_NUM_DESCRIPTORS 2 344#define TSO_NUM_DESCRIPTORS 2
345#define TSO_OFFLOAD_ON TYPHOON_OFFLOAD_TCP_SEGMENT 345#define TSO_OFFLOAD_ON TYPHOON_OFFLOAD_TCP_SEGMENT
346#else 346#else
@@ -2131,7 +2131,7 @@ typhoon_open(struct net_device *dev)
2131 goto out_sleep; 2131 goto out_sleep;
2132 } 2132 }
2133 2133
2134 err = request_irq(dev->irq, &typhoon_interrupt, SA_SHIRQ, 2134 err = request_irq(dev->irq, &typhoon_interrupt, IRQF_SHARED,
2135 dev->name, dev); 2135 dev->name, dev);
2136 if(err < 0) 2136 if(err < 0)
2137 goto out_sleep; 2137 goto out_sleep;
@@ -2568,9 +2568,10 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2568 2568
2569 pci_set_drvdata(pdev, dev); 2569 pci_set_drvdata(pdev, dev);
2570 2570
2571 printk(KERN_INFO "%s: %s at %s 0x%lx, ", 2571 printk(KERN_INFO "%s: %s at %s 0x%llx, ",
2572 dev->name, typhoon_card_info[card_id].name, 2572 dev->name, typhoon_card_info[card_id].name,
2573 use_mmio ? "MMIO" : "IO", pci_resource_start(pdev, use_mmio)); 2573 use_mmio ? "MMIO" : "IO",
2574 (unsigned long long)pci_resource_start(pdev, use_mmio));
2574 for(i = 0; i < 5; i++) 2575 for(i = 0; i < 5; i++)
2575 printk("%2.2x:", dev->dev_addr[i]); 2576 printk("%2.2x:", dev->dev_addr[i]);
2576 printk("%2.2x\n", dev->dev_addr[i]); 2577 printk("%2.2x\n", dev->dev_addr[i]);
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index fdc21037f6dc..d3d0ec970318 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -25,117 +25,13 @@
25 version. He may or may not be interested in bug reports on this 25 version. He may or may not be interested in bug reports on this
26 code. You can find his versions at: 26 code. You can find his versions at:
27 http://www.scyld.com/network/via-rhine.html 27 http://www.scyld.com/network/via-rhine.html
28 28 [link no longer provides useful info -jgarzik]
29
30 Linux kernel version history:
31
32 LK1.1.0:
33 - Jeff Garzik: softnet 'n stuff
34
35 LK1.1.1:
36 - Justin Guyett: softnet and locking fixes
37 - Jeff Garzik: use PCI interface
38
39 LK1.1.2:
40 - Urban Widmark: minor cleanups, merges from Becker 1.03a/1.04 versions
41
42 LK1.1.3:
43 - Urban Widmark: use PCI DMA interface (with thanks to the eepro100.c
44 code) update "Theory of Operation" with
45 softnet/locking changes
46 - Dave Miller: PCI DMA and endian fixups
47 - Jeff Garzik: MOD_xxx race fixes, updated PCI resource allocation
48
49 LK1.1.4:
50 - Urban Widmark: fix gcc 2.95.2 problem and
51 remove writel's to fixed address 0x7c
52
53 LK1.1.5:
54 - Urban Widmark: mdio locking, bounce buffer changes
55 merges from Beckers 1.05 version
56 added netif_running_on/off support
57
58 LK1.1.6:
59 - Urban Widmark: merges from Beckers 1.08b version (VT6102 + mdio)
60 set netif_running_on/off on startup, del_timer_sync
61
62 LK1.1.7:
63 - Manfred Spraul: added reset into tx_timeout
64
65 LK1.1.9:
66 - Urban Widmark: merges from Beckers 1.10 version
67 (media selection + eeprom reload)
68 - David Vrabel: merges from D-Link "1.11" version
69 (disable WOL and PME on startup)
70
71 LK1.1.10:
72 - Manfred Spraul: use "singlecopy" for unaligned buffers
73 don't allocate bounce buffers for !ReqTxAlign cards
74
75 LK1.1.11:
76 - David Woodhouse: Set dev->base_addr before the first time we call
77 wait_for_reset(). It's a lot happier that way.
78 Free np->tx_bufs only if we actually allocated it.
79
80 LK1.1.12:
81 - Martin Eriksson: Allow Memory-Mapped IO to be enabled.
82
83 LK1.1.13 (jgarzik):
84 - Add ethtool support
85 - Replace some MII-related magic numbers with constants
86
87 LK1.1.14 (Ivan G.):
88 - fixes comments for Rhine-III
89 - removes W_MAX_TIMEOUT (unused)
90 - adds HasDavicomPhy for Rhine-I (basis: linuxfet driver; my card
91 is R-I and has Davicom chip, flag is referenced in kernel driver)
92 - sends chip_id as a parameter to wait_for_reset since np is not
93 initialized on first call
94 - changes mmio "else if (chip_id==VT6102)" to "else" so it will work
95 for Rhine-III's (documentation says same bit is correct)
96 - transmit frame queue message is off by one - fixed
97 - adds IntrNormalSummary to "Something Wicked" exclusion list
98 so normal interrupts will not trigger the message (src: Donald Becker)
99 (Roger Luethi)
100 - show confused chip where to continue after Tx error
101 - location of collision counter is chip specific
102 - allow selecting backoff algorithm (module parameter)
103
104 LK1.1.15 (jgarzik):
105 - Use new MII lib helper generic_mii_ioctl
106
107 LK1.1.16 (Roger Luethi)
108 - Etherleak fix
109 - Handle Tx buffer underrun
110 - Fix bugs in full duplex handling
111 - New reset code uses "force reset" cmd on Rhine-II
112 - Various clean ups
113
114 LK1.1.17 (Roger Luethi)
115 - Fix race in via_rhine_start_tx()
116 - On errors, wait for Tx engine to turn off before scavenging
117 - Handle Tx descriptor write-back race on Rhine-II
118 - Force flushing for PCI posted writes
119 - More reset code changes
120
121 LK1.1.18 (Roger Luethi)
122 - No filtering multicast in promisc mode (Edward Peng)
123 - Fix for Rhine-I Tx timeouts
124
125 LK1.1.19 (Roger Luethi)
126 - Increase Tx threshold for unspecified errors
127
128 LK1.2.0-2.6 (Roger Luethi)
129 - Massive clean-up
130 - Rewrite PHY, media handling (remove options, full_duplex, backoff)
131 - Fix Tx engine race for good
132 - Craig Brind: Zero padded aligned buffers for short packets.
133 29
134*/ 30*/
135 31
136#define DRV_NAME "via-rhine" 32#define DRV_NAME "via-rhine"
137#define DRV_VERSION "1.2.0-2.6" 33#define DRV_VERSION "1.4.0"
138#define DRV_RELDATE "June-10-2004" 34#define DRV_RELDATE "June-27-2006"
139 35
140 36
141/* A few user-configurable values. 37/* A few user-configurable values.
@@ -356,12 +252,11 @@ enum rhine_quirks {
356/* Beware of PCI posted writes */ 252/* Beware of PCI posted writes */
357#define IOSYNC do { ioread8(ioaddr + StationAddr); } while (0) 253#define IOSYNC do { ioread8(ioaddr + StationAddr); } while (0)
358 254
359static struct pci_device_id rhine_pci_tbl[] = 255static const struct pci_device_id rhine_pci_tbl[] = {
360{ 256 { 0x1106, 0x3043, PCI_ANY_ID, PCI_ANY_ID, }, /* VT86C100A */
361 {0x1106, 0x3043, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, /* VT86C100A */ 257 { 0x1106, 0x3065, PCI_ANY_ID, PCI_ANY_ID, }, /* VT6102 */
362 {0x1106, 0x3065, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, /* VT6102 */ 258 { 0x1106, 0x3106, PCI_ANY_ID, PCI_ANY_ID, }, /* 6105{,L,LOM} */
363 {0x1106, 0x3106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, /* 6105{,L,LOM} */ 259 { 0x1106, 0x3053, PCI_ANY_ID, PCI_ANY_ID, }, /* VT6105M */
364 {0x1106, 0x3053, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, /* VT6105M */
365 { } /* terminate list */ 260 { } /* terminate list */
366}; 261};
367MODULE_DEVICE_TABLE(pci, rhine_pci_tbl); 262MODULE_DEVICE_TABLE(pci, rhine_pci_tbl);
@@ -1210,7 +1105,7 @@ static int rhine_open(struct net_device *dev)
1210 void __iomem *ioaddr = rp->base; 1105 void __iomem *ioaddr = rp->base;
1211 int rc; 1106 int rc;
1212 1107
1213 rc = request_irq(rp->pdev->irq, &rhine_interrupt, SA_SHIRQ, dev->name, 1108 rc = request_irq(rp->pdev->irq, &rhine_interrupt, IRQF_SHARED, dev->name,
1214 dev); 1109 dev);
1215 if (rc) 1110 if (rc)
1216 return rc; 1111 return rc;
@@ -1284,11 +1179,8 @@ static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev)
1284 /* Calculate the next Tx descriptor entry. */ 1179 /* Calculate the next Tx descriptor entry. */
1285 entry = rp->cur_tx % TX_RING_SIZE; 1180 entry = rp->cur_tx % TX_RING_SIZE;
1286 1181
1287 if (skb->len < ETH_ZLEN) { 1182 if (skb_padto(skb, ETH_ZLEN))
1288 skb = skb_padto(skb, ETH_ZLEN); 1183 return 0;
1289 if (skb == NULL)
1290 return 0;
1291 }
1292 1184
1293 rp->tx_skbuff[entry] = skb; 1185 rp->tx_skbuff[entry] = skb;
1294 1186
@@ -2002,7 +1894,7 @@ static int rhine_resume(struct pci_dev *pdev)
2002 if (!netif_running(dev)) 1894 if (!netif_running(dev))
2003 return 0; 1895 return 0;
2004 1896
2005 if (request_irq(dev->irq, rhine_interrupt, SA_SHIRQ, dev->name, dev)) 1897 if (request_irq(dev->irq, rhine_interrupt, IRQF_SHARED, dev->name, dev))
2006 printk(KERN_ERR "via-rhine %s: request_irq failed\n", dev->name); 1898 printk(KERN_ERR "via-rhine %s: request_irq failed\n", dev->name);
2007 1899
2008 ret = pci_set_power_state(pdev, PCI_D0); 1900 ret = pci_set_power_state(pdev, PCI_D0);
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 2eb6b5f9ba0d..f5b0078eb4ad 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -47,7 +47,6 @@
47 47
48#include <linux/module.h> 48#include <linux/module.h>
49#include <linux/types.h> 49#include <linux/types.h>
50#include <linux/config.h>
51#include <linux/init.h> 50#include <linux/init.h>
52#include <linux/mm.h> 51#include <linux/mm.h>
53#include <linux/errno.h> 52#include <linux/errno.h>
@@ -65,7 +64,6 @@
65#include <linux/wait.h> 64#include <linux/wait.h>
66#include <asm/io.h> 65#include <asm/io.h>
67#include <linux/if.h> 66#include <linux/if.h>
68#include <linux/config.h>
69#include <asm/uaccess.h> 67#include <asm/uaccess.h>
70#include <linux/proc_fs.h> 68#include <linux/proc_fs.h>
71#include <linux/inetdevice.h> 69#include <linux/inetdevice.h>
@@ -231,7 +229,8 @@ static int rx_copybreak = 200;
231module_param(rx_copybreak, int, 0644); 229module_param(rx_copybreak, int, 0644);
232MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames"); 230MODULE_PARM_DESC(rx_copybreak, "Copy breakpoint for copy-only-tiny-frames");
233 231
234static void velocity_init_info(struct pci_dev *pdev, struct velocity_info *vptr, struct velocity_info_tbl *info); 232static void velocity_init_info(struct pci_dev *pdev, struct velocity_info *vptr,
233 const struct velocity_info_tbl *info);
235static int velocity_get_pci_info(struct velocity_info *, struct pci_dev *pdev); 234static int velocity_get_pci_info(struct velocity_info *, struct pci_dev *pdev);
236static void velocity_print_info(struct velocity_info *vptr); 235static void velocity_print_info(struct velocity_info *vptr);
237static int velocity_open(struct net_device *dev); 236static int velocity_open(struct net_device *dev);
@@ -248,6 +247,7 @@ static void velocity_free_rd_ring(struct velocity_info *vptr);
248static void velocity_free_tx_buf(struct velocity_info *vptr, struct velocity_td_info *); 247static void velocity_free_tx_buf(struct velocity_info *vptr, struct velocity_td_info *);
249static int velocity_soft_reset(struct velocity_info *vptr); 248static int velocity_soft_reset(struct velocity_info *vptr);
250static void mii_init(struct velocity_info *vptr, u32 mii_status); 249static void mii_init(struct velocity_info *vptr, u32 mii_status);
250static u32 velocity_get_link(struct net_device *dev);
251static u32 velocity_get_opt_media_mode(struct velocity_info *vptr); 251static u32 velocity_get_opt_media_mode(struct velocity_info *vptr);
252static void velocity_print_link_status(struct velocity_info *vptr); 252static void velocity_print_link_status(struct velocity_info *vptr);
253static void safe_disable_mii_autopoll(struct mac_regs __iomem * regs); 253static void safe_disable_mii_autopoll(struct mac_regs __iomem * regs);
@@ -295,9 +295,9 @@ static void velocity_unregister_notifier(void)
295 * Internal board variants. At the moment we have only one 295 * Internal board variants. At the moment we have only one
296 */ 296 */
297 297
298static struct velocity_info_tbl chip_info_table[] = { 298static const struct velocity_info_tbl chip_info_table[] __devinitdata = {
299 {CHIP_TYPE_VT6110, "VIA Networking Velocity Family Gigabit Ethernet Adapter", 256, 1, 0x00FFFFFFUL}, 299 {CHIP_TYPE_VT6110, "VIA Networking Velocity Family Gigabit Ethernet Adapter", 1, 0x00FFFFFFUL},
300 {0, NULL} 300 { }
301}; 301};
302 302
303/* 303/*
@@ -305,10 +305,9 @@ static struct velocity_info_tbl chip_info_table[] = {
305 * device driver. Used for hotplug autoloading. 305 * device driver. Used for hotplug autoloading.
306 */ 306 */
307 307
308static struct pci_device_id velocity_id_table[] __devinitdata = { 308static const struct pci_device_id velocity_id_table[] __devinitdata = {
309 {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X, 309 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) },
310 PCI_ANY_ID, PCI_ANY_ID, 0, 0, (unsigned long) chip_info_table}, 310 { }
311 {0, }
312}; 311};
313 312
314MODULE_DEVICE_TABLE(pci, velocity_id_table); 313MODULE_DEVICE_TABLE(pci, velocity_id_table);
@@ -342,7 +341,7 @@ static char __devinit *get_chip_name(enum chip_type chip_id)
342static void __devexit velocity_remove1(struct pci_dev *pdev) 341static void __devexit velocity_remove1(struct pci_dev *pdev)
343{ 342{
344 struct net_device *dev = pci_get_drvdata(pdev); 343 struct net_device *dev = pci_get_drvdata(pdev);
345 struct velocity_info *vptr = dev->priv; 344 struct velocity_info *vptr = netdev_priv(dev);
346 345
347#ifdef CONFIG_PM 346#ifdef CONFIG_PM
348 unsigned long flags; 347 unsigned long flags;
@@ -687,21 +686,23 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
687 static int first = 1; 686 static int first = 1;
688 struct net_device *dev; 687 struct net_device *dev;
689 int i; 688 int i;
690 struct velocity_info_tbl *info = (struct velocity_info_tbl *) ent->driver_data; 689 const struct velocity_info_tbl *info = &chip_info_table[ent->driver_data];
691 struct velocity_info *vptr; 690 struct velocity_info *vptr;
692 struct mac_regs __iomem * regs; 691 struct mac_regs __iomem * regs;
693 int ret = -ENOMEM; 692 int ret = -ENOMEM;
694 693
694 /* FIXME: this driver, like almost all other ethernet drivers,
695 * can support more than MAX_UNITS.
696 */
695 if (velocity_nics >= MAX_UNITS) { 697 if (velocity_nics >= MAX_UNITS) {
696 printk(KERN_NOTICE VELOCITY_NAME ": already found %d NICs.\n", 698 dev_notice(&pdev->dev, "already found %d NICs.\n",
697 velocity_nics); 699 velocity_nics);
698 return -ENODEV; 700 return -ENODEV;
699 } 701 }
700 702
701 dev = alloc_etherdev(sizeof(struct velocity_info)); 703 dev = alloc_etherdev(sizeof(struct velocity_info));
702 704 if (!dev) {
703 if (dev == NULL) { 705 dev_err(&pdev->dev, "allocate net device failed.\n");
704 printk(KERN_ERR VELOCITY_NAME ": allocate net device failed.\n");
705 goto out; 706 goto out;
706 } 707 }
707 708
@@ -709,7 +710,7 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
709 710
710 SET_MODULE_OWNER(dev); 711 SET_MODULE_OWNER(dev);
711 SET_NETDEV_DEV(dev, &pdev->dev); 712 SET_NETDEV_DEV(dev, &pdev->dev);
712 vptr = dev->priv; 713 vptr = netdev_priv(dev);
713 714
714 715
715 if (first) { 716 if (first) {
@@ -732,17 +733,17 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
732 733
733 ret = velocity_get_pci_info(vptr, pdev); 734 ret = velocity_get_pci_info(vptr, pdev);
734 if (ret < 0) { 735 if (ret < 0) {
735 printk(KERN_ERR VELOCITY_NAME ": Failed to find PCI device.\n"); 736 /* error message already printed */
736 goto err_disable; 737 goto err_disable;
737 } 738 }
738 739
739 ret = pci_request_regions(pdev, VELOCITY_NAME); 740 ret = pci_request_regions(pdev, VELOCITY_NAME);
740 if (ret < 0) { 741 if (ret < 0) {
741 printk(KERN_ERR VELOCITY_NAME ": Failed to find PCI device.\n"); 742 dev_err(&pdev->dev, "No PCI resources.\n");
742 goto err_disable; 743 goto err_disable;
743 } 744 }
744 745
745 regs = ioremap(vptr->memaddr, vptr->io_size); 746 regs = ioremap(vptr->memaddr, VELOCITY_IO_SIZE);
746 if (regs == NULL) { 747 if (regs == NULL) {
747 ret = -EIO; 748 ret = -EIO;
748 goto err_release_res; 749 goto err_release_res;
@@ -798,6 +799,9 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
798 if (ret < 0) 799 if (ret < 0)
799 goto err_iounmap; 800 goto err_iounmap;
800 801
802 if (velocity_get_link(dev))
803 netif_carrier_off(dev);
804
801 velocity_print_info(vptr); 805 velocity_print_info(vptr);
802 pci_set_drvdata(pdev, dev); 806 pci_set_drvdata(pdev, dev);
803 807
@@ -857,13 +861,14 @@ static void __devinit velocity_print_info(struct velocity_info *vptr)
857 * discovered. 861 * discovered.
858 */ 862 */
859 863
860static void __devinit velocity_init_info(struct pci_dev *pdev, struct velocity_info *vptr, struct velocity_info_tbl *info) 864static void __devinit velocity_init_info(struct pci_dev *pdev,
865 struct velocity_info *vptr,
866 const struct velocity_info_tbl *info)
861{ 867{
862 memset(vptr, 0, sizeof(struct velocity_info)); 868 memset(vptr, 0, sizeof(struct velocity_info));
863 869
864 vptr->pdev = pdev; 870 vptr->pdev = pdev;
865 vptr->chip_id = info->chip_id; 871 vptr->chip_id = info->chip_id;
866 vptr->io_size = info->io_size;
867 vptr->num_txq = info->txqueue; 872 vptr->num_txq = info->txqueue;
868 vptr->multicast_limit = MCAM_SIZE; 873 vptr->multicast_limit = MCAM_SIZE;
869 spin_lock_init(&vptr->lock); 874 spin_lock_init(&vptr->lock);
@@ -881,8 +886,7 @@ static void __devinit velocity_init_info(struct pci_dev *pdev, struct velocity_i
881 886
882static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pci_dev *pdev) 887static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pci_dev *pdev)
883{ 888{
884 889 if (pci_read_config_byte(pdev, PCI_REVISION_ID, &vptr->rev_id) < 0)
885 if(pci_read_config_byte(pdev, PCI_REVISION_ID, &vptr->rev_id) < 0)
886 return -EIO; 890 return -EIO;
887 891
888 pci_set_master(pdev); 892 pci_set_master(pdev);
@@ -890,24 +894,20 @@ static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pc
890 vptr->ioaddr = pci_resource_start(pdev, 0); 894 vptr->ioaddr = pci_resource_start(pdev, 0);
891 vptr->memaddr = pci_resource_start(pdev, 1); 895 vptr->memaddr = pci_resource_start(pdev, 1);
892 896
893 if(!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) 897 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_IO)) {
894 { 898 dev_err(&pdev->dev,
895 printk(KERN_ERR "%s: region #0 is not an I/O resource, aborting.\n", 899 "region #0 is not an I/O resource, aborting.\n");
896 pci_name(pdev));
897 return -EINVAL; 900 return -EINVAL;
898 } 901 }
899 902
900 if((pci_resource_flags(pdev, 1) & IORESOURCE_IO)) 903 if ((pci_resource_flags(pdev, 1) & IORESOURCE_IO)) {
901 { 904 dev_err(&pdev->dev,
902 printk(KERN_ERR "%s: region #1 is an I/O resource, aborting.\n", 905 "region #1 is an I/O resource, aborting.\n");
903 pci_name(pdev));
904 return -EINVAL; 906 return -EINVAL;
905 } 907 }
906 908
907 if(pci_resource_len(pdev, 1) < 256) 909 if (pci_resource_len(pdev, 1) < VELOCITY_IO_SIZE) {
908 { 910 dev_err(&pdev->dev, "region #1 is too small.\n");
909 printk(KERN_ERR "%s: region #1 is too small.\n",
910 pci_name(pdev));
911 return -EINVAL; 911 return -EINVAL;
912 } 912 }
913 vptr->pdev = pdev; 913 vptr->pdev = pdev;
@@ -1653,8 +1653,10 @@ static void velocity_error(struct velocity_info *vptr, int status)
1653 1653
1654 if (linked) { 1654 if (linked) {
1655 vptr->mii_status &= ~VELOCITY_LINK_FAIL; 1655 vptr->mii_status &= ~VELOCITY_LINK_FAIL;
1656 netif_carrier_on(vptr->dev);
1656 } else { 1657 } else {
1657 vptr->mii_status |= VELOCITY_LINK_FAIL; 1658 vptr->mii_status |= VELOCITY_LINK_FAIL;
1659 netif_carrier_off(vptr->dev);
1658 } 1660 }
1659 1661
1660 velocity_print_link_status(vptr); 1662 velocity_print_link_status(vptr);
@@ -1724,7 +1726,7 @@ static void velocity_free_tx_buf(struct velocity_info *vptr, struct velocity_td_
1724 1726
1725static int velocity_open(struct net_device *dev) 1727static int velocity_open(struct net_device *dev)
1726{ 1728{
1727 struct velocity_info *vptr = dev->priv; 1729 struct velocity_info *vptr = netdev_priv(dev);
1728 int ret; 1730 int ret;
1729 1731
1730 vptr->rx_buf_sz = (dev->mtu <= 1504 ? PKT_BUF_SZ : dev->mtu + 32); 1732 vptr->rx_buf_sz = (dev->mtu <= 1504 ? PKT_BUF_SZ : dev->mtu + 32);
@@ -1746,7 +1748,7 @@ static int velocity_open(struct net_device *dev)
1746 1748
1747 velocity_init_registers(vptr, VELOCITY_INIT_COLD); 1749 velocity_init_registers(vptr, VELOCITY_INIT_COLD);
1748 1750
1749 ret = request_irq(vptr->pdev->irq, &velocity_intr, SA_SHIRQ, 1751 ret = request_irq(vptr->pdev->irq, &velocity_intr, IRQF_SHARED,
1750 dev->name, dev); 1752 dev->name, dev);
1751 if (ret < 0) { 1753 if (ret < 0) {
1752 /* Power down the chip */ 1754 /* Power down the chip */
@@ -1781,7 +1783,7 @@ err_free_desc_rings:
1781 1783
1782static int velocity_change_mtu(struct net_device *dev, int new_mtu) 1784static int velocity_change_mtu(struct net_device *dev, int new_mtu)
1783{ 1785{
1784 struct velocity_info *vptr = dev->priv; 1786 struct velocity_info *vptr = netdev_priv(dev);
1785 unsigned long flags; 1787 unsigned long flags;
1786 int oldmtu = dev->mtu; 1788 int oldmtu = dev->mtu;
1787 int ret = 0; 1789 int ret = 0;
@@ -1857,7 +1859,7 @@ static void velocity_shutdown(struct velocity_info *vptr)
1857 1859
1858static int velocity_close(struct net_device *dev) 1860static int velocity_close(struct net_device *dev)
1859{ 1861{
1860 struct velocity_info *vptr = dev->priv; 1862 struct velocity_info *vptr = netdev_priv(dev);
1861 1863
1862 netif_stop_queue(dev); 1864 netif_stop_queue(dev);
1863 velocity_shutdown(vptr); 1865 velocity_shutdown(vptr);
@@ -1890,7 +1892,7 @@ static int velocity_close(struct net_device *dev)
1890 1892
1891static int velocity_xmit(struct sk_buff *skb, struct net_device *dev) 1893static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
1892{ 1894{
1893 struct velocity_info *vptr = dev->priv; 1895 struct velocity_info *vptr = netdev_priv(dev);
1894 int qnum = 0; 1896 int qnum = 0;
1895 struct tx_desc *td_ptr; 1897 struct tx_desc *td_ptr;
1896 struct velocity_td_info *tdinfo; 1898 struct velocity_td_info *tdinfo;
@@ -2045,7 +2047,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev)
2045static int velocity_intr(int irq, void *dev_instance, struct pt_regs *regs) 2047static int velocity_intr(int irq, void *dev_instance, struct pt_regs *regs)
2046{ 2048{
2047 struct net_device *dev = dev_instance; 2049 struct net_device *dev = dev_instance;
2048 struct velocity_info *vptr = dev->priv; 2050 struct velocity_info *vptr = netdev_priv(dev);
2049 u32 isr_status; 2051 u32 isr_status;
2050 int max_count = 0; 2052 int max_count = 0;
2051 2053
@@ -2100,7 +2102,7 @@ static int velocity_intr(int irq, void *dev_instance, struct pt_regs *regs)
2100 2102
2101static void velocity_set_multi(struct net_device *dev) 2103static void velocity_set_multi(struct net_device *dev)
2102{ 2104{
2103 struct velocity_info *vptr = dev->priv; 2105 struct velocity_info *vptr = netdev_priv(dev);
2104 struct mac_regs __iomem * regs = vptr->mac_regs; 2106 struct mac_regs __iomem * regs = vptr->mac_regs;
2105 u8 rx_mode; 2107 u8 rx_mode;
2106 int i; 2108 int i;
@@ -2149,7 +2151,7 @@ static void velocity_set_multi(struct net_device *dev)
2149 2151
2150static struct net_device_stats *velocity_get_stats(struct net_device *dev) 2152static struct net_device_stats *velocity_get_stats(struct net_device *dev)
2151{ 2153{
2152 struct velocity_info *vptr = dev->priv; 2154 struct velocity_info *vptr = netdev_priv(dev);
2153 2155
2154 /* If the hardware is down, don't touch MII */ 2156 /* If the hardware is down, don't touch MII */
2155 if(!netif_running(dev)) 2157 if(!netif_running(dev))
@@ -2192,7 +2194,7 @@ static struct net_device_stats *velocity_get_stats(struct net_device *dev)
2192 2194
2193static int velocity_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 2195static int velocity_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2194{ 2196{
2195 struct velocity_info *vptr = dev->priv; 2197 struct velocity_info *vptr = netdev_priv(dev);
2196 int ret; 2198 int ret;
2197 2199
2198 /* If we are asked for information and the device is power 2200 /* If we are asked for information and the device is power
@@ -2821,7 +2823,7 @@ static void enable_flow_control_ability(struct velocity_info *vptr)
2821 2823
2822static int velocity_ethtool_up(struct net_device *dev) 2824static int velocity_ethtool_up(struct net_device *dev)
2823{ 2825{
2824 struct velocity_info *vptr = dev->priv; 2826 struct velocity_info *vptr = netdev_priv(dev);
2825 if (!netif_running(dev)) 2827 if (!netif_running(dev))
2826 pci_set_power_state(vptr->pdev, PCI_D0); 2828 pci_set_power_state(vptr->pdev, PCI_D0);
2827 return 0; 2829 return 0;
@@ -2837,14 +2839,14 @@ static int velocity_ethtool_up(struct net_device *dev)
2837 2839
2838static void velocity_ethtool_down(struct net_device *dev) 2840static void velocity_ethtool_down(struct net_device *dev)
2839{ 2841{
2840 struct velocity_info *vptr = dev->priv; 2842 struct velocity_info *vptr = netdev_priv(dev);
2841 if (!netif_running(dev)) 2843 if (!netif_running(dev))
2842 pci_set_power_state(vptr->pdev, PCI_D3hot); 2844 pci_set_power_state(vptr->pdev, PCI_D3hot);
2843} 2845}
2844 2846
2845static int velocity_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2847static int velocity_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2846{ 2848{
2847 struct velocity_info *vptr = dev->priv; 2849 struct velocity_info *vptr = netdev_priv(dev);
2848 struct mac_regs __iomem * regs = vptr->mac_regs; 2850 struct mac_regs __iomem * regs = vptr->mac_regs;
2849 u32 status; 2851 u32 status;
2850 status = check_connection_type(vptr->mac_regs); 2852 status = check_connection_type(vptr->mac_regs);
@@ -2869,7 +2871,7 @@ static int velocity_get_settings(struct net_device *dev, struct ethtool_cmd *cmd
2869 2871
2870static int velocity_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2872static int velocity_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2871{ 2873{
2872 struct velocity_info *vptr = dev->priv; 2874 struct velocity_info *vptr = netdev_priv(dev);
2873 u32 curr_status; 2875 u32 curr_status;
2874 u32 new_status = 0; 2876 u32 new_status = 0;
2875 int ret = 0; 2877 int ret = 0;
@@ -2892,14 +2894,14 @@ static int velocity_set_settings(struct net_device *dev, struct ethtool_cmd *cmd
2892 2894
2893static u32 velocity_get_link(struct net_device *dev) 2895static u32 velocity_get_link(struct net_device *dev)
2894{ 2896{
2895 struct velocity_info *vptr = dev->priv; 2897 struct velocity_info *vptr = netdev_priv(dev);
2896 struct mac_regs __iomem * regs = vptr->mac_regs; 2898 struct mac_regs __iomem * regs = vptr->mac_regs;
2897 return BYTE_REG_BITS_IS_ON(PHYSR0_LINKGD, &regs->PHYSR0) ? 0 : 1; 2899 return BYTE_REG_BITS_IS_ON(PHYSR0_LINKGD, &regs->PHYSR0) ? 0 : 1;
2898} 2900}
2899 2901
2900static void velocity_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 2902static void velocity_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
2901{ 2903{
2902 struct velocity_info *vptr = dev->priv; 2904 struct velocity_info *vptr = netdev_priv(dev);
2903 strcpy(info->driver, VELOCITY_NAME); 2905 strcpy(info->driver, VELOCITY_NAME);
2904 strcpy(info->version, VELOCITY_VERSION); 2906 strcpy(info->version, VELOCITY_VERSION);
2905 strcpy(info->bus_info, pci_name(vptr->pdev)); 2907 strcpy(info->bus_info, pci_name(vptr->pdev));
@@ -2907,7 +2909,7 @@ static void velocity_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo
2907 2909
2908static void velocity_ethtool_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 2910static void velocity_ethtool_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2909{ 2911{
2910 struct velocity_info *vptr = dev->priv; 2912 struct velocity_info *vptr = netdev_priv(dev);
2911 wol->supported = WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_ARP; 2913 wol->supported = WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_ARP;
2912 wol->wolopts |= WAKE_MAGIC; 2914 wol->wolopts |= WAKE_MAGIC;
2913 /* 2915 /*
@@ -2923,7 +2925,7 @@ static void velocity_ethtool_get_wol(struct net_device *dev, struct ethtool_woli
2923 2925
2924static int velocity_ethtool_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 2926static int velocity_ethtool_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2925{ 2927{
2926 struct velocity_info *vptr = dev->priv; 2928 struct velocity_info *vptr = netdev_priv(dev);
2927 2929
2928 if (!(wol->wolopts & (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_ARP))) 2930 if (!(wol->wolopts & (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_ARP)))
2929 return -EFAULT; 2931 return -EFAULT;
@@ -2988,7 +2990,7 @@ static struct ethtool_ops velocity_ethtool_ops = {
2988 2990
2989static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 2991static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2990{ 2992{
2991 struct velocity_info *vptr = dev->priv; 2993 struct velocity_info *vptr = netdev_priv(dev);
2992 struct mac_regs __iomem * regs = vptr->mac_regs; 2994 struct mac_regs __iomem * regs = vptr->mac_regs;
2993 unsigned long flags; 2995 unsigned long flags;
2994 struct mii_ioctl_data *miidata = if_mii(ifr); 2996 struct mii_ioctl_data *miidata = if_mii(ifr);
diff --git a/drivers/net/via-velocity.h b/drivers/net/via-velocity.h
index f1b2640ebdc6..496c3d597444 100644
--- a/drivers/net/via-velocity.h
+++ b/drivers/net/via-velocity.h
@@ -31,6 +31,8 @@
31#define VELOCITY_FULL_DRV_NAM "VIA Networking Velocity Family Gigabit Ethernet Adapter Driver" 31#define VELOCITY_FULL_DRV_NAM "VIA Networking Velocity Family Gigabit Ethernet Adapter Driver"
32#define VELOCITY_VERSION "1.13" 32#define VELOCITY_VERSION "1.13"
33 33
34#define VELOCITY_IO_SIZE 256
35
34#define PKT_BUF_SZ 1540 36#define PKT_BUF_SZ 1540
35 37
36#define MAX_UNITS 8 38#define MAX_UNITS 8
@@ -1191,7 +1193,6 @@ enum chip_type {
1191struct velocity_info_tbl { 1193struct velocity_info_tbl {
1192 enum chip_type chip_id; 1194 enum chip_type chip_id;
1193 char *name; 1195 char *name;
1194 int io_size;
1195 int txqueue; 1196 int txqueue;
1196 u32 flags; 1197 u32 flags;
1197}; 1198};
@@ -1751,7 +1752,6 @@ struct velocity_info {
1751 struct mac_regs __iomem * mac_regs; 1752 struct mac_regs __iomem * mac_regs;
1752 unsigned long memaddr; 1753 unsigned long memaddr;
1753 unsigned long ioaddr; 1754 unsigned long ioaddr;
1754 u32 io_size;
1755 1755
1756 u8 rev_id; 1756 u8 rev_id;
1757 1757
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index b5328b0ff927..54b8e492ef97 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -134,18 +134,6 @@ config SEALEVEL_4021
134 The driver will be compiled as a module: the 134 The driver will be compiled as a module: the
135 module will be called sealevel. 135 module will be called sealevel.
136 136
137config SYNCLINK_SYNCPPP
138 tristate "SyncLink HDLC/SYNCPPP support"
139 depends on WAN
140 help
141 Enables HDLC/SYNCPPP support for the SyncLink WAN driver.
142
143 Normally the SyncLink WAN driver works with the main PPP driver
144 <file:drivers/net/ppp_generic.c> and pppd program.
145 HDLC/SYNCPPP support allows use of the Cisco HDLC/PPP driver
146 <file:drivers/net/wan/syncppp.c>. The SyncLink WAN driver (in
147 character devices) must also be enabled.
148
149# Generic HDLC 137# Generic HDLC
150config HDLC 138config HDLC
151 tristate "Generic HDLC layer" 139 tristate "Generic HDLC layer"
diff --git a/drivers/net/wan/Makefile b/drivers/net/wan/Makefile
index 823c6d5ab90d..316ca6869d5e 100644
--- a/drivers/net/wan/Makefile
+++ b/drivers/net/wan/Makefile
@@ -28,7 +28,6 @@ obj-$(CONFIG_COSA) += syncppp.o cosa.o
28obj-$(CONFIG_FARSYNC) += syncppp.o farsync.o 28obj-$(CONFIG_FARSYNC) += syncppp.o farsync.o
29obj-$(CONFIG_DSCC4) += dscc4.o 29obj-$(CONFIG_DSCC4) += dscc4.o
30obj-$(CONFIG_LANMEDIA) += syncppp.o 30obj-$(CONFIG_LANMEDIA) += syncppp.o
31obj-$(CONFIG_SYNCLINK_SYNCPPP) += syncppp.o
32obj-$(CONFIG_X25_ASY) += x25_asy.o 31obj-$(CONFIG_X25_ASY) += x25_asy.o
33 32
34obj-$(CONFIG_LANMEDIA) += lmc/ 33obj-$(CONFIG_LANMEDIA) += lmc/
diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c
index 43d854ace233..c92ac9fde083 100644
--- a/drivers/net/wan/c101.c
+++ b/drivers/net/wan/c101.c
@@ -7,7 +7,7 @@
7 * under the terms of version 2 of the GNU General Public License 7 * under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation. 8 * as published by the Free Software Foundation.
9 * 9 *
10 * For information see http://hq.pm.waw.pl/hdlc/ 10 * For information see <http://www.kernel.org/pub/linux/utils/net/hdlc/>
11 * 11 *
12 * Sources of information: 12 * Sources of information:
13 * Hitachi HD64570 SCA User's Manual 13 * Hitachi HD64570 SCA User's Manual
@@ -326,21 +326,21 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
326 if (request_irq(irq, sca_intr, 0, devname, card)) { 326 if (request_irq(irq, sca_intr, 0, devname, card)) {
327 printk(KERN_ERR "c101: could not allocate IRQ\n"); 327 printk(KERN_ERR "c101: could not allocate IRQ\n");
328 c101_destroy_card(card); 328 c101_destroy_card(card);
329 return(-EBUSY); 329 return -EBUSY;
330 } 330 }
331 card->irq = irq; 331 card->irq = irq;
332 332
333 if (!request_mem_region(winbase, C101_MAPPED_RAM_SIZE, devname)) { 333 if (!request_mem_region(winbase, C101_MAPPED_RAM_SIZE, devname)) {
334 printk(KERN_ERR "c101: could not request RAM window\n"); 334 printk(KERN_ERR "c101: could not request RAM window\n");
335 c101_destroy_card(card); 335 c101_destroy_card(card);
336 return(-EBUSY); 336 return -EBUSY;
337 } 337 }
338 card->phy_winbase = winbase; 338 card->phy_winbase = winbase;
339 card->win0base = ioremap(winbase, C101_MAPPED_RAM_SIZE); 339 card->win0base = ioremap(winbase, C101_MAPPED_RAM_SIZE);
340 if (!card->win0base) { 340 if (!card->win0base) {
341 printk(KERN_ERR "c101: could not map I/O address\n"); 341 printk(KERN_ERR "c101: could not map I/O address\n");
342 c101_destroy_card(card); 342 c101_destroy_card(card);
343 return -EBUSY; 343 return -EFAULT;
344 } 344 }
345 345
346 card->tx_ring_buffers = TX_RING_BUFFERS; 346 card->tx_ring_buffers = TX_RING_BUFFERS;
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index e392ee8b37a1..1f95b4864ea1 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -79,13 +79,11 @@
79 79
80/* ---------- Headers, macros, data structures ---------- */ 80/* ---------- Headers, macros, data structures ---------- */
81 81
82#include <linux/config.h>
83#include <linux/module.h> 82#include <linux/module.h>
84#include <linux/kernel.h> 83#include <linux/kernel.h>
85#include <linux/slab.h> 84#include <linux/slab.h>
86#include <linux/poll.h> 85#include <linux/poll.h>
87#include <linux/fs.h> 86#include <linux/fs.h>
88#include <linux/devfs_fs_kernel.h>
89#include <linux/interrupt.h> 87#include <linux/interrupt.h>
90#include <linux/delay.h> 88#include <linux/delay.h>
91#include <linux/errno.h> 89#include <linux/errno.h>
@@ -393,7 +391,6 @@ static int __init cosa_init(void)
393 err = -ENODEV; 391 err = -ENODEV;
394 goto out; 392 goto out;
395 } 393 }
396 devfs_mk_dir("cosa");
397 cosa_class = class_create(THIS_MODULE, "cosa"); 394 cosa_class = class_create(THIS_MODULE, "cosa");
398 if (IS_ERR(cosa_class)) { 395 if (IS_ERR(cosa_class)) {
399 err = PTR_ERR(cosa_class); 396 err = PTR_ERR(cosa_class);
@@ -402,13 +399,6 @@ static int __init cosa_init(void)
402 for (i=0; i<nr_cards; i++) { 399 for (i=0; i<nr_cards; i++) {
403 class_device_create(cosa_class, NULL, MKDEV(cosa_major, i), 400 class_device_create(cosa_class, NULL, MKDEV(cosa_major, i),
404 NULL, "cosa%d", i); 401 NULL, "cosa%d", i);
405 err = devfs_mk_cdev(MKDEV(cosa_major, i),
406 S_IFCHR|S_IRUSR|S_IWUSR,
407 "cosa/%d", i);
408 if (err) {
409 class_device_destroy(cosa_class, MKDEV(cosa_major, i));
410 goto out_chrdev;
411 }
412 } 402 }
413 err = 0; 403 err = 0;
414 goto out; 404 goto out;
@@ -426,12 +416,9 @@ static void __exit cosa_exit(void)
426 int i; 416 int i;
427 printk(KERN_INFO "Unloading the cosa module\n"); 417 printk(KERN_INFO "Unloading the cosa module\n");
428 418
429 for (i=0; i<nr_cards; i++) { 419 for (i=0; i<nr_cards; i++)
430 class_device_destroy(cosa_class, MKDEV(cosa_major, i)); 420 class_device_destroy(cosa_class, MKDEV(cosa_major, i));
431 devfs_remove("cosa/%d", i);
432 }
433 class_destroy(cosa_class); 421 class_destroy(cosa_class);
434 devfs_remove("cosa");
435 for (cosa=cosa_cards; nr_cards--; cosa++) { 422 for (cosa=cosa_cards; nr_cards--; cosa++) {
436 /* Clean up the per-channel data */ 423 /* Clean up the per-channel data */
437 for (i=0; i<cosa->nchannels; i++) { 424 for (i=0; i<cosa->nchannels; i++) {
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 4505540e3c59..684af4316ffd 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -732,15 +732,15 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev,
732 ioaddr = ioremap(pci_resource_start(pdev, 0), 732 ioaddr = ioremap(pci_resource_start(pdev, 0),
733 pci_resource_len(pdev, 0)); 733 pci_resource_len(pdev, 0));
734 if (!ioaddr) { 734 if (!ioaddr) {
735 printk(KERN_ERR "%s: cannot remap MMIO region %lx @ %lx\n", 735 printk(KERN_ERR "%s: cannot remap MMIO region %llx @ %llx\n",
736 DRV_NAME, pci_resource_len(pdev, 0), 736 DRV_NAME, (unsigned long long)pci_resource_len(pdev, 0),
737 pci_resource_start(pdev, 0)); 737 (unsigned long long)pci_resource_start(pdev, 0));
738 rc = -EIO; 738 rc = -EIO;
739 goto err_free_mmio_regions_2; 739 goto err_free_mmio_regions_2;
740 } 740 }
741 printk(KERN_DEBUG "Siemens DSCC4, MMIO at %#lx (regs), %#lx (lbi), IRQ %d\n", 741 printk(KERN_DEBUG "Siemens DSCC4, MMIO at %#llx (regs), %#llx (lbi), IRQ %d\n",
742 pci_resource_start(pdev, 0), 742 (unsigned long long)pci_resource_start(pdev, 0),
743 pci_resource_start(pdev, 1), pdev->irq); 743 (unsigned long long)pci_resource_start(pdev, 1), pdev->irq);
744 744
745 /* Cf errata DS5 p.2 */ 745 /* Cf errata DS5 p.2 */
746 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xf8); 746 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xf8);
@@ -752,7 +752,7 @@ static int __devinit dscc4_init_one(struct pci_dev *pdev,
752 752
753 priv = pci_get_drvdata(pdev); 753 priv = pci_get_drvdata(pdev);
754 754
755 rc = request_irq(pdev->irq, dscc4_irq, SA_SHIRQ, DRV_NAME, priv->root); 755 rc = request_irq(pdev->irq, dscc4_irq, IRQF_SHARED, DRV_NAME, priv->root);
756 if (rc < 0) { 756 if (rc < 0) {
757 printk(KERN_WARNING "%s: IRQ %d busy\n", DRV_NAME, pdev->irq); 757 printk(KERN_WARNING "%s: IRQ %d busy\n", DRV_NAME, pdev->irq);
758 goto err_release_4; 758 goto err_release_4;
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 7981a2c7906e..3705db04a343 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -2519,7 +2519,7 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2519 dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem); 2519 dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem);
2520 2520
2521 /* Register the interrupt handler */ 2521 /* Register the interrupt handler */
2522 if (request_irq(pdev->irq, fst_intr, SA_SHIRQ, FST_DEV_NAME, card)) { 2522 if (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) {
2523 printk_err("Unable to register interrupt %d\n", card->irq); 2523 printk_err("Unable to register interrupt %d\n", card->irq);
2524 pci_release_regions(pdev); 2524 pci_release_regions(pdev);
2525 pci_disable_device(pdev); 2525 pci_disable_device(pdev);
diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c
index 46cef8f92133..b7da55140fbd 100644
--- a/drivers/net/wan/hdlc_generic.c
+++ b/drivers/net/wan/hdlc_generic.c
@@ -22,7 +22,6 @@
22 * - proto.start() and stop() are called with spin_lock_irq held. 22 * - proto.start() and stop() are called with spin_lock_irq held.
23 */ 23 */
24 24
25#include <linux/config.h>
26#include <linux/module.h> 25#include <linux/module.h>
27#include <linux/kernel.h> 26#include <linux/kernel.h>
28#include <linux/slab.h> 27#include <linux/slab.h>
@@ -259,7 +258,7 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
259 } 258 }
260} 259}
261 260
262static void hdlc_setup(struct net_device *dev) 261void hdlc_setup(struct net_device *dev)
263{ 262{
264 hdlc_device *hdlc = dev_to_hdlc(dev); 263 hdlc_device *hdlc = dev_to_hdlc(dev);
265 264
@@ -288,26 +287,6 @@ struct net_device *alloc_hdlcdev(void *priv)
288 return dev; 287 return dev;
289} 288}
290 289
291int register_hdlc_device(struct net_device *dev)
292{
293 int result = dev_alloc_name(dev, "hdlc%d");
294 if (result < 0)
295 return result;
296
297 result = register_netdev(dev);
298 if (result != 0)
299 return -EIO;
300
301#if 0
302 if (netif_carrier_ok(dev))
303 netif_carrier_off(dev); /* no carrier until DCD goes up */
304#endif
305
306 return 0;
307}
308
309
310
311void unregister_hdlc_device(struct net_device *dev) 290void unregister_hdlc_device(struct net_device *dev)
312{ 291{
313 rtnl_lock(); 292 rtnl_lock();
@@ -326,8 +305,8 @@ EXPORT_SYMBOL(hdlc_open);
326EXPORT_SYMBOL(hdlc_close); 305EXPORT_SYMBOL(hdlc_close);
327EXPORT_SYMBOL(hdlc_set_carrier); 306EXPORT_SYMBOL(hdlc_set_carrier);
328EXPORT_SYMBOL(hdlc_ioctl); 307EXPORT_SYMBOL(hdlc_ioctl);
308EXPORT_SYMBOL(hdlc_setup);
329EXPORT_SYMBOL(alloc_hdlcdev); 309EXPORT_SYMBOL(alloc_hdlcdev);
330EXPORT_SYMBOL(register_hdlc_device);
331EXPORT_SYMBOL(unregister_hdlc_device); 310EXPORT_SYMBOL(unregister_hdlc_device);
332 311
333static struct packet_type hdlc_packet_type = { 312static struct packet_type hdlc_packet_type = {
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c
index cf5c805452a3..a4f735723c41 100644
--- a/drivers/net/wan/hostess_sv11.c
+++ b/drivers/net/wan/hostess_sv11.c
@@ -264,7 +264,7 @@ static struct sv11_device *sv11_init(int iobase, int irq)
264 /* We want a fast IRQ for this device. Actually we'd like an even faster 264 /* We want a fast IRQ for this device. Actually we'd like an even faster
265 IRQ ;) - This is one driver RtLinux is made for */ 265 IRQ ;) - This is one driver RtLinux is made for */
266 266
267 if(request_irq(irq, &z8530_interrupt, SA_INTERRUPT, "Hostess SV11", dev)<0) 267 if(request_irq(irq, &z8530_interrupt, IRQF_DISABLED, "Hostess SV11", dev)<0)
268 { 268 {
269 printk(KERN_WARNING "hostess: IRQ %d already in use.\n", irq); 269 printk(KERN_WARNING "hostess: IRQ %d already in use.\n", irq);
270 goto fail1; 270 goto fail1;
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 40926d779161..39f44241a728 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -1058,7 +1058,7 @@ static int lmc_open (struct net_device *dev) /*fold00*/
1058 lmc_softreset (sc); 1058 lmc_softreset (sc);
1059 1059
1060 /* Since we have to use PCI bus, this should work on x86,alpha,ppc */ 1060 /* Since we have to use PCI bus, this should work on x86,alpha,ppc */
1061 if (request_irq (dev->irq, &lmc_interrupt, SA_SHIRQ, dev->name, dev)){ 1061 if (request_irq (dev->irq, &lmc_interrupt, IRQF_SHARED, dev->name, dev)){
1062 printk(KERN_WARNING "%s: could not get irq: %d\n", dev->name, dev->irq); 1062 printk(KERN_WARNING "%s: could not get irq: %d\n", dev->name, dev->irq);
1063 lmc_trace(dev, "lmc_open irq failed out"); 1063 lmc_trace(dev, "lmc_open irq failed out");
1064 return -EAGAIN; 1064 return -EAGAIN;
diff --git a/drivers/net/wan/lmc/lmc_media.c b/drivers/net/wan/lmc/lmc_media.c
index af8b55fdd9d9..ae01555d24cf 100644
--- a/drivers/net/wan/lmc/lmc_media.c
+++ b/drivers/net/wan/lmc/lmc_media.c
@@ -1,6 +1,5 @@
1/* $Id: lmc_media.c,v 1.13 2000/04/11 05:25:26 asj Exp $ */ 1/* $Id: lmc_media.c,v 1.13 2000/04/11 05:25:26 asj Exp $ */
2 2
3#include <linux/config.h>
4#include <linux/kernel.h> 3#include <linux/kernel.h>
5#include <linux/string.h> 4#include <linux/string.h>
6#include <linux/timer.h> 5#include <linux/timer.h>
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
index cd32751b64eb..e013b817cab8 100644
--- a/drivers/net/wan/n2.c
+++ b/drivers/net/wan/n2.c
@@ -7,7 +7,7 @@
7 * under the terms of version 2 of the GNU General Public License 7 * under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation. 8 * as published by the Free Software Foundation.
9 * 9 *
10 * For information see http://hq.pm.waw.pl/hdlc/ 10 * For information see <http://www.kernel.org/pub/linux/utils/net/hdlc/>
11 * 11 *
12 * Note: integrated CSU/DSU/DDS are not supported by this driver 12 * Note: integrated CSU/DSU/DDS are not supported by this driver
13 * 13 *
@@ -387,6 +387,11 @@ static int __init n2_run(unsigned long io, unsigned long irq,
387 } 387 }
388 card->phy_winbase = winbase; 388 card->phy_winbase = winbase;
389 card->winbase = ioremap(winbase, USE_WINDOWSIZE); 389 card->winbase = ioremap(winbase, USE_WINDOWSIZE);
390 if (!card->winbase) {
391 printk(KERN_ERR "n2: ioremap() failed\n");
392 n2_destroy_card(card);
393 return -EFAULT;
394 }
390 395
391 outb(0, io + N2_PCR); 396 outb(0, io + N2_PCR);
392 outb(winbase >> 12, io + N2_BAR); 397 outb(winbase >> 12, io + N2_BAR);
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index a3e65d1bc19b..567effff4a3e 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -3445,9 +3445,9 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3445 3445
3446 card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL); 3446 card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL);
3447 if (card == NULL) { 3447 if (card == NULL) {
3448 printk("PC300 found at RAM 0x%08lx, " 3448 printk("PC300 found at RAM 0x%016llx, "
3449 "but could not allocate card structure.\n", 3449 "but could not allocate card structure.\n",
3450 pci_resource_start(pdev, 3)); 3450 (unsigned long long)pci_resource_start(pdev, 3));
3451 err = -ENOMEM; 3451 err = -ENOMEM;
3452 goto err_disable_dev; 3452 goto err_disable_dev;
3453 } 3453 }
@@ -3600,7 +3600,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
3600 } 3600 }
3601 3601
3602 /* Allocate IRQ */ 3602 /* Allocate IRQ */
3603 if (request_irq(card->hw.irq, cpc_intr, SA_SHIRQ, "Cyclades-PC300", card)) { 3603 if (request_irq(card->hw.irq, cpc_intr, IRQF_SHARED, "Cyclades-PC300", card)) {
3604 printk ("PC300 found at RAM 0x%08x, but could not allocate IRQ%d.\n", 3604 printk ("PC300 found at RAM 0x%08x, but could not allocate IRQ%d.\n",
3605 card->hw.ramphys, card->hw.irq); 3605 card->hw.ramphys, card->hw.irq);
3606 goto err_io_unmap; 3606 goto err_io_unmap;
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
index f485a97844cc..4df61fa3214b 100644
--- a/drivers/net/wan/pci200syn.c
+++ b/drivers/net/wan/pci200syn.c
@@ -7,7 +7,7 @@
7 * under the terms of version 2 of the GNU General Public License 7 * under the terms of version 2 of the GNU General Public License
8 * as published by the Free Software Foundation. 8 * as published by the Free Software Foundation.
9 * 9 *
10 * For information see http://hq.pm.waw.pl/hdlc/ 10 * For information see <http://www.kernel.org/pub/linux/utils/net/hdlc/>
11 * 11 *
12 * Sources of information: 12 * Sources of information:
13 * Hitachi HD64572 SCA-II User's Manual 13 * Hitachi HD64572 SCA-II User's Manual
@@ -354,6 +354,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
354 card->rambase == NULL) { 354 card->rambase == NULL) {
355 printk(KERN_ERR "pci200syn: ioremap() failed\n"); 355 printk(KERN_ERR "pci200syn: ioremap() failed\n");
356 pci200_pci_remove_one(pdev); 356 pci200_pci_remove_one(pdev);
357 return -EFAULT;
357 } 358 }
358 359
359 /* Reset PLX */ 360 /* Reset PLX */
@@ -401,7 +402,7 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
401 writew(readw(p) | 0x0040, p); 402 writew(readw(p) | 0x0040, p);
402 403
403 /* Allocate IRQ */ 404 /* Allocate IRQ */
404 if (request_irq(pdev->irq, sca_intr, SA_SHIRQ, devname, card)) { 405 if (request_irq(pdev->irq, sca_intr, IRQF_SHARED, devname, card)) {
405 printk(KERN_WARNING "pci200syn: could not allocate IRQ%d.\n", 406 printk(KERN_WARNING "pci200syn: could not allocate IRQ%d.\n",
406 pdev->irq); 407 pdev->irq);
407 pci200_pci_remove_one(pdev); 408 pci200_pci_remove_one(pdev);
diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c
index 175ba13bce41..fc75bec19029 100644
--- a/drivers/net/wan/sbni.c
+++ b/drivers/net/wan/sbni.c
@@ -37,7 +37,6 @@
37 * Known problem: this driver wasn't tested on multiprocessor machine. 37 * Known problem: this driver wasn't tested on multiprocessor machine.
38 */ 38 */
39 39
40#include <linux/config.h>
41#include <linux/module.h> 40#include <linux/module.h>
42#include <linux/kernel.h> 41#include <linux/kernel.h>
43#include <linux/ptrace.h> 42#include <linux/ptrace.h>
@@ -1193,7 +1192,7 @@ sbni_open( struct net_device *dev )
1193 } 1192 }
1194 } 1193 }
1195 1194
1196 if( request_irq(dev->irq, sbni_interrupt, SA_SHIRQ, dev->name, dev) ) { 1195 if( request_irq(dev->irq, sbni_interrupt, IRQF_SHARED, dev->name, dev) ) {
1197 printk( KERN_ERR "%s: unable to get IRQ %d.\n", 1196 printk( KERN_ERR "%s: unable to get IRQ %d.\n",
1198 dev->name, dev->irq ); 1197 dev->name, dev->irq );
1199 return -EAGAIN; 1198 return -EAGAIN;
diff --git a/drivers/net/wan/sdla.c b/drivers/net/wan/sdla.c
index 22e794071cf4..7628c2d81f45 100644
--- a/drivers/net/wan/sdla.c
+++ b/drivers/net/wan/sdla.c
@@ -60,9 +60,9 @@
60 60
61static const char* version = "SDLA driver v0.30, 12 Sep 1996, mike.mclagan@linux.org"; 61static const char* version = "SDLA driver v0.30, 12 Sep 1996, mike.mclagan@linux.org";
62 62
63static unsigned int valid_port[] __initdata = { 0x250, 0x270, 0x280, 0x300, 0x350, 0x360, 0x380, 0x390}; 63static unsigned int valid_port[] = { 0x250, 0x270, 0x280, 0x300, 0x350, 0x360, 0x380, 0x390};
64 64
65static unsigned int valid_mem[] __initdata = { 65static unsigned int valid_mem[] = {
66 0xA0000, 0xA2000, 0xA4000, 0xA6000, 0xA8000, 0xAA000, 0xAC000, 0xAE000, 66 0xA0000, 0xA2000, 0xA4000, 0xA6000, 0xA8000, 0xAA000, 0xAC000, 0xAE000,
67 0xB0000, 0xB2000, 0xB4000, 0xB6000, 0xB8000, 0xBA000, 0xBC000, 0xBE000, 67 0xB0000, 0xB2000, 0xB4000, 0xB6000, 0xB8000, 0xBA000, 0xBC000, 0xBE000,
68 0xC0000, 0xC2000, 0xC4000, 0xC6000, 0xC8000, 0xCA000, 0xCC000, 0xCE000, 68 0xC0000, 0xC2000, 0xC4000, 0xC6000, 0xC8000, 0xCA000, 0xCC000, 0xCE000,
diff --git a/drivers/net/wan/sealevel.c b/drivers/net/wan/sealevel.c
index 050e854e7774..70fb1b98b1dd 100644
--- a/drivers/net/wan/sealevel.c
+++ b/drivers/net/wan/sealevel.c
@@ -322,7 +322,7 @@ static __init struct slvl_board *slvl_init(int iobase, int irq,
322 /* We want a fast IRQ for this device. Actually we'd like an even faster 322 /* We want a fast IRQ for this device. Actually we'd like an even faster
323 IRQ ;) - This is one driver RtLinux is made for */ 323 IRQ ;) - This is one driver RtLinux is made for */
324 324
325 if(request_irq(irq, &z8530_interrupt, SA_INTERRUPT, "SeaLevel", dev)<0) 325 if(request_irq(irq, &z8530_interrupt, IRQF_DISABLED, "SeaLevel", dev)<0)
326 { 326 {
327 printk(KERN_WARNING "sealevel: IRQ %d already in use.\n", irq); 327 printk(KERN_WARNING "sealevel: IRQ %d already in use.\n", irq);
328 goto fail1_1; 328 goto fail1_1;
diff --git a/drivers/net/wan/syncppp.c b/drivers/net/wan/syncppp.c
index 2d1bba06a085..c13b459a0137 100644
--- a/drivers/net/wan/syncppp.c
+++ b/drivers/net/wan/syncppp.c
@@ -37,7 +37,6 @@
37 */ 37 */
38#undef DEBUG 38#undef DEBUG
39 39
40#include <linux/config.h>
41#include <linux/module.h> 40#include <linux/module.h>
42#include <linux/kernel.h> 41#include <linux/kernel.h>
43#include <linux/errno.h> 42#include <linux/errno.h>
diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
index 29a756dd979b..d564224cdca9 100644
--- a/drivers/net/wan/wanxl.c
+++ b/drivers/net/wan/wanxl.c
@@ -634,7 +634,13 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
634 634
635 /* set up PLX mapping */ 635 /* set up PLX mapping */
636 plx_phy = pci_resource_start(pdev, 0); 636 plx_phy = pci_resource_start(pdev, 0);
637
637 card->plx = ioremap_nocache(plx_phy, 0x70); 638 card->plx = ioremap_nocache(plx_phy, 0x70);
639 if (!card->plx) {
640 printk(KERN_ERR "wanxl: ioremap() failed\n");
641 wanxl_pci_remove_one(pdev);
642 return -EFAULT;
643 }
638 644
639#if RESET_WHILE_LOADING 645#if RESET_WHILE_LOADING
640 wanxl_reset(card); 646 wanxl_reset(card);
@@ -700,6 +706,12 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
700 } 706 }
701 707
702 mem = ioremap_nocache(mem_phy, PDM_OFFSET + sizeof(firmware)); 708 mem = ioremap_nocache(mem_phy, PDM_OFFSET + sizeof(firmware));
709 if (!mem) {
710 printk(KERN_ERR "wanxl: ioremap() failed\n");
711 wanxl_pci_remove_one(pdev);
712 return -EFAULT;
713 }
714
703 for (i = 0; i < sizeof(firmware); i += 4) 715 for (i = 0; i < sizeof(firmware); i += 4)
704 writel(htonl(*(u32*)(firmware + i)), mem + PDM_OFFSET + i); 716 writel(htonl(*(u32*)(firmware + i)), mem + PDM_OFFSET + i);
705 717
@@ -743,7 +755,7 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
743 pci_name(pdev), plx_phy, ramsize / 1024, mem_phy, pdev->irq); 755 pci_name(pdev), plx_phy, ramsize / 1024, mem_phy, pdev->irq);
744 756
745 /* Allocate IRQ */ 757 /* Allocate IRQ */
746 if (request_irq(pdev->irq, wanxl_intr, SA_SHIRQ, "wanXL", card)) { 758 if (request_irq(pdev->irq, wanxl_intr, IRQF_SHARED, "wanXL", card)) {
747 printk(KERN_WARNING "wanXL %s: could not allocate IRQ%i.\n", 759 printk(KERN_WARNING "wanXL %s: could not allocate IRQ%i.\n",
748 pci_name(pdev), pdev->irq); 760 pci_name(pdev), pdev->irq);
749 wanxl_pci_remove_one(pdev); 761 wanxl_pci_remove_one(pdev);
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 30ec235e6935..fa9d2c4edc93 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -550,6 +550,7 @@ config USB_ZD1201
550 550
551source "drivers/net/wireless/hostap/Kconfig" 551source "drivers/net/wireless/hostap/Kconfig"
552source "drivers/net/wireless/bcm43xx/Kconfig" 552source "drivers/net/wireless/bcm43xx/Kconfig"
553source "drivers/net/wireless/zd1211rw/Kconfig"
553 554
554# yes, this works even when no drivers are selected 555# yes, this works even when no drivers are selected
555config NET_WIRELESS 556config NET_WIRELESS
diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile
index 512603de309a..c613af17a159 100644
--- a/drivers/net/wireless/Makefile
+++ b/drivers/net/wireless/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_PRISM54) += prism54/
36 36
37obj-$(CONFIG_HOSTAP) += hostap/ 37obj-$(CONFIG_HOSTAP) += hostap/
38obj-$(CONFIG_BCM43XX) += bcm43xx/ 38obj-$(CONFIG_BCM43XX) += bcm43xx/
39obj-$(CONFIG_ZD1211RW) += zd1211rw/
39 40
40# 16-bit wireless PCMCIA client drivers 41# 16-bit wireless PCMCIA client drivers
41obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o 42obj-$(CONFIG_PCMCIA_RAYCS) += ray_cs.o
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 4069b79d8259..a4dd13942714 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -19,7 +19,6 @@
19 19
20======================================================================*/ 20======================================================================*/
21 21
22#include <linux/config.h>
23#include <linux/init.h> 22#include <linux/init.h>
24 23
25#include <linux/kernel.h> 24#include <linux/kernel.h>
@@ -2849,7 +2848,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2849 reset_card (dev, 1); 2848 reset_card (dev, 1);
2850 msleep(400); 2849 msleep(400);
2851 2850
2852 rc = request_irq( dev->irq, airo_interrupt, SA_SHIRQ, dev->name, dev ); 2851 rc = request_irq( dev->irq, airo_interrupt, IRQF_SHARED, dev->name, dev );
2853 if (rc) { 2852 if (rc) {
2854 airo_print_err(dev->name, "register interrupt %d failed, rc %d", 2853 airo_print_err(dev->name, "register interrupt %d failed, rc %d",
2855 irq, rc); 2854 irq, rc);
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index af0cbb6c5c0c..ac9437d497f0 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -20,7 +20,6 @@
20 20
21======================================================================*/ 21======================================================================*/
22 22
23#include <linux/config.h>
24#ifdef __IN_PCMCIA_PACKAGE__ 23#ifdef __IN_PCMCIA_PACKAGE__
25#include <pcmcia/k_compat.h> 24#include <pcmcia/k_compat.h>
26#endif 25#endif
diff --git a/drivers/net/wireless/airport.c b/drivers/net/wireless/airport.c
index 7b321f7cf358..38fac3bbcd82 100644
--- a/drivers/net/wireless/airport.c
+++ b/drivers/net/wireless/airport.c
@@ -14,7 +14,6 @@
14#define DRIVER_NAME "airport" 14#define DRIVER_NAME "airport"
15#define PFX DRIVER_NAME ": " 15#define PFX DRIVER_NAME ": "
16 16
17#include <linux/config.h>
18#include <linux/module.h> 17#include <linux/module.h>
19#include <linux/kernel.h> 18#include <linux/kernel.h>
20#include <linux/init.h> 19#include <linux/init.h>
diff --git a/drivers/net/wireless/arlan-main.c b/drivers/net/wireless/arlan-main.c
index bed6823d9809..bb6bea4f3233 100644
--- a/drivers/net/wireless/arlan-main.c
+++ b/drivers/net/wireless/arlan-main.c
@@ -5,7 +5,6 @@
5 * This module provides support for the Arlan 655 card made by Aironet 5 * This module provides support for the Arlan 655 card made by Aironet
6 */ 6 */
7 7
8#include <linux/config.h>
9#include "arlan.h" 8#include "arlan.h"
10 9
11#if BITS_PER_LONG != 32 10#if BITS_PER_LONG != 32
diff --git a/drivers/net/wireless/arlan-proc.c b/drivers/net/wireless/arlan-proc.c
index a2cca521f444..5fa985435ffa 100644
--- a/drivers/net/wireless/arlan-proc.c
+++ b/drivers/net/wireless/arlan-proc.c
@@ -1,4 +1,3 @@
1#include <linux/config.h>
2#include "arlan.h" 1#include "arlan.h"
3 2
4#include <linux/sysctl.h> 3#include <linux/sysctl.h>
diff --git a/drivers/net/wireless/arlan.h b/drivers/net/wireless/arlan.h
index 70a6d7b83c4a..3ed1df75900f 100644
--- a/drivers/net/wireless/arlan.h
+++ b/drivers/net/wireless/arlan.h
@@ -5,7 +5,6 @@
5 */ 5 */
6 6
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/config.h>
9#include <linux/kernel.h> 8#include <linux/kernel.h>
10#include <linux/types.h> 9#include <linux/types.h>
11#include <linux/skbuff.h> 10#include <linux/skbuff.h>
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 8606c88886fc..995c7bea5897 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -39,7 +39,6 @@
39 39
40******************************************************************************/ 40******************************************************************************/
41 41
42#include <linux/config.h>
43#include <linux/init.h> 42#include <linux/init.h>
44 43
45#include <linux/kernel.h> 44#include <linux/kernel.h>
@@ -1578,7 +1577,7 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
1578 1577
1579 SET_NETDEV_DEV(dev, sys_dev); 1578 SET_NETDEV_DEV(dev, sys_dev);
1580 1579
1581 if ((rc = request_irq(dev->irq, service_interrupt, SA_SHIRQ, dev->name, dev))) { 1580 if ((rc = request_irq(dev->irq, service_interrupt, IRQF_SHARED, dev->name, dev))) {
1582 printk(KERN_ERR "%s: register interrupt %d failed, rc %d\n", dev->name, irq, rc); 1581 printk(KERN_ERR "%s: register interrupt %d failed, rc %d\n", dev->name, irq, rc);
1583 goto err_out_free; 1582 goto err_out_free;
1584 } 1583 }
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 26bf1127524d..785664090bb4 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -29,7 +29,6 @@
29 29
30******************************************************************************/ 30******************************************************************************/
31 31
32#include <linux/config.h>
33#ifdef __IN_PCMCIA_PACKAGE__ 32#ifdef __IN_PCMCIA_PACKAGE__
34#include <pcmcia/k_compat.h> 33#include <pcmcia/k_compat.h>
35#endif 34#endif
diff --git a/drivers/net/wireless/atmel_pci.c b/drivers/net/wireless/atmel_pci.c
index a61b3bc6cccf..d425c3cefded 100644
--- a/drivers/net/wireless/atmel_pci.c
+++ b/drivers/net/wireless/atmel_pci.c
@@ -19,7 +19,6 @@
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 20
21******************************************************************************/ 21******************************************************************************/
22#include <linux/config.h>
23#include <linux/pci.h> 22#include <linux/pci.h>
24#include <linux/kernel.h> 23#include <linux/kernel.h>
25#include <linux/module.h> 24#include <linux/module.h>
diff --git a/drivers/net/wireless/bcm43xx/Kconfig b/drivers/net/wireless/bcm43xx/Kconfig
index 25ea4748f0b9..533993f538fc 100644
--- a/drivers/net/wireless/bcm43xx/Kconfig
+++ b/drivers/net/wireless/bcm43xx/Kconfig
@@ -2,6 +2,7 @@ config BCM43XX
2 tristate "Broadcom BCM43xx wireless support" 2 tristate "Broadcom BCM43xx wireless support"
3 depends on PCI && IEEE80211 && IEEE80211_SOFTMAC && NET_RADIO && EXPERIMENTAL 3 depends on PCI && IEEE80211 && IEEE80211_SOFTMAC && NET_RADIO && EXPERIMENTAL
4 select FW_LOADER 4 select FW_LOADER
5 select HW_RANDOM
5 ---help--- 6 ---help---
6 This is an experimental driver for the Broadcom 43xx wireless chip, 7 This is an experimental driver for the Broadcom 43xx wireless chip,
7 found in the Apple Airport Extreme and various other devices. 8 found in the Apple Airport Extreme and various other devices.
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index d8f917c21ea4..17a56828e232 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -1,6 +1,7 @@
1#ifndef BCM43xx_H_ 1#ifndef BCM43xx_H_
2#define BCM43xx_H_ 2#define BCM43xx_H_
3 3
4#include <linux/hw_random.h>
4#include <linux/version.h> 5#include <linux/version.h>
5#include <linux/kernel.h> 6#include <linux/kernel.h>
6#include <linux/spinlock.h> 7#include <linux/spinlock.h>
@@ -82,6 +83,7 @@
82#define BCM43xx_MMIO_TSF_1 0x634 /* core rev < 3 only */ 83#define BCM43xx_MMIO_TSF_1 0x634 /* core rev < 3 only */
83#define BCM43xx_MMIO_TSF_2 0x636 /* core rev < 3 only */ 84#define BCM43xx_MMIO_TSF_2 0x636 /* core rev < 3 only */
84#define BCM43xx_MMIO_TSF_3 0x638 /* core rev < 3 only */ 85#define BCM43xx_MMIO_TSF_3 0x638 /* core rev < 3 only */
86#define BCM43xx_MMIO_RNG 0x65A
85#define BCM43xx_MMIO_POWERUP_DELAY 0x6A8 87#define BCM43xx_MMIO_POWERUP_DELAY 0x6A8
86 88
87/* SPROM offsets. */ 89/* SPROM offsets. */
@@ -750,6 +752,10 @@ struct bcm43xx_private {
750 const struct firmware *initvals0; 752 const struct firmware *initvals0;
751 const struct firmware *initvals1; 753 const struct firmware *initvals1;
752 754
755 /* Random Number Generator. */
756 struct hwrng rng;
757 char rng_name[20 + 1];
758
753 /* Debugging stuff follows. */ 759 /* Debugging stuff follows. */
754#ifdef CONFIG_BCM43XX_DEBUG 760#ifdef CONFIG_BCM43XX_DEBUG
755 struct bcm43xx_dfsentry *dfsentry; 761 struct bcm43xx_dfsentry *dfsentry;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_ethtool.c b/drivers/net/wireless/bcm43xx/bcm43xx_ethtool.c
index b3ffcf501311..e386dcc32e8c 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_ethtool.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_ethtool.c
@@ -32,7 +32,7 @@
32#include <linux/netdevice.h> 32#include <linux/netdevice.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/version.h> 35#include <linux/utsrelease.h>
36 36
37 37
38static void bcm43xx_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 38static void bcm43xx_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index 085d7857fe31..e1c5a939bca4 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -1885,6 +1885,15 @@ static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id, struct pt_re
1885 1885
1886 spin_lock(&bcm->irq_lock); 1886 spin_lock(&bcm->irq_lock);
1887 1887
1888 /* Only accept IRQs, if we are initialized properly.
1889 * This avoids an RX race while initializing.
1890 * We should probably not enable IRQs before we are initialized
1891 * completely, but some careful work is needed to fix this. I think it
1892 * is best to stay with this cheap workaround for now... .
1893 */
1894 if (unlikely(bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED))
1895 goto out;
1896
1888 reason = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON); 1897 reason = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
1889 if (reason == 0xffffffff) { 1898 if (reason == 0xffffffff) {
1890 /* irq not for us (shared irq) */ 1899 /* irq not for us (shared irq) */
@@ -1906,19 +1915,11 @@ static irqreturn_t bcm43xx_interrupt_handler(int irq, void *dev_id, struct pt_re
1906 1915
1907 bcm43xx_interrupt_ack(bcm, reason); 1916 bcm43xx_interrupt_ack(bcm, reason);
1908 1917
1909 /* Only accept IRQs, if we are initialized properly. 1918 /* disable all IRQs. They are enabled again in the bottom half. */
1910 * This avoids an RX race while initializing. 1919 bcm->irq_savedstate = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
1911 * We should probably not enable IRQs before we are initialized 1920 /* save the reason code and call our bottom half. */
1912 * completely, but some careful work is needed to fix this. I think it 1921 bcm->irq_reason = reason;
1913 * is best to stay with this cheap workaround for now... . 1922 tasklet_schedule(&bcm->isr_tasklet);
1914 */
1915 if (likely(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED)) {
1916 /* disable all IRQs. They are enabled again in the bottom half. */
1917 bcm->irq_savedstate = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
1918 /* save the reason code and call our bottom half. */
1919 bcm->irq_reason = reason;
1920 tasklet_schedule(&bcm->isr_tasklet);
1921 }
1922 1923
1923out: 1924out:
1924 mmiowb(); 1925 mmiowb();
@@ -2175,7 +2176,7 @@ static int bcm43xx_initialize_irq(struct bcm43xx_private *bcm)
2175 } 2176 }
2176#endif 2177#endif
2177 res = request_irq(bcm->irq, bcm43xx_interrupt_handler, 2178 res = request_irq(bcm->irq, bcm43xx_interrupt_handler,
2178 SA_SHIRQ, KBUILD_MODNAME, bcm); 2179 IRQF_SHARED, KBUILD_MODNAME, bcm);
2179 if (res) { 2180 if (res) {
2180 printk(KERN_ERR PFX "Cannot register IRQ%d\n", bcm->irq); 2181 printk(KERN_ERR PFX "Cannot register IRQ%d\n", bcm->irq);
2181 return -ENODEV; 2182 return -ENODEV;
@@ -3237,6 +3238,39 @@ static void bcm43xx_security_init(struct bcm43xx_private *bcm)
3237 bcm43xx_clear_keys(bcm); 3238 bcm43xx_clear_keys(bcm);
3238} 3239}
3239 3240
3241static int bcm43xx_rng_read(struct hwrng *rng, u32 *data)
3242{
3243 struct bcm43xx_private *bcm = (struct bcm43xx_private *)rng->priv;
3244 unsigned long flags;
3245
3246 bcm43xx_lock_irqonly(bcm, flags);
3247 *data = bcm43xx_read16(bcm, BCM43xx_MMIO_RNG);
3248 bcm43xx_unlock_irqonly(bcm, flags);
3249
3250 return (sizeof(u16));
3251}
3252
3253static void bcm43xx_rng_exit(struct bcm43xx_private *bcm)
3254{
3255 hwrng_unregister(&bcm->rng);
3256}
3257
3258static int bcm43xx_rng_init(struct bcm43xx_private *bcm)
3259{
3260 int err;
3261
3262 snprintf(bcm->rng_name, ARRAY_SIZE(bcm->rng_name),
3263 "%s_%s", KBUILD_MODNAME, bcm->net_dev->name);
3264 bcm->rng.name = bcm->rng_name;
3265 bcm->rng.data_read = bcm43xx_rng_read;
3266 bcm->rng.priv = (unsigned long)bcm;
3267 err = hwrng_register(&bcm->rng);
3268 if (err)
3269 printk(KERN_ERR PFX "RNG init failed (%d)\n", err);
3270
3271 return err;
3272}
3273
3240/* This is the opposite of bcm43xx_init_board() */ 3274/* This is the opposite of bcm43xx_init_board() */
3241static void bcm43xx_free_board(struct bcm43xx_private *bcm) 3275static void bcm43xx_free_board(struct bcm43xx_private *bcm)
3242{ 3276{
@@ -3248,6 +3282,7 @@ static void bcm43xx_free_board(struct bcm43xx_private *bcm)
3248 3282
3249 bcm43xx_set_status(bcm, BCM43xx_STAT_SHUTTINGDOWN); 3283 bcm43xx_set_status(bcm, BCM43xx_STAT_SHUTTINGDOWN);
3250 3284
3285 bcm43xx_rng_exit(bcm);
3251 for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) { 3286 for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
3252 if (!bcm->core_80211[i].available) 3287 if (!bcm->core_80211[i].available)
3253 continue; 3288 continue;
@@ -3325,6 +3360,9 @@ static int bcm43xx_init_board(struct bcm43xx_private *bcm)
3325 bcm43xx_switch_core(bcm, &bcm->core_80211[0]); 3360 bcm43xx_switch_core(bcm, &bcm->core_80211[0]);
3326 bcm43xx_mac_enable(bcm); 3361 bcm43xx_mac_enable(bcm);
3327 } 3362 }
3363 err = bcm43xx_rng_init(bcm);
3364 if (err)
3365 goto err_80211_unwind;
3328 bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC); 3366 bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC);
3329 bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr)); 3367 bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr));
3330 dprintk(KERN_INFO PFX "80211 cores initialized\n"); 3368 dprintk(KERN_INFO PFX "80211 cores initialized\n");
@@ -3661,6 +3699,10 @@ static void bcm43xx_ieee80211_set_security(struct net_device *net_dev,
3661 secinfo->encrypt = sec->encrypt; 3699 secinfo->encrypt = sec->encrypt;
3662 dprintk(", .encrypt = %d", sec->encrypt); 3700 dprintk(", .encrypt = %d", sec->encrypt);
3663 } 3701 }
3702 if (sec->flags & SEC_AUTH_MODE) {
3703 secinfo->auth_mode = sec->auth_mode;
3704 dprintk(", .auth_mode = %d\n", sec->auth_mode);
3705 }
3664 dprintk("\n"); 3706 dprintk("\n");
3665 if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED && 3707 if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED &&
3666 !bcm->ieee->host_encrypt) { 3708 !bcm->ieee->host_encrypt) {
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.h b/drivers/net/wireless/bcm43xx/bcm43xx_main.h
index 30a202b258b5..116493671f88 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.h
@@ -112,30 +112,6 @@ int bcm43xx_channel_to_freq(struct bcm43xx_private *bcm,
112 return bcm43xx_channel_to_freq_bg(channel); 112 return bcm43xx_channel_to_freq_bg(channel);
113} 113}
114 114
115/* Lightweight function to check if a channel number is valid.
116 * Note that this does _NOT_ check for geographical restrictions!
117 */
118static inline
119int bcm43xx_is_valid_channel_a(u8 channel)
120{
121 return (channel >= IEEE80211_52GHZ_MIN_CHANNEL
122 && channel <= IEEE80211_52GHZ_MAX_CHANNEL);
123}
124static inline
125int bcm43xx_is_valid_channel_bg(u8 channel)
126{
127 return (channel >= IEEE80211_24GHZ_MIN_CHANNEL
128 && channel <= IEEE80211_24GHZ_MAX_CHANNEL);
129}
130static inline
131int bcm43xx_is_valid_channel(struct bcm43xx_private *bcm,
132 u8 channel)
133{
134 if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A)
135 return bcm43xx_is_valid_channel_a(channel);
136 return bcm43xx_is_valid_channel_bg(channel);
137}
138
139void bcm43xx_tsf_read(struct bcm43xx_private *bcm, u64 *tsf); 115void bcm43xx_tsf_read(struct bcm43xx_private *bcm, u64 *tsf);
140void bcm43xx_tsf_write(struct bcm43xx_private *bcm, u64 tsf); 116void bcm43xx_tsf_write(struct bcm43xx_private *bcm, u64 tsf);
141 117
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
index af5c0bff1696..bb9c484d7e19 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_radio.c
@@ -1594,11 +1594,11 @@ int bcm43xx_radio_selectchannel(struct bcm43xx_private *bcm,
1594 u16 r8, tmp; 1594 u16 r8, tmp;
1595 u16 freq; 1595 u16 freq;
1596 1596
1597 if (!ieee80211_is_valid_channel(bcm->ieee, channel))
1598 return -EINVAL;
1597 if ((radio->manufact == 0x17F) && 1599 if ((radio->manufact == 0x17F) &&
1598 (radio->version == 0x2060) && 1600 (radio->version == 0x2060) &&
1599 (radio->revision == 1)) { 1601 (radio->revision == 1)) {
1600 if (channel > 200)
1601 return -EINVAL;
1602 freq = channel2freq_a(channel); 1602 freq = channel2freq_a(channel);
1603 1603
1604 r8 = bcm43xx_radio_read16(bcm, 0x0008); 1604 r8 = bcm43xx_radio_read16(bcm, 0x0008);
@@ -1651,9 +1651,6 @@ int bcm43xx_radio_selectchannel(struct bcm43xx_private *bcm,
1651 TODO(); //TODO: TSSI2dbm workaround 1651 TODO(); //TODO: TSSI2dbm workaround
1652 bcm43xx_phy_xmitpower(bcm);//FIXME correct? 1652 bcm43xx_phy_xmitpower(bcm);//FIXME correct?
1653 } else { 1653 } else {
1654 if ((channel < 1) || (channel > 14))
1655 return -EINVAL;
1656
1657 if (synthetic_pu_workaround) 1654 if (synthetic_pu_workaround)
1658 bcm43xx_synth_pu_workaround(bcm, channel); 1655 bcm43xx_synth_pu_workaround(bcm, channel);
1659 1656
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index c35cb3a0777e..5c36e29efff7 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
@@ -119,7 +119,7 @@ static int bcm43xx_wx_set_channelfreq(struct net_device *net_dev,
119 channel = bcm43xx_freq_to_channel(bcm, data->freq.m); 119 channel = bcm43xx_freq_to_channel(bcm, data->freq.m);
120 freq = data->freq.m; 120 freq = data->freq.m;
121 } 121 }
122 if (!bcm43xx_is_valid_channel(bcm, channel)) 122 if (!ieee80211_is_valid_channel(bcm->ieee, channel))
123 goto out_unlock; 123 goto out_unlock;
124 if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) { 124 if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) {
125 //ieee80211softmac_disassoc(softmac, $REASON); 125 //ieee80211softmac_disassoc(softmac, $REASON);
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
index d8ece28c079f..6dbd855b3647 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
@@ -296,11 +296,14 @@ void bcm43xx_generate_txhdr(struct bcm43xx_private *bcm,
296 u16 control = 0; 296 u16 control = 0;
297 u16 wsec_rate = 0; 297 u16 wsec_rate = 0;
298 u16 encrypt_frame; 298 u16 encrypt_frame;
299 const u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(wireless_header->frame_ctl));
300 const int is_mgt = (ftype == IEEE80211_FTYPE_MGMT);
299 301
300 /* Now construct the TX header. */ 302 /* Now construct the TX header. */
301 memset(txhdr, 0, sizeof(*txhdr)); 303 memset(txhdr, 0, sizeof(*txhdr));
302 304
303 bitrate = bcm->softmac->txrates.default_rate; 305 bitrate = ieee80211softmac_suggest_txrate(bcm->softmac,
306 is_multicast_ether_addr(wireless_header->addr1), is_mgt);
304 ofdm_modulation = !(ieee80211_is_cck_rate(bitrate)); 307 ofdm_modulation = !(ieee80211_is_cck_rate(bitrate));
305 fallback_bitrate = bcm43xx_calc_fallback_rate(bitrate); 308 fallback_bitrate = bcm43xx_calc_fallback_rate(bitrate);
306 fallback_ofdm_modulation = !(ieee80211_is_cck_rate(fallback_bitrate)); 309 fallback_ofdm_modulation = !(ieee80211_is_cck_rate(fallback_bitrate));
diff --git a/drivers/net/wireless/hermes.c b/drivers/net/wireless/hermes.c
index 2aa2f389c0d5..29d39105f5b8 100644
--- a/drivers/net/wireless/hermes.c
+++ b/drivers/net/wireless/hermes.c
@@ -38,7 +38,6 @@
38 * under either the MPL or the GPL. 38 * under either the MPL or the GPL.
39 */ 39 */
40 40
41#include <linux/config.h>
42#include <linux/module.h> 41#include <linux/module.h>
43#include <linux/kernel.h> 42#include <linux/kernel.h>
44#include <linux/init.h> 43#include <linux/init.h>
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index db03dc2646df..52e6df5c1a92 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -1,6 +1,5 @@
1#define PRISM2_PCCARD 1#define PRISM2_PCCARD
2 2
3#include <linux/config.h>
4#include <linux/module.h> 3#include <linux/module.h>
5#include <linux/init.h> 4#include <linux/init.h>
6#include <linux/if.h> 5#include <linux/if.h>
@@ -844,7 +843,7 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
844 PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001), 843 PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001),
845 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001), 844 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001),
846 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), 845 PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),
847 PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), 846/* PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), conflict with pcnet_cs */
848 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), 847 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
849 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), 848 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
850 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010), 849 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index 328e9a1d13b5..dafaa5ff5aa6 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -30,7 +30,6 @@
30 */ 30 */
31 31
32 32
33#include <linux/config.h>
34 33
35#include <asm/delay.h> 34#include <asm/delay.h>
36#include <asm/uaccess.h> 35#include <asm/uaccess.h>
@@ -3096,6 +3095,14 @@ static void prism2_clear_set_tim_queue(local_info_t *local)
3096} 3095}
3097 3096
3098 3097
3098/*
3099 * HostAP uses two layers of net devices, where the inner
3100 * layer gets called all the time from the outer layer.
3101 * This is a natural nesting, which needs a split lock type.
3102 */
3103static struct lock_class_key hostap_netdev_xmit_lock_key;
3104
3105
3099static struct net_device * 3106static struct net_device *
3100prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx, 3107prism2_init_local_data(struct prism2_helper_functions *funcs, int card_idx,
3101 struct device *sdev) 3108 struct device *sdev)
@@ -3260,6 +3267,8 @@ while (0)
3260 SET_NETDEV_DEV(dev, sdev); 3267 SET_NETDEV_DEV(dev, sdev);
3261 if (ret >= 0) 3268 if (ret >= 0)
3262 ret = register_netdevice(dev); 3269 ret = register_netdevice(dev);
3270
3271 lockdep_set_class(&dev->_xmit_lock, &hostap_netdev_xmit_lock_key);
3263 rtnl_unlock(); 3272 rtnl_unlock();
3264 if (ret < 0) { 3273 if (ret < 0) {
3265 printk(KERN_WARNING "%s: register netdevice failed!\n", 3274 printk(KERN_WARNING "%s: register netdevice failed!\n",
diff --git a/drivers/net/wireless/hostap/hostap_main.c b/drivers/net/wireless/hostap/hostap_main.c
index 93786f4218f0..53374fcba77e 100644
--- a/drivers/net/wireless/hostap/hostap_main.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
@@ -12,7 +12,6 @@
12 * more details. 12 * more details.
13 */ 13 */
14 14
15#include <linux/config.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/init.h> 16#include <linux/init.h>
18#include <linux/slab.h> 17#include <linux/slab.h>
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index 194f07097581..c2fa011be291 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -4,7 +4,6 @@
4 * driver patches from Reyk Floeter <reyk@vantronix.net> and 4 * driver patches from Reyk Floeter <reyk@vantronix.net> and
5 * Andy Warner <andyw@pobox.com> */ 5 * Andy Warner <andyw@pobox.com> */
6 6
7#include <linux/config.h>
8#include <linux/module.h> 7#include <linux/module.h>
9#include <linux/init.h> 8#include <linux/init.h>
10#include <linux/if.h> 9#include <linux/if.h>
@@ -338,7 +337,7 @@ static int prism2_pci_probe(struct pci_dev *pdev,
338 337
339 pci_set_drvdata(pdev, dev); 338 pci_set_drvdata(pdev, dev);
340 339
341 if (request_irq(dev->irq, prism2_interrupt, SA_SHIRQ, dev->name, 340 if (request_irq(dev->irq, prism2_interrupt, IRQF_SHARED, dev->name,
342 dev)) { 341 dev)) {
343 printk(KERN_WARNING "%s: request_irq failed\n", dev->name); 342 printk(KERN_WARNING "%s: request_irq failed\n", dev->name);
344 goto fail; 343 goto fail;
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index edaaa943eb8f..6dfa041be66d 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -7,7 +7,6 @@
7 */ 7 */
8 8
9 9
10#include <linux/config.h>
11#include <linux/module.h> 10#include <linux/module.h>
12#include <linux/init.h> 11#include <linux/init.h>
13#include <linux/if.h> 12#include <linux/if.h>
@@ -67,10 +66,12 @@ static struct pci_device_id prism2_plx_id_table[] __devinitdata = {
67 PLXDEV(0x10b7, 0x7770, "3Com AirConnect PCI 777A"), 66 PLXDEV(0x10b7, 0x7770, "3Com AirConnect PCI 777A"),
68 PLXDEV(0x111a, 0x1023, "Siemens SpeedStream SS1023"), 67 PLXDEV(0x111a, 0x1023, "Siemens SpeedStream SS1023"),
69 PLXDEV(0x126c, 0x8030, "Nortel emobility"), 68 PLXDEV(0x126c, 0x8030, "Nortel emobility"),
69 PLXDEV(0x1562, 0x0001, "Symbol LA-4123"),
70 PLXDEV(0x1385, 0x4100, "Netgear MA301"), 70 PLXDEV(0x1385, 0x4100, "Netgear MA301"),
71 PLXDEV(0x15e8, 0x0130, "National Datacomm NCP130 (PLX9052)"), 71 PLXDEV(0x15e8, 0x0130, "National Datacomm NCP130 (PLX9052)"),
72 PLXDEV(0x15e8, 0x0131, "National Datacomm NCP130 (TMD7160)"), 72 PLXDEV(0x15e8, 0x0131, "National Datacomm NCP130 (TMD7160)"),
73 PLXDEV(0x1638, 0x1100, "Eumitcom WL11000"), 73 PLXDEV(0x1638, 0x1100, "Eumitcom WL11000"),
74 PLXDEV(0x16ab, 0x1100, "Global Sun Tech GL24110P"),
74 PLXDEV(0x16ab, 0x1101, "Global Sun Tech GL24110P (?)"), 75 PLXDEV(0x16ab, 0x1101, "Global Sun Tech GL24110P (?)"),
75 PLXDEV(0x16ab, 0x1102, "Linksys WPC11 with WDT11"), 76 PLXDEV(0x16ab, 0x1102, "Linksys WPC11 with WDT11"),
76 PLXDEV(0x16ab, 0x1103, "Longshine 8031"), 77 PLXDEV(0x16ab, 0x1103, "Longshine 8031"),
@@ -551,7 +552,7 @@ static int prism2_plx_probe(struct pci_dev *pdev,
551 552
552 pci_set_drvdata(pdev, dev); 553 pci_set_drvdata(pdev, dev);
553 554
554 if (request_irq(dev->irq, prism2_interrupt, SA_SHIRQ, dev->name, 555 if (request_irq(dev->irq, prism2_interrupt, IRQF_SHARED, dev->name,
555 dev)) { 556 dev)) {
556 printk(KERN_WARNING "%s: request_irq failed\n", dev->name); 557 printk(KERN_WARNING "%s: request_irq failed\n", dev->name);
557 goto fail; 558 goto fail;
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 72335c8eb97f..e955db435b30 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -134,7 +134,6 @@ that only one external action is invoked at a time.
134*/ 134*/
135 135
136#include <linux/compiler.h> 136#include <linux/compiler.h>
137#include <linux/config.h>
138#include <linux/errno.h> 137#include <linux/errno.h>
139#include <linux/if_arp.h> 138#include <linux/if_arp.h>
140#include <linux/in6.h> 139#include <linux/in6.h>
@@ -1485,7 +1484,7 @@ static int ipw2100_hw_stop_adapter(struct ipw2100_priv *priv)
1485 * 1484 *
1486 * Sending the PREPARE_FOR_POWER_DOWN will restrict the 1485 * Sending the PREPARE_FOR_POWER_DOWN will restrict the
1487 * hardware from going into standby mode and will transition 1486 * hardware from going into standby mode and will transition
1488 * out of D0-standy if it is already in that state. 1487 * out of D0-standby if it is already in that state.
1489 * 1488 *
1490 * STATUS_PREPARE_POWER_DOWN_COMPLETE will be sent by the 1489 * STATUS_PREPARE_POWER_DOWN_COMPLETE will be sent by the
1491 * driver upon completion. Once received, the driver can 1490 * driver upon completion. Once received, the driver can
@@ -5358,7 +5357,7 @@ static int ipw2100_set_key(struct ipw2100_priv *priv,
5358 idx, keylen, len); 5357 idx, keylen, len);
5359 5358
5360 /* NOTE: We don't check cached values in case the firmware was reset 5359 /* NOTE: We don't check cached values in case the firmware was reset
5361 * or some other problem is occuring. If the user is setting the key, 5360 * or some other problem is occurring. If the user is setting the key,
5362 * then we push the change */ 5361 * then we push the change */
5363 5362
5364 wep_key->idx = idx; 5363 wep_key->idx = idx;
@@ -6230,7 +6229,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6230 ipw2100_queues_initialize(priv); 6229 ipw2100_queues_initialize(priv);
6231 6230
6232 err = request_irq(pci_dev->irq, 6231 err = request_irq(pci_dev->irq,
6233 ipw2100_interrupt, SA_SHIRQ, dev->name, priv); 6232 ipw2100_interrupt, IRQF_SHARED, dev->name, priv);
6234 if (err) { 6233 if (err) {
6235 printk(KERN_WARNING DRV_NAME 6234 printk(KERN_WARNING DRV_NAME
6236 "Error calling request_irq: %d.\n", pci_dev->irq); 6235 "Error calling request_irq: %d.\n", pci_dev->irq);
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 081a8999666e..b3300ffe4eec 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -1229,12 +1229,6 @@ static struct ipw_fw_error *ipw_alloc_error_log(struct ipw_priv *priv)
1229 return error; 1229 return error;
1230} 1230}
1231 1231
1232static void ipw_free_error_log(struct ipw_fw_error *error)
1233{
1234 if (error)
1235 kfree(error);
1236}
1237
1238static ssize_t show_event_log(struct device *d, 1232static ssize_t show_event_log(struct device *d,
1239 struct device_attribute *attr, char *buf) 1233 struct device_attribute *attr, char *buf)
1240{ 1234{
@@ -1296,10 +1290,9 @@ static ssize_t clear_error(struct device *d,
1296 const char *buf, size_t count) 1290 const char *buf, size_t count)
1297{ 1291{
1298 struct ipw_priv *priv = dev_get_drvdata(d); 1292 struct ipw_priv *priv = dev_get_drvdata(d);
1299 if (priv->error) { 1293
1300 ipw_free_error_log(priv->error); 1294 kfree(priv->error);
1301 priv->error = NULL; 1295 priv->error = NULL;
1302 }
1303 return count; 1296 return count;
1304} 1297}
1305 1298
@@ -1970,8 +1963,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
1970 struct ipw_fw_error *error = 1963 struct ipw_fw_error *error =
1971 ipw_alloc_error_log(priv); 1964 ipw_alloc_error_log(priv);
1972 ipw_dump_error_log(priv, error); 1965 ipw_dump_error_log(priv, error);
1973 if (error) 1966 kfree(error);
1974 ipw_free_error_log(error);
1975 } 1967 }
1976#endif 1968#endif
1977 } else { 1969 } else {
@@ -11553,7 +11545,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
11553 11545
11554 ipw_sw_reset(priv, 1); 11546 ipw_sw_reset(priv, 1);
11555 11547
11556 err = request_irq(pdev->irq, ipw_isr, SA_SHIRQ, DRV_NAME, priv); 11548 err = request_irq(pdev->irq, ipw_isr, IRQF_SHARED, DRV_NAME, priv);
11557 if (err) { 11549 if (err) {
11558 IPW_ERROR("Error allocating IRQ %d\n", pdev->irq); 11550 IPW_ERROR("Error allocating IRQ %d\n", pdev->irq);
11559 goto out_destroy_workqueue; 11551 goto out_destroy_workqueue;
@@ -11693,10 +11685,8 @@ static void ipw_pci_remove(struct pci_dev *pdev)
11693 } 11685 }
11694 } 11686 }
11695 11687
11696 if (priv->error) { 11688 kfree(priv->error);
11697 ipw_free_error_log(priv->error); 11689 priv->error = NULL;
11698 priv->error = NULL;
11699 }
11700 11690
11701#ifdef CONFIG_IPW2200_PROMISCUOUS 11691#ifdef CONFIG_IPW2200_PROMISCUOUS
11702 ipw_prom_free(priv); 11692 ipw_prom_free(priv);
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index ea12ad66b8e8..8b1cd7c749a4 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -31,7 +31,6 @@
31 31
32#include <linux/module.h> 32#include <linux/module.h>
33#include <linux/moduleparam.h> 33#include <linux/moduleparam.h>
34#include <linux/config.h>
35#include <linux/init.h> 34#include <linux/init.h>
36#include <linux/mutex.h> 35#include <linux/mutex.h>
37 36
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 9343d970537b..36b5e004305e 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -37,7 +37,6 @@
37/* To have statistics (just packets sent) define this */ 37/* To have statistics (just packets sent) define this */
38#undef NETWAVE_STATS 38#undef NETWAVE_STATS
39 39
40#include <linux/config.h>
41#include <linux/module.h> 40#include <linux/module.h>
42#include <linux/kernel.h> 41#include <linux/kernel.h>
43#include <linux/init.h> 42#include <linux/init.h>
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 8a31b591a901..d6ed5781b93a 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -76,7 +76,6 @@
76 76
77#define DRIVER_NAME "orinoco" 77#define DRIVER_NAME "orinoco"
78 78
79#include <linux/config.h>
80#include <linux/module.h> 79#include <linux/module.h>
81#include <linux/kernel.h> 80#include <linux/kernel.h>
82#include <linux/init.h> 81#include <linux/init.h>
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index b2aec4d9fbb1..bc14689cbf24 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -13,7 +13,6 @@
13#define DRIVER_NAME "orinoco_cs" 13#define DRIVER_NAME "orinoco_cs"
14#define PFX DRIVER_NAME ": " 14#define PFX DRIVER_NAME ": "
15 15
16#include <linux/config.h>
17#include <linux/module.h> 16#include <linux/module.h>
18#include <linux/kernel.h> 17#include <linux/kernel.h>
19#include <linux/init.h> 18#include <linux/init.h>
diff --git a/drivers/net/wireless/orinoco_nortel.c b/drivers/net/wireless/orinoco_nortel.c
index 74b9d5b2ba9e..bf05b907747e 100644
--- a/drivers/net/wireless/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco_nortel.c
@@ -40,7 +40,6 @@
40#define DRIVER_NAME "orinoco_nortel" 40#define DRIVER_NAME "orinoco_nortel"
41#define PFX DRIVER_NAME ": " 41#define PFX DRIVER_NAME ": "
42 42
43#include <linux/config.h>
44#include <linux/module.h> 43#include <linux/module.h>
45#include <linux/kernel.h> 44#include <linux/kernel.h>
46#include <linux/init.h> 45#include <linux/init.h>
@@ -199,7 +198,7 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
199 198
200 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); 199 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
201 200
202 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ, 201 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
203 dev->name, dev); 202 dev->name, dev);
204 if (err) { 203 if (err) {
205 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); 204 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
diff --git a/drivers/net/wireless/orinoco_pci.c b/drivers/net/wireless/orinoco_pci.c
index 1c105f40f8d5..1759c543fbee 100644
--- a/drivers/net/wireless/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco_pci.c
@@ -44,7 +44,6 @@
44#define DRIVER_NAME "orinoco_pci" 44#define DRIVER_NAME "orinoco_pci"
45#define PFX DRIVER_NAME ": " 45#define PFX DRIVER_NAME ": "
46 46
47#include <linux/config.h>
48#include <linux/module.h> 47#include <linux/module.h>
49#include <linux/kernel.h> 48#include <linux/kernel.h>
50#include <linux/init.h> 49#include <linux/init.h>
@@ -154,7 +153,7 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
154 153
155 hermes_struct_init(&priv->hw, hermes_io, HERMES_32BIT_REGSPACING); 154 hermes_struct_init(&priv->hw, hermes_io, HERMES_32BIT_REGSPACING);
156 155
157 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ, 156 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
158 dev->name, dev); 157 dev->name, dev);
159 if (err) { 158 if (err) {
160 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); 159 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
diff --git a/drivers/net/wireless/orinoco_pci.h b/drivers/net/wireless/orinoco_pci.h
index 7eb1e08113e0..be1abea4b64f 100644
--- a/drivers/net/wireless/orinoco_pci.h
+++ b/drivers/net/wireless/orinoco_pci.h
@@ -63,7 +63,7 @@ static int orinoco_pci_resume(struct pci_dev *pdev)
63 pci_enable_device(pdev); 63 pci_enable_device(pdev);
64 pci_restore_state(pdev); 64 pci_restore_state(pdev);
65 65
66 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ, 66 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
67 dev->name, dev); 67 dev->name, dev);
68 if (err) { 68 if (err) {
69 printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n", 69 printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n",
diff --git a/drivers/net/wireless/orinoco_plx.c b/drivers/net/wireless/orinoco_plx.c
index 84f696c77551..7f006f624171 100644
--- a/drivers/net/wireless/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco_plx.c
@@ -86,7 +86,6 @@
86#define DRIVER_NAME "orinoco_plx" 86#define DRIVER_NAME "orinoco_plx"
87#define PFX DRIVER_NAME ": " 87#define PFX DRIVER_NAME ": "
88 88
89#include <linux/config.h>
90#include <linux/module.h> 89#include <linux/module.h>
91#include <linux/kernel.h> 90#include <linux/kernel.h>
92#include <linux/init.h> 91#include <linux/init.h>
@@ -238,7 +237,7 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
238 237
239 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); 238 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
240 239
241 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ, 240 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
242 dev->name, dev); 241 dev->name, dev);
243 if (err) { 242 if (err) {
244 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); 243 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
diff --git a/drivers/net/wireless/orinoco_tmd.c b/drivers/net/wireless/orinoco_tmd.c
index d2b4decb7a7d..0831721e4d6c 100644
--- a/drivers/net/wireless/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco_tmd.c
@@ -40,7 +40,6 @@
40#define DRIVER_NAME "orinoco_tmd" 40#define DRIVER_NAME "orinoco_tmd"
41#define PFX DRIVER_NAME ": " 41#define PFX DRIVER_NAME ": "
42 42
43#include <linux/config.h>
44#include <linux/module.h> 43#include <linux/module.h>
45#include <linux/kernel.h> 44#include <linux/kernel.h>
46#include <linux/init.h> 45#include <linux/init.h>
@@ -140,7 +139,7 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
140 139
141 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); 140 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
142 141
143 err = request_irq(pdev->irq, orinoco_interrupt, SA_SHIRQ, 142 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
144 dev->name, dev); 143 dev->name, dev);
145 if (err) { 144 if (err) {
146 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); 145 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
diff --git a/drivers/net/wireless/prism54/islpci_hotplug.c b/drivers/net/wireless/prism54/islpci_hotplug.c
index bfa0cc319a09..09fc17a0f029 100644
--- a/drivers/net/wireless/prism54/islpci_hotplug.c
+++ b/drivers/net/wireless/prism54/islpci_hotplug.c
@@ -189,7 +189,7 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
189 189
190 /* request for the interrupt before uploading the firmware */ 190 /* request for the interrupt before uploading the firmware */
191 rvalue = request_irq(pdev->irq, &islpci_interrupt, 191 rvalue = request_irq(pdev->irq, &islpci_interrupt,
192 SA_SHIRQ, ndev->name, priv); 192 IRQF_SHARED, ndev->name, priv);
193 193
194 if (rvalue) { 194 if (rvalue) {
195 /* error, could not hook the handler to the irq */ 195 /* error, could not hook the handler to the irq */
diff --git a/drivers/net/wireless/prism54/islpci_mgt.c b/drivers/net/wireless/prism54/islpci_mgt.c
index 6a60c5970cb5..2e061a80b294 100644
--- a/drivers/net/wireless/prism54/islpci_mgt.c
+++ b/drivers/net/wireless/prism54/islpci_mgt.c
@@ -18,7 +18,6 @@
18 * 18 *
19 */ 19 */
20 20
21#include <linux/config.h>
22#include <linux/netdevice.h> 21#include <linux/netdevice.h>
23#include <linux/module.h> 22#include <linux/module.h>
24#include <linux/pci.h> 23#include <linux/pci.h>
diff --git a/drivers/net/wireless/prism54/prismcompat.h b/drivers/net/wireless/prism54/prismcompat.h
index 55541c01752e..d71eca55a302 100644
--- a/drivers/net/wireless/prism54/prismcompat.h
+++ b/drivers/net/wireless/prism54/prismcompat.h
@@ -29,7 +29,6 @@
29 29
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/firmware.h> 31#include <linux/firmware.h>
32#include <linux/config.h>
33#include <linux/moduleparam.h> 32#include <linux/moduleparam.h>
34#include <linux/workqueue.h> 33#include <linux/workqueue.h>
35#include <linux/compiler.h> 34#include <linux/compiler.h>
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 879eb427607c..61b83a5e737a 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -30,7 +30,6 @@
30 * 30 *
31=============================================================================*/ 31=============================================================================*/
32 32
33#include <linux/config.h>
34#include <linux/module.h> 33#include <linux/module.h>
35#include <linux/kernel.h> 34#include <linux/kernel.h>
36#include <linux/proc_fs.h> 35#include <linux/proc_fs.h>
@@ -924,8 +923,7 @@ static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev)
924 923
925 if (length < ETH_ZLEN) 924 if (length < ETH_ZLEN)
926 { 925 {
927 skb = skb_padto(skb, ETH_ZLEN); 926 if (skb_padto(skb, ETH_ZLEN))
928 if (skb == NULL)
929 return 0; 927 return 0;
930 length = ETH_ZLEN; 928 length = ETH_ZLEN;
931 } 929 }
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 7f9aa139c347..15465278c789 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -21,7 +21,6 @@
21#define DRIVER_NAME "spectrum_cs" 21#define DRIVER_NAME "spectrum_cs"
22#define PFX DRIVER_NAME ": " 22#define PFX DRIVER_NAME ": "
23 23
24#include <linux/config.h>
25#include <linux/module.h> 24#include <linux/module.h>
26#include <linux/kernel.h> 25#include <linux/kernel.h>
27#include <linux/init.h> 26#include <linux/init.h>
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index 18a44580b53b..fd31885c6844 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -81,7 +81,6 @@ static const char StripVersion[] = "1.3A-STUART.CHESHIRE";
81/************************************************************************/ 81/************************************************************************/
82/* Header files */ 82/* Header files */
83 83
84#include <linux/config.h>
85#include <linux/kernel.h> 84#include <linux/kernel.h>
86#include <linux/module.h> 85#include <linux/module.h>
87#include <linux/init.h> 86#include <linux/init.h>
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
index dade4b903579..5b69befdab74 100644
--- a/drivers/net/wireless/wavelan.c
+++ b/drivers/net/wireless/wavelan.c
@@ -1695,8 +1695,8 @@ static int wv_frequency_list(unsigned long ioaddr, /* I/O port of the card */
1695 /* Look in the table if the frequency is allowed */ 1695 /* Look in the table if the frequency is allowed */
1696 if (table[9 - (freq / 16)] & (1 << (freq % 16))) { 1696 if (table[9 - (freq / 16)] & (1 << (freq % 16))) {
1697 /* Compute approximate channel number */ 1697 /* Compute approximate channel number */
1698 while ((((channel_bands[c] >> 1) - 24) < freq) && 1698 while ((c < NELS(channel_bands)) &&
1699 (c < NELS(channel_bands))) 1699 (((channel_bands[c] >> 1) - 24) < freq))
1700 c++; 1700 c++;
1701 list[i].i = c; /* Set the list index */ 1701 list[i].i = c; /* Set the list index */
1702 1702
@@ -2903,6 +2903,7 @@ static int wavelan_packet_xmit(struct sk_buff *skb, struct net_device * dev)
2903{ 2903{
2904 net_local *lp = (net_local *) dev->priv; 2904 net_local *lp = (net_local *) dev->priv;
2905 unsigned long flags; 2905 unsigned long flags;
2906 char data[ETH_ZLEN];
2906 2907
2907#ifdef DEBUG_TX_TRACE 2908#ifdef DEBUG_TX_TRACE
2908 printk(KERN_DEBUG "%s: ->wavelan_packet_xmit(0x%X)\n", dev->name, 2909 printk(KERN_DEBUG "%s: ->wavelan_packet_xmit(0x%X)\n", dev->name,
@@ -2937,15 +2938,16 @@ static int wavelan_packet_xmit(struct sk_buff *skb, struct net_device * dev)
2937 * able to detect collisions, therefore in theory we don't really 2938 * able to detect collisions, therefore in theory we don't really
2938 * need to pad. Jean II */ 2939 * need to pad. Jean II */
2939 if (skb->len < ETH_ZLEN) { 2940 if (skb->len < ETH_ZLEN) {
2940 skb = skb_padto(skb, ETH_ZLEN); 2941 memset(data, 0, ETH_ZLEN);
2941 if (skb == NULL) 2942 memcpy(data, skb->data, skb->len);
2942 return 0; 2943 /* Write packet on the card */
2944 if(wv_packet_write(dev, data, ETH_ZLEN))
2945 return 1; /* We failed */
2943 } 2946 }
2944 2947 else if(wv_packet_write(dev, skb->data, skb->len))
2945 /* Write packet on the card */
2946 if(wv_packet_write(dev, skb->data, skb->len))
2947 return 1; /* We failed */ 2948 return 1; /* We failed */
2948 2949
2950
2949 dev_kfree_skb(skb); 2951 dev_kfree_skb(skb);
2950 2952
2951#ifdef DEBUG_TX_TRACE 2953#ifdef DEBUG_TX_TRACE
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index f7724eb2fa7e..561250f73fd3 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -3194,11 +3194,8 @@ wavelan_packet_xmit(struct sk_buff * skb,
3194 * and we don't have the Ethernet specific requirement of beeing 3194 * and we don't have the Ethernet specific requirement of beeing
3195 * able to detect collisions, therefore in theory we don't really 3195 * able to detect collisions, therefore in theory we don't really
3196 * need to pad. Jean II */ 3196 * need to pad. Jean II */
3197 if (skb->len < ETH_ZLEN) { 3197 if (skb_padto(skb, ETH_ZLEN))
3198 skb = skb_padto(skb, ETH_ZLEN); 3198 return 0;
3199 if (skb == NULL)
3200 return 0;
3201 }
3202 3199
3203 wv_packet_write(dev, skb->data, skb->len); 3200 wv_packet_write(dev, skb->data, skb->len);
3204 3201
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index c65fe7a391ec..f34a36b0c7b0 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -411,7 +411,6 @@
411/***************************** INCLUDES *****************************/ 411/***************************** INCLUDES *****************************/
412 412
413/* Linux headers that we need */ 413/* Linux headers that we need */
414#include <linux/config.h>
415#include <linux/module.h> 414#include <linux/module.h>
416#include <linux/kernel.h> 415#include <linux/kernel.h>
417#include <linux/init.h> 416#include <linux/init.h>
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index e52a650f6737..c03e400facee 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -28,7 +28,6 @@
28 */ 28 */
29#undef REALLY_SLOW_IO /* most systems can safely undef this */ 29#undef REALLY_SLOW_IO /* most systems can safely undef this */
30 30
31#include <linux/config.h>
32#include <linux/delay.h> 31#include <linux/delay.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/ethtool.h> 33#include <linux/ethtool.h>
diff --git a/drivers/net/wireless/zd1211rw/Kconfig b/drivers/net/wireless/zd1211rw/Kconfig
new file mode 100644
index 000000000000..66ed55bc5460
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/Kconfig
@@ -0,0 +1,19 @@
1config ZD1211RW
2 tristate "ZyDAS ZD1211/ZD1211B USB-wireless support"
3 depends on USB && IEEE80211 && IEEE80211_SOFTMAC && NET_RADIO && EXPERIMENTAL
4 select FW_LOADER
5 ---help---
6 This is an experimental driver for the ZyDAS ZD1211/ZD1211B wireless
7 chip, present in many USB-wireless adapters.
8
9 Device firmware is required alongside this driver. You can download the
10 firmware distribution from http://zd1211.ath.cx/get-firmware
11
12config ZD1211RW_DEBUG
13 bool "ZyDAS ZD1211 debugging"
14 depends on ZD1211RW
15 ---help---
16 ZD1211 debugging messages. Choosing Y will result in additional debug
17 messages being saved to your kernel logs, which may help debug any
18 problems.
19
diff --git a/drivers/net/wireless/zd1211rw/Makefile b/drivers/net/wireless/zd1211rw/Makefile
new file mode 100644
index 000000000000..500314fc74d2
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/Makefile
@@ -0,0 +1,11 @@
1obj-$(CONFIG_ZD1211RW) += zd1211rw.o
2
3zd1211rw-objs := zd_chip.o zd_ieee80211.o \
4 zd_mac.o zd_netdev.o \
5 zd_rf_al2230.o zd_rf_rf2959.o \
6 zd_rf.o zd_usb.o zd_util.o
7
8ifeq ($(CONFIG_ZD1211RW_DEBUG),y)
9EXTRA_CFLAGS += -DDEBUG
10endif
11
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
new file mode 100644
index 000000000000..efc9c4bd826f
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -0,0 +1,1615 @@
1/* zd_chip.c
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18/* This file implements all the hardware specific functions for the ZD1211
19 * and ZD1211B chips. Support for the ZD1211B was possible after Timothy
20 * Legge sent me a ZD1211B device. Thank you Tim. -- Uli
21 */
22
23#include <linux/kernel.h>
24#include <linux/errno.h>
25
26#include "zd_def.h"
27#include "zd_chip.h"
28#include "zd_ieee80211.h"
29#include "zd_mac.h"
30#include "zd_rf.h"
31#include "zd_util.h"
32
33void zd_chip_init(struct zd_chip *chip,
34 struct net_device *netdev,
35 struct usb_interface *intf)
36{
37 memset(chip, 0, sizeof(*chip));
38 mutex_init(&chip->mutex);
39 zd_usb_init(&chip->usb, netdev, intf);
40 zd_rf_init(&chip->rf);
41}
42
43void zd_chip_clear(struct zd_chip *chip)
44{
45 mutex_lock(&chip->mutex);
46 zd_usb_clear(&chip->usb);
47 zd_rf_clear(&chip->rf);
48 mutex_unlock(&chip->mutex);
49 mutex_destroy(&chip->mutex);
50 memset(chip, 0, sizeof(*chip));
51}
52
53static int scnprint_mac_oui(const u8 *addr, char *buffer, size_t size)
54{
55 return scnprintf(buffer, size, "%02x-%02x-%02x",
56 addr[0], addr[1], addr[2]);
57}
58
59/* Prints an identifier line, which will support debugging. */
60static int scnprint_id(struct zd_chip *chip, char *buffer, size_t size)
61{
62 int i = 0;
63
64 i = scnprintf(buffer, size, "zd1211%s chip ",
65 chip->is_zd1211b ? "b" : "");
66 i += zd_usb_scnprint_id(&chip->usb, buffer+i, size-i);
67 i += scnprintf(buffer+i, size-i, " ");
68 i += scnprint_mac_oui(chip->e2p_mac, buffer+i, size-i);
69 i += scnprintf(buffer+i, size-i, " ");
70 i += zd_rf_scnprint_id(&chip->rf, buffer+i, size-i);
71 i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c", chip->pa_type,
72 chip->patch_cck_gain ? 'g' : '-',
73 chip->patch_cr157 ? '7' : '-',
74 chip->patch_6m_band_edge ? '6' : '-');
75 return i;
76}
77
78static void print_id(struct zd_chip *chip)
79{
80 char buffer[80];
81
82 scnprint_id(chip, buffer, sizeof(buffer));
83 buffer[sizeof(buffer)-1] = 0;
84 dev_info(zd_chip_dev(chip), "%s\n", buffer);
85}
86
87/* Read a variable number of 32-bit values. Parameter count is not allowed to
88 * exceed USB_MAX_IOREAD32_COUNT.
89 */
90int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr,
91 unsigned int count)
92{
93 int r;
94 int i;
95 zd_addr_t *a16 = (zd_addr_t *)NULL;
96 u16 *v16;
97 unsigned int count16;
98
99 if (count > USB_MAX_IOREAD32_COUNT)
100 return -EINVAL;
101
102 /* Allocate a single memory block for values and addresses. */
103 count16 = 2*count;
104 a16 = (zd_addr_t *)kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)),
105 GFP_NOFS);
106 if (!a16) {
107 dev_dbg_f(zd_chip_dev(chip),
108 "error ENOMEM in allocation of a16\n");
109 r = -ENOMEM;
110 goto out;
111 }
112 v16 = (u16 *)(a16 + count16);
113
114 for (i = 0; i < count; i++) {
115 int j = 2*i;
116 /* We read the high word always first. */
117 a16[j] = zd_inc_word(addr[i]);
118 a16[j+1] = addr[i];
119 }
120
121 r = zd_ioread16v_locked(chip, v16, a16, count16);
122 if (r) {
123 dev_dbg_f(zd_chip_dev(chip),
124 "error: zd_ioread16v_locked. Error number %d\n", r);
125 goto out;
126 }
127
128 for (i = 0; i < count; i++) {
129 int j = 2*i;
130 values[i] = (v16[j] << 16) | v16[j+1];
131 }
132
133out:
134 kfree((void *)a16);
135 return r;
136}
137
138int _zd_iowrite32v_locked(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
139 unsigned int count)
140{
141 int i, j, r;
142 struct zd_ioreq16 *ioreqs16;
143 unsigned int count16;
144
145 ZD_ASSERT(mutex_is_locked(&chip->mutex));
146
147 if (count == 0)
148 return 0;
149 if (count > USB_MAX_IOWRITE32_COUNT)
150 return -EINVAL;
151
152 /* Allocate a single memory block for values and addresses. */
153 count16 = 2*count;
154 ioreqs16 = kmalloc(count16 * sizeof(struct zd_ioreq16), GFP_NOFS);
155 if (!ioreqs16) {
156 r = -ENOMEM;
157 dev_dbg_f(zd_chip_dev(chip),
158 "error %d in ioreqs16 allocation\n", r);
159 goto out;
160 }
161
162 for (i = 0; i < count; i++) {
163 j = 2*i;
164 /* We write the high word always first. */
165 ioreqs16[j].value = ioreqs[i].value >> 16;
166 ioreqs16[j].addr = zd_inc_word(ioreqs[i].addr);
167 ioreqs16[j+1].value = ioreqs[i].value;
168 ioreqs16[j+1].addr = ioreqs[i].addr;
169 }
170
171 r = zd_usb_iowrite16v(&chip->usb, ioreqs16, count16);
172#ifdef DEBUG
173 if (r) {
174 dev_dbg_f(zd_chip_dev(chip),
175 "error %d in zd_usb_write16v\n", r);
176 }
177#endif /* DEBUG */
178out:
179 kfree(ioreqs16);
180 return r;
181}
182
183int zd_iowrite16a_locked(struct zd_chip *chip,
184 const struct zd_ioreq16 *ioreqs, unsigned int count)
185{
186 int r;
187 unsigned int i, j, t, max;
188
189 ZD_ASSERT(mutex_is_locked(&chip->mutex));
190 for (i = 0; i < count; i += j + t) {
191 t = 0;
192 max = count-i;
193 if (max > USB_MAX_IOWRITE16_COUNT)
194 max = USB_MAX_IOWRITE16_COUNT;
195 for (j = 0; j < max; j++) {
196 if (!ioreqs[i+j].addr) {
197 t = 1;
198 break;
199 }
200 }
201
202 r = zd_usb_iowrite16v(&chip->usb, &ioreqs[i], j);
203 if (r) {
204 dev_dbg_f(zd_chip_dev(chip),
205 "error zd_usb_iowrite16v. Error number %d\n",
206 r);
207 return r;
208 }
209 }
210
211 return 0;
212}
213
214/* Writes a variable number of 32 bit registers. The functions will split
215 * that in several USB requests. A split can be forced by inserting an IO
216 * request with an zero address field.
217 */
218int zd_iowrite32a_locked(struct zd_chip *chip,
219 const struct zd_ioreq32 *ioreqs, unsigned int count)
220{
221 int r;
222 unsigned int i, j, t, max;
223
224 for (i = 0; i < count; i += j + t) {
225 t = 0;
226 max = count-i;
227 if (max > USB_MAX_IOWRITE32_COUNT)
228 max = USB_MAX_IOWRITE32_COUNT;
229 for (j = 0; j < max; j++) {
230 if (!ioreqs[i+j].addr) {
231 t = 1;
232 break;
233 }
234 }
235
236 r = _zd_iowrite32v_locked(chip, &ioreqs[i], j);
237 if (r) {
238 dev_dbg_f(zd_chip_dev(chip),
239 "error _zd_iowrite32v_locked."
240 " Error number %d\n", r);
241 return r;
242 }
243 }
244
245 return 0;
246}
247
248int zd_ioread16(struct zd_chip *chip, zd_addr_t addr, u16 *value)
249{
250 int r;
251
252 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
253 mutex_lock(&chip->mutex);
254 r = zd_ioread16_locked(chip, value, addr);
255 mutex_unlock(&chip->mutex);
256 return r;
257}
258
259int zd_ioread32(struct zd_chip *chip, zd_addr_t addr, u32 *value)
260{
261 int r;
262
263 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
264 mutex_lock(&chip->mutex);
265 r = zd_ioread32_locked(chip, value, addr);
266 mutex_unlock(&chip->mutex);
267 return r;
268}
269
270int zd_iowrite16(struct zd_chip *chip, zd_addr_t addr, u16 value)
271{
272 int r;
273
274 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
275 mutex_lock(&chip->mutex);
276 r = zd_iowrite16_locked(chip, value, addr);
277 mutex_unlock(&chip->mutex);
278 return r;
279}
280
281int zd_iowrite32(struct zd_chip *chip, zd_addr_t addr, u32 value)
282{
283 int r;
284
285 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
286 mutex_lock(&chip->mutex);
287 r = zd_iowrite32_locked(chip, value, addr);
288 mutex_unlock(&chip->mutex);
289 return r;
290}
291
292int zd_ioread32v(struct zd_chip *chip, const zd_addr_t *addresses,
293 u32 *values, unsigned int count)
294{
295 int r;
296
297 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
298 mutex_lock(&chip->mutex);
299 r = zd_ioread32v_locked(chip, values, addresses, count);
300 mutex_unlock(&chip->mutex);
301 return r;
302}
303
304int zd_iowrite32a(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
305 unsigned int count)
306{
307 int r;
308
309 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
310 mutex_lock(&chip->mutex);
311 r = zd_iowrite32a_locked(chip, ioreqs, count);
312 mutex_unlock(&chip->mutex);
313 return r;
314}
315
316static int read_pod(struct zd_chip *chip, u8 *rf_type)
317{
318 int r;
319 u32 value;
320
321 ZD_ASSERT(mutex_is_locked(&chip->mutex));
322 r = zd_ioread32_locked(chip, &value, E2P_POD);
323 if (r)
324 goto error;
325 dev_dbg_f(zd_chip_dev(chip), "E2P_POD %#010x\n", value);
326
327 /* FIXME: AL2230 handling (Bit 7 in POD) */
328 *rf_type = value & 0x0f;
329 chip->pa_type = (value >> 16) & 0x0f;
330 chip->patch_cck_gain = (value >> 8) & 0x1;
331 chip->patch_cr157 = (value >> 13) & 0x1;
332 chip->patch_6m_band_edge = (value >> 21) & 0x1;
333
334 dev_dbg_f(zd_chip_dev(chip),
335 "RF %s %#01x PA type %#01x patch CCK %d patch CR157 %d "
336 "patch 6M %d\n",
337 zd_rf_name(*rf_type), *rf_type,
338 chip->pa_type, chip->patch_cck_gain,
339 chip->patch_cr157, chip->patch_6m_band_edge);
340 return 0;
341error:
342 *rf_type = 0;
343 chip->pa_type = 0;
344 chip->patch_cck_gain = 0;
345 chip->patch_cr157 = 0;
346 chip->patch_6m_band_edge = 0;
347 return r;
348}
349
350static int _read_mac_addr(struct zd_chip *chip, u8 *mac_addr,
351 const zd_addr_t *addr)
352{
353 int r;
354 u32 parts[2];
355
356 r = zd_ioread32v_locked(chip, parts, (const zd_addr_t *)addr, 2);
357 if (r) {
358 dev_dbg_f(zd_chip_dev(chip),
359 "error: couldn't read e2p macs. Error number %d\n", r);
360 return r;
361 }
362
363 mac_addr[0] = parts[0];
364 mac_addr[1] = parts[0] >> 8;
365 mac_addr[2] = parts[0] >> 16;
366 mac_addr[3] = parts[0] >> 24;
367 mac_addr[4] = parts[1];
368 mac_addr[5] = parts[1] >> 8;
369
370 return 0;
371}
372
373static int read_e2p_mac_addr(struct zd_chip *chip)
374{
375 static const zd_addr_t addr[2] = { E2P_MAC_ADDR_P1, E2P_MAC_ADDR_P2 };
376
377 ZD_ASSERT(mutex_is_locked(&chip->mutex));
378 return _read_mac_addr(chip, chip->e2p_mac, (const zd_addr_t *)addr);
379}
380
381/* MAC address: if custom mac addresses are to to be used CR_MAC_ADDR_P1 and
382 * CR_MAC_ADDR_P2 must be overwritten
383 */
384void zd_get_e2p_mac_addr(struct zd_chip *chip, u8 *mac_addr)
385{
386 mutex_lock(&chip->mutex);
387 memcpy(mac_addr, chip->e2p_mac, ETH_ALEN);
388 mutex_unlock(&chip->mutex);
389}
390
391static int read_mac_addr(struct zd_chip *chip, u8 *mac_addr)
392{
393 static const zd_addr_t addr[2] = { CR_MAC_ADDR_P1, CR_MAC_ADDR_P2 };
394 return _read_mac_addr(chip, mac_addr, (const zd_addr_t *)addr);
395}
396
397int zd_read_mac_addr(struct zd_chip *chip, u8 *mac_addr)
398{
399 int r;
400
401 dev_dbg_f(zd_chip_dev(chip), "\n");
402 mutex_lock(&chip->mutex);
403 r = read_mac_addr(chip, mac_addr);
404 mutex_unlock(&chip->mutex);
405 return r;
406}
407
408int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr)
409{
410 int r;
411 struct zd_ioreq32 reqs[2] = {
412 [0] = { .addr = CR_MAC_ADDR_P1 },
413 [1] = { .addr = CR_MAC_ADDR_P2 },
414 };
415
416 reqs[0].value = (mac_addr[3] << 24)
417 | (mac_addr[2] << 16)
418 | (mac_addr[1] << 8)
419 | mac_addr[0];
420 reqs[1].value = (mac_addr[5] << 8)
421 | mac_addr[4];
422
423 dev_dbg_f(zd_chip_dev(chip),
424 "mac addr " MAC_FMT "\n", MAC_ARG(mac_addr));
425
426 mutex_lock(&chip->mutex);
427 r = zd_iowrite32a_locked(chip, reqs, ARRAY_SIZE(reqs));
428#ifdef DEBUG
429 {
430 u8 tmp[ETH_ALEN];
431 read_mac_addr(chip, tmp);
432 }
433#endif /* DEBUG */
434 mutex_unlock(&chip->mutex);
435 return r;
436}
437
438int zd_read_regdomain(struct zd_chip *chip, u8 *regdomain)
439{
440 int r;
441 u32 value;
442
443 mutex_lock(&chip->mutex);
444 r = zd_ioread32_locked(chip, &value, E2P_SUBID);
445 mutex_unlock(&chip->mutex);
446 if (r)
447 return r;
448
449 *regdomain = value >> 16;
450 dev_dbg_f(zd_chip_dev(chip), "regdomain: %#04x\n", *regdomain);
451
452 return 0;
453}
454
455static int read_values(struct zd_chip *chip, u8 *values, size_t count,
456 zd_addr_t e2p_addr, u32 guard)
457{
458 int r;
459 int i;
460 u32 v;
461
462 ZD_ASSERT(mutex_is_locked(&chip->mutex));
463 for (i = 0;;) {
464 r = zd_ioread32_locked(chip, &v, e2p_addr+i/2);
465 if (r)
466 return r;
467 v -= guard;
468 if (i+4 < count) {
469 values[i++] = v;
470 values[i++] = v >> 8;
471 values[i++] = v >> 16;
472 values[i++] = v >> 24;
473 continue;
474 }
475 for (;i < count; i++)
476 values[i] = v >> (8*(i%3));
477 return 0;
478 }
479}
480
481static int read_pwr_cal_values(struct zd_chip *chip)
482{
483 return read_values(chip, chip->pwr_cal_values,
484 E2P_CHANNEL_COUNT, E2P_PWR_CAL_VALUE1,
485 0);
486}
487
488static int read_pwr_int_values(struct zd_chip *chip)
489{
490 return read_values(chip, chip->pwr_int_values,
491 E2P_CHANNEL_COUNT, E2P_PWR_INT_VALUE1,
492 E2P_PWR_INT_GUARD);
493}
494
495static int read_ofdm_cal_values(struct zd_chip *chip)
496{
497 int r;
498 int i;
499 static const zd_addr_t addresses[] = {
500 E2P_36M_CAL_VALUE1,
501 E2P_48M_CAL_VALUE1,
502 E2P_54M_CAL_VALUE1,
503 };
504
505 for (i = 0; i < 3; i++) {
506 r = read_values(chip, chip->ofdm_cal_values[i],
507 E2P_CHANNEL_COUNT, addresses[i], 0);
508 if (r)
509 return r;
510 }
511 return 0;
512}
513
514static int read_cal_int_tables(struct zd_chip *chip)
515{
516 int r;
517
518 r = read_pwr_cal_values(chip);
519 if (r)
520 return r;
521 r = read_pwr_int_values(chip);
522 if (r)
523 return r;
524 r = read_ofdm_cal_values(chip);
525 if (r)
526 return r;
527 return 0;
528}
529
530/* phy means physical registers */
531int zd_chip_lock_phy_regs(struct zd_chip *chip)
532{
533 int r;
534 u32 tmp;
535
536 ZD_ASSERT(mutex_is_locked(&chip->mutex));
537 r = zd_ioread32_locked(chip, &tmp, CR_REG1);
538 if (r) {
539 dev_err(zd_chip_dev(chip), "error ioread32(CR_REG1): %d\n", r);
540 return r;
541 }
542
543 dev_dbg_f(zd_chip_dev(chip),
544 "CR_REG1: 0x%02x -> 0x%02x\n", tmp, tmp & ~UNLOCK_PHY_REGS);
545 tmp &= ~UNLOCK_PHY_REGS;
546
547 r = zd_iowrite32_locked(chip, tmp, CR_REG1);
548 if (r)
549 dev_err(zd_chip_dev(chip), "error iowrite32(CR_REG1): %d\n", r);
550 return r;
551}
552
553int zd_chip_unlock_phy_regs(struct zd_chip *chip)
554{
555 int r;
556 u32 tmp;
557
558 ZD_ASSERT(mutex_is_locked(&chip->mutex));
559 r = zd_ioread32_locked(chip, &tmp, CR_REG1);
560 if (r) {
561 dev_err(zd_chip_dev(chip),
562 "error ioread32(CR_REG1): %d\n", r);
563 return r;
564 }
565
566 dev_dbg_f(zd_chip_dev(chip),
567 "CR_REG1: 0x%02x -> 0x%02x\n", tmp, tmp | UNLOCK_PHY_REGS);
568 tmp |= UNLOCK_PHY_REGS;
569
570 r = zd_iowrite32_locked(chip, tmp, CR_REG1);
571 if (r)
572 dev_err(zd_chip_dev(chip), "error iowrite32(CR_REG1): %d\n", r);
573 return r;
574}
575
576/* CR157 can be optionally patched by the EEPROM */
577static int patch_cr157(struct zd_chip *chip)
578{
579 int r;
580 u32 value;
581
582 if (!chip->patch_cr157)
583 return 0;
584
585 r = zd_ioread32_locked(chip, &value, E2P_PHY_REG);
586 if (r)
587 return r;
588
589 dev_dbg_f(zd_chip_dev(chip), "patching value %x\n", value >> 8);
590 return zd_iowrite32_locked(chip, value >> 8, CR157);
591}
592
593/*
594 * 6M band edge can be optionally overwritten for certain RF's
595 * Vendor driver says: for FCC regulation, enabled per HWFeature 6M band edge
596 * bit (for AL2230, AL2230S)
597 */
598static int patch_6m_band_edge(struct zd_chip *chip, int channel)
599{
600 struct zd_ioreq16 ioreqs[] = {
601 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
602 { CR47, 0x1e },
603 };
604
605 if (!chip->patch_6m_band_edge || !chip->rf.patch_6m_band_edge)
606 return 0;
607
608 /* FIXME: Channel 11 is not the edge for all regulatory domains. */
609 if (channel == 1 || channel == 11)
610 ioreqs[0].value = 0x12;
611
612 dev_dbg_f(zd_chip_dev(chip), "patching for channel %d\n", channel);
613 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
614}
615
616static int zd1211_hw_reset_phy(struct zd_chip *chip)
617{
618 static const struct zd_ioreq16 ioreqs[] = {
619 { CR0, 0x0a }, { CR1, 0x06 }, { CR2, 0x26 },
620 { CR3, 0x38 }, { CR4, 0x80 }, { CR9, 0xa0 },
621 { CR10, 0x81 }, { CR11, 0x00 }, { CR12, 0x7f },
622 { CR13, 0x8c }, { CR14, 0x80 }, { CR15, 0x3d },
623 { CR16, 0x20 }, { CR17, 0x1e }, { CR18, 0x0a },
624 { CR19, 0x48 }, { CR20, 0x0c }, { CR21, 0x0c },
625 { CR22, 0x23 }, { CR23, 0x90 }, { CR24, 0x14 },
626 { CR25, 0x40 }, { CR26, 0x10 }, { CR27, 0x19 },
627 { CR28, 0x7f }, { CR29, 0x80 }, { CR30, 0x4b },
628 { CR31, 0x60 }, { CR32, 0x43 }, { CR33, 0x08 },
629 { CR34, 0x06 }, { CR35, 0x0a }, { CR36, 0x00 },
630 { CR37, 0x00 }, { CR38, 0x38 }, { CR39, 0x0c },
631 { CR40, 0x84 }, { CR41, 0x2a }, { CR42, 0x80 },
632 { CR43, 0x10 }, { CR44, 0x12 }, { CR46, 0xff },
633 { CR47, 0x1E }, { CR48, 0x26 }, { CR49, 0x5b },
634 { CR64, 0xd0 }, { CR65, 0x04 }, { CR66, 0x58 },
635 { CR67, 0xc9 }, { CR68, 0x88 }, { CR69, 0x41 },
636 { CR70, 0x23 }, { CR71, 0x10 }, { CR72, 0xff },
637 { CR73, 0x32 }, { CR74, 0x30 }, { CR75, 0x65 },
638 { CR76, 0x41 }, { CR77, 0x1b }, { CR78, 0x30 },
639 { CR79, 0x68 }, { CR80, 0x64 }, { CR81, 0x64 },
640 { CR82, 0x00 }, { CR83, 0x00 }, { CR84, 0x00 },
641 { CR85, 0x02 }, { CR86, 0x00 }, { CR87, 0x00 },
642 { CR88, 0xff }, { CR89, 0xfc }, { CR90, 0x00 },
643 { CR91, 0x00 }, { CR92, 0x00 }, { CR93, 0x08 },
644 { CR94, 0x00 }, { CR95, 0x00 }, { CR96, 0xff },
645 { CR97, 0xe7 }, { CR98, 0x00 }, { CR99, 0x00 },
646 { CR100, 0x00 }, { CR101, 0xae }, { CR102, 0x02 },
647 { CR103, 0x00 }, { CR104, 0x03 }, { CR105, 0x65 },
648 { CR106, 0x04 }, { CR107, 0x00 }, { CR108, 0x0a },
649 { CR109, 0xaa }, { CR110, 0xaa }, { CR111, 0x25 },
650 { CR112, 0x25 }, { CR113, 0x00 }, { CR119, 0x1e },
651 { CR125, 0x90 }, { CR126, 0x00 }, { CR127, 0x00 },
652 { },
653 { CR5, 0x00 }, { CR6, 0x00 }, { CR7, 0x00 },
654 { CR8, 0x00 }, { CR9, 0x20 }, { CR12, 0xf0 },
655 { CR20, 0x0e }, { CR21, 0x0e }, { CR27, 0x10 },
656 { CR44, 0x33 }, { CR47, 0x1E }, { CR83, 0x24 },
657 { CR84, 0x04 }, { CR85, 0x00 }, { CR86, 0x0C },
658 { CR87, 0x12 }, { CR88, 0x0C }, { CR89, 0x00 },
659 { CR90, 0x10 }, { CR91, 0x08 }, { CR93, 0x00 },
660 { CR94, 0x01 }, { CR95, 0x00 }, { CR96, 0x50 },
661 { CR97, 0x37 }, { CR98, 0x35 }, { CR101, 0x13 },
662 { CR102, 0x27 }, { CR103, 0x27 }, { CR104, 0x18 },
663 { CR105, 0x12 }, { CR109, 0x27 }, { CR110, 0x27 },
664 { CR111, 0x27 }, { CR112, 0x27 }, { CR113, 0x27 },
665 { CR114, 0x27 }, { CR115, 0x26 }, { CR116, 0x24 },
666 { CR117, 0xfc }, { CR118, 0xfa }, { CR120, 0x4f },
667 { CR123, 0x27 }, { CR125, 0xaa }, { CR127, 0x03 },
668 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
669 { CR131, 0x0C }, { CR136, 0xdf }, { CR137, 0x40 },
670 { CR138, 0xa0 }, { CR139, 0xb0 }, { CR140, 0x99 },
671 { CR141, 0x82 }, { CR142, 0x54 }, { CR143, 0x1c },
672 { CR144, 0x6c }, { CR147, 0x07 }, { CR148, 0x4c },
673 { CR149, 0x50 }, { CR150, 0x0e }, { CR151, 0x18 },
674 { CR160, 0xfe }, { CR161, 0xee }, { CR162, 0xaa },
675 { CR163, 0xfa }, { CR164, 0xfa }, { CR165, 0xea },
676 { CR166, 0xbe }, { CR167, 0xbe }, { CR168, 0x6a },
677 { CR169, 0xba }, { CR170, 0xba }, { CR171, 0xba },
678 /* Note: CR204 must lead the CR203 */
679 { CR204, 0x7d },
680 { },
681 { CR203, 0x30 },
682 };
683
684 int r, t;
685
686 dev_dbg_f(zd_chip_dev(chip), "\n");
687
688 r = zd_chip_lock_phy_regs(chip);
689 if (r)
690 goto out;
691
692 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
693 if (r)
694 goto unlock;
695
696 r = patch_cr157(chip);
697unlock:
698 t = zd_chip_unlock_phy_regs(chip);
699 if (t && !r)
700 r = t;
701out:
702 return r;
703}
704
705static int zd1211b_hw_reset_phy(struct zd_chip *chip)
706{
707 static const struct zd_ioreq16 ioreqs[] = {
708 { CR0, 0x14 }, { CR1, 0x06 }, { CR2, 0x26 },
709 { CR3, 0x38 }, { CR4, 0x80 }, { CR9, 0xe0 },
710 { CR10, 0x81 },
711 /* power control { { CR11, 1 << 6 }, */
712 { CR11, 0x00 },
713 { CR12, 0xf0 }, { CR13, 0x8c }, { CR14, 0x80 },
714 { CR15, 0x3d }, { CR16, 0x20 }, { CR17, 0x1e },
715 { CR18, 0x0a }, { CR19, 0x48 },
716 { CR20, 0x10 }, /* Org:0x0E, ComTrend:RalLink AP */
717 { CR21, 0x0e }, { CR22, 0x23 }, { CR23, 0x90 },
718 { CR24, 0x14 }, { CR25, 0x40 }, { CR26, 0x10 },
719 { CR27, 0x10 }, { CR28, 0x7f }, { CR29, 0x80 },
720 { CR30, 0x49 }, /* jointly decoder, no ASIC */
721 { CR31, 0x60 }, { CR32, 0x43 }, { CR33, 0x08 },
722 { CR34, 0x06 }, { CR35, 0x0a }, { CR36, 0x00 },
723 { CR37, 0x00 }, { CR38, 0x38 }, { CR39, 0x0c },
724 { CR40, 0x84 }, { CR41, 0x2a }, { CR42, 0x80 },
725 { CR43, 0x10 }, { CR44, 0x33 }, { CR46, 0xff },
726 { CR47, 0x1E }, { CR48, 0x26 }, { CR49, 0x5b },
727 { CR64, 0xd0 }, { CR65, 0x04 }, { CR66, 0x58 },
728 { CR67, 0xc9 }, { CR68, 0x88 }, { CR69, 0x41 },
729 { CR70, 0x23 }, { CR71, 0x10 }, { CR72, 0xff },
730 { CR73, 0x32 }, { CR74, 0x30 }, { CR75, 0x65 },
731 { CR76, 0x41 }, { CR77, 0x1b }, { CR78, 0x30 },
732 { CR79, 0xf0 }, { CR80, 0x64 }, { CR81, 0x64 },
733 { CR82, 0x00 }, { CR83, 0x24 }, { CR84, 0x04 },
734 { CR85, 0x00 }, { CR86, 0x0c }, { CR87, 0x12 },
735 { CR88, 0x0c }, { CR89, 0x00 }, { CR90, 0x58 },
736 { CR91, 0x04 }, { CR92, 0x00 }, { CR93, 0x00 },
737 { CR94, 0x01 },
738 { CR95, 0x20 }, /* ZD1211B */
739 { CR96, 0x50 }, { CR97, 0x37 }, { CR98, 0x35 },
740 { CR99, 0x00 }, { CR100, 0x01 }, { CR101, 0x13 },
741 { CR102, 0x27 }, { CR103, 0x27 }, { CR104, 0x18 },
742 { CR105, 0x12 }, { CR106, 0x04 }, { CR107, 0x00 },
743 { CR108, 0x0a }, { CR109, 0x27 }, { CR110, 0x27 },
744 { CR111, 0x27 }, { CR112, 0x27 }, { CR113, 0x27 },
745 { CR114, 0x27 }, { CR115, 0x26 }, { CR116, 0x24 },
746 { CR117, 0xfc }, { CR118, 0xfa }, { CR119, 0x1e },
747 { CR125, 0x90 }, { CR126, 0x00 }, { CR127, 0x00 },
748 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
749 { CR131, 0x0c }, { CR136, 0xdf }, { CR137, 0xa0 },
750 { CR138, 0xa8 }, { CR139, 0xb4 }, { CR140, 0x98 },
751 { CR141, 0x82 }, { CR142, 0x53 }, { CR143, 0x1c },
752 { CR144, 0x6c }, { CR147, 0x07 }, { CR148, 0x40 },
753 { CR149, 0x40 }, /* Org:0x50 ComTrend:RalLink AP */
754 { CR150, 0x14 }, /* Org:0x0E ComTrend:RalLink AP */
755 { CR151, 0x18 }, { CR159, 0x70 }, { CR160, 0xfe },
756 { CR161, 0xee }, { CR162, 0xaa }, { CR163, 0xfa },
757 { CR164, 0xfa }, { CR165, 0xea }, { CR166, 0xbe },
758 { CR167, 0xbe }, { CR168, 0x6a }, { CR169, 0xba },
759 { CR170, 0xba }, { CR171, 0xba },
760 /* Note: CR204 must lead the CR203 */
761 { CR204, 0x7d },
762 {},
763 { CR203, 0x30 },
764 };
765
766 int r, t;
767
768 dev_dbg_f(zd_chip_dev(chip), "\n");
769
770 r = zd_chip_lock_phy_regs(chip);
771 if (r)
772 goto out;
773
774 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
775 if (r)
776 goto unlock;
777
778 r = patch_cr157(chip);
779unlock:
780 t = zd_chip_unlock_phy_regs(chip);
781 if (t && !r)
782 r = t;
783out:
784 return r;
785}
786
787static int hw_reset_phy(struct zd_chip *chip)
788{
789 return chip->is_zd1211b ? zd1211b_hw_reset_phy(chip) :
790 zd1211_hw_reset_phy(chip);
791}
792
793static int zd1211_hw_init_hmac(struct zd_chip *chip)
794{
795 static const struct zd_ioreq32 ioreqs[] = {
796 { CR_ACK_TIMEOUT_EXT, 0x20 },
797 { CR_ADDA_MBIAS_WARMTIME, 0x30000808 },
798 { CR_ZD1211_RETRY_MAX, 0x2 },
799 { CR_SNIFFER_ON, 0 },
800 { CR_RX_FILTER, AP_RX_FILTER },
801 { CR_GROUP_HASH_P1, 0x00 },
802 { CR_GROUP_HASH_P2, 0x80000000 },
803 { CR_REG1, 0xa4 },
804 { CR_ADDA_PWR_DWN, 0x7f },
805 { CR_BCN_PLCP_CFG, 0x00f00401 },
806 { CR_PHY_DELAY, 0x00 },
807 { CR_ACK_TIMEOUT_EXT, 0x80 },
808 { CR_ADDA_PWR_DWN, 0x00 },
809 { CR_ACK_TIME_80211, 0x100 },
810 { CR_IFS_VALUE, 0x547c032 },
811 { CR_RX_PE_DELAY, 0x70 },
812 { CR_PS_CTRL, 0x10000000 },
813 { CR_RTS_CTS_RATE, 0x02030203 },
814 { CR_RX_THRESHOLD, 0x000c0640 },
815 { CR_AFTER_PNP, 0x1 },
816 { CR_WEP_PROTECT, 0x114 },
817 };
818
819 int r;
820
821 dev_dbg_f(zd_chip_dev(chip), "\n");
822 ZD_ASSERT(mutex_is_locked(&chip->mutex));
823 r = zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
824#ifdef DEBUG
825 if (r) {
826 dev_err(zd_chip_dev(chip),
827 "error in zd_iowrite32a_locked. Error number %d\n", r);
828 }
829#endif /* DEBUG */
830 return r;
831}
832
833static int zd1211b_hw_init_hmac(struct zd_chip *chip)
834{
835 static const struct zd_ioreq32 ioreqs[] = {
836 { CR_ACK_TIMEOUT_EXT, 0x20 },
837 { CR_ADDA_MBIAS_WARMTIME, 0x30000808 },
838 { CR_ZD1211B_RETRY_MAX, 0x02020202 },
839 { CR_ZD1211B_TX_PWR_CTL4, 0x007f003f },
840 { CR_ZD1211B_TX_PWR_CTL3, 0x007f003f },
841 { CR_ZD1211B_TX_PWR_CTL2, 0x003f001f },
842 { CR_ZD1211B_TX_PWR_CTL1, 0x001f000f },
843 { CR_ZD1211B_AIFS_CTL1, 0x00280028 },
844 { CR_ZD1211B_AIFS_CTL2, 0x008C003C },
845 { CR_ZD1211B_TXOP, 0x01800824 },
846 { CR_SNIFFER_ON, 0 },
847 { CR_RX_FILTER, AP_RX_FILTER },
848 { CR_GROUP_HASH_P1, 0x00 },
849 { CR_GROUP_HASH_P2, 0x80000000 },
850 { CR_REG1, 0xa4 },
851 { CR_ADDA_PWR_DWN, 0x7f },
852 { CR_BCN_PLCP_CFG, 0x00f00401 },
853 { CR_PHY_DELAY, 0x00 },
854 { CR_ACK_TIMEOUT_EXT, 0x80 },
855 { CR_ADDA_PWR_DWN, 0x00 },
856 { CR_ACK_TIME_80211, 0x100 },
857 { CR_IFS_VALUE, 0x547c032 },
858 { CR_RX_PE_DELAY, 0x70 },
859 { CR_PS_CTRL, 0x10000000 },
860 { CR_RTS_CTS_RATE, 0x02030203 },
861 { CR_RX_THRESHOLD, 0x000c0640 },
862 { CR_AFTER_PNP, 0x1 },
863 { CR_WEP_PROTECT, 0x114 },
864 };
865
866 int r;
867
868 dev_dbg_f(zd_chip_dev(chip), "\n");
869 ZD_ASSERT(mutex_is_locked(&chip->mutex));
870 r = zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
871 if (r) {
872 dev_dbg_f(zd_chip_dev(chip),
873 "error in zd_iowrite32a_locked. Error number %d\n", r);
874 }
875 return r;
876}
877
878static int hw_init_hmac(struct zd_chip *chip)
879{
880 return chip->is_zd1211b ?
881 zd1211b_hw_init_hmac(chip) : zd1211_hw_init_hmac(chip);
882}
883
884struct aw_pt_bi {
885 u32 atim_wnd_period;
886 u32 pre_tbtt;
887 u32 beacon_interval;
888};
889
890static int get_aw_pt_bi(struct zd_chip *chip, struct aw_pt_bi *s)
891{
892 int r;
893 static const zd_addr_t aw_pt_bi_addr[] =
894 { CR_ATIM_WND_PERIOD, CR_PRE_TBTT, CR_BCN_INTERVAL };
895 u32 values[3];
896
897 r = zd_ioread32v_locked(chip, values, (const zd_addr_t *)aw_pt_bi_addr,
898 ARRAY_SIZE(aw_pt_bi_addr));
899 if (r) {
900 memset(s, 0, sizeof(*s));
901 return r;
902 }
903
904 s->atim_wnd_period = values[0];
905 s->pre_tbtt = values[1];
906 s->beacon_interval = values[2];
907 dev_dbg_f(zd_chip_dev(chip), "aw %u pt %u bi %u\n",
908 s->atim_wnd_period, s->pre_tbtt, s->beacon_interval);
909 return 0;
910}
911
912static int set_aw_pt_bi(struct zd_chip *chip, struct aw_pt_bi *s)
913{
914 struct zd_ioreq32 reqs[3];
915
916 if (s->beacon_interval <= 5)
917 s->beacon_interval = 5;
918 if (s->pre_tbtt < 4 || s->pre_tbtt >= s->beacon_interval)
919 s->pre_tbtt = s->beacon_interval - 1;
920 if (s->atim_wnd_period >= s->pre_tbtt)
921 s->atim_wnd_period = s->pre_tbtt - 1;
922
923 reqs[0].addr = CR_ATIM_WND_PERIOD;
924 reqs[0].value = s->atim_wnd_period;
925 reqs[1].addr = CR_PRE_TBTT;
926 reqs[1].value = s->pre_tbtt;
927 reqs[2].addr = CR_BCN_INTERVAL;
928 reqs[2].value = s->beacon_interval;
929
930 dev_dbg_f(zd_chip_dev(chip),
931 "aw %u pt %u bi %u\n", s->atim_wnd_period, s->pre_tbtt,
932 s->beacon_interval);
933 return zd_iowrite32a_locked(chip, reqs, ARRAY_SIZE(reqs));
934}
935
936
937static int set_beacon_interval(struct zd_chip *chip, u32 interval)
938{
939 int r;
940 struct aw_pt_bi s;
941
942 ZD_ASSERT(mutex_is_locked(&chip->mutex));
943 r = get_aw_pt_bi(chip, &s);
944 if (r)
945 return r;
946 s.beacon_interval = interval;
947 return set_aw_pt_bi(chip, &s);
948}
949
950int zd_set_beacon_interval(struct zd_chip *chip, u32 interval)
951{
952 int r;
953
954 mutex_lock(&chip->mutex);
955 r = set_beacon_interval(chip, interval);
956 mutex_unlock(&chip->mutex);
957 return r;
958}
959
960static int hw_init(struct zd_chip *chip)
961{
962 int r;
963
964 dev_dbg_f(zd_chip_dev(chip), "\n");
965 ZD_ASSERT(mutex_is_locked(&chip->mutex));
966 r = hw_reset_phy(chip);
967 if (r)
968 return r;
969
970 r = hw_init_hmac(chip);
971 if (r)
972 return r;
973 r = set_beacon_interval(chip, 100);
974 if (r)
975 return r;
976 return 0;
977}
978
979#ifdef DEBUG
980static int dump_cr(struct zd_chip *chip, const zd_addr_t addr,
981 const char *addr_string)
982{
983 int r;
984 u32 value;
985
986 r = zd_ioread32_locked(chip, &value, addr);
987 if (r) {
988 dev_dbg_f(zd_chip_dev(chip),
989 "error reading %s. Error number %d\n", addr_string, r);
990 return r;
991 }
992
993 dev_dbg_f(zd_chip_dev(chip), "%s %#010x\n",
994 addr_string, (unsigned int)value);
995 return 0;
996}
997
998static int test_init(struct zd_chip *chip)
999{
1000 int r;
1001
1002 r = dump_cr(chip, CR_AFTER_PNP, "CR_AFTER_PNP");
1003 if (r)
1004 return r;
1005 r = dump_cr(chip, CR_GPI_EN, "CR_GPI_EN");
1006 if (r)
1007 return r;
1008 return dump_cr(chip, CR_INTERRUPT, "CR_INTERRUPT");
1009}
1010
1011static void dump_fw_registers(struct zd_chip *chip)
1012{
1013 static const zd_addr_t addr[4] = {
1014 FW_FIRMWARE_VER, FW_USB_SPEED, FW_FIX_TX_RATE,
1015 FW_LINK_STATUS
1016 };
1017
1018 int r;
1019 u16 values[4];
1020
1021 r = zd_ioread16v_locked(chip, values, (const zd_addr_t*)addr,
1022 ARRAY_SIZE(addr));
1023 if (r) {
1024 dev_dbg_f(zd_chip_dev(chip), "error %d zd_ioread16v_locked\n",
1025 r);
1026 return;
1027 }
1028
1029 dev_dbg_f(zd_chip_dev(chip), "FW_FIRMWARE_VER %#06hx\n", values[0]);
1030 dev_dbg_f(zd_chip_dev(chip), "FW_USB_SPEED %#06hx\n", values[1]);
1031 dev_dbg_f(zd_chip_dev(chip), "FW_FIX_TX_RATE %#06hx\n", values[2]);
1032 dev_dbg_f(zd_chip_dev(chip), "FW_LINK_STATUS %#06hx\n", values[3]);
1033}
1034#endif /* DEBUG */
1035
1036static int print_fw_version(struct zd_chip *chip)
1037{
1038 int r;
1039 u16 version;
1040
1041 r = zd_ioread16_locked(chip, &version, FW_FIRMWARE_VER);
1042 if (r)
1043 return r;
1044
1045 dev_info(zd_chip_dev(chip),"firmware version %04hx\n", version);
1046 return 0;
1047}
1048
1049static int set_mandatory_rates(struct zd_chip *chip, enum ieee80211_std std)
1050{
1051 u32 rates;
1052 ZD_ASSERT(mutex_is_locked(&chip->mutex));
1053 /* This sets the mandatory rates, which only depend from the standard
1054 * that the device is supporting. Until further notice we should try
1055 * to support 802.11g also for full speed USB.
1056 */
1057 switch (std) {
1058 case IEEE80211B:
1059 rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M;
1060 break;
1061 case IEEE80211G:
1062 rates = CR_RATE_1M|CR_RATE_2M|CR_RATE_5_5M|CR_RATE_11M|
1063 CR_RATE_6M|CR_RATE_12M|CR_RATE_24M;
1064 break;
1065 default:
1066 return -EINVAL;
1067 }
1068 return zd_iowrite32_locked(chip, rates, CR_MANDATORY_RATE_TBL);
1069}
1070
1071int zd_chip_enable_hwint(struct zd_chip *chip)
1072{
1073 int r;
1074
1075 mutex_lock(&chip->mutex);
1076 r = zd_iowrite32_locked(chip, HWINT_ENABLED, CR_INTERRUPT);
1077 mutex_unlock(&chip->mutex);
1078 return r;
1079}
1080
1081static int disable_hwint(struct zd_chip *chip)
1082{
1083 return zd_iowrite32_locked(chip, HWINT_DISABLED, CR_INTERRUPT);
1084}
1085
1086int zd_chip_disable_hwint(struct zd_chip *chip)
1087{
1088 int r;
1089
1090 mutex_lock(&chip->mutex);
1091 r = disable_hwint(chip);
1092 mutex_unlock(&chip->mutex);
1093 return r;
1094}
1095
1096int zd_chip_init_hw(struct zd_chip *chip, u8 device_type)
1097{
1098 int r;
1099 u8 rf_type;
1100
1101 dev_dbg_f(zd_chip_dev(chip), "\n");
1102
1103 mutex_lock(&chip->mutex);
1104 chip->is_zd1211b = (device_type == DEVICE_ZD1211B) != 0;
1105
1106#ifdef DEBUG
1107 r = test_init(chip);
1108 if (r)
1109 goto out;
1110#endif
1111 r = zd_iowrite32_locked(chip, 1, CR_AFTER_PNP);
1112 if (r)
1113 goto out;
1114
1115 r = zd_usb_init_hw(&chip->usb);
1116 if (r)
1117 goto out;
1118
1119 /* GPI is always disabled, also in the other driver.
1120 */
1121 r = zd_iowrite32_locked(chip, 0, CR_GPI_EN);
1122 if (r)
1123 goto out;
1124 r = zd_iowrite32_locked(chip, CWIN_SIZE, CR_CWMIN_CWMAX);
1125 if (r)
1126 goto out;
1127 /* Currently we support IEEE 802.11g for full and high speed USB.
1128 * It might be discussed, whether we should suppport pure b mode for
1129 * full speed USB.
1130 */
1131 r = set_mandatory_rates(chip, IEEE80211G);
1132 if (r)
1133 goto out;
1134 /* Disabling interrupts is certainly a smart thing here.
1135 */
1136 r = disable_hwint(chip);
1137 if (r)
1138 goto out;
1139 r = read_pod(chip, &rf_type);
1140 if (r)
1141 goto out;
1142 r = hw_init(chip);
1143 if (r)
1144 goto out;
1145 r = zd_rf_init_hw(&chip->rf, rf_type);
1146 if (r)
1147 goto out;
1148
1149 r = print_fw_version(chip);
1150 if (r)
1151 goto out;
1152
1153#ifdef DEBUG
1154 dump_fw_registers(chip);
1155 r = test_init(chip);
1156 if (r)
1157 goto out;
1158#endif /* DEBUG */
1159
1160 r = read_e2p_mac_addr(chip);
1161 if (r)
1162 goto out;
1163
1164 r = read_cal_int_tables(chip);
1165 if (r)
1166 goto out;
1167
1168 print_id(chip);
1169out:
1170 mutex_unlock(&chip->mutex);
1171 return r;
1172}
1173
1174static int update_pwr_int(struct zd_chip *chip, u8 channel)
1175{
1176 u8 value = chip->pwr_int_values[channel - 1];
1177 dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_int %#04x\n",
1178 channel, value);
1179 return zd_iowrite32_locked(chip, value, CR31);
1180}
1181
1182static int update_pwr_cal(struct zd_chip *chip, u8 channel)
1183{
1184 u8 value = chip->pwr_cal_values[channel-1];
1185 dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_cal %#04x\n",
1186 channel, value);
1187 return zd_iowrite32_locked(chip, value, CR68);
1188}
1189
1190static int update_ofdm_cal(struct zd_chip *chip, u8 channel)
1191{
1192 struct zd_ioreq32 ioreqs[3];
1193
1194 ioreqs[0].addr = CR67;
1195 ioreqs[0].value = chip->ofdm_cal_values[OFDM_36M_INDEX][channel-1];
1196 ioreqs[1].addr = CR66;
1197 ioreqs[1].value = chip->ofdm_cal_values[OFDM_48M_INDEX][channel-1];
1198 ioreqs[2].addr = CR65;
1199 ioreqs[2].value = chip->ofdm_cal_values[OFDM_54M_INDEX][channel-1];
1200
1201 dev_dbg_f(zd_chip_dev(chip),
1202 "channel %d ofdm_cal 36M %#04x 48M %#04x 54M %#04x\n",
1203 channel, ioreqs[0].value, ioreqs[1].value, ioreqs[2].value);
1204 return zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
1205}
1206
1207static int update_channel_integration_and_calibration(struct zd_chip *chip,
1208 u8 channel)
1209{
1210 int r;
1211
1212 r = update_pwr_int(chip, channel);
1213 if (r)
1214 return r;
1215 if (chip->is_zd1211b) {
1216 static const struct zd_ioreq32 ioreqs[] = {
1217 { CR69, 0x28 },
1218 {},
1219 { CR69, 0x2a },
1220 };
1221
1222 r = update_ofdm_cal(chip, channel);
1223 if (r)
1224 return r;
1225 r = update_pwr_cal(chip, channel);
1226 if (r)
1227 return r;
1228 r = zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
1229 if (r)
1230 return r;
1231 }
1232
1233 return 0;
1234}
1235
1236/* The CCK baseband gain can be optionally patched by the EEPROM */
1237static int patch_cck_gain(struct zd_chip *chip)
1238{
1239 int r;
1240 u32 value;
1241
1242 if (!chip->patch_cck_gain)
1243 return 0;
1244
1245 ZD_ASSERT(mutex_is_locked(&chip->mutex));
1246 r = zd_ioread32_locked(chip, &value, E2P_PHY_REG);
1247 if (r)
1248 return r;
1249 dev_dbg_f(zd_chip_dev(chip), "patching value %x\n", value & 0xff);
1250 return zd_iowrite32_locked(chip, value & 0xff, CR47);
1251}
1252
1253int zd_chip_set_channel(struct zd_chip *chip, u8 channel)
1254{
1255 int r, t;
1256
1257 mutex_lock(&chip->mutex);
1258 r = zd_chip_lock_phy_regs(chip);
1259 if (r)
1260 goto out;
1261 r = zd_rf_set_channel(&chip->rf, channel);
1262 if (r)
1263 goto unlock;
1264 r = update_channel_integration_and_calibration(chip, channel);
1265 if (r)
1266 goto unlock;
1267 r = patch_cck_gain(chip);
1268 if (r)
1269 goto unlock;
1270 r = patch_6m_band_edge(chip, channel);
1271 if (r)
1272 goto unlock;
1273 r = zd_iowrite32_locked(chip, 0, CR_CONFIG_PHILIPS);
1274unlock:
1275 t = zd_chip_unlock_phy_regs(chip);
1276 if (t && !r)
1277 r = t;
1278out:
1279 mutex_unlock(&chip->mutex);
1280 return r;
1281}
1282
1283u8 zd_chip_get_channel(struct zd_chip *chip)
1284{
1285 u8 channel;
1286
1287 mutex_lock(&chip->mutex);
1288 channel = chip->rf.channel;
1289 mutex_unlock(&chip->mutex);
1290 return channel;
1291}
1292
1293static u16 led_mask(int led)
1294{
1295 switch (led) {
1296 case 1:
1297 return LED1;
1298 case 2:
1299 return LED2;
1300 default:
1301 return 0;
1302 }
1303}
1304
1305static int read_led_reg(struct zd_chip *chip, u16 *status)
1306{
1307 ZD_ASSERT(mutex_is_locked(&chip->mutex));
1308 return zd_ioread16_locked(chip, status, CR_LED);
1309}
1310
1311static int write_led_reg(struct zd_chip *chip, u16 status)
1312{
1313 ZD_ASSERT(mutex_is_locked(&chip->mutex));
1314 return zd_iowrite16_locked(chip, status, CR_LED);
1315}
1316
1317int zd_chip_led_status(struct zd_chip *chip, int led, enum led_status status)
1318{
1319 int r, ret;
1320 u16 mask = led_mask(led);
1321 u16 reg;
1322
1323 if (!mask)
1324 return -EINVAL;
1325 mutex_lock(&chip->mutex);
1326 r = read_led_reg(chip, &reg);
1327 if (r)
1328 return r;
1329 switch (status) {
1330 case LED_STATUS:
1331 return (reg & mask) ? LED_ON : LED_OFF;
1332 case LED_OFF:
1333 reg &= ~mask;
1334 ret = LED_OFF;
1335 break;
1336 case LED_FLIP:
1337 reg ^= mask;
1338 ret = (reg&mask) ? LED_ON : LED_OFF;
1339 break;
1340 case LED_ON:
1341 reg |= mask;
1342 ret = LED_ON;
1343 break;
1344 default:
1345 return -EINVAL;
1346 }
1347 r = write_led_reg(chip, reg);
1348 if (r) {
1349 ret = r;
1350 goto out;
1351 }
1352out:
1353 mutex_unlock(&chip->mutex);
1354 return r;
1355}
1356
1357int zd_chip_led_flip(struct zd_chip *chip, int led,
1358 const unsigned int *phases_msecs, unsigned int count)
1359{
1360 int i, r;
1361 enum led_status status;
1362
1363 r = zd_chip_led_status(chip, led, LED_STATUS);
1364 if (r)
1365 return r;
1366 status = r;
1367 for (i = 0; i < count; i++) {
1368 r = zd_chip_led_status(chip, led, LED_FLIP);
1369 if (r < 0)
1370 goto out;
1371 msleep(phases_msecs[i]);
1372 }
1373
1374out:
1375 zd_chip_led_status(chip, led, status);
1376 return r;
1377}
1378
1379int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates)
1380{
1381 int r;
1382
1383 if (cr_rates & ~(CR_RATES_80211B|CR_RATES_80211G))
1384 return -EINVAL;
1385
1386 mutex_lock(&chip->mutex);
1387 r = zd_iowrite32_locked(chip, cr_rates, CR_BASIC_RATE_TBL);
1388 mutex_unlock(&chip->mutex);
1389 return r;
1390}
1391
1392static int ofdm_qual_db(u8 status_quality, u8 rate, unsigned int size)
1393{
1394 static const u16 constants[] = {
1395 715, 655, 585, 540, 470, 410, 360, 315,
1396 270, 235, 205, 175, 150, 125, 105, 85,
1397 65, 50, 40, 25, 15
1398 };
1399
1400 int i;
1401 u32 x;
1402
1403 /* It seems that their quality parameter is somehow per signal
1404 * and is now transferred per bit.
1405 */
1406 switch (rate) {
1407 case ZD_OFDM_RATE_6M:
1408 case ZD_OFDM_RATE_12M:
1409 case ZD_OFDM_RATE_24M:
1410 size *= 2;
1411 break;
1412 case ZD_OFDM_RATE_9M:
1413 case ZD_OFDM_RATE_18M:
1414 case ZD_OFDM_RATE_36M:
1415 case ZD_OFDM_RATE_54M:
1416 size *= 4;
1417 size /= 3;
1418 break;
1419 case ZD_OFDM_RATE_48M:
1420 size *= 3;
1421 size /= 2;
1422 break;
1423 default:
1424 return -EINVAL;
1425 }
1426
1427 x = (10000 * status_quality)/size;
1428 for (i = 0; i < ARRAY_SIZE(constants); i++) {
1429 if (x > constants[i])
1430 break;
1431 }
1432
1433 return i;
1434}
1435
1436static unsigned int log10times100(unsigned int x)
1437{
1438 static const u8 log10[] = {
1439 0,
1440 0, 30, 47, 60, 69, 77, 84, 90, 95, 100,
1441 104, 107, 111, 114, 117, 120, 123, 125, 127, 130,
1442 132, 134, 136, 138, 139, 141, 143, 144, 146, 147,
1443 149, 150, 151, 153, 154, 155, 156, 157, 159, 160,
1444 161, 162, 163, 164, 165, 166, 167, 168, 169, 169,
1445 170, 171, 172, 173, 174, 174, 175, 176, 177, 177,
1446 178, 179, 179, 180, 181, 181, 182, 183, 183, 184,
1447 185, 185, 186, 186, 187, 188, 188, 189, 189, 190,
1448 190, 191, 191, 192, 192, 193, 193, 194, 194, 195,
1449 195, 196, 196, 197, 197, 198, 198, 199, 199, 200,
1450 200, 200, 201, 201, 202, 202, 202, 203, 203, 204,
1451 204, 204, 205, 205, 206, 206, 206, 207, 207, 207,
1452 208, 208, 208, 209, 209, 210, 210, 210, 211, 211,
1453 211, 212, 212, 212, 213, 213, 213, 213, 214, 214,
1454 214, 215, 215, 215, 216, 216, 216, 217, 217, 217,
1455 217, 218, 218, 218, 219, 219, 219, 219, 220, 220,
1456 220, 220, 221, 221, 221, 222, 222, 222, 222, 223,
1457 223, 223, 223, 224, 224, 224, 224,
1458 };
1459
1460 return x < ARRAY_SIZE(log10) ? log10[x] : 225;
1461}
1462
1463enum {
1464 MAX_CCK_EVM_DB = 45,
1465};
1466
1467static int cck_evm_db(u8 status_quality)
1468{
1469 return (20 * log10times100(status_quality)) / 100;
1470}
1471
1472static int cck_snr_db(u8 status_quality)
1473{
1474 int r = MAX_CCK_EVM_DB - cck_evm_db(status_quality);
1475 ZD_ASSERT(r >= 0);
1476 return r;
1477}
1478
1479static int rx_qual_db(const void *rx_frame, unsigned int size,
1480 const struct rx_status *status)
1481{
1482 return (status->frame_status&ZD_RX_OFDM) ?
1483 ofdm_qual_db(status->signal_quality_ofdm,
1484 zd_ofdm_plcp_header_rate(rx_frame),
1485 size) :
1486 cck_snr_db(status->signal_quality_cck);
1487}
1488
1489u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size,
1490 const struct rx_status *status)
1491{
1492 int r = rx_qual_db(rx_frame, size, status);
1493 if (r < 0)
1494 r = 0;
1495 r = (r * 100) / 14;
1496 if (r > 100)
1497 r = 100;
1498 return r;
1499}
1500
1501u8 zd_rx_strength_percent(u8 rssi)
1502{
1503 int r = (rssi*100) / 30;
1504 if (r > 100)
1505 r = 100;
1506 return (u8) r;
1507}
1508
1509u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status)
1510{
1511 static const u16 ofdm_rates[] = {
1512 [ZD_OFDM_RATE_6M] = 60,
1513 [ZD_OFDM_RATE_9M] = 90,
1514 [ZD_OFDM_RATE_12M] = 120,
1515 [ZD_OFDM_RATE_18M] = 180,
1516 [ZD_OFDM_RATE_24M] = 240,
1517 [ZD_OFDM_RATE_36M] = 360,
1518 [ZD_OFDM_RATE_48M] = 480,
1519 [ZD_OFDM_RATE_54M] = 540,
1520 };
1521 u16 rate;
1522 if (status->frame_status & ZD_RX_OFDM) {
1523 u8 ofdm_rate = zd_ofdm_plcp_header_rate(rx_frame);
1524 rate = ofdm_rates[ofdm_rate & 0xf];
1525 } else {
1526 u8 cck_rate = zd_cck_plcp_header_rate(rx_frame);
1527 switch (cck_rate) {
1528 case ZD_CCK_SIGNAL_1M:
1529 rate = 10;
1530 break;
1531 case ZD_CCK_SIGNAL_2M:
1532 rate = 20;
1533 break;
1534 case ZD_CCK_SIGNAL_5M5:
1535 rate = 55;
1536 break;
1537 case ZD_CCK_SIGNAL_11M:
1538 rate = 110;
1539 break;
1540 default:
1541 rate = 0;
1542 }
1543 }
1544
1545 return rate;
1546}
1547
1548int zd_chip_switch_radio_on(struct zd_chip *chip)
1549{
1550 int r;
1551
1552 mutex_lock(&chip->mutex);
1553 r = zd_switch_radio_on(&chip->rf);
1554 mutex_unlock(&chip->mutex);
1555 return r;
1556}
1557
1558int zd_chip_switch_radio_off(struct zd_chip *chip)
1559{
1560 int r;
1561
1562 mutex_lock(&chip->mutex);
1563 r = zd_switch_radio_off(&chip->rf);
1564 mutex_unlock(&chip->mutex);
1565 return r;
1566}
1567
1568int zd_chip_enable_int(struct zd_chip *chip)
1569{
1570 int r;
1571
1572 mutex_lock(&chip->mutex);
1573 r = zd_usb_enable_int(&chip->usb);
1574 mutex_unlock(&chip->mutex);
1575 return r;
1576}
1577
1578void zd_chip_disable_int(struct zd_chip *chip)
1579{
1580 mutex_lock(&chip->mutex);
1581 zd_usb_disable_int(&chip->usb);
1582 mutex_unlock(&chip->mutex);
1583}
1584
1585int zd_chip_enable_rx(struct zd_chip *chip)
1586{
1587 int r;
1588
1589 mutex_lock(&chip->mutex);
1590 r = zd_usb_enable_rx(&chip->usb);
1591 mutex_unlock(&chip->mutex);
1592 return r;
1593}
1594
1595void zd_chip_disable_rx(struct zd_chip *chip)
1596{
1597 mutex_lock(&chip->mutex);
1598 zd_usb_disable_rx(&chip->usb);
1599 mutex_unlock(&chip->mutex);
1600}
1601
1602int zd_rfwritev_locked(struct zd_chip *chip,
1603 const u32* values, unsigned int count, u8 bits)
1604{
1605 int r;
1606 unsigned int i;
1607
1608 for (i = 0; i < count; i++) {
1609 r = zd_rfwrite_locked(chip, values[i], bits);
1610 if (r)
1611 return r;
1612 }
1613
1614 return 0;
1615}
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
new file mode 100644
index 000000000000..805121093ab5
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -0,0 +1,825 @@
1/* zd_chip.h
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#ifndef _ZD_CHIP_H
19#define _ZD_CHIP_H
20
21#include "zd_types.h"
22#include "zd_rf.h"
23#include "zd_usb.h"
24
25/* Header for the Media Access Controller (MAC) and the Baseband Processor
26 * (BBP). It appears that the ZD1211 wraps the old ZD1205 with USB glue and
27 * adds a processor for handling the USB protocol.
28 */
29
30/* 8-bit hardware registers */
31#define CR0 CTL_REG(0x0000)
32#define CR1 CTL_REG(0x0004)
33#define CR2 CTL_REG(0x0008)
34#define CR3 CTL_REG(0x000C)
35
36#define CR5 CTL_REG(0x0010)
37/* bit 5: if set short preamble used
38 * bit 6: filter band - Japan channel 14 on, else off
39 */
40#define CR6 CTL_REG(0x0014)
41#define CR7 CTL_REG(0x0018)
42#define CR8 CTL_REG(0x001C)
43
44#define CR4 CTL_REG(0x0020)
45
46#define CR9 CTL_REG(0x0024)
47/* bit 2: antenna switch (together with CR10) */
48#define CR10 CTL_REG(0x0028)
49/* bit 1: antenna switch (together with CR9)
50 * RF2959 controls with CR11 radion on and off
51 */
52#define CR11 CTL_REG(0x002C)
53/* bit 6: TX power control for OFDM
54 * RF2959 controls with CR10 radio on and off
55 */
56#define CR12 CTL_REG(0x0030)
57#define CR13 CTL_REG(0x0034)
58#define CR14 CTL_REG(0x0038)
59#define CR15 CTL_REG(0x003C)
60#define CR16 CTL_REG(0x0040)
61#define CR17 CTL_REG(0x0044)
62#define CR18 CTL_REG(0x0048)
63#define CR19 CTL_REG(0x004C)
64#define CR20 CTL_REG(0x0050)
65#define CR21 CTL_REG(0x0054)
66#define CR22 CTL_REG(0x0058)
67#define CR23 CTL_REG(0x005C)
68#define CR24 CTL_REG(0x0060) /* CCA threshold */
69#define CR25 CTL_REG(0x0064)
70#define CR26 CTL_REG(0x0068)
71#define CR27 CTL_REG(0x006C)
72#define CR28 CTL_REG(0x0070)
73#define CR29 CTL_REG(0x0074)
74#define CR30 CTL_REG(0x0078)
75#define CR31 CTL_REG(0x007C) /* TX power control for RF in CCK mode */
76#define CR32 CTL_REG(0x0080)
77#define CR33 CTL_REG(0x0084)
78#define CR34 CTL_REG(0x0088)
79#define CR35 CTL_REG(0x008C)
80#define CR36 CTL_REG(0x0090)
81#define CR37 CTL_REG(0x0094)
82#define CR38 CTL_REG(0x0098)
83#define CR39 CTL_REG(0x009C)
84#define CR40 CTL_REG(0x00A0)
85#define CR41 CTL_REG(0x00A4)
86#define CR42 CTL_REG(0x00A8)
87#define CR43 CTL_REG(0x00AC)
88#define CR44 CTL_REG(0x00B0)
89#define CR45 CTL_REG(0x00B4)
90#define CR46 CTL_REG(0x00B8)
91#define CR47 CTL_REG(0x00BC) /* CCK baseband gain
92 * (patch value might be in EEPROM)
93 */
94#define CR48 CTL_REG(0x00C0)
95#define CR49 CTL_REG(0x00C4)
96#define CR50 CTL_REG(0x00C8)
97#define CR51 CTL_REG(0x00CC) /* TX power control for RF in 6-36M modes */
98#define CR52 CTL_REG(0x00D0) /* TX power control for RF in 48M mode */
99#define CR53 CTL_REG(0x00D4) /* TX power control for RF in 54M mode */
100#define CR54 CTL_REG(0x00D8)
101#define CR55 CTL_REG(0x00DC)
102#define CR56 CTL_REG(0x00E0)
103#define CR57 CTL_REG(0x00E4)
104#define CR58 CTL_REG(0x00E8)
105#define CR59 CTL_REG(0x00EC)
106#define CR60 CTL_REG(0x00F0)
107#define CR61 CTL_REG(0x00F4)
108#define CR62 CTL_REG(0x00F8)
109#define CR63 CTL_REG(0x00FC)
110#define CR64 CTL_REG(0x0100)
111#define CR65 CTL_REG(0x0104) /* OFDM 54M calibration */
112#define CR66 CTL_REG(0x0108) /* OFDM 48M calibration */
113#define CR67 CTL_REG(0x010C) /* OFDM 36M calibration */
114#define CR68 CTL_REG(0x0110) /* CCK calibration */
115#define CR69 CTL_REG(0x0114)
116#define CR70 CTL_REG(0x0118)
117#define CR71 CTL_REG(0x011C)
118#define CR72 CTL_REG(0x0120)
119#define CR73 CTL_REG(0x0124)
120#define CR74 CTL_REG(0x0128)
121#define CR75 CTL_REG(0x012C)
122#define CR76 CTL_REG(0x0130)
123#define CR77 CTL_REG(0x0134)
124#define CR78 CTL_REG(0x0138)
125#define CR79 CTL_REG(0x013C)
126#define CR80 CTL_REG(0x0140)
127#define CR81 CTL_REG(0x0144)
128#define CR82 CTL_REG(0x0148)
129#define CR83 CTL_REG(0x014C)
130#define CR84 CTL_REG(0x0150)
131#define CR85 CTL_REG(0x0154)
132#define CR86 CTL_REG(0x0158)
133#define CR87 CTL_REG(0x015C)
134#define CR88 CTL_REG(0x0160)
135#define CR89 CTL_REG(0x0164)
136#define CR90 CTL_REG(0x0168)
137#define CR91 CTL_REG(0x016C)
138#define CR92 CTL_REG(0x0170)
139#define CR93 CTL_REG(0x0174)
140#define CR94 CTL_REG(0x0178)
141#define CR95 CTL_REG(0x017C)
142#define CR96 CTL_REG(0x0180)
143#define CR97 CTL_REG(0x0184)
144#define CR98 CTL_REG(0x0188)
145#define CR99 CTL_REG(0x018C)
146#define CR100 CTL_REG(0x0190)
147#define CR101 CTL_REG(0x0194)
148#define CR102 CTL_REG(0x0198)
149#define CR103 CTL_REG(0x019C)
150#define CR104 CTL_REG(0x01A0)
151#define CR105 CTL_REG(0x01A4)
152#define CR106 CTL_REG(0x01A8)
153#define CR107 CTL_REG(0x01AC)
154#define CR108 CTL_REG(0x01B0)
155#define CR109 CTL_REG(0x01B4)
156#define CR110 CTL_REG(0x01B8)
157#define CR111 CTL_REG(0x01BC)
158#define CR112 CTL_REG(0x01C0)
159#define CR113 CTL_REG(0x01C4)
160#define CR114 CTL_REG(0x01C8)
161#define CR115 CTL_REG(0x01CC)
162#define CR116 CTL_REG(0x01D0)
163#define CR117 CTL_REG(0x01D4)
164#define CR118 CTL_REG(0x01D8)
165#define CR119 CTL_REG(0x01DC)
166#define CR120 CTL_REG(0x01E0)
167#define CR121 CTL_REG(0x01E4)
168#define CR122 CTL_REG(0x01E8)
169#define CR123 CTL_REG(0x01EC)
170#define CR124 CTL_REG(0x01F0)
171#define CR125 CTL_REG(0x01F4)
172#define CR126 CTL_REG(0x01F8)
173#define CR127 CTL_REG(0x01FC)
174#define CR128 CTL_REG(0x0200)
175#define CR129 CTL_REG(0x0204)
176#define CR130 CTL_REG(0x0208)
177#define CR131 CTL_REG(0x020C)
178#define CR132 CTL_REG(0x0210)
179#define CR133 CTL_REG(0x0214)
180#define CR134 CTL_REG(0x0218)
181#define CR135 CTL_REG(0x021C)
182#define CR136 CTL_REG(0x0220)
183#define CR137 CTL_REG(0x0224)
184#define CR138 CTL_REG(0x0228)
185#define CR139 CTL_REG(0x022C)
186#define CR140 CTL_REG(0x0230)
187#define CR141 CTL_REG(0x0234)
188#define CR142 CTL_REG(0x0238)
189#define CR143 CTL_REG(0x023C)
190#define CR144 CTL_REG(0x0240)
191#define CR145 CTL_REG(0x0244)
192#define CR146 CTL_REG(0x0248)
193#define CR147 CTL_REG(0x024C)
194#define CR148 CTL_REG(0x0250)
195#define CR149 CTL_REG(0x0254)
196#define CR150 CTL_REG(0x0258)
197#define CR151 CTL_REG(0x025C)
198#define CR152 CTL_REG(0x0260)
199#define CR153 CTL_REG(0x0264)
200#define CR154 CTL_REG(0x0268)
201#define CR155 CTL_REG(0x026C)
202#define CR156 CTL_REG(0x0270)
203#define CR157 CTL_REG(0x0274)
204#define CR158 CTL_REG(0x0278)
205#define CR159 CTL_REG(0x027C)
206#define CR160 CTL_REG(0x0280)
207#define CR161 CTL_REG(0x0284)
208#define CR162 CTL_REG(0x0288)
209#define CR163 CTL_REG(0x028C)
210#define CR164 CTL_REG(0x0290)
211#define CR165 CTL_REG(0x0294)
212#define CR166 CTL_REG(0x0298)
213#define CR167 CTL_REG(0x029C)
214#define CR168 CTL_REG(0x02A0)
215#define CR169 CTL_REG(0x02A4)
216#define CR170 CTL_REG(0x02A8)
217#define CR171 CTL_REG(0x02AC)
218#define CR172 CTL_REG(0x02B0)
219#define CR173 CTL_REG(0x02B4)
220#define CR174 CTL_REG(0x02B8)
221#define CR175 CTL_REG(0x02BC)
222#define CR176 CTL_REG(0x02C0)
223#define CR177 CTL_REG(0x02C4)
224#define CR178 CTL_REG(0x02C8)
225#define CR179 CTL_REG(0x02CC)
226#define CR180 CTL_REG(0x02D0)
227#define CR181 CTL_REG(0x02D4)
228#define CR182 CTL_REG(0x02D8)
229#define CR183 CTL_REG(0x02DC)
230#define CR184 CTL_REG(0x02E0)
231#define CR185 CTL_REG(0x02E4)
232#define CR186 CTL_REG(0x02E8)
233#define CR187 CTL_REG(0x02EC)
234#define CR188 CTL_REG(0x02F0)
235#define CR189 CTL_REG(0x02F4)
236#define CR190 CTL_REG(0x02F8)
237#define CR191 CTL_REG(0x02FC)
238#define CR192 CTL_REG(0x0300)
239#define CR193 CTL_REG(0x0304)
240#define CR194 CTL_REG(0x0308)
241#define CR195 CTL_REG(0x030C)
242#define CR196 CTL_REG(0x0310)
243#define CR197 CTL_REG(0x0314)
244#define CR198 CTL_REG(0x0318)
245#define CR199 CTL_REG(0x031C)
246#define CR200 CTL_REG(0x0320)
247#define CR201 CTL_REG(0x0324)
248#define CR202 CTL_REG(0x0328)
249#define CR203 CTL_REG(0x032C) /* I2C bus template value & flash control */
250#define CR204 CTL_REG(0x0330)
251#define CR205 CTL_REG(0x0334)
252#define CR206 CTL_REG(0x0338)
253#define CR207 CTL_REG(0x033C)
254#define CR208 CTL_REG(0x0340)
255#define CR209 CTL_REG(0x0344)
256#define CR210 CTL_REG(0x0348)
257#define CR211 CTL_REG(0x034C)
258#define CR212 CTL_REG(0x0350)
259#define CR213 CTL_REG(0x0354)
260#define CR214 CTL_REG(0x0358)
261#define CR215 CTL_REG(0x035C)
262#define CR216 CTL_REG(0x0360)
263#define CR217 CTL_REG(0x0364)
264#define CR218 CTL_REG(0x0368)
265#define CR219 CTL_REG(0x036C)
266#define CR220 CTL_REG(0x0370)
267#define CR221 CTL_REG(0x0374)
268#define CR222 CTL_REG(0x0378)
269#define CR223 CTL_REG(0x037C)
270#define CR224 CTL_REG(0x0380)
271#define CR225 CTL_REG(0x0384)
272#define CR226 CTL_REG(0x0388)
273#define CR227 CTL_REG(0x038C)
274#define CR228 CTL_REG(0x0390)
275#define CR229 CTL_REG(0x0394)
276#define CR230 CTL_REG(0x0398)
277#define CR231 CTL_REG(0x039C)
278#define CR232 CTL_REG(0x03A0)
279#define CR233 CTL_REG(0x03A4)
280#define CR234 CTL_REG(0x03A8)
281#define CR235 CTL_REG(0x03AC)
282#define CR236 CTL_REG(0x03B0)
283
284#define CR240 CTL_REG(0x03C0)
285/* bit 7: host-controlled RF register writes
286 * CR241-CR245: for hardware controlled writing of RF bits, not needed for
287 * USB
288 */
289#define CR241 CTL_REG(0x03C4)
290#define CR242 CTL_REG(0x03C8)
291#define CR243 CTL_REG(0x03CC)
292#define CR244 CTL_REG(0x03D0)
293#define CR245 CTL_REG(0x03D4)
294
295#define CR251 CTL_REG(0x03EC) /* only used for activation and deactivation of
296 * Airoha RFs AL2230 and AL7230B
297 */
298#define CR252 CTL_REG(0x03F0)
299#define CR253 CTL_REG(0x03F4)
300#define CR254 CTL_REG(0x03F8)
301#define CR255 CTL_REG(0x03FC)
302
303#define CR_MAX_PHY_REG 255
304
305/* Taken from the ZYDAS driver, not all of them are relevant for the ZSD1211
306 * driver.
307 */
308
309#define CR_RF_IF_CLK CTL_REG(0x0400)
310#define CR_RF_IF_DATA CTL_REG(0x0404)
311#define CR_PE1_PE2 CTL_REG(0x0408)
312#define CR_PE2_DLY CTL_REG(0x040C)
313#define CR_LE1 CTL_REG(0x0410)
314#define CR_LE2 CTL_REG(0x0414)
315/* Seems to enable/disable GPI (General Purpose IO?) */
316#define CR_GPI_EN CTL_REG(0x0418)
317#define CR_RADIO_PD CTL_REG(0x042C)
318#define CR_RF2948_PD CTL_REG(0x042C)
319#define CR_ENABLE_PS_MANUAL_AGC CTL_REG(0x043C)
320#define CR_CONFIG_PHILIPS CTL_REG(0x0440)
321#define CR_SA2400_SER_AP CTL_REG(0x0444)
322#define CR_I2C_WRITE CTL_REG(0x0444)
323#define CR_SA2400_SER_RP CTL_REG(0x0448)
324#define CR_RADIO_PE CTL_REG(0x0458)
325#define CR_RST_BUS_MASTER CTL_REG(0x045C)
326#define CR_RFCFG CTL_REG(0x0464)
327#define CR_HSTSCHG CTL_REG(0x046C)
328#define CR_PHY_ON CTL_REG(0x0474)
329#define CR_RX_DELAY CTL_REG(0x0478)
330#define CR_RX_PE_DELAY CTL_REG(0x047C)
331#define CR_GPIO_1 CTL_REG(0x0490)
332#define CR_GPIO_2 CTL_REG(0x0494)
333#define CR_EncryBufMux CTL_REG(0x04A8)
334#define CR_PS_CTRL CTL_REG(0x0500)
335#define CR_ADDA_PWR_DWN CTL_REG(0x0504)
336#define CR_ADDA_MBIAS_WARMTIME CTL_REG(0x0508)
337#define CR_MAC_PS_STATE CTL_REG(0x050C)
338
339#define CR_INTERRUPT CTL_REG(0x0510)
340#define INT_TX_COMPLETE 0x00000001
341#define INT_RX_COMPLETE 0x00000002
342#define INT_RETRY_FAIL 0x00000004
343#define INT_WAKEUP 0x00000008
344#define INT_DTIM_NOTIFY 0x00000020
345#define INT_CFG_NEXT_BCN 0x00000040
346#define INT_BUS_ABORT 0x00000080
347#define INT_TX_FIFO_READY 0x00000100
348#define INT_UART 0x00000200
349#define INT_TX_COMPLETE_EN 0x00010000
350#define INT_RX_COMPLETE_EN 0x00020000
351#define INT_RETRY_FAIL_EN 0x00040000
352#define INT_WAKEUP_EN 0x00080000
353#define INT_DTIM_NOTIFY_EN 0x00200000
354#define INT_CFG_NEXT_BCN_EN 0x00400000
355#define INT_BUS_ABORT_EN 0x00800000
356#define INT_TX_FIFO_READY_EN 0x01000000
357#define INT_UART_EN 0x02000000
358
359#define CR_TSF_LOW_PART CTL_REG(0x0514)
360#define CR_TSF_HIGH_PART CTL_REG(0x0518)
361
362/* Following three values are in time units (1024us)
363 * Following condition must be met:
364 * atim < tbtt < bcn
365 */
366#define CR_ATIM_WND_PERIOD CTL_REG(0x051C)
367#define CR_BCN_INTERVAL CTL_REG(0x0520)
368#define CR_PRE_TBTT CTL_REG(0x0524)
369/* in units of TU(1024us) */
370
371/* for UART support */
372#define CR_UART_RBR_THR_DLL CTL_REG(0x0540)
373#define CR_UART_DLM_IER CTL_REG(0x0544)
374#define CR_UART_IIR_FCR CTL_REG(0x0548)
375#define CR_UART_LCR CTL_REG(0x054c)
376#define CR_UART_MCR CTL_REG(0x0550)
377#define CR_UART_LSR CTL_REG(0x0554)
378#define CR_UART_MSR CTL_REG(0x0558)
379#define CR_UART_ECR CTL_REG(0x055c)
380#define CR_UART_STATUS CTL_REG(0x0560)
381
382#define CR_PCI_TX_ADDR_P1 CTL_REG(0x0600)
383#define CR_PCI_TX_AddR_P2 CTL_REG(0x0604)
384#define CR_PCI_RX_AddR_P1 CTL_REG(0x0608)
385#define CR_PCI_RX_AddR_P2 CTL_REG(0x060C)
386
387/* must be overwritten if custom MAC address will be used */
388#define CR_MAC_ADDR_P1 CTL_REG(0x0610)
389#define CR_MAC_ADDR_P2 CTL_REG(0x0614)
390#define CR_BSSID_P1 CTL_REG(0x0618)
391#define CR_BSSID_P2 CTL_REG(0x061C)
392#define CR_BCN_PLCP_CFG CTL_REG(0x0620)
393#define CR_GROUP_HASH_P1 CTL_REG(0x0624)
394#define CR_GROUP_HASH_P2 CTL_REG(0x0628)
395#define CR_RX_TIMEOUT CTL_REG(0x062C)
396
397/* Basic rates supported by the BSS. When producing ACK or CTS messages, the
398 * device will use a rate in this table that is less than or equal to the rate
399 * of the incoming frame which prompted the response */
400#define CR_BASIC_RATE_TBL CTL_REG(0x0630)
401#define CR_RATE_1M 0x0001 /* 802.11b */
402#define CR_RATE_2M 0x0002 /* 802.11b */
403#define CR_RATE_5_5M 0x0004 /* 802.11b */
404#define CR_RATE_11M 0x0008 /* 802.11b */
405#define CR_RATE_6M 0x0100 /* 802.11g */
406#define CR_RATE_9M 0x0200 /* 802.11g */
407#define CR_RATE_12M 0x0400 /* 802.11g */
408#define CR_RATE_18M 0x0800 /* 802.11g */
409#define CR_RATE_24M 0x1000 /* 802.11g */
410#define CR_RATE_36M 0x2000 /* 802.11g */
411#define CR_RATE_48M 0x4000 /* 802.11g */
412#define CR_RATE_54M 0x8000 /* 802.11g */
413#define CR_RATES_80211G 0xff00
414#define CR_RATES_80211B 0x000f
415
416/* Mandatory rates required in the BSS. When producing ACK or CTS messages, if
417 * the device could not find an appropriate rate in CR_BASIC_RATE_TBL, it will
418 * look for a rate in this table that is less than or equal to the rate of
419 * the incoming frame. */
420#define CR_MANDATORY_RATE_TBL CTL_REG(0x0634)
421#define CR_RTS_CTS_RATE CTL_REG(0x0638)
422
423#define CR_WEP_PROTECT CTL_REG(0x063C)
424#define CR_RX_THRESHOLD CTL_REG(0x0640)
425
426/* register for controlling the LEDS */
427#define CR_LED CTL_REG(0x0644)
428/* masks for controlling LEDs */
429#define LED1 0x0100
430#define LED2 0x0200
431
432/* Seems to indicate that the configuration is over.
433 */
434#define CR_AFTER_PNP CTL_REG(0x0648)
435#define CR_ACK_TIME_80211 CTL_REG(0x0658)
436
437#define CR_RX_OFFSET CTL_REG(0x065c)
438
439#define CR_PHY_DELAY CTL_REG(0x066C)
440#define CR_BCN_FIFO CTL_REG(0x0670)
441#define CR_SNIFFER_ON CTL_REG(0x0674)
442
443#define CR_ENCRYPTION_TYPE CTL_REG(0x0678)
444#define NO_WEP 0
445#define WEP64 1
446#define WEP128 5
447#define WEP256 6
448#define ENC_SNIFFER 8
449
450#define CR_ZD1211_RETRY_MAX CTL_REG(0x067C)
451
452#define CR_REG1 CTL_REG(0x0680)
453/* Setting the bit UNLOCK_PHY_REGS disallows the write access to physical
454 * registers, so one could argue it is a LOCK bit. But calling it
455 * LOCK_PHY_REGS makes it confusing.
456 */
457#define UNLOCK_PHY_REGS 0x0080
458
459#define CR_DEVICE_STATE CTL_REG(0x0684)
460#define CR_UNDERRUN_CNT CTL_REG(0x0688)
461
462#define CR_RX_FILTER CTL_REG(0x068c)
463#define RX_FILTER_ASSOC_RESPONSE 0x0002
464#define RX_FILTER_PROBE_RESPONSE 0x0020
465#define RX_FILTER_BEACON 0x0100
466#define RX_FILTER_AUTH 0x0800
467/* Sniff modus sets filter to 0xfffff */
468
469#define CR_ACK_TIMEOUT_EXT CTL_REG(0x0690)
470#define CR_BCN_FIFO_SEMAPHORE CTL_REG(0x0694)
471#define CR_IFS_VALUE CTL_REG(0x0698)
472#define CR_RX_TIME_OUT CTL_REG(0x069C)
473#define CR_TOTAL_RX_FRM CTL_REG(0x06A0)
474#define CR_CRC32_CNT CTL_REG(0x06A4)
475#define CR_CRC16_CNT CTL_REG(0x06A8)
476#define CR_DECRYPTION_ERR_UNI CTL_REG(0x06AC)
477#define CR_RX_FIFO_OVERRUN CTL_REG(0x06B0)
478
479#define CR_DECRYPTION_ERR_MUL CTL_REG(0x06BC)
480
481#define CR_NAV_CNT CTL_REG(0x06C4)
482#define CR_NAV_CCA CTL_REG(0x06C8)
483#define CR_RETRY_CNT CTL_REG(0x06CC)
484
485#define CR_READ_TCB_ADDR CTL_REG(0x06E8)
486#define CR_READ_RFD_ADDR CTL_REG(0x06EC)
487#define CR_CWMIN_CWMAX CTL_REG(0x06F0)
488#define CR_TOTAL_TX_FRM CTL_REG(0x06F4)
489
490/* CAM: Continuous Access Mode (power management) */
491#define CR_CAM_MODE CTL_REG(0x0700)
492#define CR_CAM_ROLL_TB_LOW CTL_REG(0x0704)
493#define CR_CAM_ROLL_TB_HIGH CTL_REG(0x0708)
494#define CR_CAM_ADDRESS CTL_REG(0x070C)
495#define CR_CAM_DATA CTL_REG(0x0710)
496
497#define CR_ROMDIR CTL_REG(0x0714)
498
499#define CR_DECRY_ERR_FLG_LOW CTL_REG(0x0714)
500#define CR_DECRY_ERR_FLG_HIGH CTL_REG(0x0718)
501
502#define CR_WEPKEY0 CTL_REG(0x0720)
503#define CR_WEPKEY1 CTL_REG(0x0724)
504#define CR_WEPKEY2 CTL_REG(0x0728)
505#define CR_WEPKEY3 CTL_REG(0x072C)
506#define CR_WEPKEY4 CTL_REG(0x0730)
507#define CR_WEPKEY5 CTL_REG(0x0734)
508#define CR_WEPKEY6 CTL_REG(0x0738)
509#define CR_WEPKEY7 CTL_REG(0x073C)
510#define CR_WEPKEY8 CTL_REG(0x0740)
511#define CR_WEPKEY9 CTL_REG(0x0744)
512#define CR_WEPKEY10 CTL_REG(0x0748)
513#define CR_WEPKEY11 CTL_REG(0x074C)
514#define CR_WEPKEY12 CTL_REG(0x0750)
515#define CR_WEPKEY13 CTL_REG(0x0754)
516#define CR_WEPKEY14 CTL_REG(0x0758)
517#define CR_WEPKEY15 CTL_REG(0x075c)
518#define CR_TKIP_MODE CTL_REG(0x0760)
519
520#define CR_EEPROM_PROTECT0 CTL_REG(0x0758)
521#define CR_EEPROM_PROTECT1 CTL_REG(0x075C)
522
523#define CR_DBG_FIFO_RD CTL_REG(0x0800)
524#define CR_DBG_SELECT CTL_REG(0x0804)
525#define CR_FIFO_Length CTL_REG(0x0808)
526
527
528#define CR_RSSI_MGC CTL_REG(0x0810)
529
530#define CR_PON CTL_REG(0x0818)
531#define CR_RX_ON CTL_REG(0x081C)
532#define CR_TX_ON CTL_REG(0x0820)
533#define CR_CHIP_EN CTL_REG(0x0824)
534#define CR_LO_SW CTL_REG(0x0828)
535#define CR_TXRX_SW CTL_REG(0x082C)
536#define CR_S_MD CTL_REG(0x0830)
537
538#define CR_USB_DEBUG_PORT CTL_REG(0x0888)
539
540#define CR_ZD1211B_TX_PWR_CTL1 CTL_REG(0x0b00)
541#define CR_ZD1211B_TX_PWR_CTL2 CTL_REG(0x0b04)
542#define CR_ZD1211B_TX_PWR_CTL3 CTL_REG(0x0b08)
543#define CR_ZD1211B_TX_PWR_CTL4 CTL_REG(0x0b0c)
544#define CR_ZD1211B_AIFS_CTL1 CTL_REG(0x0b10)
545#define CR_ZD1211B_AIFS_CTL2 CTL_REG(0x0b14)
546#define CR_ZD1211B_TXOP CTL_REG(0x0b20)
547#define CR_ZD1211B_RETRY_MAX CTL_REG(0x0b28)
548
549#define AP_RX_FILTER 0x0400feff
550#define STA_RX_FILTER 0x0000ffff
551
552#define CWIN_SIZE 0x007f043f
553
554
555#define HWINT_ENABLED 0x004f0000
556#define HWINT_DISABLED 0
557
558#define E2P_PWR_INT_GUARD 8
559#define E2P_CHANNEL_COUNT 14
560
561/* If you compare this addresses with the ZYDAS orignal driver, please notify
562 * that we use word mapping for the EEPROM.
563 */
564
565/*
566 * Upper 16 bit contains the regulatory domain.
567 */
568#define E2P_SUBID E2P_REG(0x00)
569#define E2P_POD E2P_REG(0x02)
570#define E2P_MAC_ADDR_P1 E2P_REG(0x04)
571#define E2P_MAC_ADDR_P2 E2P_REG(0x06)
572#define E2P_PWR_CAL_VALUE1 E2P_REG(0x08)
573#define E2P_PWR_CAL_VALUE2 E2P_REG(0x0a)
574#define E2P_PWR_CAL_VALUE3 E2P_REG(0x0c)
575#define E2P_PWR_CAL_VALUE4 E2P_REG(0x0e)
576#define E2P_PWR_INT_VALUE1 E2P_REG(0x10)
577#define E2P_PWR_INT_VALUE2 E2P_REG(0x12)
578#define E2P_PWR_INT_VALUE3 E2P_REG(0x14)
579#define E2P_PWR_INT_VALUE4 E2P_REG(0x16)
580
581/* Contains a bit for each allowed channel. It gives for Europe (ETSI 0x30)
582 * also only 11 channels. */
583#define E2P_ALLOWED_CHANNEL E2P_REG(0x18)
584
585#define E2P_PHY_REG E2P_REG(0x1a)
586#define E2P_DEVICE_VER E2P_REG(0x20)
587#define E2P_36M_CAL_VALUE1 E2P_REG(0x28)
588#define E2P_36M_CAL_VALUE2 E2P_REG(0x2a)
589#define E2P_36M_CAL_VALUE3 E2P_REG(0x2c)
590#define E2P_36M_CAL_VALUE4 E2P_REG(0x2e)
591#define E2P_11A_INT_VALUE1 E2P_REG(0x30)
592#define E2P_11A_INT_VALUE2 E2P_REG(0x32)
593#define E2P_11A_INT_VALUE3 E2P_REG(0x34)
594#define E2P_11A_INT_VALUE4 E2P_REG(0x36)
595#define E2P_48M_CAL_VALUE1 E2P_REG(0x38)
596#define E2P_48M_CAL_VALUE2 E2P_REG(0x3a)
597#define E2P_48M_CAL_VALUE3 E2P_REG(0x3c)
598#define E2P_48M_CAL_VALUE4 E2P_REG(0x3e)
599#define E2P_48M_INT_VALUE1 E2P_REG(0x40)
600#define E2P_48M_INT_VALUE2 E2P_REG(0x42)
601#define E2P_48M_INT_VALUE3 E2P_REG(0x44)
602#define E2P_48M_INT_VALUE4 E2P_REG(0x46)
603#define E2P_54M_CAL_VALUE1 E2P_REG(0x48) /* ??? */
604#define E2P_54M_CAL_VALUE2 E2P_REG(0x4a)
605#define E2P_54M_CAL_VALUE3 E2P_REG(0x4c)
606#define E2P_54M_CAL_VALUE4 E2P_REG(0x4e)
607#define E2P_54M_INT_VALUE1 E2P_REG(0x50)
608#define E2P_54M_INT_VALUE2 E2P_REG(0x52)
609#define E2P_54M_INT_VALUE3 E2P_REG(0x54)
610#define E2P_54M_INT_VALUE4 E2P_REG(0x56)
611
612/* All 16 bit values */
613#define FW_FIRMWARE_VER FW_REG(0)
614/* non-zero if USB high speed connection */
615#define FW_USB_SPEED FW_REG(1)
616#define FW_FIX_TX_RATE FW_REG(2)
617/* Seems to be able to control LEDs over the firmware */
618#define FW_LINK_STATUS FW_REG(3)
619#define FW_SOFT_RESET FW_REG(4)
620#define FW_FLASH_CHK FW_REG(5)
621
622enum {
623 CR_BASE_OFFSET = 0x9000,
624 FW_START_OFFSET = 0xee00,
625 FW_BASE_ADDR_OFFSET = FW_START_OFFSET + 0x1d,
626 EEPROM_START_OFFSET = 0xf800,
627 EEPROM_SIZE = 0x800, /* words */
628 LOAD_CODE_SIZE = 0xe, /* words */
629 LOAD_VECT_SIZE = 0x10000 - 0xfff7, /* words */
630 EEPROM_REGS_OFFSET = LOAD_CODE_SIZE + LOAD_VECT_SIZE,
631 E2P_BASE_OFFSET = EEPROM_START_OFFSET +
632 EEPROM_REGS_OFFSET,
633};
634
635#define FW_REG_TABLE_ADDR USB_ADDR(FW_START_OFFSET + 0x1d)
636
637enum {
638 /* indices for ofdm_cal_values */
639 OFDM_36M_INDEX = 0,
640 OFDM_48M_INDEX = 1,
641 OFDM_54M_INDEX = 2,
642};
643
644struct zd_chip {
645 struct zd_usb usb;
646 struct zd_rf rf;
647 struct mutex mutex;
648 u8 e2p_mac[ETH_ALEN];
649 /* EepSetPoint in the vendor driver */
650 u8 pwr_cal_values[E2P_CHANNEL_COUNT];
651 /* integration values in the vendor driver */
652 u8 pwr_int_values[E2P_CHANNEL_COUNT];
653 /* SetPointOFDM in the vendor driver */
654 u8 ofdm_cal_values[3][E2P_CHANNEL_COUNT];
655 u8 pa_type:4, patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
656 is_zd1211b:1;
657};
658
659static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb)
660{
661 return container_of(usb, struct zd_chip, usb);
662}
663
664static inline struct zd_chip *zd_rf_to_chip(struct zd_rf *rf)
665{
666 return container_of(rf, struct zd_chip, rf);
667}
668
669#define zd_chip_dev(chip) (&(chip)->usb.intf->dev)
670
671void zd_chip_init(struct zd_chip *chip,
672 struct net_device *netdev,
673 struct usb_interface *intf);
674void zd_chip_clear(struct zd_chip *chip);
675int zd_chip_init_hw(struct zd_chip *chip, u8 device_type);
676int zd_chip_reset(struct zd_chip *chip);
677
678static inline int zd_ioread16v_locked(struct zd_chip *chip, u16 *values,
679 const zd_addr_t *addresses,
680 unsigned int count)
681{
682 ZD_ASSERT(mutex_is_locked(&chip->mutex));
683 return zd_usb_ioread16v(&chip->usb, values, addresses, count);
684}
685
686static inline int zd_ioread16_locked(struct zd_chip *chip, u16 *value,
687 const zd_addr_t addr)
688{
689 ZD_ASSERT(mutex_is_locked(&chip->mutex));
690 return zd_usb_ioread16(&chip->usb, value, addr);
691}
692
693int zd_ioread32v_locked(struct zd_chip *chip, u32 *values,
694 const zd_addr_t *addresses, unsigned int count);
695
696static inline int zd_ioread32_locked(struct zd_chip *chip, u32 *value,
697 const zd_addr_t addr)
698{
699 return zd_ioread32v_locked(chip, value, (const zd_addr_t *)&addr, 1);
700}
701
702static inline int zd_iowrite16_locked(struct zd_chip *chip, u16 value,
703 zd_addr_t addr)
704{
705 struct zd_ioreq16 ioreq;
706
707 ZD_ASSERT(mutex_is_locked(&chip->mutex));
708 ioreq.addr = addr;
709 ioreq.value = value;
710
711 return zd_usb_iowrite16v(&chip->usb, &ioreq, 1);
712}
713
714int zd_iowrite16a_locked(struct zd_chip *chip,
715 const struct zd_ioreq16 *ioreqs, unsigned int count);
716
717int _zd_iowrite32v_locked(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
718 unsigned int count);
719
720static inline int zd_iowrite32_locked(struct zd_chip *chip, u32 value,
721 zd_addr_t addr)
722{
723 struct zd_ioreq32 ioreq;
724
725 ioreq.addr = addr;
726 ioreq.value = value;
727
728 return _zd_iowrite32v_locked(chip, &ioreq, 1);
729}
730
731int zd_iowrite32a_locked(struct zd_chip *chip,
732 const struct zd_ioreq32 *ioreqs, unsigned int count);
733
734static inline int zd_rfwrite_locked(struct zd_chip *chip, u32 value, u8 bits)
735{
736 ZD_ASSERT(mutex_is_locked(&chip->mutex));
737 return zd_usb_rfwrite(&chip->usb, value, bits);
738}
739
740int zd_rfwritev_locked(struct zd_chip *chip,
741 const u32* values, unsigned int count, u8 bits);
742
743/* Locking functions for reading and writing registers.
744 * The different parameters are intentional.
745 */
746int zd_ioread16(struct zd_chip *chip, zd_addr_t addr, u16 *value);
747int zd_iowrite16(struct zd_chip *chip, zd_addr_t addr, u16 value);
748int zd_ioread32(struct zd_chip *chip, zd_addr_t addr, u32 *value);
749int zd_iowrite32(struct zd_chip *chip, zd_addr_t addr, u32 value);
750int zd_ioread32v(struct zd_chip *chip, const zd_addr_t *addresses,
751 u32 *values, unsigned int count);
752int zd_iowrite32a(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
753 unsigned int count);
754
755int zd_chip_set_channel(struct zd_chip *chip, u8 channel);
756static inline u8 _zd_chip_get_channel(struct zd_chip *chip)
757{
758 return chip->rf.channel;
759}
760u8 zd_chip_get_channel(struct zd_chip *chip);
761int zd_read_regdomain(struct zd_chip *chip, u8 *regdomain);
762void zd_get_e2p_mac_addr(struct zd_chip *chip, u8 *mac_addr);
763int zd_read_mac_addr(struct zd_chip *chip, u8 *mac_addr);
764int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr);
765int zd_chip_switch_radio_on(struct zd_chip *chip);
766int zd_chip_switch_radio_off(struct zd_chip *chip);
767int zd_chip_enable_int(struct zd_chip *chip);
768void zd_chip_disable_int(struct zd_chip *chip);
769int zd_chip_enable_rx(struct zd_chip *chip);
770void zd_chip_disable_rx(struct zd_chip *chip);
771int zd_chip_enable_hwint(struct zd_chip *chip);
772int zd_chip_disable_hwint(struct zd_chip *chip);
773
774static inline int zd_get_encryption_type(struct zd_chip *chip, u32 *type)
775{
776 return zd_ioread32(chip, CR_ENCRYPTION_TYPE, type);
777}
778
779static inline int zd_set_encryption_type(struct zd_chip *chip, u32 type)
780{
781 return zd_iowrite32(chip, CR_ENCRYPTION_TYPE, type);
782}
783
784static inline int zd_chip_get_basic_rates(struct zd_chip *chip, u16 *cr_rates)
785{
786 return zd_ioread16(chip, CR_BASIC_RATE_TBL, cr_rates);
787}
788
789int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates);
790
791static inline int zd_chip_set_rx_filter(struct zd_chip *chip, u32 filter)
792{
793 return zd_iowrite32(chip, CR_RX_FILTER, filter);
794}
795
796int zd_chip_lock_phy_regs(struct zd_chip *chip);
797int zd_chip_unlock_phy_regs(struct zd_chip *chip);
798
799enum led_status {
800 LED_OFF = 0,
801 LED_ON = 1,
802 LED_FLIP = 2,
803 LED_STATUS = 3,
804};
805
806int zd_chip_led_status(struct zd_chip *chip, int led, enum led_status status);
807int zd_chip_led_flip(struct zd_chip *chip, int led,
808 const unsigned int *phases_msecs, unsigned int count);
809
810int zd_set_beacon_interval(struct zd_chip *chip, u32 interval);
811
812static inline int zd_get_beacon_interval(struct zd_chip *chip, u32 *interval)
813{
814 return zd_ioread32(chip, CR_BCN_INTERVAL, interval);
815}
816
817struct rx_status;
818
819u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size,
820 const struct rx_status *status);
821u8 zd_rx_strength_percent(u8 rssi);
822
823u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status);
824
825#endif /* _ZD_CHIP_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_def.h b/drivers/net/wireless/zd1211rw/zd_def.h
new file mode 100644
index 000000000000..465906812fc4
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_def.h
@@ -0,0 +1,48 @@
1/* zd_def.h
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#ifndef _ZD_DEF_H
19#define _ZD_DEF_H
20
21#include <linux/kernel.h>
22#include <linux/stringify.h>
23#include <linux/device.h>
24#include <linux/kernel.h>
25
26#define dev_printk_f(level, dev, fmt, args...) \
27 dev_printk(level, dev, "%s() " fmt, __func__, ##args)
28
29#ifdef DEBUG
30# define dev_dbg_f(dev, fmt, args...) \
31 dev_printk_f(KERN_DEBUG, dev, fmt, ## args)
32#else
33# define dev_dbg_f(dev, fmt, args...) do { (void)(dev); } while (0)
34#endif /* DEBUG */
35
36#ifdef DEBUG
37# define ZD_ASSERT(x) \
38do { \
39 if (!(x)) { \
40 pr_debug("%s:%d ASSERT %s VIOLATED!\n", \
41 __FILE__, __LINE__, __stringify(x)); \
42 } \
43} while (0)
44#else
45# define ZD_ASSERT(x) do { } while (0)
46#endif
47
48#endif /* _ZD_DEF_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.c b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
new file mode 100644
index 000000000000..66905f7b61ff
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.c
@@ -0,0 +1,191 @@
1/* zd_ieee80211.c
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18/*
19 * A lot of this code is generic and should be moved into the upper layers
20 * at some point.
21 */
22
23#include <linux/errno.h>
24#include <linux/wireless.h>
25#include <linux/kernel.h>
26#include <net/ieee80211.h>
27
28#include "zd_def.h"
29#include "zd_ieee80211.h"
30#include "zd_mac.h"
31
32static const struct channel_range channel_ranges[] = {
33 [0] = { 0, 0},
34 [ZD_REGDOMAIN_FCC] = { 1, 12},
35 [ZD_REGDOMAIN_IC] = { 1, 12},
36 [ZD_REGDOMAIN_ETSI] = { 1, 14},
37 [ZD_REGDOMAIN_JAPAN] = { 1, 14},
38 [ZD_REGDOMAIN_SPAIN] = { 1, 14},
39 [ZD_REGDOMAIN_FRANCE] = { 1, 14},
40 [ZD_REGDOMAIN_JAPAN_ADD] = {14, 15},
41};
42
43const struct channel_range *zd_channel_range(u8 regdomain)
44{
45 if (regdomain >= ARRAY_SIZE(channel_ranges))
46 regdomain = 0;
47 return &channel_ranges[regdomain];
48}
49
50int zd_regdomain_supports_channel(u8 regdomain, u8 channel)
51{
52 const struct channel_range *range = zd_channel_range(regdomain);
53 return range->start <= channel && channel < range->end;
54}
55
56int zd_regdomain_supported(u8 regdomain)
57{
58 const struct channel_range *range = zd_channel_range(regdomain);
59 return range->start != 0;
60}
61
62/* Stores channel frequencies in MHz. */
63static const u16 channel_frequencies[] = {
64 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447,
65 2452, 2457, 2462, 2467, 2472, 2484,
66};
67
68#define NUM_CHANNELS ARRAY_SIZE(channel_frequencies)
69
70static int compute_freq(struct iw_freq *freq, u32 mhz, u32 hz)
71{
72 u32 factor;
73
74 freq->e = 0;
75 if (mhz >= 1000000000U) {
76 pr_debug("zd1211 mhz %u to large\n", mhz);
77 freq->m = 0;
78 return -EINVAL;
79 }
80
81 factor = 1000;
82 while (mhz >= factor) {
83
84 freq->e += 1;
85 factor *= 10;
86 }
87
88 factor /= 1000U;
89 freq->m = mhz * (1000000U/factor) + hz/factor;
90
91 return 0;
92}
93
94int zd_channel_to_freq(struct iw_freq *freq, u8 channel)
95{
96 if (channel > NUM_CHANNELS) {
97 freq->m = 0;
98 freq->e = 0;
99 return -EINVAL;
100 }
101 if (!channel) {
102 freq->m = 0;
103 freq->e = 0;
104 return -EINVAL;
105 }
106 return compute_freq(freq, channel_frequencies[channel-1], 0);
107}
108
109static int freq_to_mhz(const struct iw_freq *freq)
110{
111 u32 factor;
112 int e;
113
114 /* Such high frequencies are not supported. */
115 if (freq->e > 6)
116 return -EINVAL;
117
118 factor = 1;
119 for (e = freq->e; e > 0; --e) {
120 factor *= 10;
121 }
122 factor = 1000000U / factor;
123
124 if (freq->m % factor) {
125 return -EINVAL;
126 }
127
128 return freq->m / factor;
129}
130
131int zd_find_channel(u8 *channel, const struct iw_freq *freq)
132{
133 int i, r;
134 u32 mhz;
135
136 if (!(freq->flags & IW_FREQ_FIXED))
137 return 0;
138
139 if (freq->m < 1000) {
140 if (freq->m > NUM_CHANNELS || freq->m == 0)
141 return -EINVAL;
142 *channel = freq->m;
143 return 1;
144 }
145
146 r = freq_to_mhz(freq);
147 if (r < 0)
148 return r;
149 mhz = r;
150
151 for (i = 0; i < NUM_CHANNELS; i++) {
152 if (mhz == channel_frequencies[i]) {
153 *channel = i+1;
154 return 1;
155 }
156 }
157
158 return -EINVAL;
159}
160
161int zd_geo_init(struct ieee80211_device *ieee, u8 regdomain)
162{
163 struct ieee80211_geo geo;
164 const struct channel_range *range;
165 int i;
166 u8 channel;
167
168 dev_dbg(zd_mac_dev(zd_netdev_mac(ieee->dev)),
169 "regdomain %#04x\n", regdomain);
170
171 range = zd_channel_range(regdomain);
172 if (range->start == 0) {
173 dev_err(zd_mac_dev(zd_netdev_mac(ieee->dev)),
174 "zd1211 regdomain %#04x not supported\n",
175 regdomain);
176 return -EINVAL;
177 }
178
179 memset(&geo, 0, sizeof(geo));
180
181 for (i = 0, channel = range->start; channel < range->end; channel++) {
182 struct ieee80211_channel *chan = &geo.bg[i++];
183 chan->freq = channel_frequencies[channel - 1];
184 chan->channel = channel;
185 }
186
187 geo.bg_channels = i;
188 memcpy(geo.name, "XX ", 4);
189 ieee80211_set_geo(ieee, &geo);
190 return 0;
191}
diff --git a/drivers/net/wireless/zd1211rw/zd_ieee80211.h b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
new file mode 100644
index 000000000000..36329890dfec
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_ieee80211.h
@@ -0,0 +1,85 @@
1#ifndef _ZD_IEEE80211_H
2#define _ZD_IEEE80211_H
3
4#include <net/ieee80211.h>
5#include "zd_types.h"
6
7/* Additional definitions from the standards.
8 */
9
10#define ZD_REGDOMAIN_FCC 0x10
11#define ZD_REGDOMAIN_IC 0x20
12#define ZD_REGDOMAIN_ETSI 0x30
13#define ZD_REGDOMAIN_SPAIN 0x31
14#define ZD_REGDOMAIN_FRANCE 0x32
15#define ZD_REGDOMAIN_JAPAN_ADD 0x40
16#define ZD_REGDOMAIN_JAPAN 0x41
17
18enum {
19 MIN_CHANNEL24 = 1,
20 MAX_CHANNEL24 = 14,
21};
22
23struct channel_range {
24 u8 start;
25 u8 end; /* exclusive (channel must be less than end) */
26};
27
28struct iw_freq;
29
30int zd_geo_init(struct ieee80211_device *ieee, u8 regdomain);
31
32const struct channel_range *zd_channel_range(u8 regdomain);
33int zd_regdomain_supports_channel(u8 regdomain, u8 channel);
34int zd_regdomain_supported(u8 regdomain);
35
36/* for 2.4 GHz band */
37int zd_channel_to_freq(struct iw_freq *freq, u8 channel);
38int zd_find_channel(u8 *channel, const struct iw_freq *freq);
39
40#define ZD_PLCP_SERVICE_LENGTH_EXTENSION 0x80
41
42struct ofdm_plcp_header {
43 u8 prefix[3];
44 __le16 service;
45} __attribute__((packed));
46
47static inline u8 zd_ofdm_plcp_header_rate(
48 const struct ofdm_plcp_header *header)
49{
50 return header->prefix[0] & 0xf;
51}
52
53#define ZD_OFDM_RATE_6M 0xb
54#define ZD_OFDM_RATE_9M 0xf
55#define ZD_OFDM_RATE_12M 0xa
56#define ZD_OFDM_RATE_18M 0xe
57#define ZD_OFDM_RATE_24M 0x9
58#define ZD_OFDM_RATE_36M 0xd
59#define ZD_OFDM_RATE_48M 0x8
60#define ZD_OFDM_RATE_54M 0xc
61
62struct cck_plcp_header {
63 u8 signal;
64 u8 service;
65 __le16 length;
66 __le16 crc16;
67} __attribute__((packed));
68
69static inline u8 zd_cck_plcp_header_rate(const struct cck_plcp_header *header)
70{
71 return header->signal;
72}
73
74#define ZD_CCK_SIGNAL_1M 0x0a
75#define ZD_CCK_SIGNAL_2M 0x14
76#define ZD_CCK_SIGNAL_5M5 0x37
77#define ZD_CCK_SIGNAL_11M 0x6e
78
79enum ieee80211_std {
80 IEEE80211B = 0x01,
81 IEEE80211A = 0x02,
82 IEEE80211G = 0x04,
83};
84
85#endif /* _ZD_IEEE80211_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
new file mode 100644
index 000000000000..3bdc54d128d0
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -0,0 +1,1057 @@
1/* zd_mac.c
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#include <linux/netdevice.h>
19#include <linux/etherdevice.h>
20#include <linux/wireless.h>
21#include <linux/usb.h>
22#include <linux/jiffies.h>
23#include <net/ieee80211_radiotap.h>
24
25#include "zd_def.h"
26#include "zd_chip.h"
27#include "zd_mac.h"
28#include "zd_ieee80211.h"
29#include "zd_netdev.h"
30#include "zd_rf.h"
31#include "zd_util.h"
32
33static void ieee_init(struct ieee80211_device *ieee);
34static void softmac_init(struct ieee80211softmac_device *sm);
35
36int zd_mac_init(struct zd_mac *mac,
37 struct net_device *netdev,
38 struct usb_interface *intf)
39{
40 struct ieee80211_device *ieee = zd_netdev_ieee80211(netdev);
41
42 memset(mac, 0, sizeof(*mac));
43 spin_lock_init(&mac->lock);
44 mac->netdev = netdev;
45
46 ieee_init(ieee);
47 softmac_init(ieee80211_priv(netdev));
48 zd_chip_init(&mac->chip, netdev, intf);
49 return 0;
50}
51
52static int reset_channel(struct zd_mac *mac)
53{
54 int r;
55 unsigned long flags;
56 const struct channel_range *range;
57
58 spin_lock_irqsave(&mac->lock, flags);
59 range = zd_channel_range(mac->regdomain);
60 if (!range->start) {
61 r = -EINVAL;
62 goto out;
63 }
64 mac->requested_channel = range->start;
65 r = 0;
66out:
67 spin_unlock_irqrestore(&mac->lock, flags);
68 return r;
69}
70
71int zd_mac_init_hw(struct zd_mac *mac, u8 device_type)
72{
73 int r;
74 struct zd_chip *chip = &mac->chip;
75 u8 addr[ETH_ALEN];
76 u8 default_regdomain;
77
78 r = zd_chip_enable_int(chip);
79 if (r)
80 goto out;
81 r = zd_chip_init_hw(chip, device_type);
82 if (r)
83 goto disable_int;
84
85 zd_get_e2p_mac_addr(chip, addr);
86 r = zd_write_mac_addr(chip, addr);
87 if (r)
88 goto disable_int;
89 ZD_ASSERT(!irqs_disabled());
90 spin_lock_irq(&mac->lock);
91 memcpy(mac->netdev->dev_addr, addr, ETH_ALEN);
92 spin_unlock_irq(&mac->lock);
93
94 r = zd_read_regdomain(chip, &default_regdomain);
95 if (r)
96 goto disable_int;
97 if (!zd_regdomain_supported(default_regdomain)) {
98 dev_dbg_f(zd_mac_dev(mac),
99 "Regulatory Domain %#04x is not supported.\n",
100 default_regdomain);
101 r = -EINVAL;
102 goto disable_int;
103 }
104 spin_lock_irq(&mac->lock);
105 mac->regdomain = mac->default_regdomain = default_regdomain;
106 spin_unlock_irq(&mac->lock);
107 r = reset_channel(mac);
108 if (r)
109 goto disable_int;
110
111 r = zd_set_encryption_type(chip, NO_WEP);
112 if (r)
113 goto disable_int;
114
115 r = zd_geo_init(zd_mac_to_ieee80211(mac), mac->regdomain);
116 if (r)
117 goto disable_int;
118
119 r = 0;
120disable_int:
121 zd_chip_disable_int(chip);
122out:
123 return r;
124}
125
126void zd_mac_clear(struct zd_mac *mac)
127{
128 /* Aquire the lock. */
129 spin_lock(&mac->lock);
130 spin_unlock(&mac->lock);
131 zd_chip_clear(&mac->chip);
132 memset(mac, 0, sizeof(*mac));
133}
134
135static int reset_mode(struct zd_mac *mac)
136{
137 struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac);
138 struct zd_ioreq32 ioreqs[3] = {
139 { CR_RX_FILTER, RX_FILTER_BEACON|RX_FILTER_PROBE_RESPONSE|
140 RX_FILTER_AUTH|RX_FILTER_ASSOC_RESPONSE },
141 { CR_SNIFFER_ON, 0U },
142 { CR_ENCRYPTION_TYPE, NO_WEP },
143 };
144
145 if (ieee->iw_mode == IW_MODE_MONITOR) {
146 ioreqs[0].value = 0xffffffff;
147 ioreqs[1].value = 0x1;
148 ioreqs[2].value = ENC_SNIFFER;
149 }
150
151 return zd_iowrite32a(&mac->chip, ioreqs, 3);
152}
153
154int zd_mac_open(struct net_device *netdev)
155{
156 struct zd_mac *mac = zd_netdev_mac(netdev);
157 struct zd_chip *chip = &mac->chip;
158 int r;
159
160 r = zd_chip_enable_int(chip);
161 if (r < 0)
162 goto out;
163
164 r = zd_chip_set_basic_rates(chip, CR_RATES_80211B | CR_RATES_80211G);
165 if (r < 0)
166 goto disable_int;
167 r = reset_mode(mac);
168 if (r)
169 goto disable_int;
170 r = zd_chip_switch_radio_on(chip);
171 if (r < 0)
172 goto disable_int;
173 r = zd_chip_set_channel(chip, mac->requested_channel);
174 if (r < 0)
175 goto disable_radio;
176 r = zd_chip_enable_rx(chip);
177 if (r < 0)
178 goto disable_radio;
179 r = zd_chip_enable_hwint(chip);
180 if (r < 0)
181 goto disable_rx;
182
183 ieee80211softmac_start(netdev);
184 return 0;
185disable_rx:
186 zd_chip_disable_rx(chip);
187disable_radio:
188 zd_chip_switch_radio_off(chip);
189disable_int:
190 zd_chip_disable_int(chip);
191out:
192 return r;
193}
194
195int zd_mac_stop(struct net_device *netdev)
196{
197 struct zd_mac *mac = zd_netdev_mac(netdev);
198 struct zd_chip *chip = &mac->chip;
199
200 netif_stop_queue(netdev);
201
202 /*
203 * The order here deliberately is a little different from the open()
204 * method, since we need to make sure there is no opportunity for RX
205 * frames to be processed by softmac after we have stopped it.
206 */
207
208 zd_chip_disable_rx(chip);
209 ieee80211softmac_stop(netdev);
210
211 zd_chip_disable_hwint(chip);
212 zd_chip_switch_radio_off(chip);
213 zd_chip_disable_int(chip);
214
215 return 0;
216}
217
218int zd_mac_set_mac_address(struct net_device *netdev, void *p)
219{
220 int r;
221 unsigned long flags;
222 struct sockaddr *addr = p;
223 struct zd_mac *mac = zd_netdev_mac(netdev);
224 struct zd_chip *chip = &mac->chip;
225
226 if (!is_valid_ether_addr(addr->sa_data))
227 return -EADDRNOTAVAIL;
228
229 dev_dbg_f(zd_mac_dev(mac),
230 "Setting MAC to " MAC_FMT "\n", MAC_ARG(addr->sa_data));
231
232 r = zd_write_mac_addr(chip, addr->sa_data);
233 if (r)
234 return r;
235
236 spin_lock_irqsave(&mac->lock, flags);
237 memcpy(netdev->dev_addr, addr->sa_data, ETH_ALEN);
238 spin_unlock_irqrestore(&mac->lock, flags);
239
240 return 0;
241}
242
243int zd_mac_set_regdomain(struct zd_mac *mac, u8 regdomain)
244{
245 int r;
246 u8 channel;
247
248 ZD_ASSERT(!irqs_disabled());
249 spin_lock_irq(&mac->lock);
250 if (regdomain == 0) {
251 regdomain = mac->default_regdomain;
252 }
253 if (!zd_regdomain_supported(regdomain)) {
254 spin_unlock_irq(&mac->lock);
255 return -EINVAL;
256 }
257 mac->regdomain = regdomain;
258 channel = mac->requested_channel;
259 spin_unlock_irq(&mac->lock);
260
261 r = zd_geo_init(zd_mac_to_ieee80211(mac), regdomain);
262 if (r)
263 return r;
264 if (!zd_regdomain_supports_channel(regdomain, channel)) {
265 r = reset_channel(mac);
266 if (r)
267 return r;
268 }
269
270 return 0;
271}
272
273u8 zd_mac_get_regdomain(struct zd_mac *mac)
274{
275 unsigned long flags;
276 u8 regdomain;
277
278 spin_lock_irqsave(&mac->lock, flags);
279 regdomain = mac->regdomain;
280 spin_unlock_irqrestore(&mac->lock, flags);
281 return regdomain;
282}
283
284static void set_channel(struct net_device *netdev, u8 channel)
285{
286 struct zd_mac *mac = zd_netdev_mac(netdev);
287
288 dev_dbg_f(zd_mac_dev(mac), "channel %d\n", channel);
289
290 zd_chip_set_channel(&mac->chip, channel);
291}
292
293/* TODO: Should not work in Managed mode. */
294int zd_mac_request_channel(struct zd_mac *mac, u8 channel)
295{
296 unsigned long lock_flags;
297 struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac);
298
299 if (ieee->iw_mode == IW_MODE_INFRA)
300 return -EPERM;
301
302 spin_lock_irqsave(&mac->lock, lock_flags);
303 if (!zd_regdomain_supports_channel(mac->regdomain, channel)) {
304 spin_unlock_irqrestore(&mac->lock, lock_flags);
305 return -EINVAL;
306 }
307 mac->requested_channel = channel;
308 spin_unlock_irqrestore(&mac->lock, lock_flags);
309 if (netif_running(mac->netdev))
310 return zd_chip_set_channel(&mac->chip, channel);
311 else
312 return 0;
313}
314
315int zd_mac_get_channel(struct zd_mac *mac, u8 *channel, u8 *flags)
316{
317 struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac);
318
319 *channel = zd_chip_get_channel(&mac->chip);
320 if (ieee->iw_mode != IW_MODE_INFRA) {
321 spin_lock_irq(&mac->lock);
322 *flags = *channel == mac->requested_channel ?
323 MAC_FIXED_CHANNEL : 0;
324 spin_unlock(&mac->lock);
325 } else {
326 *flags = 0;
327 }
328 dev_dbg_f(zd_mac_dev(mac), "channel %u flags %u\n", *channel, *flags);
329 return 0;
330}
331
332/* If wrong rate is given, we are falling back to the slowest rate: 1MBit/s */
333static u8 cs_typed_rate(u8 cs_rate)
334{
335 static const u8 typed_rates[16] = {
336 [ZD_CS_CCK_RATE_1M] = ZD_CS_CCK|ZD_CS_CCK_RATE_1M,
337 [ZD_CS_CCK_RATE_2M] = ZD_CS_CCK|ZD_CS_CCK_RATE_2M,
338 [ZD_CS_CCK_RATE_5_5M] = ZD_CS_CCK|ZD_CS_CCK_RATE_5_5M,
339 [ZD_CS_CCK_RATE_11M] = ZD_CS_CCK|ZD_CS_CCK_RATE_11M,
340 [ZD_OFDM_RATE_6M] = ZD_CS_OFDM|ZD_OFDM_RATE_6M,
341 [ZD_OFDM_RATE_9M] = ZD_CS_OFDM|ZD_OFDM_RATE_9M,
342 [ZD_OFDM_RATE_12M] = ZD_CS_OFDM|ZD_OFDM_RATE_12M,
343 [ZD_OFDM_RATE_18M] = ZD_CS_OFDM|ZD_OFDM_RATE_18M,
344 [ZD_OFDM_RATE_24M] = ZD_CS_OFDM|ZD_OFDM_RATE_24M,
345 [ZD_OFDM_RATE_36M] = ZD_CS_OFDM|ZD_OFDM_RATE_36M,
346 [ZD_OFDM_RATE_48M] = ZD_CS_OFDM|ZD_OFDM_RATE_48M,
347 [ZD_OFDM_RATE_54M] = ZD_CS_OFDM|ZD_OFDM_RATE_54M,
348 };
349
350 ZD_ASSERT(ZD_CS_RATE_MASK == 0x0f);
351 return typed_rates[cs_rate & ZD_CS_RATE_MASK];
352}
353
354/* Fallback to lowest rate, if rate is unknown. */
355static u8 rate_to_cs_rate(u8 rate)
356{
357 switch (rate) {
358 case IEEE80211_CCK_RATE_2MB:
359 return ZD_CS_CCK_RATE_2M;
360 case IEEE80211_CCK_RATE_5MB:
361 return ZD_CS_CCK_RATE_5_5M;
362 case IEEE80211_CCK_RATE_11MB:
363 return ZD_CS_CCK_RATE_11M;
364 case IEEE80211_OFDM_RATE_6MB:
365 return ZD_OFDM_RATE_6M;
366 case IEEE80211_OFDM_RATE_9MB:
367 return ZD_OFDM_RATE_9M;
368 case IEEE80211_OFDM_RATE_12MB:
369 return ZD_OFDM_RATE_12M;
370 case IEEE80211_OFDM_RATE_18MB:
371 return ZD_OFDM_RATE_18M;
372 case IEEE80211_OFDM_RATE_24MB:
373 return ZD_OFDM_RATE_24M;
374 case IEEE80211_OFDM_RATE_36MB:
375 return ZD_OFDM_RATE_36M;
376 case IEEE80211_OFDM_RATE_48MB:
377 return ZD_OFDM_RATE_48M;
378 case IEEE80211_OFDM_RATE_54MB:
379 return ZD_OFDM_RATE_54M;
380 }
381 return ZD_CS_CCK_RATE_1M;
382}
383
384int zd_mac_set_mode(struct zd_mac *mac, u32 mode)
385{
386 struct ieee80211_device *ieee;
387
388 switch (mode) {
389 case IW_MODE_AUTO:
390 case IW_MODE_ADHOC:
391 case IW_MODE_INFRA:
392 mac->netdev->type = ARPHRD_ETHER;
393 break;
394 case IW_MODE_MONITOR:
395 mac->netdev->type = ARPHRD_IEEE80211_RADIOTAP;
396 break;
397 default:
398 dev_dbg_f(zd_mac_dev(mac), "wrong mode %u\n", mode);
399 return -EINVAL;
400 }
401
402 ieee = zd_mac_to_ieee80211(mac);
403 ZD_ASSERT(!irqs_disabled());
404 spin_lock_irq(&ieee->lock);
405 ieee->iw_mode = mode;
406 spin_unlock_irq(&ieee->lock);
407
408 if (netif_running(mac->netdev))
409 return reset_mode(mac);
410
411 return 0;
412}
413
414int zd_mac_get_mode(struct zd_mac *mac, u32 *mode)
415{
416 unsigned long flags;
417 struct ieee80211_device *ieee;
418
419 ieee = zd_mac_to_ieee80211(mac);
420 spin_lock_irqsave(&ieee->lock, flags);
421 *mode = ieee->iw_mode;
422 spin_unlock_irqrestore(&ieee->lock, flags);
423 return 0;
424}
425
426int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range)
427{
428 int i;
429 const struct channel_range *channel_range;
430 u8 regdomain;
431
432 memset(range, 0, sizeof(*range));
433
434 /* FIXME: Not so important and depends on the mode. For 802.11g
435 * usually this value is used. It seems to be that Bit/s number is
436 * given here.
437 */
438 range->throughput = 27 * 1000 * 1000;
439
440 range->max_qual.qual = 100;
441 range->max_qual.level = 100;
442
443 /* FIXME: Needs still to be tuned. */
444 range->avg_qual.qual = 71;
445 range->avg_qual.level = 80;
446
447 /* FIXME: depends on standard? */
448 range->min_rts = 256;
449 range->max_rts = 2346;
450
451 range->min_frag = MIN_FRAG_THRESHOLD;
452 range->max_frag = MAX_FRAG_THRESHOLD;
453
454 range->max_encoding_tokens = WEP_KEYS;
455 range->num_encoding_sizes = 2;
456 range->encoding_size[0] = 5;
457 range->encoding_size[1] = WEP_KEY_LEN;
458
459 range->we_version_compiled = WIRELESS_EXT;
460 range->we_version_source = 20;
461
462 ZD_ASSERT(!irqs_disabled());
463 spin_lock_irq(&mac->lock);
464 regdomain = mac->regdomain;
465 spin_unlock_irq(&mac->lock);
466 channel_range = zd_channel_range(regdomain);
467
468 range->num_channels = channel_range->end - channel_range->start;
469 range->old_num_channels = range->num_channels;
470 range->num_frequency = range->num_channels;
471 range->old_num_frequency = range->num_frequency;
472
473 for (i = 0; i < range->num_frequency; i++) {
474 struct iw_freq *freq = &range->freq[i];
475 freq->i = channel_range->start + i;
476 zd_channel_to_freq(freq, freq->i);
477 }
478
479 return 0;
480}
481
482static int zd_calc_tx_length_us(u8 *service, u8 cs_rate, u16 tx_length)
483{
484 static const u8 rate_divisor[] = {
485 [ZD_CS_CCK_RATE_1M] = 1,
486 [ZD_CS_CCK_RATE_2M] = 2,
487 [ZD_CS_CCK_RATE_5_5M] = 11, /* bits must be doubled */
488 [ZD_CS_CCK_RATE_11M] = 11,
489 [ZD_OFDM_RATE_6M] = 6,
490 [ZD_OFDM_RATE_9M] = 9,
491 [ZD_OFDM_RATE_12M] = 12,
492 [ZD_OFDM_RATE_18M] = 18,
493 [ZD_OFDM_RATE_24M] = 24,
494 [ZD_OFDM_RATE_36M] = 36,
495 [ZD_OFDM_RATE_48M] = 48,
496 [ZD_OFDM_RATE_54M] = 54,
497 };
498
499 u32 bits = (u32)tx_length * 8;
500 u32 divisor;
501
502 divisor = rate_divisor[cs_rate];
503 if (divisor == 0)
504 return -EINVAL;
505
506 switch (cs_rate) {
507 case ZD_CS_CCK_RATE_5_5M:
508 bits = (2*bits) + 10; /* round up to the next integer */
509 break;
510 case ZD_CS_CCK_RATE_11M:
511 if (service) {
512 u32 t = bits % 11;
513 *service &= ~ZD_PLCP_SERVICE_LENGTH_EXTENSION;
514 if (0 < t && t <= 3) {
515 *service |= ZD_PLCP_SERVICE_LENGTH_EXTENSION;
516 }
517 }
518 bits += 10; /* round up to the next integer */
519 break;
520 }
521
522 return bits/divisor;
523}
524
525enum {
526 R2M_SHORT_PREAMBLE = 0x01,
527 R2M_11A = 0x02,
528};
529
530static u8 cs_rate_to_modulation(u8 cs_rate, int flags)
531{
532 u8 modulation;
533
534 modulation = cs_typed_rate(cs_rate);
535 if (flags & R2M_SHORT_PREAMBLE) {
536 switch (ZD_CS_RATE(modulation)) {
537 case ZD_CS_CCK_RATE_2M:
538 case ZD_CS_CCK_RATE_5_5M:
539 case ZD_CS_CCK_RATE_11M:
540 modulation |= ZD_CS_CCK_PREA_SHORT;
541 return modulation;
542 }
543 }
544 if (flags & R2M_11A) {
545 if (ZD_CS_TYPE(modulation) == ZD_CS_OFDM)
546 modulation |= ZD_CS_OFDM_MODE_11A;
547 }
548 return modulation;
549}
550
551static void cs_set_modulation(struct zd_mac *mac, struct zd_ctrlset *cs,
552 struct ieee80211_hdr_4addr *hdr)
553{
554 struct ieee80211softmac_device *softmac = ieee80211_priv(mac->netdev);
555 u16 ftype = WLAN_FC_GET_TYPE(le16_to_cpu(hdr->frame_ctl));
556 u8 rate, cs_rate;
557 int is_mgt = (ftype == IEEE80211_FTYPE_MGMT) != 0;
558
559 /* FIXME: 802.11a? short preamble? */
560 rate = ieee80211softmac_suggest_txrate(softmac,
561 is_multicast_ether_addr(hdr->addr1), is_mgt);
562
563 cs_rate = rate_to_cs_rate(rate);
564 cs->modulation = cs_rate_to_modulation(cs_rate, 0);
565}
566
567static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
568 struct ieee80211_hdr_4addr *header)
569{
570 unsigned int tx_length = le16_to_cpu(cs->tx_length);
571 u16 fctl = le16_to_cpu(header->frame_ctl);
572 u16 ftype = WLAN_FC_GET_TYPE(fctl);
573 u16 stype = WLAN_FC_GET_STYPE(fctl);
574
575 /*
576 * CONTROL:
577 * - start at 0x00
578 * - if fragment 0, enable bit 0
579 * - if backoff needed, enable bit 0
580 * - if burst (backoff not needed) disable bit 0
581 * - if multicast, enable bit 1
582 * - if PS-POLL frame, enable bit 2
583 * - if in INDEPENDENT_BSS mode and zd1205_DestPowerSave, then enable
584 * bit 4 (FIXME: wtf)
585 * - if frag_len > RTS threshold, set bit 5 as long if it isnt
586 * multicast or mgt
587 * - if bit 5 is set, and we are in OFDM mode, unset bit 5 and set bit
588 * 7
589 */
590
591 cs->control = 0;
592
593 /* First fragment */
594 if (WLAN_GET_SEQ_FRAG(le16_to_cpu(header->seq_ctl)) == 0)
595 cs->control |= ZD_CS_NEED_RANDOM_BACKOFF;
596
597 /* Multicast */
598 if (is_multicast_ether_addr(header->addr1))
599 cs->control |= ZD_CS_MULTICAST;
600
601 /* PS-POLL */
602 if (stype == IEEE80211_STYPE_PSPOLL)
603 cs->control |= ZD_CS_PS_POLL_FRAME;
604
605 if (!is_multicast_ether_addr(header->addr1) &&
606 ftype != IEEE80211_FTYPE_MGMT &&
607 tx_length > zd_netdev_ieee80211(mac->netdev)->rts)
608 {
609 /* FIXME: check the logic */
610 if (ZD_CS_TYPE(cs->modulation) == ZD_CS_OFDM) {
611 /* 802.11g */
612 cs->control |= ZD_CS_SELF_CTS;
613 } else { /* 802.11b */
614 cs->control |= ZD_CS_RTS;
615 }
616 }
617
618 /* FIXME: Management frame? */
619}
620
621static int fill_ctrlset(struct zd_mac *mac,
622 struct ieee80211_txb *txb,
623 int frag_num)
624{
625 int r;
626 struct sk_buff *skb = txb->fragments[frag_num];
627 struct ieee80211_hdr_4addr *hdr =
628 (struct ieee80211_hdr_4addr *) skb->data;
629 unsigned int frag_len = skb->len + IEEE80211_FCS_LEN;
630 unsigned int next_frag_len;
631 unsigned int packet_length;
632 struct zd_ctrlset *cs = (struct zd_ctrlset *)
633 skb_push(skb, sizeof(struct zd_ctrlset));
634
635 if (frag_num+1 < txb->nr_frags) {
636 next_frag_len = txb->fragments[frag_num+1]->len +
637 IEEE80211_FCS_LEN;
638 } else {
639 next_frag_len = 0;
640 }
641 ZD_ASSERT(frag_len <= 0xffff);
642 ZD_ASSERT(next_frag_len <= 0xffff);
643
644 cs_set_modulation(mac, cs, hdr);
645
646 cs->tx_length = cpu_to_le16(frag_len);
647
648 cs_set_control(mac, cs, hdr);
649
650 packet_length = frag_len + sizeof(struct zd_ctrlset) + 10;
651 ZD_ASSERT(packet_length <= 0xffff);
652 /* ZD1211B: Computing the length difference this way, gives us
653 * flexibility to compute the packet length.
654 */
655 cs->packet_length = cpu_to_le16(mac->chip.is_zd1211b ?
656 packet_length - frag_len : packet_length);
657
658 /*
659 * CURRENT LENGTH:
660 * - transmit frame length in microseconds
661 * - seems to be derived from frame length
662 * - see Cal_Us_Service() in zdinlinef.h
663 * - if macp->bTxBurstEnable is enabled, then multiply by 4
664 * - bTxBurstEnable is never set in the vendor driver
665 *
666 * SERVICE:
667 * - "for PLCP configuration"
668 * - always 0 except in some situations at 802.11b 11M
669 * - see line 53 of zdinlinef.h
670 */
671 cs->service = 0;
672 r = zd_calc_tx_length_us(&cs->service, ZD_CS_RATE(cs->modulation),
673 le16_to_cpu(cs->tx_length));
674 if (r < 0)
675 return r;
676 cs->current_length = cpu_to_le16(r);
677
678 if (next_frag_len == 0) {
679 cs->next_frame_length = 0;
680 } else {
681 r = zd_calc_tx_length_us(NULL, ZD_CS_RATE(cs->modulation),
682 next_frag_len);
683 if (r < 0)
684 return r;
685 cs->next_frame_length = cpu_to_le16(r);
686 }
687
688 return 0;
689}
690
691static int zd_mac_tx(struct zd_mac *mac, struct ieee80211_txb *txb, int pri)
692{
693 int i, r;
694
695 for (i = 0; i < txb->nr_frags; i++) {
696 struct sk_buff *skb = txb->fragments[i];
697
698 r = fill_ctrlset(mac, txb, i);
699 if (r)
700 return r;
701 r = zd_usb_tx(&mac->chip.usb, skb->data, skb->len);
702 if (r)
703 return r;
704 }
705
706 /* FIXME: shouldn't this be handled by the upper layers? */
707 mac->netdev->trans_start = jiffies;
708
709 ieee80211_txb_free(txb);
710 return 0;
711}
712
713struct zd_rt_hdr {
714 struct ieee80211_radiotap_header rt_hdr;
715 u8 rt_flags;
716 u16 rt_channel;
717 u16 rt_chbitmask;
718 u16 rt_rate;
719};
720
721static void fill_rt_header(void *buffer, struct zd_mac *mac,
722 const struct ieee80211_rx_stats *stats,
723 const struct rx_status *status)
724{
725 struct zd_rt_hdr *hdr = buffer;
726
727 hdr->rt_hdr.it_version = PKTHDR_RADIOTAP_VERSION;
728 hdr->rt_hdr.it_pad = 0;
729 hdr->rt_hdr.it_len = cpu_to_le16(sizeof(struct zd_rt_hdr));
730 hdr->rt_hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
731 (1 << IEEE80211_RADIOTAP_CHANNEL) |
732 (1 << IEEE80211_RADIOTAP_RATE));
733
734 hdr->rt_flags = 0;
735 if (status->decryption_type & (ZD_RX_WEP64|ZD_RX_WEP128|ZD_RX_WEP256))
736 hdr->rt_flags |= IEEE80211_RADIOTAP_F_WEP;
737
738 /* FIXME: 802.11a */
739 hdr->rt_channel = cpu_to_le16(ieee80211chan2mhz(
740 _zd_chip_get_channel(&mac->chip)));
741 hdr->rt_chbitmask = cpu_to_le16(IEEE80211_CHAN_2GHZ |
742 ((status->frame_status & ZD_RX_FRAME_MODULATION_MASK) ==
743 ZD_RX_OFDM ? IEEE80211_CHAN_OFDM : IEEE80211_CHAN_CCK));
744
745 hdr->rt_rate = stats->rate / 5;
746}
747
748/* Returns 1 if the data packet is for us and 0 otherwise. */
749static int is_data_packet_for_us(struct ieee80211_device *ieee,
750 struct ieee80211_hdr_4addr *hdr)
751{
752 struct net_device *netdev = ieee->dev;
753 u16 fc = le16_to_cpu(hdr->frame_ctl);
754
755 ZD_ASSERT(WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA);
756
757 switch (ieee->iw_mode) {
758 case IW_MODE_ADHOC:
759 if ((fc & (IEEE80211_FCTL_TODS|IEEE80211_FCTL_FROMDS)) != 0 ||
760 memcmp(hdr->addr3, ieee->bssid, ETH_ALEN) != 0)
761 return 0;
762 break;
763 case IW_MODE_AUTO:
764 case IW_MODE_INFRA:
765 if ((fc & (IEEE80211_FCTL_TODS|IEEE80211_FCTL_FROMDS)) !=
766 IEEE80211_FCTL_FROMDS ||
767 memcmp(hdr->addr2, ieee->bssid, ETH_ALEN) != 0)
768 return 0;
769 break;
770 default:
771 ZD_ASSERT(ieee->iw_mode != IW_MODE_MONITOR);
772 return 0;
773 }
774
775 return memcmp(hdr->addr1, netdev->dev_addr, ETH_ALEN) == 0 ||
776 is_multicast_ether_addr(hdr->addr1) ||
777 (netdev->flags & IFF_PROMISC);
778}
779
780/* Filters receiving packets. If it returns 1 send it to ieee80211_rx, if 0
781 * return. If an error is detected -EINVAL is returned. ieee80211_rx_mgt() is
782 * called here.
783 *
784 * It has been based on ieee80211_rx_any.
785 */
786static int filter_rx(struct ieee80211_device *ieee,
787 const u8 *buffer, unsigned int length,
788 struct ieee80211_rx_stats *stats)
789{
790 struct ieee80211_hdr_4addr *hdr;
791 u16 fc;
792
793 if (ieee->iw_mode == IW_MODE_MONITOR)
794 return 1;
795
796 hdr = (struct ieee80211_hdr_4addr *)buffer;
797 fc = le16_to_cpu(hdr->frame_ctl);
798 if ((fc & IEEE80211_FCTL_VERS) != 0)
799 return -EINVAL;
800
801 switch (WLAN_FC_GET_TYPE(fc)) {
802 case IEEE80211_FTYPE_MGMT:
803 if (length < sizeof(struct ieee80211_hdr_3addr))
804 return -EINVAL;
805 ieee80211_rx_mgt(ieee, hdr, stats);
806 return 0;
807 case IEEE80211_FTYPE_CTL:
808 /* Ignore invalid short buffers */
809 return 0;
810 case IEEE80211_FTYPE_DATA:
811 if (length < sizeof(struct ieee80211_hdr_3addr))
812 return -EINVAL;
813 return is_data_packet_for_us(ieee, hdr);
814 }
815
816 return -EINVAL;
817}
818
819static void update_qual_rssi(struct zd_mac *mac, u8 qual_percent, u8 rssi)
820{
821 unsigned long flags;
822
823 spin_lock_irqsave(&mac->lock, flags);
824 mac->qual_average = (7 * mac->qual_average + qual_percent) / 8;
825 mac->rssi_average = (7 * mac->rssi_average + rssi) / 8;
826 spin_unlock_irqrestore(&mac->lock, flags);
827}
828
829static int fill_rx_stats(struct ieee80211_rx_stats *stats,
830 const struct rx_status **pstatus,
831 struct zd_mac *mac,
832 const u8 *buffer, unsigned int length)
833{
834 const struct rx_status *status;
835
836 *pstatus = status = zd_tail(buffer, length, sizeof(struct rx_status));
837 if (status->frame_status & ZD_RX_ERROR) {
838 /* FIXME: update? */
839 return -EINVAL;
840 }
841 memset(stats, 0, sizeof(struct ieee80211_rx_stats));
842 stats->len = length - (ZD_PLCP_HEADER_SIZE + IEEE80211_FCS_LEN +
843 + sizeof(struct rx_status));
844 /* FIXME: 802.11a */
845 stats->freq = IEEE80211_24GHZ_BAND;
846 stats->received_channel = _zd_chip_get_channel(&mac->chip);
847 stats->rssi = zd_rx_strength_percent(status->signal_strength);
848 stats->signal = zd_rx_qual_percent(buffer,
849 length - sizeof(struct rx_status),
850 status);
851 stats->mask = IEEE80211_STATMASK_RSSI | IEEE80211_STATMASK_SIGNAL;
852 stats->rate = zd_rx_rate(buffer, status);
853 if (stats->rate)
854 stats->mask |= IEEE80211_STATMASK_RATE;
855
856 update_qual_rssi(mac, stats->signal, stats->rssi);
857 return 0;
858}
859
860int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length)
861{
862 int r;
863 struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac);
864 struct ieee80211_rx_stats stats;
865 const struct rx_status *status;
866 struct sk_buff *skb;
867
868 if (length < ZD_PLCP_HEADER_SIZE + IEEE80211_1ADDR_LEN +
869 IEEE80211_FCS_LEN + sizeof(struct rx_status))
870 return -EINVAL;
871
872 r = fill_rx_stats(&stats, &status, mac, buffer, length);
873 if (r)
874 return r;
875
876 length -= ZD_PLCP_HEADER_SIZE+IEEE80211_FCS_LEN+
877 sizeof(struct rx_status);
878 buffer += ZD_PLCP_HEADER_SIZE;
879
880 r = filter_rx(ieee, buffer, length, &stats);
881 if (r <= 0)
882 return r;
883
884 skb = dev_alloc_skb(sizeof(struct zd_rt_hdr) + length);
885 if (!skb)
886 return -ENOMEM;
887 if (ieee->iw_mode == IW_MODE_MONITOR)
888 fill_rt_header(skb_put(skb, sizeof(struct zd_rt_hdr)), mac,
889 &stats, status);
890 memcpy(skb_put(skb, length), buffer, length);
891
892 r = ieee80211_rx(ieee, skb, &stats);
893 if (!r) {
894 ZD_ASSERT(in_irq());
895 dev_kfree_skb_irq(skb);
896 }
897 return 0;
898}
899
900static int netdev_tx(struct ieee80211_txb *txb, struct net_device *netdev,
901 int pri)
902{
903 return zd_mac_tx(zd_netdev_mac(netdev), txb, pri);
904}
905
906static void set_security(struct net_device *netdev,
907 struct ieee80211_security *sec)
908{
909 struct ieee80211_device *ieee = zd_netdev_ieee80211(netdev);
910 struct ieee80211_security *secinfo = &ieee->sec;
911 int keyidx;
912
913 dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)), "\n");
914
915 for (keyidx = 0; keyidx<WEP_KEYS; keyidx++)
916 if (sec->flags & (1<<keyidx)) {
917 secinfo->encode_alg[keyidx] = sec->encode_alg[keyidx];
918 secinfo->key_sizes[keyidx] = sec->key_sizes[keyidx];
919 memcpy(secinfo->keys[keyidx], sec->keys[keyidx],
920 SCM_KEY_LEN);
921 }
922
923 if (sec->flags & SEC_ACTIVE_KEY) {
924 secinfo->active_key = sec->active_key;
925 dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)),
926 " .active_key = %d\n", sec->active_key);
927 }
928 if (sec->flags & SEC_UNICAST_GROUP) {
929 secinfo->unicast_uses_group = sec->unicast_uses_group;
930 dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)),
931 " .unicast_uses_group = %d\n",
932 sec->unicast_uses_group);
933 }
934 if (sec->flags & SEC_LEVEL) {
935 secinfo->level = sec->level;
936 dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)),
937 " .level = %d\n", sec->level);
938 }
939 if (sec->flags & SEC_ENABLED) {
940 secinfo->enabled = sec->enabled;
941 dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)),
942 " .enabled = %d\n", sec->enabled);
943 }
944 if (sec->flags & SEC_ENCRYPT) {
945 secinfo->encrypt = sec->encrypt;
946 dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)),
947 " .encrypt = %d\n", sec->encrypt);
948 }
949 if (sec->flags & SEC_AUTH_MODE) {
950 secinfo->auth_mode = sec->auth_mode;
951 dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)),
952 " .auth_mode = %d\n", sec->auth_mode);
953 }
954}
955
956static void ieee_init(struct ieee80211_device *ieee)
957{
958 ieee->mode = IEEE_B | IEEE_G;
959 ieee->freq_band = IEEE80211_24GHZ_BAND;
960 ieee->modulation = IEEE80211_OFDM_MODULATION | IEEE80211_CCK_MODULATION;
961 ieee->tx_headroom = sizeof(struct zd_ctrlset);
962 ieee->set_security = set_security;
963 ieee->hard_start_xmit = netdev_tx;
964
965 /* Software encryption/decryption for now */
966 ieee->host_build_iv = 0;
967 ieee->host_encrypt = 1;
968 ieee->host_decrypt = 1;
969
970 /* FIXME: default to managed mode, until ieee80211 and zd1211rw can
971 * correctly support AUTO */
972 ieee->iw_mode = IW_MODE_INFRA;
973}
974
975static void softmac_init(struct ieee80211softmac_device *sm)
976{
977 sm->set_channel = set_channel;
978}
979
980struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev)
981{
982 struct zd_mac *mac = zd_netdev_mac(ndev);
983 struct iw_statistics *iw_stats = &mac->iw_stats;
984
985 memset(iw_stats, 0, sizeof(struct iw_statistics));
986 /* We are not setting the status, because ieee->state is not updated
987 * at all and this driver doesn't track authentication state.
988 */
989 spin_lock_irq(&mac->lock);
990 iw_stats->qual.qual = mac->qual_average;
991 iw_stats->qual.level = mac->rssi_average;
992 iw_stats->qual.updated = IW_QUAL_QUAL_UPDATED|IW_QUAL_LEVEL_UPDATED|
993 IW_QUAL_NOISE_INVALID;
994 spin_unlock_irq(&mac->lock);
995 /* TODO: update counter */
996 return iw_stats;
997}
998
999#ifdef DEBUG
1000static const char* decryption_types[] = {
1001 [ZD_RX_NO_WEP] = "none",
1002 [ZD_RX_WEP64] = "WEP64",
1003 [ZD_RX_TKIP] = "TKIP",
1004 [ZD_RX_AES] = "AES",
1005 [ZD_RX_WEP128] = "WEP128",
1006 [ZD_RX_WEP256] = "WEP256",
1007};
1008
1009static const char *decryption_type_string(u8 type)
1010{
1011 const char *s;
1012
1013 if (type < ARRAY_SIZE(decryption_types)) {
1014 s = decryption_types[type];
1015 } else {
1016 s = NULL;
1017 }
1018 return s ? s : "unknown";
1019}
1020
1021static int is_ofdm(u8 frame_status)
1022{
1023 return (frame_status & ZD_RX_OFDM);
1024}
1025
1026void zd_dump_rx_status(const struct rx_status *status)
1027{
1028 const char* modulation;
1029 u8 quality;
1030
1031 if (is_ofdm(status->frame_status)) {
1032 modulation = "ofdm";
1033 quality = status->signal_quality_ofdm;
1034 } else {
1035 modulation = "cck";
1036 quality = status->signal_quality_cck;
1037 }
1038 pr_debug("rx status %s strength %#04x qual %#04x decryption %s\n",
1039 modulation, status->signal_strength, quality,
1040 decryption_type_string(status->decryption_type));
1041 if (status->frame_status & ZD_RX_ERROR) {
1042 pr_debug("rx error %s%s%s%s%s%s\n",
1043 (status->frame_status & ZD_RX_TIMEOUT_ERROR) ?
1044 "timeout " : "",
1045 (status->frame_status & ZD_RX_FIFO_OVERRUN_ERROR) ?
1046 "fifo " : "",
1047 (status->frame_status & ZD_RX_DECRYPTION_ERROR) ?
1048 "decryption " : "",
1049 (status->frame_status & ZD_RX_CRC32_ERROR) ?
1050 "crc32 " : "",
1051 (status->frame_status & ZD_RX_NO_ADDR1_MATCH_ERROR) ?
1052 "addr1 " : "",
1053 (status->frame_status & ZD_RX_CRC16_ERROR) ?
1054 "crc16" : "");
1055 }
1056}
1057#endif /* DEBUG */
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
new file mode 100644
index 000000000000..71e382c589ee
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -0,0 +1,190 @@
1/* zd_mac.c
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#ifndef _ZD_MAC_H
19#define _ZD_MAC_H
20
21#include <linux/wireless.h>
22#include <linux/kernel.h>
23#include <net/ieee80211.h>
24#include <net/ieee80211softmac.h>
25
26#include "zd_chip.h"
27#include "zd_netdev.h"
28
29struct zd_ctrlset {
30 u8 modulation;
31 __le16 tx_length;
32 u8 control;
33 /* stores only the difference to tx_length on ZD1211B */
34 __le16 packet_length;
35 __le16 current_length;
36 u8 service;
37 __le16 next_frame_length;
38} __attribute__((packed));
39
40#define ZD_CS_RESERVED_SIZE 25
41
42/* zd_crtlset field modulation */
43#define ZD_CS_RATE_MASK 0x0f
44#define ZD_CS_TYPE_MASK 0x10
45#define ZD_CS_RATE(modulation) ((modulation) & ZD_CS_RATE_MASK)
46#define ZD_CS_TYPE(modulation) ((modulation) & ZD_CS_TYPE_MASK)
47
48#define ZD_CS_CCK 0x00
49#define ZD_CS_OFDM 0x10
50
51#define ZD_CS_CCK_RATE_1M 0x00
52#define ZD_CS_CCK_RATE_2M 0x01
53#define ZD_CS_CCK_RATE_5_5M 0x02
54#define ZD_CS_CCK_RATE_11M 0x03
55/* The rates for OFDM are encoded as in the PLCP header. Use ZD_OFDM_RATE_*.
56 */
57
58/* bit 5 is preamble (when in CCK mode), or a/g selection (when in OFDM mode) */
59#define ZD_CS_CCK_PREA_LONG 0x00
60#define ZD_CS_CCK_PREA_SHORT 0x20
61#define ZD_CS_OFDM_MODE_11G 0x00
62#define ZD_CS_OFDM_MODE_11A 0x20
63
64/* zd_ctrlset control field */
65#define ZD_CS_NEED_RANDOM_BACKOFF 0x01
66#define ZD_CS_MULTICAST 0x02
67
68#define ZD_CS_FRAME_TYPE_MASK 0x0c
69#define ZD_CS_DATA_FRAME 0x00
70#define ZD_CS_PS_POLL_FRAME 0x04
71#define ZD_CS_MANAGEMENT_FRAME 0x08
72#define ZD_CS_NO_SEQUENCE_CTL_FRAME 0x0c
73
74#define ZD_CS_WAKE_DESTINATION 0x10
75#define ZD_CS_RTS 0x20
76#define ZD_CS_ENCRYPT 0x40
77#define ZD_CS_SELF_CTS 0x80
78
79/* Incoming frames are prepended by a PLCP header */
80#define ZD_PLCP_HEADER_SIZE 5
81
82struct rx_length_info {
83 __le16 length[3];
84 __le16 tag;
85} __attribute__((packed));
86
87#define RX_LENGTH_INFO_TAG 0x697e
88
89struct rx_status {
90 /* rssi */
91 u8 signal_strength;
92 u8 signal_quality_cck;
93 u8 signal_quality_ofdm;
94 u8 decryption_type;
95 u8 frame_status;
96} __attribute__((packed));
97
98/* rx_status field decryption_type */
99#define ZD_RX_NO_WEP 0
100#define ZD_RX_WEP64 1
101#define ZD_RX_TKIP 2
102#define ZD_RX_AES 4
103#define ZD_RX_WEP128 5
104#define ZD_RX_WEP256 6
105
106/* rx_status field frame_status */
107#define ZD_RX_FRAME_MODULATION_MASK 0x01
108#define ZD_RX_CCK 0x00
109#define ZD_RX_OFDM 0x01
110
111#define ZD_RX_TIMEOUT_ERROR 0x02
112#define ZD_RX_FIFO_OVERRUN_ERROR 0x04
113#define ZD_RX_DECRYPTION_ERROR 0x08
114#define ZD_RX_CRC32_ERROR 0x10
115#define ZD_RX_NO_ADDR1_MATCH_ERROR 0x20
116#define ZD_RX_CRC16_ERROR 0x40
117#define ZD_RX_ERROR 0x80
118
119enum mac_flags {
120 MAC_FIXED_CHANNEL = 0x01,
121};
122
123struct zd_mac {
124 struct net_device *netdev;
125 struct zd_chip chip;
126 spinlock_t lock;
127 /* Unlocked reading possible */
128 struct iw_statistics iw_stats;
129 u8 qual_average;
130 u8 rssi_average;
131 u8 regdomain;
132 u8 default_regdomain;
133 u8 requested_channel;
134};
135
136static inline struct ieee80211_device *zd_mac_to_ieee80211(struct zd_mac *mac)
137{
138 return zd_netdev_ieee80211(mac->netdev);
139}
140
141static inline struct zd_mac *zd_netdev_mac(struct net_device *netdev)
142{
143 return ieee80211softmac_priv(netdev);
144}
145
146static inline struct zd_mac *zd_chip_to_mac(struct zd_chip *chip)
147{
148 return container_of(chip, struct zd_mac, chip);
149}
150
151static inline struct zd_mac *zd_usb_to_mac(struct zd_usb *usb)
152{
153 return zd_chip_to_mac(zd_usb_to_chip(usb));
154}
155
156#define zd_mac_dev(mac) (zd_chip_dev(&(mac)->chip))
157
158int zd_mac_init(struct zd_mac *mac,
159 struct net_device *netdev,
160 struct usb_interface *intf);
161void zd_mac_clear(struct zd_mac *mac);
162
163int zd_mac_init_hw(struct zd_mac *mac, u8 device_type);
164
165int zd_mac_open(struct net_device *netdev);
166int zd_mac_stop(struct net_device *netdev);
167int zd_mac_set_mac_address(struct net_device *dev, void *p);
168
169int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length);
170
171int zd_mac_set_regdomain(struct zd_mac *zd_mac, u8 regdomain);
172u8 zd_mac_get_regdomain(struct zd_mac *zd_mac);
173
174int zd_mac_request_channel(struct zd_mac *mac, u8 channel);
175int zd_mac_get_channel(struct zd_mac *mac, u8 *channel, u8 *flags);
176
177int zd_mac_set_mode(struct zd_mac *mac, u32 mode);
178int zd_mac_get_mode(struct zd_mac *mac, u32 *mode);
179
180int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range);
181
182struct iw_statistics *zd_mac_get_wireless_stats(struct net_device *ndev);
183
184#ifdef DEBUG
185void zd_dump_rx_status(const struct rx_status *status);
186#else
187#define zd_dump_rx_status(status)
188#endif /* DEBUG */
189
190#endif /* _ZD_MAC_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_netdev.c b/drivers/net/wireless/zd1211rw/zd_netdev.c
new file mode 100644
index 000000000000..9df232c2c863
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_netdev.c
@@ -0,0 +1,267 @@
1/* zd_netdev.c
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#include <linux/netdevice.h>
19#include <linux/etherdevice.h>
20#include <linux/skbuff.h>
21#include <net/ieee80211.h>
22#include <net/ieee80211softmac.h>
23#include <net/ieee80211softmac_wx.h>
24#include <net/iw_handler.h>
25
26#include "zd_def.h"
27#include "zd_netdev.h"
28#include "zd_mac.h"
29#include "zd_ieee80211.h"
30
31/* Region 0 means reset regdomain to default. */
32static int zd_set_regdomain(struct net_device *netdev,
33 struct iw_request_info *info,
34 union iwreq_data *req, char *extra)
35{
36 const u8 *regdomain = (u8 *)req;
37 return zd_mac_set_regdomain(zd_netdev_mac(netdev), *regdomain);
38}
39
40static int zd_get_regdomain(struct net_device *netdev,
41 struct iw_request_info *info,
42 union iwreq_data *req, char *extra)
43{
44 u8 *regdomain = (u8 *)req;
45 if (!regdomain)
46 return -EINVAL;
47 *regdomain = zd_mac_get_regdomain(zd_netdev_mac(netdev));
48 return 0;
49}
50
51static const struct iw_priv_args zd_priv_args[] = {
52 {
53 .cmd = ZD_PRIV_SET_REGDOMAIN,
54 .set_args = IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
55 .name = "set_regdomain",
56 },
57 {
58 .cmd = ZD_PRIV_GET_REGDOMAIN,
59 .get_args = IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
60 .name = "get_regdomain",
61 },
62};
63
64#define PRIV_OFFSET(x) [(x)-SIOCIWFIRSTPRIV]
65
66static const iw_handler zd_priv_handler[] = {
67 PRIV_OFFSET(ZD_PRIV_SET_REGDOMAIN) = zd_set_regdomain,
68 PRIV_OFFSET(ZD_PRIV_GET_REGDOMAIN) = zd_get_regdomain,
69};
70
71static int iw_get_name(struct net_device *netdev,
72 struct iw_request_info *info,
73 union iwreq_data *req, char *extra)
74{
75 /* FIXME: check whether 802.11a will also supported, add also
76 * zd1211B, if we support it.
77 */
78 strlcpy(req->name, "802.11g zd1211", IFNAMSIZ);
79 return 0;
80}
81
82static int iw_set_freq(struct net_device *netdev,
83 struct iw_request_info *info,
84 union iwreq_data *req, char *extra)
85{
86 int r;
87 struct zd_mac *mac = zd_netdev_mac(netdev);
88 struct iw_freq *freq = &req->freq;
89 u8 channel;
90
91 r = zd_find_channel(&channel, freq);
92 if (r < 0)
93 return r;
94 r = zd_mac_request_channel(mac, channel);
95 return r;
96}
97
98static int iw_get_freq(struct net_device *netdev,
99 struct iw_request_info *info,
100 union iwreq_data *req, char *extra)
101{
102 int r;
103 struct zd_mac *mac = zd_netdev_mac(netdev);
104 struct iw_freq *freq = &req->freq;
105 u8 channel;
106 u8 flags;
107
108 r = zd_mac_get_channel(mac, &channel, &flags);
109 if (r)
110 return r;
111
112 freq->flags = (flags & MAC_FIXED_CHANNEL) ?
113 IW_FREQ_FIXED : IW_FREQ_AUTO;
114 dev_dbg_f(zd_mac_dev(mac), "channel %s\n",
115 (flags & MAC_FIXED_CHANNEL) ? "fixed" : "auto");
116 return zd_channel_to_freq(freq, channel);
117}
118
119static int iw_set_mode(struct net_device *netdev,
120 struct iw_request_info *info,
121 union iwreq_data *req, char *extra)
122{
123 return zd_mac_set_mode(zd_netdev_mac(netdev), req->mode);
124}
125
126static int iw_get_mode(struct net_device *netdev,
127 struct iw_request_info *info,
128 union iwreq_data *req, char *extra)
129{
130 return zd_mac_get_mode(zd_netdev_mac(netdev), &req->mode);
131}
132
133static int iw_get_range(struct net_device *netdev,
134 struct iw_request_info *info,
135 union iwreq_data *req, char *extra)
136{
137 struct iw_range *range = (struct iw_range *)extra;
138
139 dev_dbg_f(zd_mac_dev(zd_netdev_mac(netdev)), "\n");
140 req->data.length = sizeof(*range);
141 return zd_mac_get_range(zd_netdev_mac(netdev), range);
142}
143
144static int iw_set_encode(struct net_device *netdev,
145 struct iw_request_info *info,
146 union iwreq_data *data,
147 char *extra)
148{
149 return ieee80211_wx_set_encode(zd_netdev_ieee80211(netdev), info,
150 data, extra);
151}
152
153static int iw_get_encode(struct net_device *netdev,
154 struct iw_request_info *info,
155 union iwreq_data *data,
156 char *extra)
157{
158 return ieee80211_wx_get_encode(zd_netdev_ieee80211(netdev), info,
159 data, extra);
160}
161
162static int iw_set_encodeext(struct net_device *netdev,
163 struct iw_request_info *info,
164 union iwreq_data *data,
165 char *extra)
166{
167 return ieee80211_wx_set_encodeext(zd_netdev_ieee80211(netdev), info,
168 data, extra);
169}
170
171static int iw_get_encodeext(struct net_device *netdev,
172 struct iw_request_info *info,
173 union iwreq_data *data,
174 char *extra)
175{
176 return ieee80211_wx_get_encodeext(zd_netdev_ieee80211(netdev), info,
177 data, extra);
178}
179
180#define WX(x) [(x)-SIOCIWFIRST]
181
182static const iw_handler zd_standard_iw_handlers[] = {
183 WX(SIOCGIWNAME) = iw_get_name,
184 WX(SIOCSIWFREQ) = iw_set_freq,
185 WX(SIOCGIWFREQ) = iw_get_freq,
186 WX(SIOCSIWMODE) = iw_set_mode,
187 WX(SIOCGIWMODE) = iw_get_mode,
188 WX(SIOCGIWRANGE) = iw_get_range,
189 WX(SIOCSIWENCODE) = iw_set_encode,
190 WX(SIOCGIWENCODE) = iw_get_encode,
191 WX(SIOCSIWENCODEEXT) = iw_set_encodeext,
192 WX(SIOCGIWENCODEEXT) = iw_get_encodeext,
193 WX(SIOCSIWAUTH) = ieee80211_wx_set_auth,
194 WX(SIOCGIWAUTH) = ieee80211_wx_get_auth,
195 WX(SIOCSIWSCAN) = ieee80211softmac_wx_trigger_scan,
196 WX(SIOCGIWSCAN) = ieee80211softmac_wx_get_scan_results,
197 WX(SIOCSIWESSID) = ieee80211softmac_wx_set_essid,
198 WX(SIOCGIWESSID) = ieee80211softmac_wx_get_essid,
199 WX(SIOCSIWAP) = ieee80211softmac_wx_set_wap,
200 WX(SIOCGIWAP) = ieee80211softmac_wx_get_wap,
201 WX(SIOCSIWRATE) = ieee80211softmac_wx_set_rate,
202 WX(SIOCGIWRATE) = ieee80211softmac_wx_get_rate,
203 WX(SIOCSIWGENIE) = ieee80211softmac_wx_set_genie,
204 WX(SIOCGIWGENIE) = ieee80211softmac_wx_get_genie,
205 WX(SIOCSIWMLME) = ieee80211softmac_wx_set_mlme,
206};
207
208static const struct iw_handler_def iw_handler_def = {
209 .standard = zd_standard_iw_handlers,
210 .num_standard = ARRAY_SIZE(zd_standard_iw_handlers),
211 .private = zd_priv_handler,
212 .num_private = ARRAY_SIZE(zd_priv_handler),
213 .private_args = zd_priv_args,
214 .num_private_args = ARRAY_SIZE(zd_priv_args),
215 .get_wireless_stats = zd_mac_get_wireless_stats,
216};
217
218struct net_device *zd_netdev_alloc(struct usb_interface *intf)
219{
220 int r;
221 struct net_device *netdev;
222 struct zd_mac *mac;
223
224 netdev = alloc_ieee80211softmac(sizeof(struct zd_mac));
225 if (!netdev) {
226 dev_dbg_f(&intf->dev, "out of memory\n");
227 return NULL;
228 }
229
230 mac = zd_netdev_mac(netdev);
231 r = zd_mac_init(mac, netdev, intf);
232 if (r) {
233 usb_set_intfdata(intf, NULL);
234 free_ieee80211(netdev);
235 return NULL;
236 }
237
238 SET_MODULE_OWNER(netdev);
239 SET_NETDEV_DEV(netdev, &intf->dev);
240
241 dev_dbg_f(&intf->dev, "netdev->flags %#06hx\n", netdev->flags);
242 dev_dbg_f(&intf->dev, "netdev->features %#010lx\n", netdev->features);
243
244 netdev->open = zd_mac_open;
245 netdev->stop = zd_mac_stop;
246 /* netdev->get_stats = */
247 /* netdev->set_multicast_list = */
248 netdev->set_mac_address = zd_mac_set_mac_address;
249 netdev->wireless_handlers = &iw_handler_def;
250 /* netdev->ethtool_ops = */
251
252 return netdev;
253}
254
255void zd_netdev_free(struct net_device *netdev)
256{
257 if (!netdev)
258 return;
259
260 zd_mac_clear(zd_netdev_mac(netdev));
261 free_ieee80211(netdev);
262}
263
264void zd_netdev_disconnect(struct net_device *netdev)
265{
266 unregister_netdev(netdev);
267}
diff --git a/drivers/net/wireless/zd1211rw/zd_netdev.h b/drivers/net/wireless/zd1211rw/zd_netdev.h
new file mode 100644
index 000000000000..374a957073c1
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_netdev.h
@@ -0,0 +1,45 @@
1/* zd_netdev.h: Header for net device related functions.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#ifndef _ZD_NETDEV_H
19#define _ZD_NETDEV_H
20
21#include <linux/usb.h>
22#include <linux/netdevice.h>
23#include <net/ieee80211.h>
24
25#define ZD_PRIV_SET_REGDOMAIN (SIOCIWFIRSTPRIV)
26#define ZD_PRIV_GET_REGDOMAIN (SIOCIWFIRSTPRIV+1)
27
28static inline struct ieee80211_device *zd_netdev_ieee80211(
29 struct net_device *ndev)
30{
31 return netdev_priv(ndev);
32}
33
34static inline struct net_device *zd_ieee80211_to_netdev(
35 struct ieee80211_device *ieee)
36{
37 return ieee->dev;
38}
39
40struct net_device *zd_netdev_alloc(struct usb_interface *intf);
41void zd_netdev_free(struct net_device *netdev);
42
43void zd_netdev_disconnect(struct net_device *netdev);
44
45#endif /* _ZD_NETDEV_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_rf.c b/drivers/net/wireless/zd1211rw/zd_rf.c
new file mode 100644
index 000000000000..d3770d2c61bc
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_rf.c
@@ -0,0 +1,151 @@
1/* zd_rf.c
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#include <linux/errno.h>
19#include <linux/string.h>
20
21#include "zd_def.h"
22#include "zd_rf.h"
23#include "zd_ieee80211.h"
24#include "zd_chip.h"
25
26static const char *rfs[] = {
27 [0] = "unknown RF0",
28 [1] = "unknown RF1",
29 [UW2451_RF] = "UW2451_RF",
30 [UCHIP_RF] = "UCHIP_RF",
31 [AL2230_RF] = "AL2230_RF",
32 [AL7230B_RF] = "AL7230B_RF",
33 [THETA_RF] = "THETA_RF",
34 [AL2210_RF] = "AL2210_RF",
35 [MAXIM_NEW_RF] = "MAXIM_NEW_RF",
36 [UW2453_RF] = "UW2453_RF",
37 [AL2230S_RF] = "AL2230S_RF",
38 [RALINK_RF] = "RALINK_RF",
39 [INTERSIL_RF] = "INTERSIL_RF",
40 [RF2959_RF] = "RF2959_RF",
41 [MAXIM_NEW2_RF] = "MAXIM_NEW2_RF",
42 [PHILIPS_RF] = "PHILIPS_RF",
43};
44
45const char *zd_rf_name(u8 type)
46{
47 if (type & 0xf0)
48 type = 0;
49 return rfs[type];
50}
51
52void zd_rf_init(struct zd_rf *rf)
53{
54 memset(rf, 0, sizeof(*rf));
55}
56
57void zd_rf_clear(struct zd_rf *rf)
58{
59 memset(rf, 0, sizeof(*rf));
60}
61
62int zd_rf_init_hw(struct zd_rf *rf, u8 type)
63{
64 int r, t;
65 struct zd_chip *chip = zd_rf_to_chip(rf);
66
67 ZD_ASSERT(mutex_is_locked(&chip->mutex));
68 switch (type) {
69 case RF2959_RF:
70 r = zd_rf_init_rf2959(rf);
71 if (r)
72 return r;
73 break;
74 case AL2230_RF:
75 r = zd_rf_init_al2230(rf);
76 if (r)
77 return r;
78 break;
79 default:
80 dev_err(zd_chip_dev(chip),
81 "RF %s %#x is not supported\n", zd_rf_name(type), type);
82 rf->type = 0;
83 return -ENODEV;
84 }
85
86 rf->type = type;
87
88 r = zd_chip_lock_phy_regs(chip);
89 if (r)
90 return r;
91 t = rf->init_hw(rf);
92 r = zd_chip_unlock_phy_regs(chip);
93 if (t)
94 r = t;
95 return r;
96}
97
98int zd_rf_scnprint_id(struct zd_rf *rf, char *buffer, size_t size)
99{
100 return scnprintf(buffer, size, "%s", zd_rf_name(rf->type));
101}
102
103int zd_rf_set_channel(struct zd_rf *rf, u8 channel)
104{
105 int r;
106
107 ZD_ASSERT(mutex_is_locked(&zd_rf_to_chip(rf)->mutex));
108 if (channel < MIN_CHANNEL24)
109 return -EINVAL;
110 if (channel > MAX_CHANNEL24)
111 return -EINVAL;
112 dev_dbg_f(zd_chip_dev(zd_rf_to_chip(rf)), "channel: %d\n", channel);
113
114 r = rf->set_channel(rf, channel);
115 if (r >= 0)
116 rf->channel = channel;
117 return r;
118}
119
120int zd_switch_radio_on(struct zd_rf *rf)
121{
122 int r, t;
123 struct zd_chip *chip = zd_rf_to_chip(rf);
124
125 ZD_ASSERT(mutex_is_locked(&chip->mutex));
126 r = zd_chip_lock_phy_regs(chip);
127 if (r)
128 return r;
129 t = rf->switch_radio_on(rf);
130 r = zd_chip_unlock_phy_regs(chip);
131 if (t)
132 r = t;
133 return r;
134}
135
136int zd_switch_radio_off(struct zd_rf *rf)
137{
138 int r, t;
139 struct zd_chip *chip = zd_rf_to_chip(rf);
140
141 /* TODO: move phy regs handling to zd_chip */
142 ZD_ASSERT(mutex_is_locked(&chip->mutex));
143 r = zd_chip_lock_phy_regs(chip);
144 if (r)
145 return r;
146 t = rf->switch_radio_off(rf);
147 r = zd_chip_unlock_phy_regs(chip);
148 if (t)
149 r = t;
150 return r;
151}
diff --git a/drivers/net/wireless/zd1211rw/zd_rf.h b/drivers/net/wireless/zd1211rw/zd_rf.h
new file mode 100644
index 000000000000..ea30f693fcc8
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_rf.h
@@ -0,0 +1,82 @@
1/* zd_rf.h
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#ifndef _ZD_RF_H
19#define _ZD_RF_H
20
21#include "zd_types.h"
22
23#define UW2451_RF 0x2
24#define UCHIP_RF 0x3
25#define AL2230_RF 0x4
26#define AL7230B_RF 0x5 /* a,b,g */
27#define THETA_RF 0x6
28#define AL2210_RF 0x7
29#define MAXIM_NEW_RF 0x8
30#define UW2453_RF 0x9
31#define AL2230S_RF 0xa
32#define RALINK_RF 0xb
33#define INTERSIL_RF 0xc
34#define RF2959_RF 0xd
35#define MAXIM_NEW2_RF 0xe
36#define PHILIPS_RF 0xf
37
38#define RF_CHANNEL(ch) [(ch)-1]
39
40/* Provides functions of the RF transceiver. */
41
42enum {
43 RF_REG_BITS = 6,
44 RF_VALUE_BITS = 18,
45 RF_RV_BITS = RF_REG_BITS + RF_VALUE_BITS,
46};
47
48struct zd_rf {
49 u8 type;
50
51 u8 channel;
52 /*
53 * Whether this RF should patch the 6M band edge
54 * (assuming E2P_POD agrees)
55 */
56 u8 patch_6m_band_edge:1;
57
58 /* RF-specific functions */
59 int (*init_hw)(struct zd_rf *rf);
60 int (*set_channel)(struct zd_rf *rf, u8 channel);
61 int (*switch_radio_on)(struct zd_rf *rf);
62 int (*switch_radio_off)(struct zd_rf *rf);
63};
64
65const char *zd_rf_name(u8 type);
66void zd_rf_init(struct zd_rf *rf);
67void zd_rf_clear(struct zd_rf *rf);
68int zd_rf_init_hw(struct zd_rf *rf, u8 type);
69
70int zd_rf_scnprint_id(struct zd_rf *rf, char *buffer, size_t size);
71
72int zd_rf_set_channel(struct zd_rf *rf, u8 channel);
73
74int zd_switch_radio_on(struct zd_rf *rf);
75int zd_switch_radio_off(struct zd_rf *rf);
76
77/* Functions for individual RF chips */
78
79int zd_rf_init_rf2959(struct zd_rf *rf);
80int zd_rf_init_al2230(struct zd_rf *rf);
81
82#endif /* _ZD_RF_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_al2230.c b/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
new file mode 100644
index 000000000000..0948b25f660d
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
@@ -0,0 +1,308 @@
1/* zd_rf_al2230.c: Functions for the AL2230 RF controller
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#include <linux/kernel.h>
19
20#include "zd_rf.h"
21#include "zd_usb.h"
22#include "zd_chip.h"
23
24static const u32 al2230_table[][3] = {
25 RF_CHANNEL( 1) = { 0x03f790, 0x033331, 0x00000d, },
26 RF_CHANNEL( 2) = { 0x03f790, 0x0b3331, 0x00000d, },
27 RF_CHANNEL( 3) = { 0x03e790, 0x033331, 0x00000d, },
28 RF_CHANNEL( 4) = { 0x03e790, 0x0b3331, 0x00000d, },
29 RF_CHANNEL( 5) = { 0x03f7a0, 0x033331, 0x00000d, },
30 RF_CHANNEL( 6) = { 0x03f7a0, 0x0b3331, 0x00000d, },
31 RF_CHANNEL( 7) = { 0x03e7a0, 0x033331, 0x00000d, },
32 RF_CHANNEL( 8) = { 0x03e7a0, 0x0b3331, 0x00000d, },
33 RF_CHANNEL( 9) = { 0x03f7b0, 0x033331, 0x00000d, },
34 RF_CHANNEL(10) = { 0x03f7b0, 0x0b3331, 0x00000d, },
35 RF_CHANNEL(11) = { 0x03e7b0, 0x033331, 0x00000d, },
36 RF_CHANNEL(12) = { 0x03e7b0, 0x0b3331, 0x00000d, },
37 RF_CHANNEL(13) = { 0x03f7c0, 0x033331, 0x00000d, },
38 RF_CHANNEL(14) = { 0x03e7c0, 0x066661, 0x00000d, },
39};
40
41static int zd1211_al2230_init_hw(struct zd_rf *rf)
42{
43 int r;
44 struct zd_chip *chip = zd_rf_to_chip(rf);
45
46 static const struct zd_ioreq16 ioreqs[] = {
47 { CR15, 0x20 }, { CR23, 0x40 }, { CR24, 0x20 },
48 { CR26, 0x11 }, { CR28, 0x3e }, { CR29, 0x00 },
49 { CR44, 0x33 }, { CR106, 0x2a }, { CR107, 0x1a },
50 { CR109, 0x09 }, { CR110, 0x27 }, { CR111, 0x2b },
51 { CR112, 0x2b }, { CR119, 0x0a }, { CR10, 0x89 },
52 /* for newest (3rd cut) AL2300 */
53 { CR17, 0x28 },
54 { CR26, 0x93 }, { CR34, 0x30 },
55 /* for newest (3rd cut) AL2300 */
56 { CR35, 0x3e },
57 { CR41, 0x24 }, { CR44, 0x32 },
58 /* for newest (3rd cut) AL2300 */
59 { CR46, 0x96 },
60 { CR47, 0x1e }, { CR79, 0x58 }, { CR80, 0x30 },
61 { CR81, 0x30 }, { CR87, 0x0a }, { CR89, 0x04 },
62 { CR92, 0x0a }, { CR99, 0x28 }, { CR100, 0x00 },
63 { CR101, 0x13 }, { CR102, 0x27 }, { CR106, 0x24 },
64 { CR107, 0x2a }, { CR109, 0x09 }, { CR110, 0x13 },
65 { CR111, 0x1f }, { CR112, 0x1f }, { CR113, 0x27 },
66 { CR114, 0x27 },
67 /* for newest (3rd cut) AL2300 */
68 { CR115, 0x24 },
69 { CR116, 0x24 }, { CR117, 0xf4 }, { CR118, 0xfc },
70 { CR119, 0x10 }, { CR120, 0x4f }, { CR121, 0x77 },
71 { CR122, 0xe0 }, { CR137, 0x88 }, { CR252, 0xff },
72 { CR253, 0xff },
73
74 /* These following happen separately in the vendor driver */
75 { },
76
77 /* shdnb(PLL_ON)=0 */
78 { CR251, 0x2f },
79 /* shdnb(PLL_ON)=1 */
80 { CR251, 0x3f },
81 { CR138, 0x28 }, { CR203, 0x06 },
82 };
83
84 static const u32 rv[] = {
85 /* Channel 1 */
86 0x03f790,
87 0x033331,
88 0x00000d,
89
90 0x0b3331,
91 0x03b812,
92 0x00fff3,
93 0x000da4,
94 0x0f4dc5, /* fix freq shift, 0x04edc5 */
95 0x0805b6,
96 0x011687,
97 0x000688,
98 0x0403b9, /* external control TX power (CR31) */
99 0x00dbba,
100 0x00099b,
101 0x0bdffc,
102 0x00000d,
103 0x00500f,
104
105 /* These writes happen separately in the vendor driver */
106 0x00d00f,
107 0x004c0f,
108 0x00540f,
109 0x00700f,
110 0x00500f,
111 };
112
113 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
114 if (r)
115 return r;
116
117 r = zd_rfwritev_locked(chip, rv, ARRAY_SIZE(rv), RF_RV_BITS);
118 if (r)
119 return r;
120
121 return 0;
122}
123
124static int zd1211b_al2230_init_hw(struct zd_rf *rf)
125{
126 int r;
127 struct zd_chip *chip = zd_rf_to_chip(rf);
128
129 static const struct zd_ioreq16 ioreqs1[] = {
130 { CR10, 0x89 }, { CR15, 0x20 },
131 { CR17, 0x2B }, /* for newest(3rd cut) AL2230 */
132 { CR23, 0x40 }, { CR24, 0x20 }, { CR26, 0x93 },
133 { CR28, 0x3e }, { CR29, 0x00 },
134 { CR33, 0x28 }, /* 5621 */
135 { CR34, 0x30 },
136 { CR35, 0x3e }, /* for newest(3rd cut) AL2230 */
137 { CR41, 0x24 }, { CR44, 0x32 },
138 { CR46, 0x99 }, /* for newest(3rd cut) AL2230 */
139 { CR47, 0x1e },
140
141 /* ZD1211B 05.06.10 */
142 { CR48, 0x00 }, { CR49, 0x00 }, { CR51, 0x01 },
143 { CR52, 0x80 }, { CR53, 0x7e }, { CR65, 0x00 },
144 { CR66, 0x00 }, { CR67, 0x00 }, { CR68, 0x00 },
145 { CR69, 0x28 },
146
147 { CR79, 0x58 }, { CR80, 0x30 }, { CR81, 0x30 },
148 { CR87, 0x0a }, { CR89, 0x04 },
149 { CR91, 0x00 }, /* 5621 */
150 { CR92, 0x0a },
151 { CR98, 0x8d }, /* 4804, for 1212 new algorithm */
152 { CR99, 0x00 }, /* 5621 */
153 { CR101, 0x13 }, { CR102, 0x27 },
154 { CR106, 0x24 }, /* for newest(3rd cut) AL2230 */
155 { CR107, 0x2a },
156 { CR109, 0x13 }, /* 4804, for 1212 new algorithm */
157 { CR110, 0x1f }, /* 4804, for 1212 new algorithm */
158 { CR111, 0x1f }, { CR112, 0x1f }, { CR113, 0x27 },
159 { CR114, 0x27 },
160 { CR115, 0x26 }, /* 24->26 at 4902 for newest(3rd cut) AL2230 */
161 { CR116, 0x24 },
162 { CR117, 0xfa }, /* for 1211b */
163 { CR118, 0xfa }, /* for 1211b */
164 { CR119, 0x10 },
165 { CR120, 0x4f },
166 { CR121, 0x6c }, /* for 1211b */
167 { CR122, 0xfc }, /* E0->FC at 4902 */
168 { CR123, 0x57 }, /* 5623 */
169 { CR125, 0xad }, /* 4804, for 1212 new algorithm */
170 { CR126, 0x6c }, /* 5614 */
171 { CR127, 0x03 }, /* 4804, for 1212 new algorithm */
172 { CR137, 0x50 }, /* 5614 */
173 { CR138, 0xa8 },
174 { CR144, 0xac }, /* 5621 */
175 { CR150, 0x0d }, { CR252, 0x00 }, { CR253, 0x00 },
176 };
177
178 static const u32 rv1[] = {
179 /* channel 1 */
180 0x03f790,
181 0x033331,
182 0x00000d,
183
184 0x0b3331,
185 0x03b812,
186 0x00fff3,
187 0x0005a4,
188 0x0f4dc5, /* fix freq shift 0x044dc5 */
189 0x0805b6,
190 0x0146c7,
191 0x000688,
192 0x0403b9, /* External control TX power (CR31) */
193 0x00dbba,
194 0x00099b,
195 0x0bdffc,
196 0x00000d,
197 0x00580f,
198 };
199
200 static const struct zd_ioreq16 ioreqs2[] = {
201 { CR47, 0x1e }, { CR_RFCFG, 0x03 },
202 };
203
204 static const u32 rv2[] = {
205 0x00880f,
206 0x00080f,
207 };
208
209 static const struct zd_ioreq16 ioreqs3[] = {
210 { CR_RFCFG, 0x00 }, { CR47, 0x1e }, { CR251, 0x7f },
211 };
212
213 static const u32 rv3[] = {
214 0x00d80f,
215 0x00780f,
216 0x00580f,
217 };
218
219 static const struct zd_ioreq16 ioreqs4[] = {
220 { CR138, 0x28 }, { CR203, 0x06 },
221 };
222
223 r = zd_iowrite16a_locked(chip, ioreqs1, ARRAY_SIZE(ioreqs1));
224 if (r)
225 return r;
226 r = zd_rfwritev_locked(chip, rv1, ARRAY_SIZE(rv1), RF_RV_BITS);
227 if (r)
228 return r;
229 r = zd_iowrite16a_locked(chip, ioreqs2, ARRAY_SIZE(ioreqs2));
230 if (r)
231 return r;
232 r = zd_rfwritev_locked(chip, rv2, ARRAY_SIZE(rv2), RF_RV_BITS);
233 if (r)
234 return r;
235 r = zd_iowrite16a_locked(chip, ioreqs3, ARRAY_SIZE(ioreqs3));
236 if (r)
237 return r;
238 r = zd_rfwritev_locked(chip, rv3, ARRAY_SIZE(rv3), RF_RV_BITS);
239 if (r)
240 return r;
241 return zd_iowrite16a_locked(chip, ioreqs4, ARRAY_SIZE(ioreqs4));
242}
243
244static int al2230_set_channel(struct zd_rf *rf, u8 channel)
245{
246 int r;
247 const u32 *rv = al2230_table[channel-1];
248 struct zd_chip *chip = zd_rf_to_chip(rf);
249 static const struct zd_ioreq16 ioreqs[] = {
250 { CR138, 0x28 },
251 { CR203, 0x06 },
252 };
253
254 r = zd_rfwritev_locked(chip, rv, 3, RF_RV_BITS);
255 if (r)
256 return r;
257 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
258}
259
260static int zd1211_al2230_switch_radio_on(struct zd_rf *rf)
261{
262 struct zd_chip *chip = zd_rf_to_chip(rf);
263 static const struct zd_ioreq16 ioreqs[] = {
264 { CR11, 0x00 },
265 { CR251, 0x3f },
266 };
267
268 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
269}
270
271static int zd1211b_al2230_switch_radio_on(struct zd_rf *rf)
272{
273 struct zd_chip *chip = zd_rf_to_chip(rf);
274 static const struct zd_ioreq16 ioreqs[] = {
275 { CR11, 0x00 },
276 { CR251, 0x7f },
277 };
278
279 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
280}
281
282static int al2230_switch_radio_off(struct zd_rf *rf)
283{
284 struct zd_chip *chip = zd_rf_to_chip(rf);
285 static const struct zd_ioreq16 ioreqs[] = {
286 { CR11, 0x04 },
287 { CR251, 0x2f },
288 };
289
290 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
291}
292
293int zd_rf_init_al2230(struct zd_rf *rf)
294{
295 struct zd_chip *chip = zd_rf_to_chip(rf);
296
297 rf->set_channel = al2230_set_channel;
298 rf->switch_radio_off = al2230_switch_radio_off;
299 if (chip->is_zd1211b) {
300 rf->init_hw = zd1211b_al2230_init_hw;
301 rf->switch_radio_on = zd1211b_al2230_switch_radio_on;
302 } else {
303 rf->init_hw = zd1211_al2230_init_hw;
304 rf->switch_radio_on = zd1211_al2230_switch_radio_on;
305 }
306 rf->patch_6m_band_edge = 1;
307 return 0;
308}
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_rf2959.c b/drivers/net/wireless/zd1211rw/zd_rf_rf2959.c
new file mode 100644
index 000000000000..58247271cc24
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_rf_rf2959.c
@@ -0,0 +1,279 @@
1/* zd_rf_rfmd.c: Functions for the RFMD RF controller
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#include <linux/kernel.h>
19
20#include "zd_rf.h"
21#include "zd_usb.h"
22#include "zd_chip.h"
23
24static u32 rf2959_table[][2] = {
25 RF_CHANNEL( 1) = { 0x181979, 0x1e6666 },
26 RF_CHANNEL( 2) = { 0x181989, 0x1e6666 },
27 RF_CHANNEL( 3) = { 0x181999, 0x1e6666 },
28 RF_CHANNEL( 4) = { 0x1819a9, 0x1e6666 },
29 RF_CHANNEL( 5) = { 0x1819b9, 0x1e6666 },
30 RF_CHANNEL( 6) = { 0x1819c9, 0x1e6666 },
31 RF_CHANNEL( 7) = { 0x1819d9, 0x1e6666 },
32 RF_CHANNEL( 8) = { 0x1819e9, 0x1e6666 },
33 RF_CHANNEL( 9) = { 0x1819f9, 0x1e6666 },
34 RF_CHANNEL(10) = { 0x181a09, 0x1e6666 },
35 RF_CHANNEL(11) = { 0x181a19, 0x1e6666 },
36 RF_CHANNEL(12) = { 0x181a29, 0x1e6666 },
37 RF_CHANNEL(13) = { 0x181a39, 0x1e6666 },
38 RF_CHANNEL(14) = { 0x181a60, 0x1c0000 },
39};
40
41#if 0
42static int bits(u32 rw, int from, int to)
43{
44 rw &= ~(0xffffffffU << (to+1));
45 rw >>= from;
46 return rw;
47}
48
49static int bit(u32 rw, int bit)
50{
51 return bits(rw, bit, bit);
52}
53
54static void dump_regwrite(u32 rw)
55{
56 int reg = bits(rw, 18, 22);
57 int rw_flag = bits(rw, 23, 23);
58 PDEBUG("rf2959 %#010x reg %d rw %d", rw, reg, rw_flag);
59
60 switch (reg) {
61 case 0:
62 PDEBUG("reg0 CFG1 ref_sel %d hybernate %d rf_vco_reg_en %d"
63 " if_vco_reg_en %d if_vga_en %d",
64 bits(rw, 14, 15), bit(rw, 3), bit(rw, 2), bit(rw, 1),
65 bit(rw, 0));
66 break;
67 case 1:
68 PDEBUG("reg1 IFPLL1 pll_en1 %d kv_en1 %d vtc_en1 %d lpf1 %d"
69 " cpl1 %d pdp1 %d autocal_en1 %d ld_en1 %d ifloopr %d"
70 " ifloopc %d dac1 %d",
71 bit(rw, 17), bit(rw, 16), bit(rw, 15), bit(rw, 14),
72 bit(rw, 13), bit(rw, 12), bit(rw, 11), bit(rw, 10),
73 bits(rw, 7, 9), bits(rw, 4, 6), bits(rw, 0, 3));
74 break;
75 case 2:
76 PDEBUG("reg2 IFPLL2 n1 %d num1 %d",
77 bits(rw, 6, 17), bits(rw, 0, 5));
78 break;
79 case 3:
80 PDEBUG("reg3 IFPLL3 num %d", bits(rw, 0, 17));
81 break;
82 case 4:
83 PDEBUG("reg4 IFPLL4 dn1 %#04x ct_def1 %d kv_def1 %d",
84 bits(rw, 8, 16), bits(rw, 4, 7), bits(rw, 0, 3));
85 break;
86 case 5:
87 PDEBUG("reg5 RFPLL1 pll_en %d kv_en %d vtc_en %d lpf %d cpl %d"
88 " pdp %d autocal_en %d ld_en %d rfloopr %d rfloopc %d"
89 " dac %d",
90 bit(rw, 17), bit(rw, 16), bit(rw, 15), bit(rw, 14),
91 bit(rw, 13), bit(rw, 12), bit(rw, 11), bit(rw, 10),
92 bits(rw, 7, 9), bits(rw, 4, 6), bits(rw, 0,3));
93 break;
94 case 6:
95 PDEBUG("reg6 RFPLL2 n %d num %d",
96 bits(rw, 6, 17), bits(rw, 0, 5));
97 break;
98 case 7:
99 PDEBUG("reg7 RFPLL3 num2 %d", bits(rw, 0, 17));
100 break;
101 case 8:
102 PDEBUG("reg8 RFPLL4 dn %#06x ct_def %d kv_def %d",
103 bits(rw, 8, 16), bits(rw, 4, 7), bits(rw, 0, 3));
104 break;
105 case 9:
106 PDEBUG("reg9 CAL1 tvco %d tlock %d m_ct_value %d ld_window %d",
107 bits(rw, 13, 17), bits(rw, 8, 12), bits(rw, 3, 7),
108 bits(rw, 0, 2));
109 break;
110 case 10:
111 PDEBUG("reg10 TXRX1 rxdcfbbyps %d pcontrol %d txvgc %d"
112 " rxlpfbw %d txlpfbw %d txdiffmode %d txenmode %d"
113 " intbiasen %d tybypass %d",
114 bit(rw, 17), bits(rw, 15, 16), bits(rw, 10, 14),
115 bits(rw, 7, 9), bits(rw, 4, 6), bit(rw, 3), bit(rw, 2),
116 bit(rw, 1), bit(rw, 0));
117 break;
118 case 11:
119 PDEBUG("reg11 PCNT1 mid_bias %d p_desired %d pc_offset %d"
120 " tx_delay %d",
121 bits(rw, 15, 17), bits(rw, 9, 14), bits(rw, 3, 8),
122 bits(rw, 0, 2));
123 break;
124 case 12:
125 PDEBUG("reg12 PCNT2 max_power %d mid_power %d min_power %d",
126 bits(rw, 12, 17), bits(rw, 6, 11), bits(rw, 0, 5));
127 break;
128 case 13:
129 PDEBUG("reg13 VCOT1 rfpll vco comp %d ifpll vco comp %d"
130 " lobias %d if_biasbuf %d if_biasvco %d rf_biasbuf %d"
131 " rf_biasvco %d",
132 bit(rw, 17), bit(rw, 16), bit(rw, 15),
133 bits(rw, 8, 9), bits(rw, 5, 7), bits(rw, 3, 4),
134 bits(rw, 0, 2));
135 break;
136 case 14:
137 PDEBUG("reg14 IQCAL rx_acal %d rx_pcal %d"
138 " tx_acal %d tx_pcal %d",
139 bits(rw, 13, 17), bits(rw, 9, 12), bits(rw, 4, 8),
140 bits(rw, 0, 3));
141 break;
142 }
143}
144#endif /* 0 */
145
146static int rf2959_init_hw(struct zd_rf *rf)
147{
148 int r;
149 struct zd_chip *chip = zd_rf_to_chip(rf);
150
151 static const struct zd_ioreq16 ioreqs[] = {
152 { CR2, 0x1E }, { CR9, 0x20 }, { CR10, 0x89 },
153 { CR11, 0x00 }, { CR15, 0xD0 }, { CR17, 0x68 },
154 { CR19, 0x4a }, { CR20, 0x0c }, { CR21, 0x0E },
155 { CR23, 0x48 },
156 /* normal size for cca threshold */
157 { CR24, 0x14 },
158 /* { CR24, 0x20 }, */
159 { CR26, 0x90 }, { CR27, 0x30 }, { CR29, 0x20 },
160 { CR31, 0xb2 }, { CR32, 0x43 }, { CR33, 0x28 },
161 { CR38, 0x30 }, { CR34, 0x0f }, { CR35, 0xF0 },
162 { CR41, 0x2a }, { CR46, 0x7F }, { CR47, 0x1E },
163 { CR51, 0xc5 }, { CR52, 0xc5 }, { CR53, 0xc5 },
164 { CR79, 0x58 }, { CR80, 0x30 }, { CR81, 0x30 },
165 { CR82, 0x00 }, { CR83, 0x24 }, { CR84, 0x04 },
166 { CR85, 0x00 }, { CR86, 0x10 }, { CR87, 0x2A },
167 { CR88, 0x10 }, { CR89, 0x24 }, { CR90, 0x18 },
168 /* { CR91, 0x18 }, */
169 /* should solve continous CTS frame problems */
170 { CR91, 0x00 },
171 { CR92, 0x0a }, { CR93, 0x00 }, { CR94, 0x01 },
172 { CR95, 0x00 }, { CR96, 0x40 }, { CR97, 0x37 },
173 { CR98, 0x05 }, { CR99, 0x28 }, { CR100, 0x00 },
174 { CR101, 0x13 }, { CR102, 0x27 }, { CR103, 0x27 },
175 { CR104, 0x18 }, { CR105, 0x12 },
176 /* normal size */
177 { CR106, 0x1a },
178 /* { CR106, 0x22 }, */
179 { CR107, 0x24 }, { CR108, 0x0a }, { CR109, 0x13 },
180 { CR110, 0x2F }, { CR111, 0x27 }, { CR112, 0x27 },
181 { CR113, 0x27 }, { CR114, 0x27 }, { CR115, 0x40 },
182 { CR116, 0x40 }, { CR117, 0xF0 }, { CR118, 0xF0 },
183 { CR119, 0x16 },
184 /* no TX continuation */
185 { CR122, 0x00 },
186 /* { CR122, 0xff }, */
187 { CR127, 0x03 }, { CR131, 0x08 }, { CR138, 0x28 },
188 { CR148, 0x44 }, { CR150, 0x10 }, { CR169, 0xBB },
189 { CR170, 0xBB },
190 };
191
192 static const u32 rv[] = {
193 0x000007, /* REG0(CFG1) */
194 0x07dd43, /* REG1(IFPLL1) */
195 0x080959, /* REG2(IFPLL2) */
196 0x0e6666,
197 0x116a57, /* REG4 */
198 0x17dd43, /* REG5 */
199 0x1819f9, /* REG6 */
200 0x1e6666,
201 0x214554,
202 0x25e7fa,
203 0x27fffa,
204 /* The Zydas driver somehow forgets to set this value. It's
205 * only set for Japan. We are using internal power control
206 * for now.
207 */
208 0x294128, /* internal power */
209 /* 0x28252c, */ /* External control TX power */
210 /* CR31_CCK, CR51_6-36M, CR52_48M, CR53_54M */
211 0x2c0000,
212 0x300000,
213 0x340000, /* REG13(0xD) */
214 0x381e0f, /* REG14(0xE) */
215 /* Bogus, RF2959's data sheet doesn't know register 27, which is
216 * actually referenced here. The commented 0x11 is 17.
217 */
218 0x6c180f, /* REG27(0x11) */
219 };
220
221 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
222 if (r)
223 return r;
224
225 return zd_rfwritev_locked(chip, rv, ARRAY_SIZE(rv), RF_RV_BITS);
226}
227
228static int rf2959_set_channel(struct zd_rf *rf, u8 channel)
229{
230 int i, r;
231 u32 *rv = rf2959_table[channel-1];
232 struct zd_chip *chip = zd_rf_to_chip(rf);
233
234 for (i = 0; i < 2; i++) {
235 r = zd_rfwrite_locked(chip, rv[i], RF_RV_BITS);
236 if (r)
237 return r;
238 }
239 return 0;
240}
241
242static int rf2959_switch_radio_on(struct zd_rf *rf)
243{
244 static const struct zd_ioreq16 ioreqs[] = {
245 { CR10, 0x89 },
246 { CR11, 0x00 },
247 };
248 struct zd_chip *chip = zd_rf_to_chip(rf);
249
250 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
251}
252
253static int rf2959_switch_radio_off(struct zd_rf *rf)
254{
255 static const struct zd_ioreq16 ioreqs[] = {
256 { CR10, 0x15 },
257 { CR11, 0x81 },
258 };
259 struct zd_chip *chip = zd_rf_to_chip(rf);
260
261 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
262}
263
264int zd_rf_init_rf2959(struct zd_rf *rf)
265{
266 struct zd_chip *chip = zd_rf_to_chip(rf);
267
268 if (chip->is_zd1211b) {
269 dev_err(zd_chip_dev(chip),
270 "RF2959 is currently not supported for ZD1211B"
271 " devices\n");
272 return -ENODEV;
273 }
274 rf->init_hw = rf2959_init_hw;
275 rf->set_channel = rf2959_set_channel;
276 rf->switch_radio_on = rf2959_switch_radio_on;
277 rf->switch_radio_off = rf2959_switch_radio_off;
278 return 0;
279}
diff --git a/drivers/net/wireless/zd1211rw/zd_types.h b/drivers/net/wireless/zd1211rw/zd_types.h
new file mode 100644
index 000000000000..0155a1584ed3
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_types.h
@@ -0,0 +1,71 @@
1/* zd_types.h
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#ifndef _ZD_TYPES_H
19#define _ZD_TYPES_H
20
21#include <linux/types.h>
22
23/* We have three register spaces mapped into the overall USB address space of
24 * 64K words (16-bit values). There is the control register space of
25 * double-word registers, the eeprom register space and the firmware register
26 * space. The control register space is byte mapped, the others are word
27 * mapped.
28 *
29 * For that reason, we are using byte offsets for control registers and word
30 * offsets for everything else.
31 */
32
33typedef u32 __nocast zd_addr_t;
34
35enum {
36 ADDR_BASE_MASK = 0xff000000,
37 ADDR_OFFSET_MASK = 0x0000ffff,
38 ADDR_ZERO_MASK = 0x00ff0000,
39 NULL_BASE = 0x00000000,
40 USB_BASE = 0x01000000,
41 CR_BASE = 0x02000000,
42 CR_MAX_OFFSET = 0x0b30,
43 E2P_BASE = 0x03000000,
44 E2P_MAX_OFFSET = 0x007e,
45 FW_BASE = 0x04000000,
46 FW_MAX_OFFSET = 0x0005,
47};
48
49#define ZD_ADDR_BASE(addr) ((u32)(addr) & ADDR_BASE_MASK)
50#define ZD_OFFSET(addr) ((u32)(addr) & ADDR_OFFSET_MASK)
51
52#define ZD_ADDR(base, offset) \
53 ((zd_addr_t)(((base) & ADDR_BASE_MASK) | ((offset) & ADDR_OFFSET_MASK)))
54
55#define ZD_NULL_ADDR ((zd_addr_t)0)
56#define USB_REG(offset) ZD_ADDR(USB_BASE, offset) /* word addressing */
57#define CTL_REG(offset) ZD_ADDR(CR_BASE, offset) /* byte addressing */
58#define E2P_REG(offset) ZD_ADDR(E2P_BASE, offset) /* word addressing */
59#define FW_REG(offset) ZD_ADDR(FW_BASE, offset) /* word addressing */
60
61static inline zd_addr_t zd_inc_word(zd_addr_t addr)
62{
63 u32 base = ZD_ADDR_BASE(addr);
64 u32 offset = ZD_OFFSET(addr);
65
66 offset += base == CR_BASE ? 2 : 1;
67
68 return base | offset;
69}
70
71#endif /* _ZD_TYPES_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
new file mode 100644
index 000000000000..ce1cb2c6aa8d
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -0,0 +1,1316 @@
1/* zd_usb.c
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#include <asm/unaligned.h>
19#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/firmware.h>
22#include <linux/device.h>
23#include <linux/errno.h>
24#include <linux/skbuff.h>
25#include <linux/usb.h>
26#include <net/ieee80211.h>
27
28#include "zd_def.h"
29#include "zd_netdev.h"
30#include "zd_mac.h"
31#include "zd_usb.h"
32#include "zd_util.h"
33
34static struct usb_device_id usb_ids[] = {
35 /* ZD1211 */
36 { USB_DEVICE(0x0ace, 0x1211), .driver_info = DEVICE_ZD1211 },
37 { USB_DEVICE(0x07b8, 0x6001), .driver_info = DEVICE_ZD1211 },
38 { USB_DEVICE(0x126f, 0xa006), .driver_info = DEVICE_ZD1211 },
39 { USB_DEVICE(0x6891, 0xa727), .driver_info = DEVICE_ZD1211 },
40 { USB_DEVICE(0x0df6, 0x9071), .driver_info = DEVICE_ZD1211 },
41 { USB_DEVICE(0x157e, 0x300b), .driver_info = DEVICE_ZD1211 },
42 /* ZD1211B */
43 { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B },
44 { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B },
45 {}
46};
47
48MODULE_LICENSE("GPL");
49MODULE_DESCRIPTION("USB driver for devices with the ZD1211 chip.");
50MODULE_AUTHOR("Ulrich Kunitz");
51MODULE_AUTHOR("Daniel Drake");
52MODULE_VERSION("1.0");
53MODULE_DEVICE_TABLE(usb, usb_ids);
54
55#define FW_ZD1211_PREFIX "zd1211/zd1211_"
56#define FW_ZD1211B_PREFIX "zd1211/zd1211b_"
57
58/* register address handling */
59
60#ifdef DEBUG
61static int check_addr(struct zd_usb *usb, zd_addr_t addr)
62{
63 u32 base = ZD_ADDR_BASE(addr);
64 u32 offset = ZD_OFFSET(addr);
65
66 if ((u32)addr & ADDR_ZERO_MASK)
67 goto invalid_address;
68 switch (base) {
69 case USB_BASE:
70 break;
71 case CR_BASE:
72 if (offset > CR_MAX_OFFSET) {
73 dev_dbg(zd_usb_dev(usb),
74 "CR offset %#010x larger than"
75 " CR_MAX_OFFSET %#10x\n",
76 offset, CR_MAX_OFFSET);
77 goto invalid_address;
78 }
79 if (offset & 1) {
80 dev_dbg(zd_usb_dev(usb),
81 "CR offset %#010x is not a multiple of 2\n",
82 offset);
83 goto invalid_address;
84 }
85 break;
86 case E2P_BASE:
87 if (offset > E2P_MAX_OFFSET) {
88 dev_dbg(zd_usb_dev(usb),
89 "E2P offset %#010x larger than"
90 " E2P_MAX_OFFSET %#010x\n",
91 offset, E2P_MAX_OFFSET);
92 goto invalid_address;
93 }
94 break;
95 case FW_BASE:
96 if (!usb->fw_base_offset) {
97 dev_dbg(zd_usb_dev(usb),
98 "ERROR: fw base offset has not been set\n");
99 return -EAGAIN;
100 }
101 if (offset > FW_MAX_OFFSET) {
102 dev_dbg(zd_usb_dev(usb),
103 "FW offset %#10x is larger than"
104 " FW_MAX_OFFSET %#010x\n",
105 offset, FW_MAX_OFFSET);
106 goto invalid_address;
107 }
108 break;
109 default:
110 dev_dbg(zd_usb_dev(usb),
111 "address has unsupported base %#010x\n", addr);
112 goto invalid_address;
113 }
114
115 return 0;
116invalid_address:
117 dev_dbg(zd_usb_dev(usb),
118 "ERROR: invalid address: %#010x\n", addr);
119 return -EINVAL;
120}
121#endif /* DEBUG */
122
123static u16 usb_addr(struct zd_usb *usb, zd_addr_t addr)
124{
125 u32 base;
126 u16 offset;
127
128 base = ZD_ADDR_BASE(addr);
129 offset = ZD_OFFSET(addr);
130
131 ZD_ASSERT(check_addr(usb, addr) == 0);
132
133 switch (base) {
134 case CR_BASE:
135 offset += CR_BASE_OFFSET;
136 break;
137 case E2P_BASE:
138 offset += E2P_BASE_OFFSET;
139 break;
140 case FW_BASE:
141 offset += usb->fw_base_offset;
142 break;
143 }
144
145 return offset;
146}
147
148/* USB device initialization */
149
150static int request_fw_file(
151 const struct firmware **fw, const char *name, struct device *device)
152{
153 int r;
154
155 dev_dbg_f(device, "fw name %s\n", name);
156
157 r = request_firmware(fw, name, device);
158 if (r)
159 dev_err(device,
160 "Could not load firmware file %s. Error number %d\n",
161 name, r);
162 return r;
163}
164
165static inline u16 get_bcdDevice(const struct usb_device *udev)
166{
167 return le16_to_cpu(udev->descriptor.bcdDevice);
168}
169
170enum upload_code_flags {
171 REBOOT = 1,
172};
173
174/* Ensures that MAX_TRANSFER_SIZE is even. */
175#define MAX_TRANSFER_SIZE (USB_MAX_TRANSFER_SIZE & ~1)
176
177static int upload_code(struct usb_device *udev,
178 const u8 *data, size_t size, u16 code_offset, int flags)
179{
180 u8 *p;
181 int r;
182
183 /* USB request blocks need "kmalloced" buffers.
184 */
185 p = kmalloc(MAX_TRANSFER_SIZE, GFP_KERNEL);
186 if (!p) {
187 dev_err(&udev->dev, "out of memory\n");
188 r = -ENOMEM;
189 goto error;
190 }
191
192 size &= ~1;
193 while (size > 0) {
194 size_t transfer_size = size <= MAX_TRANSFER_SIZE ?
195 size : MAX_TRANSFER_SIZE;
196
197 dev_dbg_f(&udev->dev, "transfer size %zu\n", transfer_size);
198
199 memcpy(p, data, transfer_size);
200 r = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
201 USB_REQ_FIRMWARE_DOWNLOAD,
202 USB_DIR_OUT | USB_TYPE_VENDOR,
203 code_offset, 0, p, transfer_size, 1000 /* ms */);
204 if (r < 0) {
205 dev_err(&udev->dev,
206 "USB control request for firmware upload"
207 " failed. Error number %d\n", r);
208 goto error;
209 }
210 transfer_size = r & ~1;
211
212 size -= transfer_size;
213 data += transfer_size;
214 code_offset += transfer_size/sizeof(u16);
215 }
216
217 if (flags & REBOOT) {
218 u8 ret;
219
220 r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
221 USB_REQ_FIRMWARE_CONFIRM,
222 USB_DIR_IN | USB_TYPE_VENDOR,
223 0, 0, &ret, sizeof(ret), 5000 /* ms */);
224 if (r != sizeof(ret)) {
225 dev_err(&udev->dev,
226 "control request firmeware confirmation failed."
227 " Return value %d\n", r);
228 if (r >= 0)
229 r = -ENODEV;
230 goto error;
231 }
232 if (ret & 0x80) {
233 dev_err(&udev->dev,
234 "Internal error while downloading."
235 " Firmware confirm return value %#04x\n",
236 (unsigned int)ret);
237 r = -ENODEV;
238 goto error;
239 }
240 dev_dbg_f(&udev->dev, "firmware confirm return value %#04x\n",
241 (unsigned int)ret);
242 }
243
244 r = 0;
245error:
246 kfree(p);
247 return r;
248}
249
250static u16 get_word(const void *data, u16 offset)
251{
252 const __le16 *p = data;
253 return le16_to_cpu(p[offset]);
254}
255
256static char *get_fw_name(char *buffer, size_t size, u8 device_type,
257 const char* postfix)
258{
259 scnprintf(buffer, size, "%s%s",
260 device_type == DEVICE_ZD1211B ?
261 FW_ZD1211B_PREFIX : FW_ZD1211_PREFIX,
262 postfix);
263 return buffer;
264}
265
266static int upload_firmware(struct usb_device *udev, u8 device_type)
267{
268 int r;
269 u16 fw_bcdDevice;
270 u16 bcdDevice;
271 const struct firmware *ub_fw = NULL;
272 const struct firmware *uph_fw = NULL;
273 char fw_name[128];
274
275 bcdDevice = get_bcdDevice(udev);
276
277 r = request_fw_file(&ub_fw,
278 get_fw_name(fw_name, sizeof(fw_name), device_type, "ub"),
279 &udev->dev);
280 if (r)
281 goto error;
282
283 fw_bcdDevice = get_word(ub_fw->data, EEPROM_REGS_OFFSET);
284
285 /* FIXME: do we have any reason to perform the kludge that the vendor
286 * driver does when there is a version mismatch? (their driver uploads
287 * different firmwares and stuff)
288 */
289 if (fw_bcdDevice != bcdDevice) {
290 dev_info(&udev->dev,
291 "firmware device id %#06x and actual device id "
292 "%#06x differ, continuing anyway\n",
293 fw_bcdDevice, bcdDevice);
294 } else {
295 dev_dbg_f(&udev->dev,
296 "firmware device id %#06x is equal to the "
297 "actual device id\n", fw_bcdDevice);
298 }
299
300
301 r = request_fw_file(&uph_fw,
302 get_fw_name(fw_name, sizeof(fw_name), device_type, "uphr"),
303 &udev->dev);
304 if (r)
305 goto error;
306
307 r = upload_code(udev, uph_fw->data, uph_fw->size, FW_START_OFFSET,
308 REBOOT);
309 if (r) {
310 dev_err(&udev->dev,
311 "Could not upload firmware code uph. Error number %d\n",
312 r);
313 }
314
315 /* FALL-THROUGH */
316error:
317 release_firmware(ub_fw);
318 release_firmware(uph_fw);
319 return r;
320}
321
322static void disable_read_regs_int(struct zd_usb *usb)
323{
324 struct zd_usb_interrupt *intr = &usb->intr;
325
326 ZD_ASSERT(in_interrupt());
327 spin_lock(&intr->lock);
328 intr->read_regs_enabled = 0;
329 spin_unlock(&intr->lock);
330}
331
332#define urb_dev(urb) (&(urb)->dev->dev)
333
334static inline void handle_regs_int(struct urb *urb)
335{
336 struct zd_usb *usb = urb->context;
337 struct zd_usb_interrupt *intr = &usb->intr;
338 int len;
339
340 ZD_ASSERT(in_interrupt());
341 spin_lock(&intr->lock);
342
343 if (intr->read_regs_enabled) {
344 intr->read_regs.length = len = urb->actual_length;
345
346 if (len > sizeof(intr->read_regs.buffer))
347 len = sizeof(intr->read_regs.buffer);
348 memcpy(intr->read_regs.buffer, urb->transfer_buffer, len);
349 intr->read_regs_enabled = 0;
350 complete(&intr->read_regs.completion);
351 goto out;
352 }
353
354 dev_dbg_f(urb_dev(urb), "regs interrupt ignored\n");
355out:
356 spin_unlock(&intr->lock);
357}
358
359static inline void handle_retry_failed_int(struct urb *urb)
360{
361 dev_dbg_f(urb_dev(urb), "retry failed interrupt\n");
362}
363
364
365static void int_urb_complete(struct urb *urb, struct pt_regs *pt_regs)
366{
367 int r;
368 struct usb_int_header *hdr;
369
370 switch (urb->status) {
371 case 0:
372 break;
373 case -ESHUTDOWN:
374 case -EINVAL:
375 case -ENODEV:
376 case -ENOENT:
377 case -ECONNRESET:
378 goto kfree;
379 case -EPIPE:
380 usb_clear_halt(urb->dev, EP_INT_IN);
381 /* FALL-THROUGH */
382 default:
383 goto resubmit;
384 }
385
386 if (urb->actual_length < sizeof(hdr)) {
387 dev_dbg_f(urb_dev(urb), "error: urb %p to small\n", urb);
388 goto resubmit;
389 }
390
391 hdr = urb->transfer_buffer;
392 if (hdr->type != USB_INT_TYPE) {
393 dev_dbg_f(urb_dev(urb), "error: urb %p wrong type\n", urb);
394 goto resubmit;
395 }
396
397 switch (hdr->id) {
398 case USB_INT_ID_REGS:
399 handle_regs_int(urb);
400 break;
401 case USB_INT_ID_RETRY_FAILED:
402 handle_retry_failed_int(urb);
403 break;
404 default:
405 dev_dbg_f(urb_dev(urb), "error: urb %p unknown id %x\n", urb,
406 (unsigned int)hdr->id);
407 goto resubmit;
408 }
409
410resubmit:
411 r = usb_submit_urb(urb, GFP_ATOMIC);
412 if (r) {
413 dev_dbg_f(urb_dev(urb), "resubmit urb %p\n", urb);
414 goto kfree;
415 }
416 return;
417kfree:
418 kfree(urb->transfer_buffer);
419}
420
421static inline int int_urb_interval(struct usb_device *udev)
422{
423 switch (udev->speed) {
424 case USB_SPEED_HIGH:
425 return 4;
426 case USB_SPEED_LOW:
427 return 10;
428 case USB_SPEED_FULL:
429 default:
430 return 1;
431 }
432}
433
434static inline int usb_int_enabled(struct zd_usb *usb)
435{
436 unsigned long flags;
437 struct zd_usb_interrupt *intr = &usb->intr;
438 struct urb *urb;
439
440 spin_lock_irqsave(&intr->lock, flags);
441 urb = intr->urb;
442 spin_unlock_irqrestore(&intr->lock, flags);
443 return urb != NULL;
444}
445
446int zd_usb_enable_int(struct zd_usb *usb)
447{
448 int r;
449 struct usb_device *udev;
450 struct zd_usb_interrupt *intr = &usb->intr;
451 void *transfer_buffer = NULL;
452 struct urb *urb;
453
454 dev_dbg_f(zd_usb_dev(usb), "\n");
455
456 urb = usb_alloc_urb(0, GFP_NOFS);
457 if (!urb) {
458 r = -ENOMEM;
459 goto out;
460 }
461
462 ZD_ASSERT(!irqs_disabled());
463 spin_lock_irq(&intr->lock);
464 if (intr->urb) {
465 spin_unlock_irq(&intr->lock);
466 r = 0;
467 goto error_free_urb;
468 }
469 intr->urb = urb;
470 spin_unlock_irq(&intr->lock);
471
472 /* TODO: make it a DMA buffer */
473 r = -ENOMEM;
474 transfer_buffer = kmalloc(USB_MAX_EP_INT_BUFFER, GFP_NOFS);
475 if (!transfer_buffer) {
476 dev_dbg_f(zd_usb_dev(usb),
477 "couldn't allocate transfer_buffer\n");
478 goto error_set_urb_null;
479 }
480
481 udev = zd_usb_to_usbdev(usb);
482 usb_fill_int_urb(urb, udev, usb_rcvintpipe(udev, EP_INT_IN),
483 transfer_buffer, USB_MAX_EP_INT_BUFFER,
484 int_urb_complete, usb,
485 intr->interval);
486
487 dev_dbg_f(zd_usb_dev(usb), "submit urb %p\n", intr->urb);
488 r = usb_submit_urb(urb, GFP_NOFS);
489 if (r) {
490 dev_dbg_f(zd_usb_dev(usb),
491 "Couldn't submit urb. Error number %d\n", r);
492 goto error;
493 }
494
495 return 0;
496error:
497 kfree(transfer_buffer);
498error_set_urb_null:
499 spin_lock_irq(&intr->lock);
500 intr->urb = NULL;
501 spin_unlock_irq(&intr->lock);
502error_free_urb:
503 usb_free_urb(urb);
504out:
505 return r;
506}
507
508void zd_usb_disable_int(struct zd_usb *usb)
509{
510 unsigned long flags;
511 struct zd_usb_interrupt *intr = &usb->intr;
512 struct urb *urb;
513
514 spin_lock_irqsave(&intr->lock, flags);
515 urb = intr->urb;
516 if (!urb) {
517 spin_unlock_irqrestore(&intr->lock, flags);
518 return;
519 }
520 intr->urb = NULL;
521 spin_unlock_irqrestore(&intr->lock, flags);
522
523 usb_kill_urb(urb);
524 dev_dbg_f(zd_usb_dev(usb), "urb %p killed\n", urb);
525 usb_free_urb(urb);
526}
527
528static void handle_rx_packet(struct zd_usb *usb, const u8 *buffer,
529 unsigned int length)
530{
531 int i;
532 struct zd_mac *mac = zd_usb_to_mac(usb);
533 const struct rx_length_info *length_info;
534
535 if (length < sizeof(struct rx_length_info)) {
536 /* It's not a complete packet anyhow. */
537 return;
538 }
539 length_info = (struct rx_length_info *)
540 (buffer + length - sizeof(struct rx_length_info));
541
542 /* It might be that three frames are merged into a single URB
543 * transaction. We have to check for the length info tag.
544 *
545 * While testing we discovered that length_info might be unaligned,
546 * because if USB transactions are merged, the last packet will not
547 * be padded. Unaligned access might also happen if the length_info
548 * structure is not present.
549 */
550 if (get_unaligned(&length_info->tag) == RX_LENGTH_INFO_TAG) {
551 unsigned int l, k, n;
552 for (i = 0, l = 0;; i++) {
553 k = le16_to_cpu(get_unaligned(
554 &length_info->length[i]));
555 n = l+k;
556 if (n > length)
557 return;
558 zd_mac_rx(mac, buffer+l, k);
559 if (i >= 2)
560 return;
561 l = (n+3) & ~3;
562 }
563 } else {
564 zd_mac_rx(mac, buffer, length);
565 }
566}
567
568static void rx_urb_complete(struct urb *urb, struct pt_regs *pt_regs)
569{
570 struct zd_usb *usb;
571 struct zd_usb_rx *rx;
572 const u8 *buffer;
573 unsigned int length;
574
575 switch (urb->status) {
576 case 0:
577 break;
578 case -ESHUTDOWN:
579 case -EINVAL:
580 case -ENODEV:
581 case -ENOENT:
582 case -ECONNRESET:
583 return;
584 case -EPIPE:
585 usb_clear_halt(urb->dev, EP_DATA_IN);
586 /* FALL-THROUGH */
587 default:
588 dev_dbg_f(urb_dev(urb), "urb %p error %d\n", urb, urb->status);
589 goto resubmit;
590 }
591
592 buffer = urb->transfer_buffer;
593 length = urb->actual_length;
594 usb = urb->context;
595 rx = &usb->rx;
596
597 if (length%rx->usb_packet_size > rx->usb_packet_size-4) {
598 /* If there is an old first fragment, we don't care. */
599 dev_dbg_f(urb_dev(urb), "*** first fragment ***\n");
600 ZD_ASSERT(length <= ARRAY_SIZE(rx->fragment));
601 spin_lock(&rx->lock);
602 memcpy(rx->fragment, buffer, length);
603 rx->fragment_length = length;
604 spin_unlock(&rx->lock);
605 goto resubmit;
606 }
607
608 spin_lock(&rx->lock);
609 if (rx->fragment_length > 0) {
610 /* We are on a second fragment, we believe */
611 ZD_ASSERT(length + rx->fragment_length <=
612 ARRAY_SIZE(rx->fragment));
613 dev_dbg_f(urb_dev(urb), "*** second fragment ***\n");
614 memcpy(rx->fragment+rx->fragment_length, buffer, length);
615 handle_rx_packet(usb, rx->fragment,
616 rx->fragment_length + length);
617 rx->fragment_length = 0;
618 spin_unlock(&rx->lock);
619 } else {
620 spin_unlock(&rx->lock);
621 handle_rx_packet(usb, buffer, length);
622 }
623
624resubmit:
625 usb_submit_urb(urb, GFP_ATOMIC);
626}
627
628struct urb *alloc_urb(struct zd_usb *usb)
629{
630 struct usb_device *udev = zd_usb_to_usbdev(usb);
631 struct urb *urb;
632 void *buffer;
633
634 urb = usb_alloc_urb(0, GFP_NOFS);
635 if (!urb)
636 return NULL;
637 buffer = usb_buffer_alloc(udev, USB_MAX_RX_SIZE, GFP_NOFS,
638 &urb->transfer_dma);
639 if (!buffer) {
640 usb_free_urb(urb);
641 return NULL;
642 }
643
644 usb_fill_bulk_urb(urb, udev, usb_rcvbulkpipe(udev, EP_DATA_IN),
645 buffer, USB_MAX_RX_SIZE,
646 rx_urb_complete, usb);
647 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
648
649 return urb;
650}
651
652void free_urb(struct urb *urb)
653{
654 if (!urb)
655 return;
656 usb_buffer_free(urb->dev, urb->transfer_buffer_length,
657 urb->transfer_buffer, urb->transfer_dma);
658 usb_free_urb(urb);
659}
660
661int zd_usb_enable_rx(struct zd_usb *usb)
662{
663 int i, r;
664 struct zd_usb_rx *rx = &usb->rx;
665 struct urb **urbs;
666
667 dev_dbg_f(zd_usb_dev(usb), "\n");
668
669 r = -ENOMEM;
670 urbs = kcalloc(URBS_COUNT, sizeof(struct urb *), GFP_NOFS);
671 if (!urbs)
672 goto error;
673 for (i = 0; i < URBS_COUNT; i++) {
674 urbs[i] = alloc_urb(usb);
675 if (!urbs[i])
676 goto error;
677 }
678
679 ZD_ASSERT(!irqs_disabled());
680 spin_lock_irq(&rx->lock);
681 if (rx->urbs) {
682 spin_unlock_irq(&rx->lock);
683 r = 0;
684 goto error;
685 }
686 rx->urbs = urbs;
687 rx->urbs_count = URBS_COUNT;
688 spin_unlock_irq(&rx->lock);
689
690 for (i = 0; i < URBS_COUNT; i++) {
691 r = usb_submit_urb(urbs[i], GFP_NOFS);
692 if (r)
693 goto error_submit;
694 }
695
696 return 0;
697error_submit:
698 for (i = 0; i < URBS_COUNT; i++) {
699 usb_kill_urb(urbs[i]);
700 }
701 spin_lock_irq(&rx->lock);
702 rx->urbs = NULL;
703 rx->urbs_count = 0;
704 spin_unlock_irq(&rx->lock);
705error:
706 if (urbs) {
707 for (i = 0; i < URBS_COUNT; i++)
708 free_urb(urbs[i]);
709 }
710 return r;
711}
712
713void zd_usb_disable_rx(struct zd_usb *usb)
714{
715 int i;
716 unsigned long flags;
717 struct urb **urbs;
718 unsigned int count;
719 struct zd_usb_rx *rx = &usb->rx;
720
721 spin_lock_irqsave(&rx->lock, flags);
722 urbs = rx->urbs;
723 count = rx->urbs_count;
724 spin_unlock_irqrestore(&rx->lock, flags);
725 if (!urbs)
726 return;
727
728 for (i = 0; i < count; i++) {
729 usb_kill_urb(urbs[i]);
730 free_urb(urbs[i]);
731 }
732 kfree(urbs);
733
734 spin_lock_irqsave(&rx->lock, flags);
735 rx->urbs = NULL;
736 rx->urbs_count = 0;
737 spin_unlock_irqrestore(&rx->lock, flags);
738}
739
740static void tx_urb_complete(struct urb *urb, struct pt_regs *pt_regs)
741{
742 int r;
743
744 switch (urb->status) {
745 case 0:
746 break;
747 case -ESHUTDOWN:
748 case -EINVAL:
749 case -ENODEV:
750 case -ENOENT:
751 case -ECONNRESET:
752 dev_dbg_f(urb_dev(urb), "urb %p error %d\n", urb, urb->status);
753 break;
754 case -EPIPE:
755 usb_clear_halt(urb->dev, EP_DATA_OUT);
756 /* FALL-THROUGH */
757 default:
758 dev_dbg_f(urb_dev(urb), "urb %p error %d\n", urb, urb->status);
759 goto resubmit;
760 }
761free_urb:
762 usb_buffer_free(urb->dev, urb->transfer_buffer_length,
763 urb->transfer_buffer, urb->transfer_dma);
764 usb_free_urb(urb);
765 return;
766resubmit:
767 r = usb_submit_urb(urb, GFP_ATOMIC);
768 if (r) {
769 dev_dbg_f(urb_dev(urb), "error resubmit urb %p %d\n", urb, r);
770 goto free_urb;
771 }
772}
773
774/* Puts the frame on the USB endpoint. It doesn't wait for
775 * completion. The frame must contain the control set.
776 */
777int zd_usb_tx(struct zd_usb *usb, const u8 *frame, unsigned int length)
778{
779 int r;
780 struct usb_device *udev = zd_usb_to_usbdev(usb);
781 struct urb *urb;
782 void *buffer;
783
784 urb = usb_alloc_urb(0, GFP_ATOMIC);
785 if (!urb) {
786 r = -ENOMEM;
787 goto out;
788 }
789
790 buffer = usb_buffer_alloc(zd_usb_to_usbdev(usb), length, GFP_ATOMIC,
791 &urb->transfer_dma);
792 if (!buffer) {
793 r = -ENOMEM;
794 goto error_free_urb;
795 }
796 memcpy(buffer, frame, length);
797
798 usb_fill_bulk_urb(urb, udev, usb_sndbulkpipe(udev, EP_DATA_OUT),
799 buffer, length, tx_urb_complete, NULL);
800 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
801
802 r = usb_submit_urb(urb, GFP_ATOMIC);
803 if (r)
804 goto error;
805 return 0;
806error:
807 usb_buffer_free(zd_usb_to_usbdev(usb), length, buffer,
808 urb->transfer_dma);
809error_free_urb:
810 usb_free_urb(urb);
811out:
812 return r;
813}
814
815static inline void init_usb_interrupt(struct zd_usb *usb)
816{
817 struct zd_usb_interrupt *intr = &usb->intr;
818
819 spin_lock_init(&intr->lock);
820 intr->interval = int_urb_interval(zd_usb_to_usbdev(usb));
821 init_completion(&intr->read_regs.completion);
822 intr->read_regs.cr_int_addr = cpu_to_le16(usb_addr(usb, CR_INTERRUPT));
823}
824
825static inline void init_usb_rx(struct zd_usb *usb)
826{
827 struct zd_usb_rx *rx = &usb->rx;
828 spin_lock_init(&rx->lock);
829 if (interface_to_usbdev(usb->intf)->speed == USB_SPEED_HIGH) {
830 rx->usb_packet_size = 512;
831 } else {
832 rx->usb_packet_size = 64;
833 }
834 ZD_ASSERT(rx->fragment_length == 0);
835}
836
837static inline void init_usb_tx(struct zd_usb *usb)
838{
839 /* FIXME: at this point we will allocate a fixed number of urb's for
840 * use in a cyclic scheme */
841}
842
843void zd_usb_init(struct zd_usb *usb, struct net_device *netdev,
844 struct usb_interface *intf)
845{
846 memset(usb, 0, sizeof(*usb));
847 usb->intf = usb_get_intf(intf);
848 usb_set_intfdata(usb->intf, netdev);
849 init_usb_interrupt(usb);
850 init_usb_tx(usb);
851 init_usb_rx(usb);
852}
853
854int zd_usb_init_hw(struct zd_usb *usb)
855{
856 int r;
857 struct zd_chip *chip = zd_usb_to_chip(usb);
858
859 ZD_ASSERT(mutex_is_locked(&chip->mutex));
860 r = zd_ioread16_locked(chip, &usb->fw_base_offset,
861 USB_REG((u16)FW_BASE_ADDR_OFFSET));
862 if (r)
863 return r;
864 dev_dbg_f(zd_usb_dev(usb), "fw_base_offset: %#06hx\n",
865 usb->fw_base_offset);
866
867 return 0;
868}
869
870void zd_usb_clear(struct zd_usb *usb)
871{
872 usb_set_intfdata(usb->intf, NULL);
873 usb_put_intf(usb->intf);
874 memset(usb, 0, sizeof(*usb));
875 /* FIXME: usb_interrupt, usb_tx, usb_rx? */
876}
877
878static const char *speed(enum usb_device_speed speed)
879{
880 switch (speed) {
881 case USB_SPEED_LOW:
882 return "low";
883 case USB_SPEED_FULL:
884 return "full";
885 case USB_SPEED_HIGH:
886 return "high";
887 default:
888 return "unknown speed";
889 }
890}
891
892static int scnprint_id(struct usb_device *udev, char *buffer, size_t size)
893{
894 return scnprintf(buffer, size, "%04hx:%04hx v%04hx %s",
895 le16_to_cpu(udev->descriptor.idVendor),
896 le16_to_cpu(udev->descriptor.idProduct),
897 get_bcdDevice(udev),
898 speed(udev->speed));
899}
900
901int zd_usb_scnprint_id(struct zd_usb *usb, char *buffer, size_t size)
902{
903 struct usb_device *udev = interface_to_usbdev(usb->intf);
904 return scnprint_id(udev, buffer, size);
905}
906
907#ifdef DEBUG
908static void print_id(struct usb_device *udev)
909{
910 char buffer[40];
911
912 scnprint_id(udev, buffer, sizeof(buffer));
913 buffer[sizeof(buffer)-1] = 0;
914 dev_dbg_f(&udev->dev, "%s\n", buffer);
915}
916#else
917#define print_id(udev) do { } while (0)
918#endif
919
920static int probe(struct usb_interface *intf, const struct usb_device_id *id)
921{
922 int r;
923 struct usb_device *udev = interface_to_usbdev(intf);
924 struct net_device *netdev = NULL;
925
926 print_id(udev);
927
928 switch (udev->speed) {
929 case USB_SPEED_LOW:
930 case USB_SPEED_FULL:
931 case USB_SPEED_HIGH:
932 break;
933 default:
934 dev_dbg_f(&intf->dev, "Unknown USB speed\n");
935 r = -ENODEV;
936 goto error;
937 }
938
939 netdev = zd_netdev_alloc(intf);
940 if (netdev == NULL) {
941 r = -ENOMEM;
942 goto error;
943 }
944
945 r = upload_firmware(udev, id->driver_info);
946 if (r) {
947 dev_err(&intf->dev,
948 "couldn't load firmware. Error number %d\n", r);
949 goto error;
950 }
951
952 r = usb_reset_configuration(udev);
953 if (r) {
954 dev_dbg_f(&intf->dev,
955 "couldn't reset configuration. Error number %d\n", r);
956 goto error;
957 }
958
959 /* At this point the interrupt endpoint is not generally enabled. We
960 * save the USB bandwidth until the network device is opened. But
961 * notify that the initialization of the MAC will require the
962 * interrupts to be temporary enabled.
963 */
964 r = zd_mac_init_hw(zd_netdev_mac(netdev), id->driver_info);
965 if (r) {
966 dev_dbg_f(&intf->dev,
967 "couldn't initialize mac. Error number %d\n", r);
968 goto error;
969 }
970
971 r = register_netdev(netdev);
972 if (r) {
973 dev_dbg_f(&intf->dev,
974 "couldn't register netdev. Error number %d\n", r);
975 goto error;
976 }
977
978 dev_dbg_f(&intf->dev, "successful\n");
979 dev_info(&intf->dev,"%s\n", netdev->name);
980 return 0;
981error:
982 usb_reset_device(interface_to_usbdev(intf));
983 zd_netdev_free(netdev);
984 return r;
985}
986
987static void disconnect(struct usb_interface *intf)
988{
989 struct net_device *netdev = zd_intf_to_netdev(intf);
990 struct zd_mac *mac = zd_netdev_mac(netdev);
991 struct zd_usb *usb = &mac->chip.usb;
992
993 dev_dbg_f(zd_usb_dev(usb), "\n");
994
995 zd_netdev_disconnect(netdev);
996
997 /* Just in case something has gone wrong! */
998 zd_usb_disable_rx(usb);
999 zd_usb_disable_int(usb);
1000
1001 /* If the disconnect has been caused by a removal of the
1002 * driver module, the reset allows reloading of the driver. If the
1003 * reset will not be executed here, the upload of the firmware in the
1004 * probe function caused by the reloading of the driver will fail.
1005 */
1006 usb_reset_device(interface_to_usbdev(intf));
1007
1008 /* If somebody still waits on this lock now, this is an error. */
1009 zd_netdev_free(netdev);
1010 dev_dbg(&intf->dev, "disconnected\n");
1011}
1012
1013static struct usb_driver driver = {
1014 .name = "zd1211rw",
1015 .id_table = usb_ids,
1016 .probe = probe,
1017 .disconnect = disconnect,
1018};
1019
1020static int __init usb_init(void)
1021{
1022 int r;
1023
1024 pr_debug("usb_init()\n");
1025
1026 r = usb_register(&driver);
1027 if (r) {
1028 printk(KERN_ERR "usb_register() failed. Error number %d\n", r);
1029 return r;
1030 }
1031
1032 pr_debug("zd1211rw initialized\n");
1033 return 0;
1034}
1035
1036static void __exit usb_exit(void)
1037{
1038 pr_debug("usb_exit()\n");
1039 usb_deregister(&driver);
1040}
1041
1042module_init(usb_init);
1043module_exit(usb_exit);
1044
1045static int usb_int_regs_length(unsigned int count)
1046{
1047 return sizeof(struct usb_int_regs) + count * sizeof(struct reg_data);
1048}
1049
1050static void prepare_read_regs_int(struct zd_usb *usb)
1051{
1052 struct zd_usb_interrupt *intr = &usb->intr;
1053
1054 spin_lock(&intr->lock);
1055 intr->read_regs_enabled = 1;
1056 INIT_COMPLETION(intr->read_regs.completion);
1057 spin_unlock(&intr->lock);
1058}
1059
1060static int get_results(struct zd_usb *usb, u16 *values,
1061 struct usb_req_read_regs *req, unsigned int count)
1062{
1063 int r;
1064 int i;
1065 struct zd_usb_interrupt *intr = &usb->intr;
1066 struct read_regs_int *rr = &intr->read_regs;
1067 struct usb_int_regs *regs = (struct usb_int_regs *)rr->buffer;
1068
1069 spin_lock(&intr->lock);
1070
1071 r = -EIO;
1072 /* The created block size seems to be larger than expected.
1073 * However results appear to be correct.
1074 */
1075 if (rr->length < usb_int_regs_length(count)) {
1076 dev_dbg_f(zd_usb_dev(usb),
1077 "error: actual length %d less than expected %d\n",
1078 rr->length, usb_int_regs_length(count));
1079 goto error_unlock;
1080 }
1081 if (rr->length > sizeof(rr->buffer)) {
1082 dev_dbg_f(zd_usb_dev(usb),
1083 "error: actual length %d exceeds buffer size %zu\n",
1084 rr->length, sizeof(rr->buffer));
1085 goto error_unlock;
1086 }
1087
1088 for (i = 0; i < count; i++) {
1089 struct reg_data *rd = &regs->regs[i];
1090 if (rd->addr != req->addr[i]) {
1091 dev_dbg_f(zd_usb_dev(usb),
1092 "rd[%d] addr %#06hx expected %#06hx\n", i,
1093 le16_to_cpu(rd->addr),
1094 le16_to_cpu(req->addr[i]));
1095 goto error_unlock;
1096 }
1097 values[i] = le16_to_cpu(rd->value);
1098 }
1099
1100 r = 0;
1101error_unlock:
1102 spin_unlock(&intr->lock);
1103 return r;
1104}
1105
1106int zd_usb_ioread16v(struct zd_usb *usb, u16 *values,
1107 const zd_addr_t *addresses, unsigned int count)
1108{
1109 int r;
1110 int i, req_len, actual_req_len;
1111 struct usb_device *udev;
1112 struct usb_req_read_regs *req = NULL;
1113 unsigned long timeout;
1114
1115 if (count < 1) {
1116 dev_dbg_f(zd_usb_dev(usb), "error: count is zero\n");
1117 return -EINVAL;
1118 }
1119 if (count > USB_MAX_IOREAD16_COUNT) {
1120 dev_dbg_f(zd_usb_dev(usb),
1121 "error: count %u exceeds possible max %u\n",
1122 count, USB_MAX_IOREAD16_COUNT);
1123 return -EINVAL;
1124 }
1125 if (in_atomic()) {
1126 dev_dbg_f(zd_usb_dev(usb),
1127 "error: io in atomic context not supported\n");
1128 return -EWOULDBLOCK;
1129 }
1130 if (!usb_int_enabled(usb)) {
1131 dev_dbg_f(zd_usb_dev(usb),
1132 "error: usb interrupt not enabled\n");
1133 return -EWOULDBLOCK;
1134 }
1135
1136 req_len = sizeof(struct usb_req_read_regs) + count * sizeof(__le16);
1137 req = kmalloc(req_len, GFP_NOFS);
1138 if (!req)
1139 return -ENOMEM;
1140 req->id = cpu_to_le16(USB_REQ_READ_REGS);
1141 for (i = 0; i < count; i++)
1142 req->addr[i] = cpu_to_le16(usb_addr(usb, addresses[i]));
1143
1144 udev = zd_usb_to_usbdev(usb);
1145 prepare_read_regs_int(usb);
1146 r = usb_bulk_msg(udev, usb_sndbulkpipe(udev, EP_REGS_OUT),
1147 req, req_len, &actual_req_len, 1000 /* ms */);
1148 if (r) {
1149 dev_dbg_f(zd_usb_dev(usb),
1150 "error in usb_bulk_msg(). Error number %d\n", r);
1151 goto error;
1152 }
1153 if (req_len != actual_req_len) {
1154 dev_dbg_f(zd_usb_dev(usb), "error in usb_bulk_msg()\n"
1155 " req_len %d != actual_req_len %d\n",
1156 req_len, actual_req_len);
1157 r = -EIO;
1158 goto error;
1159 }
1160
1161 timeout = wait_for_completion_timeout(&usb->intr.read_regs.completion,
1162 msecs_to_jiffies(1000));
1163 if (!timeout) {
1164 disable_read_regs_int(usb);
1165 dev_dbg_f(zd_usb_dev(usb), "read timed out\n");
1166 r = -ETIMEDOUT;
1167 goto error;
1168 }
1169
1170 r = get_results(usb, values, req, count);
1171error:
1172 kfree(req);
1173 return r;
1174}
1175
1176int zd_usb_iowrite16v(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs,
1177 unsigned int count)
1178{
1179 int r;
1180 struct usb_device *udev;
1181 struct usb_req_write_regs *req = NULL;
1182 int i, req_len, actual_req_len;
1183
1184 if (count == 0)
1185 return 0;
1186 if (count > USB_MAX_IOWRITE16_COUNT) {
1187 dev_dbg_f(zd_usb_dev(usb),
1188 "error: count %u exceeds possible max %u\n",
1189 count, USB_MAX_IOWRITE16_COUNT);
1190 return -EINVAL;
1191 }
1192 if (in_atomic()) {
1193 dev_dbg_f(zd_usb_dev(usb),
1194 "error: io in atomic context not supported\n");
1195 return -EWOULDBLOCK;
1196 }
1197
1198 req_len = sizeof(struct usb_req_write_regs) +
1199 count * sizeof(struct reg_data);
1200 req = kmalloc(req_len, GFP_NOFS);
1201 if (!req)
1202 return -ENOMEM;
1203
1204 req->id = cpu_to_le16(USB_REQ_WRITE_REGS);
1205 for (i = 0; i < count; i++) {
1206 struct reg_data *rw = &req->reg_writes[i];
1207 rw->addr = cpu_to_le16(usb_addr(usb, ioreqs[i].addr));
1208 rw->value = cpu_to_le16(ioreqs[i].value);
1209 }
1210
1211 udev = zd_usb_to_usbdev(usb);
1212 r = usb_bulk_msg(udev, usb_sndbulkpipe(udev, EP_REGS_OUT),
1213 req, req_len, &actual_req_len, 1000 /* ms */);
1214 if (r) {
1215 dev_dbg_f(zd_usb_dev(usb),
1216 "error in usb_bulk_msg(). Error number %d\n", r);
1217 goto error;
1218 }
1219 if (req_len != actual_req_len) {
1220 dev_dbg_f(zd_usb_dev(usb),
1221 "error in usb_bulk_msg()"
1222 " req_len %d != actual_req_len %d\n",
1223 req_len, actual_req_len);
1224 r = -EIO;
1225 goto error;
1226 }
1227
1228 /* FALL-THROUGH with r == 0 */
1229error:
1230 kfree(req);
1231 return r;
1232}
1233
1234int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits)
1235{
1236 int r;
1237 struct usb_device *udev;
1238 struct usb_req_rfwrite *req = NULL;
1239 int i, req_len, actual_req_len;
1240 u16 bit_value_template;
1241
1242 if (in_atomic()) {
1243 dev_dbg_f(zd_usb_dev(usb),
1244 "error: io in atomic context not supported\n");
1245 return -EWOULDBLOCK;
1246 }
1247 if (bits < USB_MIN_RFWRITE_BIT_COUNT) {
1248 dev_dbg_f(zd_usb_dev(usb),
1249 "error: bits %d are smaller than"
1250 " USB_MIN_RFWRITE_BIT_COUNT %d\n",
1251 bits, USB_MIN_RFWRITE_BIT_COUNT);
1252 return -EINVAL;
1253 }
1254 if (bits > USB_MAX_RFWRITE_BIT_COUNT) {
1255 dev_dbg_f(zd_usb_dev(usb),
1256 "error: bits %d exceed USB_MAX_RFWRITE_BIT_COUNT %d\n",
1257 bits, USB_MAX_RFWRITE_BIT_COUNT);
1258 return -EINVAL;
1259 }
1260#ifdef DEBUG
1261 if (value & (~0UL << bits)) {
1262 dev_dbg_f(zd_usb_dev(usb),
1263 "error: value %#09x has bits >= %d set\n",
1264 value, bits);
1265 return -EINVAL;
1266 }
1267#endif /* DEBUG */
1268
1269 dev_dbg_f(zd_usb_dev(usb), "value %#09x bits %d\n", value, bits);
1270
1271 r = zd_usb_ioread16(usb, &bit_value_template, CR203);
1272 if (r) {
1273 dev_dbg_f(zd_usb_dev(usb),
1274 "error %d: Couldn't read CR203\n", r);
1275 goto out;
1276 }
1277 bit_value_template &= ~(RF_IF_LE|RF_CLK|RF_DATA);
1278
1279 req_len = sizeof(struct usb_req_rfwrite) + bits * sizeof(__le16);
1280 req = kmalloc(req_len, GFP_NOFS);
1281 if (!req)
1282 return -ENOMEM;
1283
1284 req->id = cpu_to_le16(USB_REQ_WRITE_RF);
1285 /* 1: 3683a, but not used in ZYDAS driver */
1286 req->value = cpu_to_le16(2);
1287 req->bits = cpu_to_le16(bits);
1288
1289 for (i = 0; i < bits; i++) {
1290 u16 bv = bit_value_template;
1291 if (value & (1 << (bits-1-i)))
1292 bv |= RF_DATA;
1293 req->bit_values[i] = cpu_to_le16(bv);
1294 }
1295
1296 udev = zd_usb_to_usbdev(usb);
1297 r = usb_bulk_msg(udev, usb_sndbulkpipe(udev, EP_REGS_OUT),
1298 req, req_len, &actual_req_len, 1000 /* ms */);
1299 if (r) {
1300 dev_dbg_f(zd_usb_dev(usb),
1301 "error in usb_bulk_msg(). Error number %d\n", r);
1302 goto out;
1303 }
1304 if (req_len != actual_req_len) {
1305 dev_dbg_f(zd_usb_dev(usb), "error in usb_bulk_msg()"
1306 " req_len %d != actual_req_len %d\n",
1307 req_len, actual_req_len);
1308 r = -EIO;
1309 goto out;
1310 }
1311
1312 /* FALL-THROUGH with r == 0 */
1313out:
1314 kfree(req);
1315 return r;
1316}
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.h b/drivers/net/wireless/zd1211rw/zd_usb.h
new file mode 100644
index 000000000000..d6420283bd5a
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_usb.h
@@ -0,0 +1,240 @@
1/* zd_usb.h: Header for USB interface implemented by ZD1211 chip
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#ifndef _ZD_USB_H
19#define _ZD_USB_H
20
21#include <linux/completion.h>
22#include <linux/netdevice.h>
23#include <linux/spinlock.h>
24#include <linux/skbuff.h>
25#include <linux/usb.h>
26
27#include "zd_def.h"
28#include "zd_types.h"
29
30enum devicetype {
31 DEVICE_ZD1211 = 0,
32 DEVICE_ZD1211B = 1,
33};
34
35enum endpoints {
36 EP_CTRL = 0,
37 EP_DATA_OUT = 1,
38 EP_DATA_IN = 2,
39 EP_INT_IN = 3,
40 EP_REGS_OUT = 4,
41};
42
43enum {
44 USB_MAX_TRANSFER_SIZE = 4096, /* bytes */
45 /* FIXME: The original driver uses this value. We have to check,
46 * whether the MAX_TRANSFER_SIZE is sufficient and this needs only be
47 * used if one combined frame is split over two USB transactions.
48 */
49 USB_MAX_RX_SIZE = 4800, /* bytes */
50 USB_MAX_IOWRITE16_COUNT = 15,
51 USB_MAX_IOWRITE32_COUNT = USB_MAX_IOWRITE16_COUNT/2,
52 USB_MAX_IOREAD16_COUNT = 15,
53 USB_MAX_IOREAD32_COUNT = USB_MAX_IOREAD16_COUNT/2,
54 USB_MIN_RFWRITE_BIT_COUNT = 16,
55 USB_MAX_RFWRITE_BIT_COUNT = 28,
56 USB_MAX_EP_INT_BUFFER = 64,
57 USB_ZD1211B_BCD_DEVICE = 0x4810,
58};
59
60enum control_requests {
61 USB_REQ_WRITE_REGS = 0x21,
62 USB_REQ_READ_REGS = 0x22,
63 USB_REQ_WRITE_RF = 0x23,
64 USB_REQ_PROG_FLASH = 0x24,
65 USB_REQ_EEPROM_START = 0x0128, /* ? request is a byte */
66 USB_REQ_EEPROM_MID = 0x28,
67 USB_REQ_EEPROM_END = 0x0228, /* ? request is a byte */
68 USB_REQ_FIRMWARE_DOWNLOAD = 0x30,
69 USB_REQ_FIRMWARE_CONFIRM = 0x31,
70 USB_REQ_FIRMWARE_READ_DATA = 0x32,
71};
72
73struct usb_req_read_regs {
74 __le16 id;
75 __le16 addr[0];
76} __attribute__((packed));
77
78struct reg_data {
79 __le16 addr;
80 __le16 value;
81} __attribute__((packed));
82
83struct usb_req_write_regs {
84 __le16 id;
85 struct reg_data reg_writes[0];
86} __attribute__((packed));
87
88enum {
89 RF_IF_LE = 0x02,
90 RF_CLK = 0x04,
91 RF_DATA = 0x08,
92};
93
94struct usb_req_rfwrite {
95 __le16 id;
96 __le16 value;
97 /* 1: 3683a */
98 /* 2: other (default) */
99 __le16 bits;
100 /* RF2595: 24 */
101 __le16 bit_values[0];
102 /* (CR203 & ~(RF_IF_LE | RF_CLK | RF_DATA)) | (bit ? RF_DATA : 0) */
103} __attribute__((packed));
104
105/* USB interrupt */
106
107enum usb_int_id {
108 USB_INT_TYPE = 0x01,
109 USB_INT_ID_REGS = 0x90,
110 USB_INT_ID_RETRY_FAILED = 0xa0,
111};
112
113enum usb_int_flags {
114 USB_INT_READ_REGS_EN = 0x01,
115};
116
117struct usb_int_header {
118 u8 type; /* must always be 1 */
119 u8 id;
120} __attribute__((packed));
121
122struct usb_int_regs {
123 struct usb_int_header hdr;
124 struct reg_data regs[0];
125} __attribute__((packed));
126
127struct usb_int_retry_fail {
128 struct usb_int_header hdr;
129 u8 new_rate;
130 u8 _dummy;
131 u8 addr[ETH_ALEN];
132 u8 ibss_wakeup_dest;
133} __attribute__((packed));
134
135struct read_regs_int {
136 struct completion completion;
137 /* Stores the USB int structure and contains the USB address of the
138 * first requested register before request.
139 */
140 u8 buffer[USB_MAX_EP_INT_BUFFER];
141 int length;
142 __le16 cr_int_addr;
143};
144
145struct zd_ioreq16 {
146 zd_addr_t addr;
147 u16 value;
148};
149
150struct zd_ioreq32 {
151 zd_addr_t addr;
152 u32 value;
153};
154
155struct zd_usb_interrupt {
156 struct read_regs_int read_regs;
157 spinlock_t lock;
158 struct urb *urb;
159 int interval;
160 u8 read_regs_enabled:1;
161};
162
163static inline struct usb_int_regs *get_read_regs(struct zd_usb_interrupt *intr)
164{
165 return (struct usb_int_regs *)intr->read_regs.buffer;
166}
167
168#define URBS_COUNT 5
169
170struct zd_usb_rx {
171 spinlock_t lock;
172 u8 fragment[2*USB_MAX_RX_SIZE];
173 unsigned int fragment_length;
174 unsigned int usb_packet_size;
175 struct urb **urbs;
176 int urbs_count;
177};
178
179struct zd_usb_tx {
180 spinlock_t lock;
181};
182
183/* Contains the usb parts. The structure doesn't require a lock, because intf
184 * and fw_base_offset, will not be changed after initialization.
185 */
186struct zd_usb {
187 struct zd_usb_interrupt intr;
188 struct zd_usb_rx rx;
189 struct zd_usb_tx tx;
190 struct usb_interface *intf;
191 u16 fw_base_offset;
192};
193
194#define zd_usb_dev(usb) (&usb->intf->dev)
195
196static inline struct usb_device *zd_usb_to_usbdev(struct zd_usb *usb)
197{
198 return interface_to_usbdev(usb->intf);
199}
200
201static inline struct net_device *zd_intf_to_netdev(struct usb_interface *intf)
202{
203 return usb_get_intfdata(intf);
204}
205
206static inline struct net_device *zd_usb_to_netdev(struct zd_usb *usb)
207{
208 return zd_intf_to_netdev(usb->intf);
209}
210
211void zd_usb_init(struct zd_usb *usb, struct net_device *netdev,
212 struct usb_interface *intf);
213int zd_usb_init_hw(struct zd_usb *usb);
214void zd_usb_clear(struct zd_usb *usb);
215
216int zd_usb_scnprint_id(struct zd_usb *usb, char *buffer, size_t size);
217
218int zd_usb_enable_int(struct zd_usb *usb);
219void zd_usb_disable_int(struct zd_usb *usb);
220
221int zd_usb_enable_rx(struct zd_usb *usb);
222void zd_usb_disable_rx(struct zd_usb *usb);
223
224int zd_usb_tx(struct zd_usb *usb, const u8 *frame, unsigned int length);
225
226int zd_usb_ioread16v(struct zd_usb *usb, u16 *values,
227 const zd_addr_t *addresses, unsigned int count);
228
229static inline int zd_usb_ioread16(struct zd_usb *usb, u16 *value,
230 const zd_addr_t addr)
231{
232 return zd_usb_ioread16v(usb, value, (const zd_addr_t *)&addr, 1);
233}
234
235int zd_usb_iowrite16v(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs,
236 unsigned int count);
237
238int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits);
239
240#endif /* _ZD_USB_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_util.c b/drivers/net/wireless/zd1211rw/zd_util.c
new file mode 100644
index 000000000000..d20036c15d11
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_util.c
@@ -0,0 +1,82 @@
1/* zd_util.c
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Utility program
18 */
19
20#include "zd_def.h"
21#include "zd_util.h"
22
23#ifdef DEBUG
24static char hex(u8 v)
25{
26 v &= 0xf;
27 return (v < 10 ? '0' : 'a' - 10) + v;
28}
29
30static char hex_print(u8 c)
31{
32 return (0x20 <= c && c < 0x7f) ? c : '.';
33}
34
35static void dump_line(const u8 *bytes, size_t size)
36{
37 char c;
38 size_t i;
39
40 size = size <= 8 ? size : 8;
41 printk(KERN_DEBUG "zd1211 %p ", bytes);
42 for (i = 0; i < 8; i++) {
43 switch (i) {
44 case 1:
45 case 5:
46 c = '.';
47 break;
48 case 3:
49 c = ':';
50 break;
51 default:
52 c = ' ';
53 }
54 if (i < size) {
55 printk("%c%c%c", hex(bytes[i] >> 4), hex(bytes[i]), c);
56 } else {
57 printk(" %c", c);
58 }
59 }
60
61 for (i = 0; i < size; i++)
62 printk("%c", hex_print(bytes[i]));
63 printk("\n");
64}
65
66void zd_hexdump(const void *bytes, size_t size)
67{
68 size_t i = 0;
69
70 do {
71 dump_line((u8 *)bytes + i, size-i);
72 i += 8;
73 } while (i < size);
74}
75#endif /* DEBUG */
76
77void *zd_tail(const void *buffer, size_t buffer_size, size_t tail_size)
78{
79 if (buffer_size < tail_size)
80 return NULL;
81 return (u8 *)buffer + (buffer_size - tail_size);
82}
diff --git a/drivers/net/wireless/zd1211rw/zd_util.h b/drivers/net/wireless/zd1211rw/zd_util.h
new file mode 100644
index 000000000000..ce26f7adea92
--- /dev/null
+++ b/drivers/net/wireless/zd1211rw/zd_util.h
@@ -0,0 +1,29 @@
1/* zd_util.h
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#ifndef _ZD_UTIL_H
19#define _ZD_UTIL_H
20
21void *zd_tail(const void *buffer, size_t buffer_size, size_t tail_size);
22
23#ifdef DEBUG
24void zd_hexdump(const void *bytes, size_t size);
25#else
26#define zd_hexdump(bytes, size)
27#endif /* DEBUG */
28
29#endif /* _ZD_UTIL_H */
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index fd0f43b7db5b..8459a18254a4 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -19,37 +19,13 @@
19 19
20 Support and updates available at 20 Support and updates available at
21 http://www.scyld.com/network/yellowfin.html 21 http://www.scyld.com/network/yellowfin.html
22 [link no longer provides useful info -jgarzik]
22 23
23
24 Linux kernel changelog:
25 -----------------------
26
27 LK1.1.1 (jgarzik): Port to 2.4 kernel
28
29 LK1.1.2 (jgarzik):
30 * Merge in becker version 1.05
31
32 LK1.1.3 (jgarzik):
33 * Various cleanups
34 * Update yellowfin_timer to correctly calculate duplex.
35 (suggested by Manfred Spraul)
36
37 LK1.1.4 (val@nmt.edu):
38 * Fix three endian-ness bugs
39 * Support dual function SYM53C885E ethernet chip
40
41 LK1.1.5 (val@nmt.edu):
42 * Fix forced full-duplex bug I introduced
43
44 LK1.1.6 (val@nmt.edu):
45 * Only print warning on truly "oversized" packets
46 * Fix theoretical bug on gigabit cards - return to 1.1.3 behavior
47
48*/ 24*/
49 25
50#define DRV_NAME "yellowfin" 26#define DRV_NAME "yellowfin"
51#define DRV_VERSION "1.05+LK1.1.6" 27#define DRV_VERSION "2.0"
52#define DRV_RELDATE "Feb 11, 2002" 28#define DRV_RELDATE "Jun 27, 2006"
53 29
54#define PFX DRV_NAME ": " 30#define PFX DRV_NAME ": "
55 31
@@ -234,26 +210,16 @@ See Packet Engines confidential appendix (prototype chips only).
234 210
235 211
236 212
237enum pci_id_flags_bits {
238 /* Set PCI command register bits before calling probe1(). */
239 PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
240 /* Read and map the single following PCI BAR. */
241 PCI_ADDR0=0<<4, PCI_ADDR1=1<<4, PCI_ADDR2=2<<4, PCI_ADDR3=3<<4,
242 PCI_ADDR_64BITS=0x100, PCI_NO_ACPI_WAKE=0x200, PCI_NO_MIN_LATENCY=0x400,
243 PCI_UNUSED_IRQ=0x800,
244};
245enum capability_flags { 213enum capability_flags {
246 HasMII=1, FullTxStatus=2, IsGigabit=4, HasMulticastBug=8, FullRxStatus=16, 214 HasMII=1, FullTxStatus=2, IsGigabit=4, HasMulticastBug=8, FullRxStatus=16,
247 HasMACAddrBug=32, /* Only on early revs. */ 215 HasMACAddrBug=32, /* Only on early revs. */
248 DontUseEeprom=64, /* Don't read the MAC from the EEPROm. */ 216 DontUseEeprom=64, /* Don't read the MAC from the EEPROm. */
249}; 217};
218
250/* The PCI I/O space extent. */ 219/* The PCI I/O space extent. */
251#define YELLOWFIN_SIZE 0x100 220enum {
252#ifdef USE_IO_OPS 221 YELLOWFIN_SIZE = 0x100,
253#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_IO | PCI_ADDR0) 222};
254#else
255#define PCI_IOTYPE (PCI_USES_MASTER | PCI_USES_MEM | PCI_ADDR1)
256#endif
257 223
258struct pci_id_info { 224struct pci_id_info {
259 const char *name; 225 const char *name;
@@ -261,24 +227,21 @@ struct pci_id_info {
261 int pci, pci_mask, subsystem, subsystem_mask; 227 int pci, pci_mask, subsystem, subsystem_mask;
262 int revision, revision_mask; /* Only 8 bits. */ 228 int revision, revision_mask; /* Only 8 bits. */
263 } id; 229 } id;
264 enum pci_id_flags_bits pci_flags;
265 int io_size; /* Needed for I/O region check or ioremap(). */
266 int drv_flags; /* Driver use, intended as capability flags. */ 230 int drv_flags; /* Driver use, intended as capability flags. */
267}; 231};
268 232
269static const struct pci_id_info pci_id_tbl[] = { 233static const struct pci_id_info pci_id_tbl[] = {
270 {"Yellowfin G-NIC Gigabit Ethernet", { 0x07021000, 0xffffffff}, 234 {"Yellowfin G-NIC Gigabit Ethernet", { 0x07021000, 0xffffffff},
271 PCI_IOTYPE, YELLOWFIN_SIZE,
272 FullTxStatus | IsGigabit | HasMulticastBug | HasMACAddrBug | DontUseEeprom}, 235 FullTxStatus | IsGigabit | HasMulticastBug | HasMACAddrBug | DontUseEeprom},
273 {"Symbios SYM83C885", { 0x07011000, 0xffffffff}, 236 {"Symbios SYM83C885", { 0x07011000, 0xffffffff},
274 PCI_IOTYPE, YELLOWFIN_SIZE, HasMII | DontUseEeprom }, 237 HasMII | DontUseEeprom },
275 {NULL,}, 238 { }
276}; 239};
277 240
278static struct pci_device_id yellowfin_pci_tbl[] = { 241static const struct pci_device_id yellowfin_pci_tbl[] = {
279 { 0x1000, 0x0702, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 242 { 0x1000, 0x0702, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
280 { 0x1000, 0x0701, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 243 { 0x1000, 0x0701, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
281 { 0, } 244 { }
282}; 245};
283MODULE_DEVICE_TABLE (pci, yellowfin_pci_tbl); 246MODULE_DEVICE_TABLE (pci, yellowfin_pci_tbl);
284 247
@@ -616,7 +579,7 @@ static int yellowfin_open(struct net_device *dev)
616 /* Reset the chip. */ 579 /* Reset the chip. */
617 iowrite32(0x80000000, ioaddr + DMACtrl); 580 iowrite32(0x80000000, ioaddr + DMACtrl);
618 581
619 i = request_irq(dev->irq, &yellowfin_interrupt, SA_SHIRQ, dev->name, dev); 582 i = request_irq(dev->irq, &yellowfin_interrupt, IRQF_SHARED, dev->name, dev);
620 if (i) return i; 583 if (i) return i;
621 584
622 if (yellowfin_debug > 1) 585 if (yellowfin_debug > 1)
@@ -862,13 +825,11 @@ static int yellowfin_start_xmit(struct sk_buff *skb, struct net_device *dev)
862 /* Fix GX chipset errata. */ 825 /* Fix GX chipset errata. */
863 if (cacheline_end > 24 || cacheline_end == 0) { 826 if (cacheline_end > 24 || cacheline_end == 0) {
864 len = skb->len + 32 - cacheline_end + 1; 827 len = skb->len + 32 - cacheline_end + 1;
865 if (len != skb->len) 828 if (skb_padto(skb, len)) {
866 skb = skb_padto(skb, len); 829 yp->tx_skbuff[entry] = NULL;
867 } 830 netif_wake_queue(dev);
868 if (skb == NULL) { 831 return 0;
869 yp->tx_skbuff[entry] = NULL; 832 }
870 netif_wake_queue(dev);
871 return 0;
872 } 833 }
873 } 834 }
874 yp->tx_skbuff[entry] = skb; 835 yp->tx_skbuff[entry] = skb;
diff --git a/drivers/net/znet.c b/drivers/net/znet.c
index 3ac047bc727d..9f0291f35290 100644
--- a/drivers/net/znet.c
+++ b/drivers/net/znet.c
@@ -85,7 +85,6 @@
85 - Understand why some traffic patterns add a 1s latency... 85 - Understand why some traffic patterns add a 1s latency...
86 */ 86 */
87 87
88#include <linux/config.h>
89#include <linux/module.h> 88#include <linux/module.h>
90#include <linux/kernel.h> 89#include <linux/kernel.h>
91#include <linux/string.h> 90#include <linux/string.h>
@@ -544,8 +543,7 @@ static int znet_send_packet(struct sk_buff *skb, struct net_device *dev)
544 printk(KERN_DEBUG "%s: ZNet_send_packet.\n", dev->name); 543 printk(KERN_DEBUG "%s: ZNet_send_packet.\n", dev->name);
545 544
546 if (length < ETH_ZLEN) { 545 if (length < ETH_ZLEN) {
547 skb = skb_padto(skb, ETH_ZLEN); 546 if (skb_padto(skb, ETH_ZLEN))
548 if (skb == NULL)
549 return 0; 547 return 0;
550 length = ETH_ZLEN; 548 length = ETH_ZLEN;
551 } 549 }
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index 8037e5806d0a..df04e050c647 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -201,7 +201,7 @@ static int __devinit zorro8390_init(struct net_device *dev,
201 dev->irq = IRQ_AMIGA_PORTS; 201 dev->irq = IRQ_AMIGA_PORTS;
202 202
203 /* Install the Interrupt handler */ 203 /* Install the Interrupt handler */
204 i = request_irq(IRQ_AMIGA_PORTS, ei_interrupt, SA_SHIRQ, DRV_NAME, dev); 204 i = request_irq(IRQ_AMIGA_PORTS, ei_interrupt, IRQF_SHARED, DRV_NAME, dev);
205 if (i) return i; 205 if (i) return i;
206 206
207 for(i = 0; i < ETHER_ADDR_LEN; i++) { 207 for(i = 0; i < ETHER_ADDR_LEN; i++) {