Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'mac89x0-fixes-and-cleanups'

Finn Thain says:

====================
Fixes, cleanup and modernization for mac89x0 driver

Changes since v4 of combined patch series:
- Removed redundant and non-portable MACH_IS_MAC tests.
- Added acked-by tags from Geert Uytterhoeven.
- Omitted patches unrelated to mac89x0 driver.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+53 -113
+4
arch/m68k/mac/config.c
··· 1088 1088 macintosh_config->expansion_type == MAC_EXP_PDS_COMM) 1089 1089 platform_device_register_simple("macsonic", -1, NULL, 0); 1090 1090 1091 + if (macintosh_config->expansion_type == MAC_EXP_PDS || 1092 + macintosh_config->expansion_type == MAC_EXP_PDS_COMM) 1093 + platform_device_register_simple("mac89x0", -1, NULL, 0); 1094 + 1091 1095 if (macintosh_config->ether_type == MAC_ETHER_MACE) 1092 1096 platform_device_register_simple("macmace", -1, NULL, 0); 1093 1097
-3
drivers/net/Space.c
··· 114 114 #ifdef CONFIG_MVME147_NET /* MVME147 internal Ethernet */ 115 115 {mvme147lance_probe, 0}, 116 116 #endif 117 - #ifdef CONFIG_MAC89x0 118 - {mac89x0_probe, 0}, 119 - #endif 120 117 {NULL, 0}, 121 118 }; 122 119
+49 -109
drivers/net/ethernet/cirrus/mac89x0.c
··· 56 56 local_irq_{dis,en}able() 57 57 */ 58 58 59 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 60 + 59 61 static const char version[] = 60 62 "cs89x0.c:v1.02 11/26/96 Russell Nelson <nelson@crynwr.com>\n"; 61 63 62 - /* ======================= configure the driver here ======================= */ 63 - 64 - /* use 0 for production, 1 for verification, >2 for debug */ 65 - #ifndef NET_DEBUG 66 - #define NET_DEBUG 0 67 - #endif 68 - 69 - /* ======================= end of configuration ======================= */ 70 - 71 - 72 - /* Always include 'config.h' first in case the user wants to turn on 73 - or override something. */ 74 64 #include <linux/module.h> 75 65 76 66 /* ··· 83 93 #include <linux/errno.h> 84 94 #include <linux/init.h> 85 95 #include <linux/netdevice.h> 96 + #include <linux/platform_device.h> 86 97 #include <linux/etherdevice.h> 87 98 #include <linux/skbuff.h> 88 99 #include <linux/delay.h> ··· 96 105 97 106 #include "cs89x0.h" 98 107 99 - static unsigned int net_debug = NET_DEBUG; 108 + static int debug = -1; 109 + module_param(debug, int, 0); 110 + MODULE_PARM_DESC(debug, "debug message level"); 100 111 101 112 /* Information that need to be kept for each board. */ 102 113 struct net_local { 114 + int msg_enable; 103 115 int chip_type; /* one of: CS8900, CS8920, CS8920M */ 104 116 char chip_revision; /* revision letter of the chip ('A'...) */ 105 117 int send_cmd; /* the propercommand used to send a packet. */ 106 118 int rx_mode; 107 119 int curr_rx_cfg; 108 120 int send_underrun; /* keep track of how many underruns in a row we get */ 109 - struct sk_buff *skb; 110 121 }; 111 122 112 123 /* Index to functions, as function prototypes. */ 113 - 114 - #if 0 115 - extern void reset_chip(struct net_device *dev); 116 - #endif 117 124 static int net_open(struct net_device *dev); 118 125 static int net_send_packet(struct sk_buff *skb, struct net_device *dev); 119 126 static irqreturn_t net_interrupt(int irq, void *dev_id); ··· 120 131 static int net_close(struct net_device *dev); 121 132 static struct net_device_stats *net_get_stats(struct net_device *dev); 122 133 static int set_mac_address(struct net_device *dev, void *addr); 123 - 124 - 125 - /* Example routines you must write ;->. */ 126 - #define tx_done(dev) 1 127 134 128 135 /* For reading/writing registers ISA-style */ 129 136 static inline int ··· 161 176 162 177 /* Probe for the CS8900 card in slot E. We won't bother looking 163 178 anywhere else until we have a really good reason to do so. */ 164 - struct net_device * __init mac89x0_probe(int unit) 179 + static int mac89x0_device_probe(struct platform_device *pdev) 165 180 { 166 181 struct net_device *dev; 167 - static int once_is_enough; 168 182 struct net_local *lp; 169 - static unsigned version_printed; 170 183 int i, slot; 171 184 unsigned rev_type = 0; 172 185 unsigned long ioaddr; ··· 172 189 int err = -ENODEV; 173 190 struct nubus_rsrc *fres; 174 191 175 - if (!MACH_IS_MAC) 176 - return ERR_PTR(-ENODEV); 177 - 178 192 dev = alloc_etherdev(sizeof(struct net_local)); 179 193 if (!dev) 180 - return ERR_PTR(-ENOMEM); 181 - 182 - if (unit >= 0) { 183 - sprintf(dev->name, "eth%d", unit); 184 - netdev_boot_setup_check(dev); 185 - } 186 - 187 - if (once_is_enough) 188 - goto out; 189 - once_is_enough = 1; 194 + return -ENOMEM; 190 195 191 196 /* We might have to parameterize this later */ 192 197 slot = 0xE; ··· 201 230 if (sig != swab16(CHIP_EISA_ID_SIG)) 202 231 goto out; 203 232 233 + SET_NETDEV_DEV(dev, &pdev->dev); 234 + 204 235 /* Initialize the net_device structure. */ 205 236 lp = netdev_priv(dev); 237 + 238 + lp->msg_enable = netif_msg_init(debug, 0); 206 239 207 240 /* Fill in the 'dev' fields. */ 208 241 dev->base_addr = ioaddr; ··· 230 255 if (lp->chip_type != CS8900 && lp->chip_revision >= 'C') 231 256 lp->send_cmd = TX_NOW; 232 257 233 - if (net_debug && version_printed++ == 0) 234 - printk(version); 258 + netif_dbg(lp, drv, dev, "%s", version); 235 259 236 - printk(KERN_INFO "%s: cs89%c0%s rev %c found at %#8lx", 237 - dev->name, 238 - lp->chip_type==CS8900?'0':'2', 239 - lp->chip_type==CS8920M?"M":"", 240 - lp->chip_revision, 241 - dev->base_addr); 260 + pr_info("cs89%c0%s rev %c found at %#8lx\n", 261 + lp->chip_type == CS8900 ? '0' : '2', 262 + lp->chip_type == CS8920M ? "M" : "", 263 + lp->chip_revision, dev->base_addr); 242 264 243 265 /* Try to read the MAC address */ 244 266 if ((readreg(dev, PP_SelfST) & (EEPROM_PRESENT | EEPROM_OK)) == 0) { 245 - printk("\nmac89x0: No EEPROM, giving up now.\n"); 267 + pr_info("No EEPROM, giving up now.\n"); 246 268 goto out1; 247 269 } else { 248 270 for (i = 0; i < ETH_ALEN; i += 2) { ··· 254 282 255 283 /* print the IRQ and ethernet address. */ 256 284 257 - printk(" IRQ %d ADDR %pM\n", dev->irq, dev->dev_addr); 285 + pr_info("MAC %pM, IRQ %d\n", dev->dev_addr, dev->irq); 258 286 259 287 dev->netdev_ops = &mac89x0_netdev_ops; 260 288 261 289 err = register_netdev(dev); 262 290 if (err) 263 291 goto out1; 264 - return NULL; 292 + 293 + platform_set_drvdata(pdev, dev); 294 + return 0; 265 295 out1: 266 296 nubus_writew(0, dev->base_addr + ADD_PORT); 267 297 out: 268 298 free_netdev(dev); 269 - return ERR_PTR(err); 299 + return err; 270 300 } 271 - 272 - #if 0 273 - /* This is useful for something, but I don't know what yet. */ 274 - void __init reset_chip(struct net_device *dev) 275 - { 276 - int reset_start_time; 277 - 278 - writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET); 279 - 280 - /* wait 30 ms */ 281 - msleep_interruptible(30); 282 - 283 - /* Wait until the chip is reset */ 284 - reset_start_time = jiffies; 285 - while( (readreg(dev, PP_SelfST) & INIT_DONE) == 0 && jiffies - reset_start_time < 2) 286 - ; 287 - } 288 - #endif 289 301 290 302 /* Open/initialize the board. This is called (in the current kernel) 291 303 sometime after booting when the 'ifconfig' program is run. ··· 330 374 struct net_local *lp = netdev_priv(dev); 331 375 unsigned long flags; 332 376 333 - if (net_debug > 3) 334 - printk("%s: sent %d byte packet of type %x\n", 335 - dev->name, skb->len, 336 - (skb->data[ETH_ALEN+ETH_ALEN] << 8) 337 - | skb->data[ETH_ALEN+ETH_ALEN+1]); 377 + netif_dbg(lp, tx_queued, dev, "sent %d byte packet of type %x\n", 378 + skb->len, skb->data[ETH_ALEN + ETH_ALEN] << 8 | 379 + skb->data[ETH_ALEN + ETH_ALEN + 1]); 338 380 339 381 /* keep the upload from being interrupted, since we 340 382 ask the chip to start transmitting before the ··· 370 416 struct net_local *lp; 371 417 int ioaddr, status; 372 418 373 - if (dev == NULL) { 374 - printk ("net_interrupt(): irq %d for unknown device.\n", irq); 375 - return IRQ_NONE; 376 - } 377 - 378 419 ioaddr = dev->base_addr; 379 420 lp = netdev_priv(dev); 380 421 ··· 381 432 faster than you can read them off, you're screwed. Hasta la 382 433 vista, baby! */ 383 434 while ((status = swab16(nubus_readw(dev->base_addr + ISQ_PORT)))) { 384 - if (net_debug > 4)printk("%s: event=%04x\n", dev->name, status); 435 + netif_dbg(lp, intr, dev, "status=%04x\n", status); 385 436 switch(status & ISQ_EVENT_MASK) { 386 437 case ISQ_RECEIVER_EVENT: 387 438 /* Got a packet(s). */ ··· 411 462 netif_wake_queue(dev); 412 463 } 413 464 if (status & TX_UNDERRUN) { 414 - if (net_debug > 0) printk("%s: transmit underrun\n", dev->name); 465 + netif_dbg(lp, tx_err, dev, "transmit underrun\n"); 415 466 lp->send_underrun++; 416 467 if (lp->send_underrun == 3) lp->send_cmd = TX_AFTER_381; 417 468 else if (lp->send_underrun == 6) lp->send_cmd = TX_AFTER_ALL; ··· 432 483 static void 433 484 net_rx(struct net_device *dev) 434 485 { 486 + struct net_local *lp = netdev_priv(dev); 435 487 struct sk_buff *skb; 436 488 int status, length; 437 489 ··· 456 506 /* Malloc up new buffer. */ 457 507 skb = alloc_skb(length, GFP_ATOMIC); 458 508 if (skb == NULL) { 459 - printk("%s: Memory squeeze, dropping packet.\n", dev->name); 460 509 dev->stats.rx_dropped++; 461 510 return; 462 511 } ··· 464 515 skb_copy_to_linear_data(skb, (void *)(dev->mem_start + PP_RxFrame), 465 516 length); 466 517 467 - if (net_debug > 3)printk("%s: received %d byte packet of type %x\n", 468 - dev->name, length, 469 - (skb->data[ETH_ALEN+ETH_ALEN] << 8) 470 - | skb->data[ETH_ALEN+ETH_ALEN+1]); 518 + netif_dbg(lp, rx_status, dev, "received %d byte packet of type %x\n", 519 + length, skb->data[ETH_ALEN + ETH_ALEN] << 8 | 520 + skb->data[ETH_ALEN + ETH_ALEN + 1]); 471 521 472 522 skb->protocol=eth_type_trans(skb,dev); 473 523 netif_rx(skb); ··· 542 594 return -EADDRNOTAVAIL; 543 595 544 596 memcpy(dev->dev_addr, saddr->sa_data, ETH_ALEN); 545 - printk("%s: Setting MAC address to %pM\n", dev->name, dev->dev_addr); 597 + netdev_info(dev, "Setting MAC address to %pM\n", dev->dev_addr); 546 598 547 599 /* set the Ethernet address */ 548 600 for (i=0; i < ETH_ALEN/2; i++) ··· 551 603 return 0; 552 604 } 553 605 554 - #ifdef MODULE 555 - 556 - static struct net_device *dev_cs89x0; 557 - static int debug; 558 - 559 - module_param(debug, int, 0); 560 - MODULE_PARM_DESC(debug, "CS89[02]0 debug level (0-5)"); 561 606 MODULE_LICENSE("GPL"); 562 607 563 - int __init 564 - init_module(void) 608 + static int mac89x0_device_remove(struct platform_device *pdev) 565 609 { 566 - net_debug = debug; 567 - dev_cs89x0 = mac89x0_probe(-1); 568 - if (IS_ERR(dev_cs89x0)) { 569 - printk(KERN_WARNING "mac89x0.c: No card found\n"); 570 - return PTR_ERR(dev_cs89x0); 571 - } 610 + struct net_device *dev = platform_get_drvdata(pdev); 611 + 612 + unregister_netdev(dev); 613 + nubus_writew(0, dev->base_addr + ADD_PORT); 614 + free_netdev(dev); 572 615 return 0; 573 616 } 574 617 575 - void 576 - cleanup_module(void) 577 - { 578 - unregister_netdev(dev_cs89x0); 579 - nubus_writew(0, dev_cs89x0->base_addr + ADD_PORT); 580 - free_netdev(dev_cs89x0); 581 - } 582 - #endif /* MODULE */ 618 + static struct platform_driver mac89x0_platform_driver = { 619 + .probe = mac89x0_device_probe, 620 + .remove = mac89x0_device_remove, 621 + .driver = { 622 + .name = "mac89x0", 623 + }, 624 + }; 625 + 626 + module_platform_driver(mac89x0_platform_driver);
-1
include/net/Space.h
··· 20 20 struct net_device *mvme147lance_probe(int unit); 21 21 struct net_device *tc515_probe(int unit); 22 22 struct net_device *lance_probe(int unit); 23 - struct net_device *mac89x0_probe(int unit); 24 23 struct net_device *cops_probe(int unit); 25 24 struct net_device *ltpc_probe(void); 26 25