aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/dm9000.c106
1 files changed, 44 insertions, 62 deletions
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 08a7365a7d10..b6d4b8e1d9e2 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -528,7 +528,6 @@ dm9000_probe(struct platform_device *pdev)
528 struct board_info *db; /* Point a board information structure */ 528 struct board_info *db; /* Point a board information structure */
529 struct net_device *ndev; 529 struct net_device *ndev;
530 const unsigned char *mac_src; 530 const unsigned char *mac_src;
531 unsigned long base;
532 int ret = 0; 531 int ret = 0;
533 int iosize; 532 int iosize;
534 int i; 533 int i;
@@ -558,81 +557,64 @@ dm9000_probe(struct platform_device *pdev)
558 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work); 557 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
559 558
560 559
561 if (pdev->num_resources < 2) { 560 if (pdev->num_resources < 3) {
562 ret = -ENODEV; 561 ret = -ENODEV;
563 goto out; 562 goto out;
564 } else if (pdev->num_resources == 2) { 563 }
565 base = pdev->resource[0].start;
566
567 if (!request_mem_region(base, 4, ndev->name)) {
568 ret = -EBUSY;
569 goto out;
570 }
571
572 ndev->base_addr = base;
573 ndev->irq = pdev->resource[1].start;
574 db->io_addr = (void __iomem *)base;
575 db->io_data = (void __iomem *)(base + 4);
576 564
577 /* ensure at least we have a default set of IO routines */ 565 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
578 dm9000_set_io(db, 2); 566 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
567 db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
579 568
580 } else { 569 if (db->addr_res == NULL || db->data_res == NULL ||
581 db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 570 db->irq_res == NULL) {
582 db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 571 dev_err(db->dev, "insufficient resources\n");
583 db->irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 572 ret = -ENOENT;
584 573 goto out;
585 if (db->addr_res == NULL || db->data_res == NULL || 574 }
586 db->irq_res == NULL) {
587 dev_err(db->dev, "insufficient resources\n");
588 ret = -ENOENT;
589 goto out;
590 }
591 575
592 i = res_size(db->addr_res); 576 iosize = res_size(db->addr_res);
593 db->addr_req = request_mem_region(db->addr_res->start, i, 577 db->addr_req = request_mem_region(db->addr_res->start, iosize,
594 pdev->name); 578 pdev->name);
595 579
596 if (db->addr_req == NULL) { 580 if (db->addr_req == NULL) {
597 dev_err(db->dev, "cannot claim address reg area\n"); 581 dev_err(db->dev, "cannot claim address reg area\n");
598 ret = -EIO; 582 ret = -EIO;
599 goto out; 583 goto out;
600 } 584 }
601
602 db->io_addr = ioremap(db->addr_res->start, i);
603 585
604 if (db->io_addr == NULL) { 586 db->io_addr = ioremap(db->addr_res->start, iosize);
605 dev_err(db->dev, "failed to ioremap address reg\n");
606 ret = -EINVAL;
607 goto out;
608 }
609 587
610 iosize = res_size(db->data_res); 588 if (db->io_addr == NULL) {
611 db->data_req = request_mem_region(db->data_res->start, iosize, 589 dev_err(db->dev, "failed to ioremap address reg\n");
612 pdev->name); 590 ret = -EINVAL;
591 goto out;
592 }
613 593
614 if (db->data_req == NULL) { 594 iosize = res_size(db->data_res);
615 dev_err(db->dev, "cannot claim data reg area\n"); 595 db->data_req = request_mem_region(db->data_res->start, iosize,
616 ret = -EIO; 596 pdev->name);
617 goto out;
618 }
619 597
620 db->io_data = ioremap(db->data_res->start, iosize); 598 if (db->data_req == NULL) {
599 dev_err(db->dev, "cannot claim data reg area\n");
600 ret = -EIO;
601 goto out;
602 }
621 603
622 if (db->io_data == NULL) { 604 db->io_data = ioremap(db->data_res->start, iosize);
623 dev_err(db->dev,"failed to ioremap data reg\n");
624 ret = -EINVAL;
625 goto out;
626 }
627 605
628 /* fill in parameters for net-dev structure */ 606 if (db->io_data == NULL) {
607 dev_err(db->dev, "failed to ioremap data reg\n");
608 ret = -EINVAL;
609 goto out;
610 }
629 611
630 ndev->base_addr = (unsigned long)db->io_addr; 612 /* fill in parameters for net-dev structure */
631 ndev->irq = db->irq_res->start; 613 ndev->base_addr = (unsigned long)db->io_addr;
614 ndev->irq = db->irq_res->start;
632 615
633 /* ensure at least we have a default set of IO routines */ 616 /* ensure at least we have a default set of IO routines */
634 dm9000_set_io(db, iosize); 617 dm9000_set_io(db, iosize);
635 }
636 618
637 /* check to see if anything is being over-ridden */ 619 /* check to see if anything is being over-ridden */
638 if (pdata != NULL) { 620 if (pdata != NULL) {