Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 29579
b: refs/heads/master
c: a46c30f
h: refs/heads/master
i:
  29577: 7858f64
  29575: b3bc786
v: v3
  • Loading branch information
David S. Miller committed Jun 24, 2006
1 parent d8669a3 commit ee82632
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 56 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ecba38abfdaf012713b661177c2a6db12bb996c3
refs/heads/master: a46c30fd62636d5d0f4209fed79c99c01dd58218
116 changes: 61 additions & 55 deletions trunk/drivers/net/myri_sbus.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* 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[] =
"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/config.h>
Expand Down Expand Up @@ -81,10 +81,6 @@ static char version[] =
#define DHDR(x)
#endif

#ifdef MODULE
static struct myri_eth *root_myri_dev;
#endif

static void myri_reset_off(void __iomem *lp, void __iomem *cregs)
{
/* Clear IRQ mask. */
Expand Down Expand Up @@ -896,8 +892,9 @@ static void dump_eeprom(struct myri_eth *mp)
}
#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;
struct net_device *dev;
struct myri_eth *mp;
Expand All @@ -913,6 +910,9 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num)
if (version_printed++ == 0)
printk(version);

SET_MODULE_OWNER(dev);
SET_NETDEV_DEV(dev, &sdev->ofdev.dev);

mp = (struct myri_eth *) dev->priv;
spin_lock_init(&mp->irq_lock);
mp->myri_sdev = sdev;
Expand Down Expand Up @@ -1092,10 +1092,9 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num)
goto err_free_irq;
}

#ifdef MODULE
mp->next_module = root_myri_dev;
root_myri_dev = mp;
#endif
dev_set_drvdata(&sdev->ofdev.dev, mp);

num++;

printk("%s: MyriCOM MyriNET Ethernet ", dev->name);

Expand All @@ -1114,61 +1113,68 @@ static int __init myri_ether_init(struct sbus_dev *sdev, int num)
return -ENODEV;
}

static int __init myri_sbus_match(struct sbus_dev *sdev)
{
char *name = sdev->prom_name;

if (!strcmp(name, "MYRICOM,mlanai") ||
!strcmp(name, "myri"))
return 1;
static int __devinit myri_sbus_probe(struct of_device *dev, const struct of_device_id *match)
{
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 sbus_dev *sdev = NULL;
static int called;
int cards = 0, v;
struct myri_eth *mp = dev_get_drvdata(&dev->dev);
struct net_device *net_dev = mp->dev;

#ifdef MODULE
root_myri_dev = NULL;
#endif
unregister_netdevice(net_dev);

if (called)
return -ENODEV;
called++;

for_each_sbus(bus) {
for_each_sbusdev(sdev, bus) {
if (myri_sbus_match(sdev)) {
cards++;
DET(("Found myricom myrinet as %s\n", sdev->prom_name));
if ((v = myri_ether_init(sdev, (cards - 1))))
return v;
}
}
free_irq(net_dev->irq, net_dev);

if (mp->eeprom.cpuvers < CPUVERS_4_0) {
sbus_iounmap(mp->regs, mp->reg_size);
} else {
sbus_iounmap(mp->cregs, PAGE_SIZE);
sbus_iounmap(mp->lregs, (256 * 1024));
sbus_iounmap(mp->lanai, (512 * 1024));
}
if (!cards)
return -ENODEV;

free_netdev(net_dev);

dev_set_drvdata(&dev->dev, NULL);

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
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 */
of_unregister_driver(&myri_sbus_driver);
}

module_init(myri_sbus_probe);
module_exit(myri_sbus_cleanup);
module_init(myri_sbus_init);
module_exit(myri_sbus_exit);

MODULE_LICENSE("GPL");

0 comments on commit ee82632

Please sign in to comment.