Skip to contentSkip to conversation

Simplify yenta code

PATCH In review Linas Vepstas 2 participants 3 messages Oct 1, 2007 Pcmcia

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Simplify yenta code

Simplify some of the resource detection logic in yenta_socket. This patch results in the same run-time behaviour as the current code, but does so with fewer lines of code. This makes the logical flow of the code a bit easier to understand.

Cc Dominik Brodowski <[email protected]>

----

 drivers/pcmcia/yenta_socket.c |   22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/pcmcia/yenta_socket.c +8 -14
Index: linux-2.6.23-rc8-mm1/drivers/pcmcia/yenta_socket.c
===================================================================
@@ -654,20 +654,14 @@ static int yenta_allocate_res(struct yen
 				pci_name(socket->dev), nr);
 	}
 
-	if (type & IORESOURCE_IO) {
-		if ((yenta_search_res(socket, res, BRIDGE_IO_MAX)) ||
-		    (yenta_search_res(socket, res, BRIDGE_IO_ACC)) ||
-		    (yenta_search_res(socket, res, BRIDGE_IO_MIN)))
-			return 1;
-	} else {
-		if (type & IORESOURCE_PREFETCH) {
-			if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
-			    (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
-			    (yenta_search_res(socket, res, BRIDGE_MEM_MIN)))
-				return 1;
-			/* Approximating prefetchable by non-prefetchable */
-			res->flags = IORESOURCE_MEM;
-		}
+	if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
+	    (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
+	    (yenta_search_res(socket, res, BRIDGE_MEM_MIN)))
+		return 1;
+
+	if (type & IORESOURCE_PREFETCH) {
+		/* Approximating prefetchable by non-prefetchable */
+		res->flags = IORESOURCE_MEM;
 		if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
 		    (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
 		    (yenta_search_res(socket, res, BRIDGE_MEM_MIN)))
#1 lore raw
Quoted 7 lines · Linas Vepstas
drivers/pcmcia/yenta_socket.c +0 -7
-	if (type & IORESOURCE_IO) {
-		if ((yenta_search_res(socket, res, BRIDGE_IO_MAX)) ||
-		    (yenta_search_res(socket, res, BRIDGE_IO_ACC)) ||
-		    (yenta_search_res(socket, res, BRIDGE_IO_MIN)))
-			return 1;
-	} else {
-		if (type & IORESOURCE_PREFETCH) {

drivers/pcmcia/yenta_socket.c static int yenta_allocate_res(struct yen · line 659

Quoted 10 lines
drivers/pcmcia/yenta_socket.c +3 -7
-			if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
-			    (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
-			    (yenta_search_res(socket, res, BRIDGE_MEM_MIN)))
-				return 1;
-			/* Approximating prefetchable by non-prefetchable */
-			res->flags = IORESOURCE_MEM;
-		}
+	if ((yenta_search_res(socket, res, BRIDGE_MEM_MAX)) ||
+	    (yenta_search_res(socket, res, BRIDGE_MEM_ACC)) ||
+	    (yenta_search_res(socket, res, BRIDGE_MEM_MIN)))

Are BRIDGE_IO_MAX and BRIDGE_MEM_MAX guaranteed to be the same?

Signature · 4 lines
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
#2 lore raw
Quoted 2 lines · Matthew Wilcox

Are BRIDGE_IO_MAX and BRIDGE_MEM_MAX guaranteed to be the same?

@#$%^&*. Red-faced, I withdraw the patch. Must be cross-eyed on a Monday morning. Sorry.

--linas