public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6] ns558.c check_region -> request_region
@ 2003-12-31 21:58 Marcel Sebek
  2004-01-01  9:12 ` Marcel Sebek
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Sebek @ 2003-12-31 21:58 UTC (permalink / raw)
  To: vojtech; +Cc: linux-kernel, linux-joystick


This patch modifies ns558.c to use request_region instead of
check_region:


diff -urN linux-2.6/drivers/input/gameport/ns558.c linux-2.6-new/drivers/input/gameport/ns558.c
--- linux-2.6/drivers/input/gameport/ns558.c	2003-08-23 13:57:35.000000000 +0200
+++ linux-2.6-new/drivers/input/gameport/ns558.c	2003-12-31 22:27:40.000000000 +0100
@@ -77,7 +77,7 @@
  * No one should be using this address.
  */
 
-	if (check_region(io, 1))
+	if (!request_region(io, 1, "ns558-isa"))
 		return;
 
 /*
@@ -89,7 +89,8 @@
 	outb(~c & ~3, io);
 	if (~(u = v = inb(io)) & 3) {
 		outb(c, io);
-		return;
+		i = 0;
+		goto out;
 	}
 /*
  * After a trigger, there must be at least some bits changing.
@@ -99,7 +100,8 @@
 
 	if (u == v) {
 		outb(c, io);
-		return;
+		i = 0;
+		goto out;
 	}
 	wait_ms(3);
 /*
@@ -110,7 +112,8 @@
 	for (i = 0; i < 1000; i++)
 		if ((u ^ inb(io)) & 0xf) {
 			outb(c, io);
-			return;
+			i = 0;
+			goto out;
 		}
 /* 
  * And now find the number of mirrors of the port.
@@ -118,7 +121,7 @@
 
 	for (i = 1; i < 5; i++) {
 
-		if (check_region(io & (-1 << i), (1 << i)))	/* Don't disturb anyone */
+		if (!request_region(io & (-1 << i), (1 << i), "ns558-isa"))	/* Don't disturb anyone */
 			break;
 
 		outb(0xff, io & (-1 << i));
@@ -126,15 +129,19 @@
 			if (inb(io & (-1 << i)) != inb((io & (-1 << i)) + (1 << i) - 1)) b++;
 		wait_ms(3);
 
-		if (b > 300)					/* We allow 30% difference */
+		if (b > 300) {					/* We allow 30% difference */
+			release_region(io & (-1 << i), (1 << i));
 			break;
+		}
+
+		release_region(io & (-1 << (i-1)), (1 << (i-1)));
 	}
 
 	i--;
 
 	if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
 		printk(KERN_ERR "ns558: Memory allocation failed.\n");
-		return;
+		goto out;
 	}
        	memset(port, 0, sizeof(struct ns558));
 	
@@ -148,8 +155,6 @@
 	sprintf(port->phys, "isa%04x/gameport0", io & (-1 << i));
 	sprintf(port->name, "NS558 ISA");
 
-	request_region(io & (-1 << i), (1 << i), "ns558-isa");
-
 	gameport_register_port(&port->gameport);
 
 	printk(KERN_INFO "gameport: NS558 ISA at %#x", port->gameport.io);
@@ -157,6 +162,9 @@
 	printk(" speed %d kHz\n", port->gameport.speed);
 
 	list_add(&port->node, &ns558_list);
+	return;
+out:
+	release_region(io & (-1 << i), (1 << i));
 }
 
 #ifdef CONFIG_PNP


-- 
Marcel Sebek
jabber: sebek@jabber.cz                     ICQ: 279852819
linux user number: 307850                 GPG ID: 5F88735E
GPG FP: 0F01 BAB8 3148 94DB B95D  1FCA 8B63 CA06 5F88 735E


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2.6] ns558.c check_region -> request_region
  2003-12-31 21:58 [PATCH 2.6] ns558.c check_region -> request_region Marcel Sebek
@ 2004-01-01  9:12 ` Marcel Sebek
  2004-01-22 13:33   ` Vojtech Pavlik
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Sebek @ 2004-01-01  9:12 UTC (permalink / raw)
  To: vojtech; +Cc: linux-kernel, linux-joystick

On Wed, Dec 31, 2003 at 10:58:57PM +0100, Marcel Sebek wrote:
> 
> This patch modifies ns558.c to use request_region instead of
> check_region:
> 
> 

The old version doesn't release region before requesting for new.
Here's an updated patch:



diff -urN linux-2.6/drivers/input/gameport/ns558.c linux-2.6-new/drivers/input/gameport/ns558.c
--- linux-2.6/drivers/input/gameport/ns558.c	2003-08-23 13:57:35.000000000 +0200
+++ linux-2.6-new/drivers/input/gameport/ns558.c	2004-01-01 10:06:23.000000000 +0100
@@ -77,7 +77,7 @@
  * No one should be using this address.
  */
 
-	if (check_region(io, 1))
+	if (!request_region(io, 1, "ns558-isa"))
 		return;
 
 /*
@@ -89,7 +89,8 @@
 	outb(~c & ~3, io);
 	if (~(u = v = inb(io)) & 3) {
 		outb(c, io);
-		return;
+		i = 0;
+		goto out;
 	}
 /*
  * After a trigger, there must be at least some bits changing.
@@ -99,7 +100,8 @@
 
 	if (u == v) {
 		outb(c, io);
-		return;
+		i = 0;
+		goto out;
 	}
 	wait_ms(3);
 /*
@@ -110,7 +112,8 @@
 	for (i = 0; i < 1000; i++)
 		if ((u ^ inb(io)) & 0xf) {
 			outb(c, io);
-			return;
+			i = 0;
+			goto out;
 		}
 /* 
  * And now find the number of mirrors of the port.
@@ -118,7 +121,9 @@
 
 	for (i = 1; i < 5; i++) {
 
-		if (check_region(io & (-1 << i), (1 << i)))	/* Don't disturb anyone */
+		release_region(io & (-1 << (i-1)), (1 << (i-1)));
+
+		if (!request_region(io & (-1 << i), (1 << i), "ns558-isa"))	/* Don't disturb anyone */
 			break;
 
 		outb(0xff, io & (-1 << i));
@@ -126,18 +131,25 @@
 			if (inb(io & (-1 << i)) != inb((io & (-1 << i)) + (1 << i) - 1)) b++;
 		wait_ms(3);
 
-		if (b > 300)					/* We allow 30% difference */
+		if (b > 300) {					/* We allow 30% difference */
+			release_region(io & (-1 << i), (1 << i));
 			break;
+		}
 	}
 
 	i--;
 
+	if (i != 4) {
+		if (!request_region(io & (-1 << i), (1 << i), "ns558-isa"))
+			return;
+	}
+
 	if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
 		printk(KERN_ERR "ns558: Memory allocation failed.\n");
-		return;
+		goto out;
 	}
-       	memset(port, 0, sizeof(struct ns558));
-	
+	memset(port, 0, sizeof(struct ns558));
+
 	port->type = NS558_ISA;
 	port->size = (1 << i);
 	port->gameport.io = io;
@@ -148,8 +160,6 @@
 	sprintf(port->phys, "isa%04x/gameport0", io & (-1 << i));
 	sprintf(port->name, "NS558 ISA");
 
-	request_region(io & (-1 << i), (1 << i), "ns558-isa");
-
 	gameport_register_port(&port->gameport);
 
 	printk(KERN_INFO "gameport: NS558 ISA at %#x", port->gameport.io);
@@ -157,6 +167,9 @@
 	printk(" speed %d kHz\n", port->gameport.speed);
 
 	list_add(&port->node, &ns558_list);
+	return;
+out:
+	release_region(io & (-1 << i), (1 << i));
 }
 
 #ifdef CONFIG_PNP

-- 
Marcel Sebek
jabber: sebek@jabber.cz                     ICQ: 279852819
linux user number: 307850                 GPG ID: 5F88735E
GPG FP: 0F01 BAB8 3148 94DB B95D  1FCA 8B63 CA06 5F88 735E


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2.6] ns558.c check_region -> request_region
  2004-01-01  9:12 ` Marcel Sebek
@ 2004-01-22 13:33   ` Vojtech Pavlik
  0 siblings, 0 replies; 3+ messages in thread
From: Vojtech Pavlik @ 2004-01-22 13:33 UTC (permalink / raw)
  To: linux-kernel, linux-joystick

On Thu, Jan 01, 2004 at 10:12:26AM +0100, Marcel Sebek wrote:
> On Wed, Dec 31, 2003 at 10:58:57PM +0100, Marcel Sebek wrote:
> > 
> > This patch modifies ns558.c to use request_region instead of
> > check_region:
> > 
> > 
> 
> The old version doesn't release region before requesting for new.

This one looks OK, applied.

> Here's an updated patch:
> 
> diff -urN linux-2.6/drivers/input/gameport/ns558.c linux-2.6-new/drivers/input/gameport/ns558.c
> --- linux-2.6/drivers/input/gameport/ns558.c	2003-08-23 13:57:35.000000000 +0200
> +++ linux-2.6-new/drivers/input/gameport/ns558.c	2004-01-01 10:06:23.000000000 +0100
> @@ -77,7 +77,7 @@
>   * No one should be using this address.
>   */
>  
> -	if (check_region(io, 1))
> +	if (!request_region(io, 1, "ns558-isa"))
>  		return;
>  
>  /*
> @@ -89,7 +89,8 @@
>  	outb(~c & ~3, io);
>  	if (~(u = v = inb(io)) & 3) {
>  		outb(c, io);
> -		return;
> +		i = 0;
> +		goto out;
>  	}
>  /*
>   * After a trigger, there must be at least some bits changing.
> @@ -99,7 +100,8 @@
>  
>  	if (u == v) {
>  		outb(c, io);
> -		return;
> +		i = 0;
> +		goto out;
>  	}
>  	wait_ms(3);
>  /*
> @@ -110,7 +112,8 @@
>  	for (i = 0; i < 1000; i++)
>  		if ((u ^ inb(io)) & 0xf) {
>  			outb(c, io);
> -			return;
> +			i = 0;
> +			goto out;
>  		}
>  /* 
>   * And now find the number of mirrors of the port.
> @@ -118,7 +121,9 @@
>  
>  	for (i = 1; i < 5; i++) {
>  
> -		if (check_region(io & (-1 << i), (1 << i)))	/* Don't disturb anyone */
> +		release_region(io & (-1 << (i-1)), (1 << (i-1)));
> +
> +		if (!request_region(io & (-1 << i), (1 << i), "ns558-isa"))	/* Don't disturb anyone */
>  			break;
>  
>  		outb(0xff, io & (-1 << i));
> @@ -126,18 +131,25 @@
>  			if (inb(io & (-1 << i)) != inb((io & (-1 << i)) + (1 << i) - 1)) b++;
>  		wait_ms(3);
>  
> -		if (b > 300)					/* We allow 30% difference */
> +		if (b > 300) {					/* We allow 30% difference */
> +			release_region(io & (-1 << i), (1 << i));
>  			break;
> +		}
>  	}
>  
>  	i--;
>  
> +	if (i != 4) {
> +		if (!request_region(io & (-1 << i), (1 << i), "ns558-isa"))
> +			return;
> +	}
> +
>  	if (!(port = kmalloc(sizeof(struct ns558), GFP_KERNEL))) {
>  		printk(KERN_ERR "ns558: Memory allocation failed.\n");
> -		return;
> +		goto out;
>  	}
> -       	memset(port, 0, sizeof(struct ns558));
> -	
> +	memset(port, 0, sizeof(struct ns558));
> +
>  	port->type = NS558_ISA;
>  	port->size = (1 << i);
>  	port->gameport.io = io;
> @@ -148,8 +160,6 @@
>  	sprintf(port->phys, "isa%04x/gameport0", io & (-1 << i));
>  	sprintf(port->name, "NS558 ISA");
>  
> -	request_region(io & (-1 << i), (1 << i), "ns558-isa");
> -
>  	gameport_register_port(&port->gameport);
>  
>  	printk(KERN_INFO "gameport: NS558 ISA at %#x", port->gameport.io);
> @@ -157,6 +167,9 @@
>  	printk(" speed %d kHz\n", port->gameport.speed);
>  
>  	list_add(&port->node, &ns558_list);
> +	return;
> +out:
> +	release_region(io & (-1 << i), (1 << i));
>  }
>  
>  #ifdef CONFIG_PNP
> 
> -- 
> Marcel Sebek
> jabber: sebek@jabber.cz                     ICQ: 279852819
> linux user number: 307850                 GPG ID: 5F88735E
> GPG FP: 0F01 BAB8 3148 94DB B95D  1FCA 8B63 CA06 5F88 735E
> 

-- 
Vojtech Pavlik
SuSE Labs, SuSE CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-01-22 13:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-31 21:58 [PATCH 2.6] ns558.c check_region -> request_region Marcel Sebek
2004-01-01  9:12 ` Marcel Sebek
2004-01-22 13:33   ` Vojtech Pavlik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox