Commit a46c30fd authored by David S. Miller's avatar David S. Miller

[NET] myri_sbus: Convert to new SBUS device layer.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ecba38ab
/* myri_sbus.h: MyriCOM MyriNET SBUS card driver. /* myri_sbus.c: MyriCOM MyriNET SBUS card driver.
* *
* Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com) * Copyright (C) 1996, 1999, 2006 David S. Miller (davem@davemloft.net)
*/ */
static char version[] = static char version[] =
"myri_sbus.c:v1.9 12/Sep/99 David S. Miller (davem@redhat.com)\n"; "myri_sbus.c:v2.0 June 23, 2006 David S. Miller (davem@davemloft.net)\n";
#include <linux/module.h> #include <linux/module.h>
#include <linux/config.h> #include <linux/config.h>
...@@ -81,10 +81,6 @@ static char version[] = ...@@ -81,10 +81,6 @@ static char version[] =
#define DHDR(x) #define DHDR(x)
#endif #endif
#ifdef MODULE
static struct myri_eth *root_myri_dev;
#endif
static void myri_reset_off(void __iomem *lp, void __iomem *cregs) static void myri_reset_off(void __iomem *lp, void __iomem *cregs)
{ {
/* Clear IRQ mask. */ /* Clear IRQ mask. */
...@@ -896,8 +892,9 @@ static void dump_eeprom(struct myri_eth *mp) ...@@ -896,8 +892,9 @@ static void dump_eeprom(struct myri_eth *mp)
} }
#endif #endif
static int __init myri_ether_init(struct sbus_dev *sdev, int num) static int __init myri_ether_init(struct sbus_dev *sdev)
{ {
static int num;
static unsigned version_printed; static unsigned version_printed;
struct net_device *dev; struct net_device *dev;
struct myri_eth *mp; struct myri_eth *mp;
...@@ -913,6 +910,9 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num) ...@@ -913,6 +910,9 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num)
if (version_printed++ == 0) if (version_printed++ == 0)
printk(version); printk(version);
SET_MODULE_OWNER(dev);
SET_NETDEV_DEV(dev, &sdev->ofdev.dev);
mp = (struct myri_eth *) dev->priv; mp = (struct myri_eth *) dev->priv;
spin_lock_init(&mp->irq_lock); spin_lock_init(&mp->irq_lock);
mp->myri_sdev = sdev; mp->myri_sdev = sdev;
...@@ -1092,10 +1092,9 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num) ...@@ -1092,10 +1092,9 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num)
goto err_free_irq; goto err_free_irq;
} }
#ifdef MODULE dev_set_drvdata(&sdev->ofdev.dev, mp);
mp->next_module = root_myri_dev;
root_myri_dev = mp; num++;
#endif
printk("%s: MyriCOM MyriNET Ethernet ", dev->name); printk("%s: MyriCOM MyriNET Ethernet ", dev->name);
...@@ -1114,61 +1113,68 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num) ...@@ -1114,61 +1113,68 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num)
return -ENODEV; return -ENODEV;
} }
static int __init myri_sbus_match(struct sbus_dev *sdev)
{
char *name = sdev->prom_name;
if (!strcmp(name, "MYRICOM,mlanai") || static int __devinit myri_sbus_probe(struct of_device *dev, const struct of_device_id *match)
!strcmp(name, "myri")) {
return 1; struct sbus_dev *sdev = to_sbus_device(&dev->dev);
return 0; return myri_ether_init(sdev);
} }
static int __init myri_sbus_probe(void) static int __devexit myri_sbus_remove(struct of_device *dev)
{ {
struct sbus_bus *bus; struct myri_eth *mp = dev_get_drvdata(&dev->dev);
struct sbus_dev *sdev = NULL; struct net_device *net_dev = mp->dev;
static int called;
int cards = 0, v;
#ifdef MODULE unregister_netdevice(net_dev);
root_myri_dev = NULL;
#endif
if (called) free_irq(net_dev->irq, net_dev);
return -ENODEV;
called++; if (mp->eeprom.cpuvers < CPUVERS_4_0) {
sbus_iounmap(mp->regs, mp->reg_size);
for_each_sbus(bus) { } else {
for_each_sbusdev(sdev, bus) { sbus_iounmap(mp->cregs, PAGE_SIZE);
if (myri_sbus_match(sdev)) { sbus_iounmap(mp->lregs, (256 * 1024));
cards++; sbus_iounmap(mp->lanai, (512 * 1024));
DET(("Found myricom myrinet as %s\n", sdev->prom_name));
if ((v = myri_ether_init(sdev, (cards - 1))))
return v;
}
}
} }
if (!cards)
return -ENODEV; free_netdev(net_dev);
dev_set_drvdata(&dev->dev, NULL);
return 0; return 0;
} }
static void __exit myri_sbus_cleanup(void) static struct of_device_id myri_sbus_match[] = {
{
.name = "MYRICOM,mlanai",
},
{
.name = "myri",
},
{},
};
MODULE_DEVICE_TABLE(of, myri_sbus_match);
static struct of_platform_driver myri_sbus_driver = {
.name = "myri",
.match_table = myri_sbus_match,
.probe = myri_sbus_probe,
.remove = __devexit_p(myri_sbus_remove),
};
static int __init myri_sbus_init(void)
{
return of_register_driver(&myri_sbus_driver, &sbus_bus_type);
}
static void __exit myri_sbus_exit(void)
{ {
#ifdef MODULE of_unregister_driver(&myri_sbus_driver);
while (root_myri_dev) {
struct myri_eth *next = root_myri_dev->next_module;
unregister_netdev(root_myri_dev->dev);
/* this will also free the co-allocated 'root_myri_dev' */
free_netdev(root_myri_dev->dev);
root_myri_dev = next;
}
#endif /* MODULE */
} }
module_init(myri_sbus_probe); module_init(myri_sbus_init);
module_exit(myri_sbus_cleanup); module_exit(myri_sbus_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment