All of lore.kernel.org
 help / color / mirror / Atom feed
From: <pazke@orbita1.ru>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] bus mouse drivers cleanup
Date: Wed, 13 Jun 2001 14:35:33 +0400	[thread overview]
Message-ID: <20010613143533.A17092@orbita1.ru> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 491 bytes --]

Hi all,

attached are patches to add (missing) error checking and proper error code returning
in case of request_region(), request_irq and misc_register() fauilures.

Drivers affected: atixlmouse.c, logibusmouse.c, msbusmouse.c, pc110pad.c.

Best regards.

P.S. Also check_region() calls removed from logibusmouse.c and msbusmouse.c

-- 
Andrey Panin            | Embedded systems software engineer
pazke@orbita1.ru        | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc

[-- Attachment #1.2: patch-atixlmouse --]
[-- Type: text/plain, Size: 889 bytes --]

diff -u -X /usr/dontdiff /linux.vanilla/drivers/char/atixlmouse.c /linux/drivers/char/atixlmouse.c
--- /linux.vanilla/drivers/char/atixlmouse.c	Tue Jun 12 10:51:22 2001
+++ /linux/drivers/char/atixlmouse.c	Tue Jun 12 11:32:59 2001
@@ -91,8 +91,9 @@
 
 static int open_mouse(struct inode * inode, struct file * file)
 {
-	if (request_irq(ATIXL_MOUSE_IRQ, mouse_interrupt, 0, "ATIXL mouse", NULL))
-		return -EBUSY;
+	int retval;
+	if ((retval = request_irq(ATIXL_MOUSE_IRQ, mouse_interrupt, SA_INTERRUPT | SA_SAMPLE_RANDOM, "ATIXL mouse", NULL)))
+		return retval;
 	ATIXL_MSE_INT_ON(); /* Interrupts are really enabled here */
 	return 0;
 }
@@ -112,7 +113,7 @@
 	 */
 
 	if (!request_region(ATIXL_MSE_DATA_PORT, 3, "atixlmouse"))
-		return -EIO;
+		return -EBUSY;
 
 	a = inb( ATIXL_MSE_SIGNATURE_PORT );	/* Get signature */
 	b = inb( ATIXL_MSE_SIGNATURE_PORT );

[-- Attachment #1.3: patch-logibusmouse --]
[-- Type: text/plain, Size: 1590 bytes --]

diff -u -X /usr/dontdiff /linux.vanilla/drivers/char/logibusmouse.c /linux/drivers/char/logibusmouse.c
--- /linux.vanilla/drivers/char/logibusmouse.c	Tue Jun 12 10:51:30 2001
+++ /linux/drivers/char/logibusmouse.c	Tue Jun 12 11:35:28 2001
@@ -116,8 +116,9 @@
 
 static int open_mouse(struct inode * inode, struct file * file)
 {
-	if (request_irq(mouse_irq, mouse_interrupt, 0, "busmouse", NULL))
-		return -EBUSY;
+	int retval;
+	if ((retval = request_irq(mouse_irq, mouse_interrupt, SA_INTERRUPT | SA_SAMPLE_RANDOM, "busmouse", NULL)))
+		return retval;
 	MSE_INT_ON();
 	return 0;
 }
@@ -128,24 +129,25 @@
 
 static int __init logi_busmouse_init(void)
 {
-	if (check_region(LOGIBM_BASE, LOGIBM_EXTENT))
-		return -EIO;
+	if (!request_region(LOGIBM_BASE, LOGIBM_EXTENT, "busmouse"))
+		return -EBUSY;
 
 	outb(MSE_CONFIG_BYTE, MSE_CONFIG_PORT);
 	outb(MSE_SIGNATURE_BYTE, MSE_SIGNATURE_PORT);
 	udelay(100L);	/* wait for reply from mouse */
-	if (inb(MSE_SIGNATURE_PORT) != MSE_SIGNATURE_BYTE)
+	if (inb(MSE_SIGNATURE_PORT) != MSE_SIGNATURE_BYTE) {
+		release_region(LOGIBM_BASE, LOGIBM_EXTENT);
 		return -EIO;
+	}
 
 	outb(MSE_DEFAULT_MODE, MSE_CONFIG_PORT);
 	MSE_INT_OFF();
-	
-	request_region(LOGIBM_BASE, LOGIBM_EXTENT, "busmouse");
 
 	msedev = register_busmouse(&busmouse);
-	if (msedev < 0)
+	if (msedev < 0) {
 		printk(KERN_WARNING "Unable to register busmouse driver.\n");
-	else
+		release_region(LOGIBM_BASE, LOGIBM_EXTENT);
+	} else
 		printk(KERN_INFO "Logitech busmouse installed.\n");
 	return msedev < 0 ? msedev : 0;
 }

[-- Attachment #1.4: patch-msbusmouse --]
[-- Type: text/plain, Size: 1488 bytes --]

diff -u -X /usr/dontdiff /linux.vanilla/drivers/char/msbusmouse.c /linux/drivers/char/msbusmouse.c
--- /linux.vanilla/drivers/char/msbusmouse.c	Tue Jun 12 10:51:22 2001
+++ /linux/drivers/char/msbusmouse.c	Tue Jun 12 11:38:18 2001
@@ -113,8 +113,9 @@
 
 static int open_mouse(struct inode * inode, struct file * file)
 {
-	if (request_irq(mouse_irq, ms_mouse_interrupt, 0, "MS Busmouse", NULL))
-		return -EBUSY;
+	int retval;
+	if ((retval = request_irq(mouse_irq, ms_mouse_interrupt, SA_INTERRUPT | SA_SAMPLE_RANDOM, "MS Busmouse", NULL)))
+		return retval;
 
 	outb(MS_MSE_START, MS_MSE_CONTROL_PORT);
 	MS_MSE_INT_ON();	
@@ -130,8 +131,8 @@
 	int present = 0;
 	int mse_byte, i;
 
-	if (check_region(MS_MSE_CONTROL_PORT, 0x04))
-		return -ENODEV;
+	if (!request_region(MS_MSE_CONTROL_PORT, 0x04, "MS Busmouse"));
+		return -EBUSY;
 
 	if (inb_p(MS_MSE_SIGNATURE_PORT) == 0xde) {
 
@@ -147,14 +148,17 @@
 				present = 0;
 		}
 	}
-	if (present == 0)
+	if (present == 0) {
+		release_region(MS_MSE_CONTROL_PORT, 0x04);
 		return -EIO;
+	}
 	MS_MSE_INT_OFF();
-	request_region(MS_MSE_CONTROL_PORT, 0x04, "MS Busmouse");
+
 	msedev = register_busmouse(&msbusmouse);
-	if (msedev < 0)
+	if (msedev < 0) {
 		printk(KERN_WARNING "Unable to register msbusmouse driver.\n");
-	else
+		release_region(MS_MSE_CONTROL_PORT, 0x04);
+	} else
 		printk(KERN_INFO "Microsoft BusMouse detected and installed.\n");
 	return msedev < 0 ? msedev : 0;
 }

[-- Attachment #1.5: patch-pc110pad --]
[-- Type: text/plain, Size: 1451 bytes --]

diff -u -X /usr/dontdiff /linux.vanilla/drivers/char/pc110pad.c /linux/drivers/char/pc110pad.c
--- /linux.vanilla/drivers/char/pc110pad.c	Tue Jun 12 10:51:26 2001
+++ /linux/drivers/char/pc110pad.c	Tue Jun 12 12:01:44 2001
@@ -802,23 +802,36 @@
 
 static int __init pc110pad_init_driver(void)
 {
+	int retval = -EBUSY;
+
 	init_MUTEX(&reader_lock);
 	current_params = default_params;
 
-	if (request_irq(current_params.irq, pad_irq, 0, "pc110pad", 0)) {
-		printk(KERN_ERR "pc110pad: Unable to get IRQ.\n");
-		return -EBUSY;
-	}
 	if (!request_region(current_params.io, 4, "pc110pad"))	{
 		printk(KERN_ERR "pc110pad: I/O area in use.\n");
-		free_irq(current_params.irq,0);
-		return -EBUSY;
+		goto err_out;
+	}
+	if ((retval = request_irq(current_params.irq, pad_irq, SA_INTERRUPT | SA_SAMPLE_RANDOM, "pc110pad", 0))) {
+		printk(KERN_ERR "pc110pad: Unable to get IRQ.\n");
+		goto err_out_release_region;
 	}
 	init_waitqueue_head(&queue);
+
+	if ((retval = misc_register(&pc110_pad))) {
+		printk(KERN_ERR "pc110pad: Unable to register driver.\n");
+		goto err_out_free_irq;
+	}
+
 	printk(banner, current_params.io, current_params.irq);
-	misc_register(&pc110_pad);
 	outb(0x30, current_params.io+2);	/* switch off digitiser */
 	return 0;
+
+err_out_free_irq:
+	free_irq(current_params.irq, 0);
+err_out_release_region:
+	release_region(current_params.io, 4);
+err_out:
+	return retval;
 }
 
 /*

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

                 reply	other threads:[~2001-06-13 10:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20010613143533.A17092@orbita1.ru \
    --to=pazke@orbita1.ru \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.