···7272#define DIRQ(x)7373#endif74747575-static struct bigmac *root_bigmac_dev;7676-7775#define DEFAULT_JAMSIZE 4 /* Toe jam */78767977#define QEC_RESET_TRIES 200···489491 }490492}491493492492-static int bigmac_init(struct bigmac *, int);494494+static int bigmac_init_hw(struct bigmac *, int);493495494496static int try_next_permutation(struct bigmac *bp, void __iomem *tregs)495497{···549551 if (ret == -1) {550552 printk(KERN_ERR "%s: Link down, cable problem?\n",551553 bp->dev->name);552552- ret = bigmac_init(bp, 0);554554+ ret = bigmac_init_hw(bp, 0);553555 if (ret) {554556 printk(KERN_ERR "%s: Error, cannot re-init the "555557 "BigMAC.\n", bp->dev->name);···619621 add_timer(&bp->bigmac_timer);620622}621623622622-static int bigmac_init(struct bigmac *bp, int from_irq)624624+static int bigmac_init_hw(struct bigmac *bp, int from_irq)623625{624626 void __iomem *gregs = bp->gregs;625627 void __iomem *cregs = bp->creg;···750752 }751753752754 printk(" RESET\n");753753- bigmac_init(bp, 1);755755+ bigmac_init_hw(bp, 1);754756}755757756758/* BigMAC transmit complete service routines. */···924926 return ret;925927 }926928 init_timer(&bp->bigmac_timer);927927- ret = bigmac_init(bp, 0);929929+ ret = bigmac_init_hw(bp, 0);928930 if (ret)929931 free_irq(dev->irq, bp);930932 return ret;···948950{949951 struct bigmac *bp = (struct bigmac *) dev->priv;950952951951- bigmac_init(bp, 0);953953+ bigmac_init_hw(bp, 0);952954 netif_wake_queue(dev);953955}954956···11021104 bp->qec_sdev = qec_sdev;11031105 bp->bigmac_sdev = qec_sdev->child;1104110611071107+ SET_NETDEV_DEV(dev, &bp->bigmac_sdev->ofdev.dev);11081108+11051109 spin_lock_init(&bp->lock);1106111011071111 /* Verify the registers we expect, are actually there. */···12261226 goto fail_and_cleanup;12271227 }1228122812291229- /* Put us into the list of instances attached for later driver12301230- * exit.12311231- */12321232- bp->next_module = root_bigmac_dev;12331233- root_bigmac_dev = bp;12291229+ dev_set_drvdata(&bp->bigmac_sdev->ofdev.dev, bp);1234123012351231 printk(KERN_INFO "%s: BigMAC 100baseT Ethernet ", dev->name);12361232 for (i = 0; i < 6; i++)···12621266/* QEC can be the parent of either QuadEthernet or12631267 * a BigMAC. We want the latter.12641268 */12651265-static int __init bigmac_match(struct sbus_dev *sdev)12691269+static int __devinit bigmac_sbus_probe(struct of_device *dev, const struct of_device_id *match)12661270{12671267- struct sbus_dev *child = sdev->child;12711271+ struct sbus_dev *sdev = to_sbus_device(&dev->dev);12721272+ struct device_node *dp = dev->node;1268127312691269- if (strcmp(sdev->prom_name, "qec") != 0)12701270- return 0;12741274+ if (!strcmp(dp->name, "be"))12751275+ sdev = sdev->parent;1271127612721272- if (child == NULL)12731273- return 0;12741274-12751275- if (strcmp(child->prom_name, "be") != 0)12761276- return 0;12771277-12781278- return 1;12771277+ return bigmac_ether_init(sdev);12791278}1280127912811281-static int __init bigmac_probe(void)12801280+static int __devexit bigmac_sbus_remove(struct of_device *dev)12821281{12831283- struct sbus_bus *sbus;12841284- struct sbus_dev *sdev = NULL;12851285- static int called;12861286- int cards = 0, v;12821282+ struct bigmac *bp = dev_get_drvdata(&dev->dev);12831283+ struct net_device *net_dev = bp->dev;1287128412881288- root_bigmac_dev = NULL;12851285+ unregister_netdevice(net_dev);1289128612901290- if (called)12911291- return -ENODEV;12921292- called++;12871287+ sbus_iounmap(bp->gregs, GLOB_REG_SIZE);12881288+ sbus_iounmap(bp->creg, CREG_REG_SIZE);12891289+ sbus_iounmap(bp->bregs, BMAC_REG_SIZE);12901290+ sbus_iounmap(bp->tregs, TCVR_REG_SIZE);12911291+ sbus_free_consistent(bp->bigmac_sdev,12921292+ PAGE_SIZE,12931293+ bp->bmac_block,12941294+ bp->bblock_dvma);1293129512941294- for_each_sbus(sbus) {12951295- for_each_sbusdev(sdev, sbus) {12961296- if (bigmac_match(sdev)) {12971297- cards++;12981298- if ((v = bigmac_ether_init(sdev)))12991299- return v;13001300- }13011301- }13021302- }13031303- if (!cards)13041304- return -ENODEV;12961296+ free_netdev(net_dev);12971297+12981298+ dev_set_drvdata(&dev->dev, NULL);12991299+13051300 return 0;13061301}1307130213081308-static void __exit bigmac_cleanup(void)13031303+static struct of_device_id bigmac_sbus_match[] = {13041304+ {13051305+ .name = "qec",13061306+ },13071307+ {13081308+ .name = "be",13091309+ },13101310+ {},13111311+};13121312+13131313+MODULE_DEVICE_TABLE(of, bigmac_sbus_match);13141314+13151315+static struct of_platform_driver bigmac_sbus_driver = {13161316+ .name = "sunbmac",13171317+ .match_table = bigmac_sbus_match,13181318+ .probe = bigmac_sbus_probe,13191319+ .remove = __devexit_p(bigmac_sbus_remove),13201320+};13211321+13221322+static int __init bigmac_init(void)13091323{13101310- while (root_bigmac_dev) {13111311- struct bigmac *bp = root_bigmac_dev;13121312- struct bigmac *bp_nxt = root_bigmac_dev->next_module;13131313-13141314- sbus_iounmap(bp->gregs, GLOB_REG_SIZE);13151315- sbus_iounmap(bp->creg, CREG_REG_SIZE);13161316- sbus_iounmap(bp->bregs, BMAC_REG_SIZE);13171317- sbus_iounmap(bp->tregs, TCVR_REG_SIZE);13181318- sbus_free_consistent(bp->bigmac_sdev,13191319- PAGE_SIZE,13201320- bp->bmac_block,13211321- bp->bblock_dvma);13221322-13231323- unregister_netdev(bp->dev);13241324- free_netdev(bp->dev);13251325- root_bigmac_dev = bp_nxt;13261326- }13241324+ return of_register_driver(&bigmac_sbus_driver, &sbus_bus_type);13271325}1328132613291329-module_init(bigmac_probe);13301330-module_exit(bigmac_cleanup);13271327+static void __exit bigmac_exit(void)13281328+{13291329+ of_unregister_driver(&bigmac_sbus_driver);13301330+}13311331+13321332+module_init(bigmac_init);13331333+module_exit(bigmac_exit);
-1
drivers/net/sunbmac.h
···332332 struct sbus_dev *qec_sdev;333333 struct sbus_dev *bigmac_sdev;334334 struct net_device *dev;335335- struct bigmac *next_module;336335};337336338337/* We use this to acquire receive skb's that we can DMA directly into. */