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

[NET] sunbmac: Convert over to new SBUS device framework.

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

+59 -65
+59 -64
drivers/net/sunbmac.c
··· 72 72 #define DIRQ(x) 73 73 #endif 74 74 75 - static struct bigmac *root_bigmac_dev; 76 - 77 75 #define DEFAULT_JAMSIZE 4 /* Toe jam */ 78 76 79 77 #define QEC_RESET_TRIES 200 ··· 489 491 } 490 492 } 491 493 492 - static int bigmac_init(struct bigmac *, int); 494 + static int bigmac_init_hw(struct bigmac *, int); 493 495 494 496 static int try_next_permutation(struct bigmac *bp, void __iomem *tregs) 495 497 { ··· 549 551 if (ret == -1) { 550 552 printk(KERN_ERR "%s: Link down, cable problem?\n", 551 553 bp->dev->name); 552 - ret = bigmac_init(bp, 0); 554 + ret = bigmac_init_hw(bp, 0); 553 555 if (ret) { 554 556 printk(KERN_ERR "%s: Error, cannot re-init the " 555 557 "BigMAC.\n", bp->dev->name); ··· 619 621 add_timer(&bp->bigmac_timer); 620 622 } 621 623 622 - static int bigmac_init(struct bigmac *bp, int from_irq) 624 + static int bigmac_init_hw(struct bigmac *bp, int from_irq) 623 625 { 624 626 void __iomem *gregs = bp->gregs; 625 627 void __iomem *cregs = bp->creg; ··· 750 752 } 751 753 752 754 printk(" RESET\n"); 753 - bigmac_init(bp, 1); 755 + bigmac_init_hw(bp, 1); 754 756 } 755 757 756 758 /* BigMAC transmit complete service routines. */ ··· 924 926 return ret; 925 927 } 926 928 init_timer(&bp->bigmac_timer); 927 - ret = bigmac_init(bp, 0); 929 + ret = bigmac_init_hw(bp, 0); 928 930 if (ret) 929 931 free_irq(dev->irq, bp); 930 932 return ret; ··· 948 950 { 949 951 struct bigmac *bp = (struct bigmac *) dev->priv; 950 952 951 - bigmac_init(bp, 0); 953 + bigmac_init_hw(bp, 0); 952 954 netif_wake_queue(dev); 953 955 } 954 956 ··· 1102 1104 bp->qec_sdev = qec_sdev; 1103 1105 bp->bigmac_sdev = qec_sdev->child; 1104 1106 1107 + SET_NETDEV_DEV(dev, &bp->bigmac_sdev->ofdev.dev); 1108 + 1105 1109 spin_lock_init(&bp->lock); 1106 1110 1107 1111 /* Verify the registers we expect, are actually there. */ ··· 1226 1226 goto fail_and_cleanup; 1227 1227 } 1228 1228 1229 - /* Put us into the list of instances attached for later driver 1230 - * exit. 1231 - */ 1232 - bp->next_module = root_bigmac_dev; 1233 - root_bigmac_dev = bp; 1229 + dev_set_drvdata(&bp->bigmac_sdev->ofdev.dev, bp); 1234 1230 1235 1231 printk(KERN_INFO "%s: BigMAC 100baseT Ethernet ", dev->name); 1236 1232 for (i = 0; i < 6; i++) ··· 1262 1266 /* QEC can be the parent of either QuadEthernet or 1263 1267 * a BigMAC. We want the latter. 1264 1268 */ 1265 - static int __init bigmac_match(struct sbus_dev *sdev) 1269 + static int __devinit bigmac_sbus_probe(struct of_device *dev, const struct of_device_id *match) 1266 1270 { 1267 - struct sbus_dev *child = sdev->child; 1271 + struct sbus_dev *sdev = to_sbus_device(&dev->dev); 1272 + struct device_node *dp = dev->node; 1268 1273 1269 - if (strcmp(sdev->prom_name, "qec") != 0) 1270 - return 0; 1274 + if (!strcmp(dp->name, "be")) 1275 + sdev = sdev->parent; 1271 1276 1272 - if (child == NULL) 1273 - return 0; 1274 - 1275 - if (strcmp(child->prom_name, "be") != 0) 1276 - return 0; 1277 - 1278 - return 1; 1277 + return bigmac_ether_init(sdev); 1279 1278 } 1280 1279 1281 - static int __init bigmac_probe(void) 1280 + static int __devexit bigmac_sbus_remove(struct of_device *dev) 1282 1281 { 1283 - struct sbus_bus *sbus; 1284 - struct sbus_dev *sdev = NULL; 1285 - static int called; 1286 - int cards = 0, v; 1282 + struct bigmac *bp = dev_get_drvdata(&dev->dev); 1283 + struct net_device *net_dev = bp->dev; 1287 1284 1288 - root_bigmac_dev = NULL; 1285 + unregister_netdevice(net_dev); 1289 1286 1290 - if (called) 1291 - return -ENODEV; 1292 - called++; 1287 + sbus_iounmap(bp->gregs, GLOB_REG_SIZE); 1288 + sbus_iounmap(bp->creg, CREG_REG_SIZE); 1289 + sbus_iounmap(bp->bregs, BMAC_REG_SIZE); 1290 + sbus_iounmap(bp->tregs, TCVR_REG_SIZE); 1291 + sbus_free_consistent(bp->bigmac_sdev, 1292 + PAGE_SIZE, 1293 + bp->bmac_block, 1294 + bp->bblock_dvma); 1293 1295 1294 - for_each_sbus(sbus) { 1295 - for_each_sbusdev(sdev, sbus) { 1296 - if (bigmac_match(sdev)) { 1297 - cards++; 1298 - if ((v = bigmac_ether_init(sdev))) 1299 - return v; 1300 - } 1301 - } 1302 - } 1303 - if (!cards) 1304 - return -ENODEV; 1296 + free_netdev(net_dev); 1297 + 1298 + dev_set_drvdata(&dev->dev, NULL); 1299 + 1305 1300 return 0; 1306 1301 } 1307 1302 1308 - static void __exit bigmac_cleanup(void) 1303 + static struct of_device_id bigmac_sbus_match[] = { 1304 + { 1305 + .name = "qec", 1306 + }, 1307 + { 1308 + .name = "be", 1309 + }, 1310 + {}, 1311 + }; 1312 + 1313 + MODULE_DEVICE_TABLE(of, bigmac_sbus_match); 1314 + 1315 + static struct of_platform_driver bigmac_sbus_driver = { 1316 + .name = "sunbmac", 1317 + .match_table = bigmac_sbus_match, 1318 + .probe = bigmac_sbus_probe, 1319 + .remove = __devexit_p(bigmac_sbus_remove), 1320 + }; 1321 + 1322 + static int __init bigmac_init(void) 1309 1323 { 1310 - while (root_bigmac_dev) { 1311 - struct bigmac *bp = root_bigmac_dev; 1312 - struct bigmac *bp_nxt = root_bigmac_dev->next_module; 1313 - 1314 - sbus_iounmap(bp->gregs, GLOB_REG_SIZE); 1315 - sbus_iounmap(bp->creg, CREG_REG_SIZE); 1316 - sbus_iounmap(bp->bregs, BMAC_REG_SIZE); 1317 - sbus_iounmap(bp->tregs, TCVR_REG_SIZE); 1318 - sbus_free_consistent(bp->bigmac_sdev, 1319 - PAGE_SIZE, 1320 - bp->bmac_block, 1321 - bp->bblock_dvma); 1322 - 1323 - unregister_netdev(bp->dev); 1324 - free_netdev(bp->dev); 1325 - root_bigmac_dev = bp_nxt; 1326 - } 1324 + return of_register_driver(&bigmac_sbus_driver, &sbus_bus_type); 1327 1325 } 1328 1326 1329 - module_init(bigmac_probe); 1330 - module_exit(bigmac_cleanup); 1327 + static void __exit bigmac_exit(void) 1328 + { 1329 + of_unregister_driver(&bigmac_sbus_driver); 1330 + } 1331 + 1332 + module_init(bigmac_init); 1333 + module_exit(bigmac_exit);
-1
drivers/net/sunbmac.h
··· 332 332 struct sbus_dev *qec_sdev; 333 333 struct sbus_dev *bigmac_sdev; 334 334 struct net_device *dev; 335 - struct bigmac *next_module; 336 335 }; 337 336 338 337 /* We use this to acquire receive skb's that we can DMA directly into. */