netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux@fluff.org>
To: netdev@vger.kernel.org
Cc: jeff@garzik.org, laurentp@cse-semaphore.com,
	Ben Dooks <ben-linux@fluff.org>
Subject: [patch v3 01/12] DM9000: Remove the 2 resources probe scheme.
Date: Tue, 24 Jun 2008 22:15:57 +0100	[thread overview]
Message-ID: <20080624211903.586586947@fluff.org.uk> (raw)
In-Reply-To: 20080624211556.566149406@fluff.org.uk

[-- Attachment #1: thirdparty/dm9000-remove-2resources.patch --]
[-- Type: text/plain, Size: 4697 bytes --]

From: Laurent Pinchart <laurentp@cse-semaphore.com>

The dm9000 driver accepts either 2 or 3 resources to describe the platform
devices. The 2 resources case abuses the ioresource mechanism by passing
ioremap()ed memory through the platform device resources. This patch removes
that case and converts boards that were using it to the 3 resources scheme.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Laurent Pinchart <laurentp@cse-semaphore.com>
---

Index: linux-2.6.26-rc7-next20080624/drivers/net/dm9000.c
===================================================================
--- linux-2.6.26-rc7-next20080624.orig/drivers/net/dm9000.c	2008-06-24 21:58:09.000000000 +0100
+++ linux-2.6.26-rc7-next20080624/drivers/net/dm9000.c	2008-06-24 21:58:25.000000000 +0100
@@ -528,7 +528,6 @@ dm9000_probe(struct platform_device *pde
 	struct board_info *db;	/* Point a board information structure */
 	struct net_device *ndev;
 	const unsigned char *mac_src;
-	unsigned long base;
 	int ret = 0;
 	int iosize;
 	int i;
@@ -558,81 +557,64 @@ dm9000_probe(struct platform_device *pde
 	INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
 
 
-	if (pdev->num_resources < 2) {
+	if (pdev->num_resources < 3) {
 		ret = -ENODEV;
 		goto out;
-	} else if (pdev->num_resources == 2) {
-		base = pdev->resource[0].start;
-
-		if (!request_mem_region(base, 4, ndev->name)) {
-			ret = -EBUSY;
-			goto out;
-		}
-
-		ndev->base_addr = base;
-		ndev->irq = pdev->resource[1].start;
-		db->io_addr = (void __iomem *)base;
-		db->io_data = (void __iomem *)(base + 4);
-
-		/* ensure at least we have a default set of IO routines */
-		dm9000_set_io(db, 2);
-
-	} 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 ||
-		    db->irq_res == NULL) {
-			dev_err(db->dev, "insufficient resources\n");
-			ret = -ENOENT;
-			goto out;
-		}
+	}
 
-		i = res_size(db->addr_res);
-		db->addr_req = request_mem_region(db->addr_res->start, i,
-						  pdev->name);
-
-		if (db->addr_req == NULL) {
-			dev_err(db->dev, "cannot claim address reg area\n");
-			ret = -EIO;
-			goto out;
-		}
+	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 ||
+	    db->irq_res == NULL) {
+		dev_err(db->dev, "insufficient resources\n");
+		ret = -ENOENT;
+		goto out;
+	}
 
-		db->io_addr = ioremap(db->addr_res->start, i);
+	iosize = res_size(db->addr_res);
+	db->addr_req = request_mem_region(db->addr_res->start, iosize,
+					  pdev->name);
+
+	if (db->addr_req == NULL) {
+		dev_err(db->dev, "cannot claim address reg area\n");
+		ret = -EIO;
+		goto out;
+	}
 
-		if (db->io_addr == NULL) {
-			dev_err(db->dev, "failed to ioremap address reg\n");
-			ret = -EINVAL;
-			goto out;
-		}
+	db->io_addr = ioremap(db->addr_res->start, iosize);
 
-		iosize = res_size(db->data_res);
-		db->data_req = request_mem_region(db->data_res->start, iosize,
-						  pdev->name);
-
-		if (db->data_req == NULL) {
-			dev_err(db->dev, "cannot claim data reg area\n");
-			ret = -EIO;
-			goto out;
-		}
+	if (db->io_addr == NULL) {
+		dev_err(db->dev, "failed to ioremap address reg\n");
+		ret = -EINVAL;
+		goto out;
+	}
 
-		db->io_data = ioremap(db->data_res->start, iosize);
+	iosize = res_size(db->data_res);
+	db->data_req = request_mem_region(db->data_res->start, iosize,
+					  pdev->name);
+
+	if (db->data_req == NULL) {
+		dev_err(db->dev, "cannot claim data reg area\n");
+		ret = -EIO;
+		goto out;
+	}
 
-		if (db->io_data == NULL) {
-			dev_err(db->dev,"failed to ioremap data reg\n");
-			ret = -EINVAL;
-			goto out;
-		}
+	db->io_data = ioremap(db->data_res->start, iosize);
 
-		/* fill in parameters for net-dev structure */
+	if (db->io_data == NULL) {
+		dev_err(db->dev, "failed to ioremap data reg\n");
+		ret = -EINVAL;
+		goto out;
+	}
 
-		ndev->base_addr = (unsigned long)db->io_addr;
-		ndev->irq	= db->irq_res->start;
+	/* fill in parameters for net-dev structure */
+	ndev->base_addr = (unsigned long)db->io_addr;
+	ndev->irq	= db->irq_res->start;
 
-		/* ensure at least we have a default set of IO routines */
-		dm9000_set_io(db, iosize);
-	}
+	/* 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 */
 	if (pdata != NULL) {

-- 
Ben (ben@fluff.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'

  reply	other threads:[~2008-06-24 21:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24 21:15 [patch v3 00/12] DM9000 for next kernel release Ben Dooks
2008-06-24 21:15 ` Ben Dooks [this message]
2008-06-25  3:06   ` [patch v3 01/12] DM9000: Remove the 2 resources probe scheme Jeff Garzik
2008-06-26 12:42     ` Ben Dooks
2008-06-24 21:15 ` [patch v3 02/12] DM9000: Fixup blackfin after removing 2 resource usage Ben Dooks
2008-06-24 21:15 ` [patch v3 03/12] DM9000: Add support for DM9000A and DM9000B chips Ben Dooks
2008-06-24 21:16 ` [patch v3 04/12] DM9000: Cleanups after the resource changes Ben Dooks
2008-06-24 21:16 ` [patch v3 05/12] DM9000: Cleanup source code Ben Dooks
2008-06-24 21:16 ` [patch v3 06/12] DM9000: Cleanup source code - remove forward declerations Ben Dooks
2008-06-24 21:16 ` [patch v3 07/12] DM9000: Use NSR to determine link-status on internal PHY Ben Dooks
2008-06-24 21:16 ` [patch v3 08/12] DM9000: Allow the use of the NSR register to get link status Ben Dooks
2008-06-24 21:16 ` [patch v3 09/12] DM9000: Add missing msleep() in EEPROM wait code Ben Dooks
2008-06-24 21:16 ` [patch v3 10/12] DM9000: Re-unit menuconfig entries for DM9000 driver Ben Dooks
2008-06-24 21:16 ` [patch v3 11/12] DM9000: Remove DEFAULT_TRIGGER for request_irq() flags Ben Dooks
2008-06-24 21:16 ` [patch v3 12/12] DM9000: Add documentation for the driver Ben Dooks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080624211903.586586947@fluff.org.uk \
    --to=ben-linux@fluff.org \
    --cc=jeff@garzik.org \
    --cc=laurentp@cse-semaphore.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).