X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fnet%2Fdm9000.c;h=e54fc10f68467c7fd9bf92e11b9fb9d3fba3cee4;hb=35d91f75c2c9548e606e813413f03c5cc35da969;hp=f4ba0ffb8637bb43f6e846703029ed79d524df0f;hpb=1a9505996dd0c12a2e56d2c6af00846e75a3850d;p=linux-2.6-omap-h63xx.git diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index f4ba0ffb863..e54fc10f684 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c @@ -48,6 +48,10 @@ * net_device_stats * * introduced tx_timeout function * * reworked locking + * + * 01-Jul-2005 Ben Dooks + * * fixed spinlock call without pointer + * * ensure spinlock is initialised */ #include @@ -148,7 +152,6 @@ static int dm9000_probe(struct device *); static int dm9000_open(struct net_device *); static int dm9000_start_xmit(struct sk_buff *, struct net_device *); static int dm9000_stop(struct net_device *); -static int dm9000_do_ioctl(struct net_device *, struct ifreq *, int); static void dm9000_timer(unsigned long); @@ -224,7 +227,7 @@ static void dm9000_outblk_32bit(void __iomem *reg, void *data, int count) static void dm9000_inblk_8bit(void __iomem *reg, void *data, int count) { - readsb(reg, data, count+1); + readsb(reg, data, count); } @@ -322,7 +325,7 @@ static void dm9000_timeout(struct net_device *dev) /* Save previous register address */ reg_save = readb(db->io_addr); - spin_lock_irqsave(db->lock,flags); + spin_lock_irqsave(&db->lock,flags); netif_stop_queue(dev); dm9000_reset(db); @@ -333,7 +336,7 @@ static void dm9000_timeout(struct net_device *dev) /* Restore previous register address */ writeb(reg_save, db->io_addr); - spin_unlock_irqrestore(db->lock,flags); + spin_unlock_irqrestore(&db->lock,flags); } @@ -364,7 +367,7 @@ dm9000_release_board(struct platform_device *pdev, struct board_info *db) } if (db->addr_res != NULL) { - release_resource(db->data_req); + release_resource(db->addr_res); kfree(db->addr_req); } } @@ -387,8 +390,6 @@ dm9000_probe(struct device *dev) int i; u32 id_val; - printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME); - /* Init network device */ ndev = alloc_etherdev(sizeof (struct board_info)); if (!ndev) { @@ -405,6 +406,8 @@ dm9000_probe(struct device *dev) db = (struct board_info *) ndev->priv; memset(db, 0, sizeof (*db)); + spin_lock_init(&db->lock); + if (pdev->num_resources < 2) { ret = -ENODEV; goto out; @@ -541,7 +544,6 @@ dm9000_probe(struct device *dev) ndev->stop = &dm9000_stop; ndev->get_stats = &dm9000_get_stats; ndev->set_multicast_list = &dm9000_hash_table; - ndev->do_ioctl = &dm9000_do_ioctl; #ifdef DM9000_PROGRAM_EEPROM program_eeprom(db); @@ -612,7 +614,7 @@ dm9000_open(struct net_device *dev) /* set and active a timer process */ init_timer(&db->timer); - db->timer.expires = DM9000_TIMER_WUT * 2; + db->timer.expires = DM9000_TIMER_WUT; db->timer.data = (unsigned long) dev; db->timer.function = &dm9000_timer; add_timer(&db->timer); @@ -845,15 +847,6 @@ dm9000_get_stats(struct net_device *dev) return &db->stats; } -/* - * Process the upper socket ioctl command - */ -static int -dm9000_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - PRINTK1("entering %s\n",__FUNCTION__); - return 0; -} /* * A periodic timer routine @@ -864,21 +857,11 @@ dm9000_timer(unsigned long data) { struct net_device *dev = (struct net_device *) data; board_info_t *db = (board_info_t *) dev->priv; - u8 reg_save; - unsigned long flags; PRINTK3("dm9000_timer()\n"); - spin_lock_irqsave(db->lock,flags); - /* Save previous register address */ - reg_save = readb(db->io_addr); - mii_check_media(&db->mii, netif_msg_link(db), 0); - /* Restore previous register address */ - writeb(reg_save, db->io_addr); - spin_unlock_irqrestore(db->lock,flags); - /* Set timer again */ db->timer.expires = DM9000_TIMER_WUT; add_timer(&db->timer); @@ -1098,9 +1081,14 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg) { board_info_t *db = (board_info_t *) dev->priv; unsigned long flags; + unsigned int reg_save; int ret; spin_lock_irqsave(&db->lock,flags); + + /* Save previous register address */ + reg_save = readb(db->io_addr); + /* Fill the phyxcer register into REG_0C */ iow(db, DM9000_EPAR, DM9000_PHY | reg); @@ -1111,6 +1099,9 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg) /* The read data keeps on REG_0D & REG_0E */ ret = (ior(db, DM9000_EPDRH) << 8) | ior(db, DM9000_EPDRL); + /* restore the previous address */ + writeb(reg_save, db->io_addr); + spin_unlock_irqrestore(&db->lock,flags); return ret; @@ -1124,9 +1115,13 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value) { board_info_t *db = (board_info_t *) dev->priv; unsigned long flags; + unsigned long reg_save; spin_lock_irqsave(&db->lock,flags); + /* Save previous register address */ + reg_save = readb(db->io_addr); + /* Fill the phyxcer register into REG_0C */ iow(db, DM9000_EPAR, DM9000_PHY | reg); @@ -1138,11 +1133,14 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value) udelay(500); /* Wait write complete */ iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer write command */ + /* restore the previous address */ + writeb(reg_save, db->io_addr); + spin_unlock_irqrestore(&db->lock,flags); } static int -dm9000_drv_suspend(struct device *dev, u32 state, u32 level) +dm9000_drv_suspend(struct device *dev, pm_message_t state, u32 level) { struct net_device *ndev = dev_get_drvdata(dev); @@ -1202,6 +1200,8 @@ static struct device_driver dm9000_driver = { static int __init dm9000_init(void) { + printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME); + return driver_register(&dm9000_driver); /* search board and register */ }