From b4ed03ff12e4bf228aaf15b2a364134348ebe8a9 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Tue, 13 Jun 2006 23:47:19 +0100 Subject: [PATCH] DM9000 - better checks for platform resources The current DM9000 driver cannot cope if it is given more than 3 resources (for example, if it is being passed an wake-up irq that it is not using yet). Check that we have been given at-least one IRQ resource. Also fix the minor type-casting for the case of 2 resources. Signed-off-by: Ben Dooks Signed-off-by: Jeff Garzik --- drivers/net/dm9000.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'drivers/net/dm9000.c') diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index 24996da4c1c4..631e0d9f2e40 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c @@ -410,10 +410,7 @@ dm9000_probe(struct platform_device *pdev) if (pdev->num_resources < 2) { ret = -ENODEV; goto out; - } - - switch (pdev->num_resources) { - case 2: + } else if (pdev->num_resources == 2) { base = pdev->resource[0].start; if (!request_mem_region(base, 4, ndev->name)) { @@ -423,17 +420,16 @@ dm9000_probe(struct platform_device *pdev) ndev->base_addr = base; ndev->irq = pdev->resource[1].start; - db->io_addr = (void *)base; - db->io_data = (void *)(base + 4); - - break; + db->io_addr = (void __iomem *)base; + db->io_data = (void __iomem *)(base + 4); - case 3: + } else { db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (db->addr_res == NULL || db->data_res == NULL) { + if (db->addr_res == NULL || db->data_res == NULL || + db->irq_res == NULL) { printk(KERN_ERR PFX "insufficient resources\n"); ret = -ENOENT; goto out; @@ -482,7 +478,6 @@ dm9000_probe(struct platform_device *pdev) /* ensure at least we have a default set of IO routines */ dm9000_set_io(db, iosize); - } /* check to see if anything is being over-ridden */ -- cgit v1.2.2 From 5b55dda6f40c46e93006b3c88f75550e0d3b3032 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Tue, 13 Jun 2006 23:50:15 +0100 Subject: [PATCH] DM9000 - check for MAC left in by bootloader The DM9000 driver does not deal with the case where there is no serial EEPROM to store the configuration, and the bootloader has placed an MAC address into the device already. If there is no valid MAC in the EEPROM, read the one already in the chip and check to see if that one is valid. Signed-off-by: Ben Dooks Signed-off-by: Jeff Garzik --- drivers/net/dm9000.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/net/dm9000.c') diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index 631e0d9f2e40..e6bdbd3a6796 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c @@ -559,6 +559,13 @@ dm9000_probe(struct platform_device *pdev) for (i = 0; i < 6; i++) ndev->dev_addr[i] = db->srom[i]; + if (!is_valid_ether_addr(ndev->dev_addr)) { + /* try reading from mac */ + + for (i = 0; i < 6; i++) + ndev->dev_addr[i] = ior(db, i+DM9000_PAR); + } + if (!is_valid_ether_addr(ndev->dev_addr)) printk("%s: Invalid ethernet MAC address. Please " "set using ifconfig\n", ndev->name); -- cgit v1.2.2 From 19af5a8b2b3fcf2a65e3077deafe95706a1d4282 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 14 Jun 2006 00:05:50 +0100 Subject: [PATCH] DM9000 - do no re-init spin lock The DM9000 initialisation sequence for the hardware re-initialise the board spin-lock, which is in my view wrong. This patch removes the extra spin lock initialisation Signed-off-by: Ben Dooks Signed-off-by: Jeff Garzik --- drivers/net/dm9000.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/net/dm9000.c') diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index e6bdbd3a6796..7eea8e1a1230 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c @@ -665,7 +665,6 @@ dm9000_init_dm9000(struct net_device *dev) db->tx_pkt_cnt = 0; db->queue_pkt_len = 0; dev->trans_start = 0; - spin_lock_init(&db->lock); } /* -- cgit v1.2.2 From 5d22a312b7afddaed3cbb2fffb3cceb0c22a6cf5 Mon Sep 17 00:00:00 2001 From: Ben Dooks Date: Wed, 14 Jun 2006 00:09:17 +0100 Subject: [PATCH] DM9000 - minor code cleanups Ensure the driver's module owner field is initialised for when this is being built and loaded as a module. Also change make the dm9000_tx_done function static, as it is not exported elsewhere. Signed-off-by: Ben Dooks Signed-off-by: Jeff Garzik --- drivers/net/dm9000.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/net/dm9000.c') diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index 7eea8e1a1230..7965a9b08e79 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c @@ -768,7 +768,7 @@ dm9000_stop(struct net_device *ndev) * receive the packet to upper layer, free the transmitted packet */ -void +static void dm9000_tx_done(struct net_device *dev, board_info_t * db) { int tx_status = ior(db, DM9000_NSR); /* Got TX status */ @@ -1188,13 +1188,14 @@ dm9000_drv_remove(struct platform_device *pdev) } static struct platform_driver dm9000_driver = { + .driver = { + .name = "dm9000", + .owner = THIS_MODULE, + }, .probe = dm9000_probe, .remove = dm9000_drv_remove, .suspend = dm9000_drv_suspend, .resume = dm9000_drv_resume, - .driver = { - .name = "dm9000", - }, }; static int __init -- cgit v1.2.2