diff options
author | Len Brown <len.brown@intel.com> | 2009-01-09 03:39:43 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-01-09 03:39:43 -0500 |
commit | b2576e1d4408e134e2188c967b1f28af39cd79d4 (patch) | |
tree | 004f3c82faab760f304ce031d6d2f572e7746a50 /drivers/net/atp.c | |
parent | 3cc8a5f4ba91f67bbdb81a43a99281a26aab8d77 (diff) | |
parent | 2150edc6c5cf00f7adb54538b9ea2a3e9cedca3f (diff) |
Merge branch 'linus' into release
Diffstat (limited to 'drivers/net/atp.c')
-rw-r--r-- | drivers/net/atp.c | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/drivers/net/atp.c b/drivers/net/atp.c index c10cd8058e23..4317b3edb3d7 100644 --- a/drivers/net/atp.c +++ b/drivers/net/atp.c | |||
@@ -204,8 +204,7 @@ static irqreturn_t atp_interrupt(int irq, void *dev_id); | |||
204 | static void net_rx(struct net_device *dev); | 204 | static void net_rx(struct net_device *dev); |
205 | static void read_block(long ioaddr, int length, unsigned char *buffer, int data_mode); | 205 | static void read_block(long ioaddr, int length, unsigned char *buffer, int data_mode); |
206 | static int net_close(struct net_device *dev); | 206 | static int net_close(struct net_device *dev); |
207 | static void set_rx_mode_8002(struct net_device *dev); | 207 | static void set_rx_mode(struct net_device *dev); |
208 | static void set_rx_mode_8012(struct net_device *dev); | ||
209 | static void tx_timeout(struct net_device *dev); | 208 | static void tx_timeout(struct net_device *dev); |
210 | 209 | ||
211 | 210 | ||
@@ -242,13 +241,23 @@ static int __init atp_init(void) | |||
242 | return -ENODEV; | 241 | return -ENODEV; |
243 | } | 242 | } |
244 | 243 | ||
244 | static const struct net_device_ops atp_netdev_ops = { | ||
245 | .ndo_open = net_open, | ||
246 | .ndo_stop = net_close, | ||
247 | .ndo_start_xmit = atp_send_packet, | ||
248 | .ndo_set_multicast_list = set_rx_mode, | ||
249 | .ndo_tx_timeout = tx_timeout, | ||
250 | .ndo_change_mtu = eth_change_mtu, | ||
251 | .ndo_set_mac_address = eth_mac_addr, | ||
252 | .ndo_validate_addr = eth_validate_addr, | ||
253 | }; | ||
254 | |||
245 | static int __init atp_probe1(long ioaddr) | 255 | static int __init atp_probe1(long ioaddr) |
246 | { | 256 | { |
247 | struct net_device *dev = NULL; | 257 | struct net_device *dev = NULL; |
248 | struct net_local *lp; | 258 | struct net_local *lp; |
249 | int saved_ctrl_reg, status, i; | 259 | int saved_ctrl_reg, status, i; |
250 | int res; | 260 | int res; |
251 | DECLARE_MAC_BUF(mac); | ||
252 | 261 | ||
253 | outb(0xff, ioaddr + PAR_DATA); | 262 | outb(0xff, ioaddr + PAR_DATA); |
254 | /* Save the original value of the Control register, in case we guessed | 263 | /* Save the original value of the Control register, in case we guessed |
@@ -324,8 +333,8 @@ static int __init atp_probe1(long ioaddr) | |||
324 | #endif | 333 | #endif |
325 | 334 | ||
326 | printk(KERN_NOTICE "%s: Pocket adapter found at %#3lx, IRQ %d, " | 335 | printk(KERN_NOTICE "%s: Pocket adapter found at %#3lx, IRQ %d, " |
327 | "SAPROM %s.\n", | 336 | "SAPROM %pM.\n", |
328 | dev->name, dev->base_addr, dev->irq, print_mac(mac, dev->dev_addr)); | 337 | dev->name, dev->base_addr, dev->irq, dev->dev_addr); |
329 | 338 | ||
330 | /* Reset the ethernet hardware and activate the printer pass-through. */ | 339 | /* Reset the ethernet hardware and activate the printer pass-through. */ |
331 | write_reg_high(ioaddr, CMR1, CMR1h_RESET | CMR1h_MUX); | 340 | write_reg_high(ioaddr, CMR1, CMR1h_RESET | CMR1h_MUX); |
@@ -343,12 +352,7 @@ static int __init atp_probe1(long ioaddr) | |||
343 | if (dev->mem_end & 0xf) | 352 | if (dev->mem_end & 0xf) |
344 | net_debug = dev->mem_end & 7; | 353 | net_debug = dev->mem_end & 7; |
345 | 354 | ||
346 | dev->open = net_open; | 355 | dev->netdev_ops = &atp_netdev_ops; |
347 | dev->stop = net_close; | ||
348 | dev->hard_start_xmit = atp_send_packet; | ||
349 | dev->set_multicast_list = | ||
350 | lp->chip_type == RTL8002 ? &set_rx_mode_8002 : &set_rx_mode_8012; | ||
351 | dev->tx_timeout = tx_timeout; | ||
352 | dev->watchdog_timeo = TX_TIMEOUT; | 356 | dev->watchdog_timeo = TX_TIMEOUT; |
353 | 357 | ||
354 | res = register_netdev(dev); | 358 | res = register_netdev(dev); |
@@ -421,7 +425,7 @@ static unsigned short __init eeprom_op(long ioaddr, u32 cmd) | |||
421 | registers that "should" only need to be set once at boot, so that | 425 | registers that "should" only need to be set once at boot, so that |
422 | there is non-reboot way to recover if something goes wrong. | 426 | there is non-reboot way to recover if something goes wrong. |
423 | 427 | ||
424 | This is an attachable device: if there is no dev->priv entry then it wasn't | 428 | This is an attachable device: if there is no private entry then it wasn't |
425 | probed for at boot-time, and we need to probe for it again. | 429 | probed for at boot-time, and we need to probe for it again. |
426 | */ | 430 | */ |
427 | static int net_open(struct net_device *dev) | 431 | static int net_open(struct net_device *dev) |
@@ -803,21 +807,22 @@ static void net_rx(struct net_device *dev) | |||
803 | 807 | ||
804 | static void read_block(long ioaddr, int length, unsigned char *p, int data_mode) | 808 | static void read_block(long ioaddr, int length, unsigned char *p, int data_mode) |
805 | { | 809 | { |
806 | |||
807 | if (data_mode <= 3) { /* Mode 0 or 1 */ | 810 | if (data_mode <= 3) { /* Mode 0 or 1 */ |
808 | outb(Ctrl_LNibRead, ioaddr + PAR_CONTROL); | 811 | outb(Ctrl_LNibRead, ioaddr + PAR_CONTROL); |
809 | outb(length == 8 ? RdAddr | HNib | MAR : RdAddr | MAR, | 812 | outb(length == 8 ? RdAddr | HNib | MAR : RdAddr | MAR, |
810 | ioaddr + PAR_DATA); | 813 | ioaddr + PAR_DATA); |
811 | if (data_mode <= 1) { /* Mode 0 or 1 */ | 814 | if (data_mode <= 1) { /* Mode 0 or 1 */ |
812 | do *p++ = read_byte_mode0(ioaddr); while (--length > 0); | 815 | do { *p++ = read_byte_mode0(ioaddr); } while (--length > 0); |
813 | } else /* Mode 2 or 3 */ | 816 | } else { /* Mode 2 or 3 */ |
814 | do *p++ = read_byte_mode2(ioaddr); while (--length > 0); | 817 | do { *p++ = read_byte_mode2(ioaddr); } while (--length > 0); |
815 | } else if (data_mode <= 5) | 818 | } |
816 | do *p++ = read_byte_mode4(ioaddr); while (--length > 0); | 819 | } else if (data_mode <= 5) { |
817 | else | 820 | do { *p++ = read_byte_mode4(ioaddr); } while (--length > 0); |
818 | do *p++ = read_byte_mode6(ioaddr); while (--length > 0); | 821 | } else { |
822 | do { *p++ = read_byte_mode6(ioaddr); } while (--length > 0); | ||
823 | } | ||
819 | 824 | ||
820 | outb(EOC+HNib+MAR, ioaddr + PAR_DATA); | 825 | outb(EOC+HNib+MAR, ioaddr + PAR_DATA); |
821 | outb(Ctrl_SelData, ioaddr + PAR_CONTROL); | 826 | outb(Ctrl_SelData, ioaddr + PAR_CONTROL); |
822 | } | 827 | } |
823 | 828 | ||
@@ -903,6 +908,17 @@ static void set_rx_mode_8012(struct net_device *dev) | |||
903 | write_reg(ioaddr, CMR2, CMR2_IRQOUT); /* Switch back to page 0 */ | 908 | write_reg(ioaddr, CMR2, CMR2_IRQOUT); /* Switch back to page 0 */ |
904 | } | 909 | } |
905 | 910 | ||
911 | static void set_rx_mode(struct net_device *dev) | ||
912 | { | ||
913 | struct net_local *lp = netdev_priv(dev); | ||
914 | |||
915 | if (lp->chip_type == RTL8002) | ||
916 | return set_rx_mode_8002(dev); | ||
917 | else | ||
918 | return set_rx_mode_8012(dev); | ||
919 | } | ||
920 | |||
921 | |||
906 | static int __init atp_init_module(void) { | 922 | static int __init atp_init_module(void) { |
907 | if (debug) /* Emit version even if no cards detected. */ | 923 | if (debug) /* Emit version even if no cards detected. */ |
908 | printk(KERN_INFO "%s", version); | 924 | printk(KERN_INFO "%s", version); |
@@ -913,7 +929,8 @@ static void __exit atp_cleanup_module(void) { | |||
913 | struct net_device *next_dev; | 929 | struct net_device *next_dev; |
914 | 930 | ||
915 | while (root_atp_dev) { | 931 | while (root_atp_dev) { |
916 | next_dev = ((struct net_local *)root_atp_dev->priv)->next_module; | 932 | struct net_local *atp_local = netdev_priv(root_atp_dev); |
933 | next_dev = atp_local->next_module; | ||
917 | unregister_netdev(root_atp_dev); | 934 | unregister_netdev(root_atp_dev); |
918 | /* No need to release_region(), since we never snarf it. */ | 935 | /* No need to release_region(), since we never snarf it. */ |
919 | free_netdev(root_atp_dev); | 936 | free_netdev(root_atp_dev); |