mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stelian Pop <stelian.pop@fr.alcove.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: [PATCH 2.4.7-ac1] SonyPI driver updates.
Date: Fri, 27 Jul 2001 15:22:50 +0200	[thread overview]
Message-ID: <20010727152250.C6860@come.alcove-fr> (raw)

This driver removes the while(1) loops from the sonypi driver
which could cause kernel hangups in case of faulty hardware,
or some obscure suspend/resume conditions.

Alan, please apply and submit it to Linus together with the
previous sonypi patches present in the -ac tree.

Thanks,

Stelian.


diff -uNr --exclude-from=dontdiff linux-2.4.6-ac5.orig/drivers/char/sonypi.c linux-2.4.6-ac5/drivers/char/sonypi.c
--- linux-2.4.6-ac5.orig/drivers/char/sonypi.c	Fri Jul 27 14:27:34 2001
+++ linux-2.4.6-ac5/drivers/char/sonypi.c	Thu Jul 26 12:14:18 2001
@@ -109,32 +109,23 @@
 }
 
 static void sonypi_ecrset(u16 addr, u16 value) {
-	int n = 100;
 
-	while (n-- && (inw_p(SONYPI_CST_IOPORT) & 3))
-		udelay(1);
+	wait_on_command(inw_p(SONYPI_CST_IOPORT) & 3);
 	outw_p(0x81, SONYPI_CST_IOPORT);
-	while (inw_p(SONYPI_CST_IOPORT) & 2)
-		udelay(1);
+	wait_on_command(inw_p(SONYPI_CST_IOPORT) & 2);
 	outw_p(addr, SONYPI_DATA_IOPORT);
-	while (inw_p(SONYPI_CST_IOPORT) & 2)
-		udelay(1);
+	wait_on_command(inw_p(SONYPI_CST_IOPORT) & 2);
 	outw_p(value, SONYPI_DATA_IOPORT);
-	while (inw_p(SONYPI_CST_IOPORT) & 2)
-		udelay(1);
+	wait_on_command(inw_p(SONYPI_CST_IOPORT) & 2);
 }
 
 static u16 sonypi_ecrget(u16 addr) {
-	int n = 100;
 
-	while (n-- && (inw_p(SONYPI_CST_IOPORT) & 3))
-		udelay(1);
+	wait_on_command(inw_p(SONYPI_CST_IOPORT) & 3);
 	outw_p(0x80, SONYPI_CST_IOPORT);
-	while (inw_p(SONYPI_CST_IOPORT) & 2)
-		udelay(1);
+	wait_on_command(inw_p(SONYPI_CST_IOPORT) & 2);
 	outw_p(addr, SONYPI_DATA_IOPORT);
-	while (inw_p(SONYPI_CST_IOPORT) & 2)
-		udelay(1);
+	wait_on_command(inw_p(SONYPI_CST_IOPORT) & 2);
 	return inw_p(SONYPI_DATA_IOPORT);
 }
 
@@ -190,8 +181,7 @@
 static u8 sonypi_call1(u8 dev) {
 	u8 v1, v2;
 
-	while (inb_p(sonypi_device.ioport2) & 2)
-		udelay(1);
+	wait_on_command(inb_p(sonypi_device.ioport2) & 2);
 	outb(dev, sonypi_device.ioport2);
 	v1 = inb_p(sonypi_device.ioport2);
 	v2 = inb_p(sonypi_device.ioport1);
@@ -201,14 +191,10 @@
 static u8 sonypi_call2(u8 dev, u8 fn) {
 	u8 v1;
 
-	while (inb_p(sonypi_device.ioport2) & 2)
-		udelay(1);
+	wait_on_command(inb_p(sonypi_device.ioport2) & 2);
 	outb(dev, sonypi_device.ioport2);
-
-	while (inb_p(sonypi_device.ioport2) & 2)
-		udelay(1);
+	wait_on_command(inb_p(sonypi_device.ioport2) & 2);
 	outb(fn, sonypi_device.ioport1);
-
 	v1 = inb_p(sonypi_device.ioport1);
 	return v1;
 }
@@ -216,18 +202,12 @@
 static u8 sonypi_call3(u8 dev, u8 fn, u8 v) {
 	u8 v1;
 
-	while (inb_p(sonypi_device.ioport2) & 2)
-		udelay(1);
+	wait_on_command(inb_p(sonypi_device.ioport2) & 2);
 	outb(dev, sonypi_device.ioport2);
-
-	while (inb_p(sonypi_device.ioport2) & 2)
-		udelay(1);
+	wait_on_command(inb_p(sonypi_device.ioport2) & 2);
 	outb(fn, sonypi_device.ioport1);
-
-	while (inb_p(sonypi_device.ioport2) & 2)
-		udelay(1);
+	wait_on_command(inb_p(sonypi_device.ioport2) & 2);
 	outb(v, sonypi_device.ioport1);
-
 	v1 = inb_p(sonypi_device.ioport1);
 	return v1;
 }
@@ -247,11 +227,8 @@
 
 /* Set brightness, hue etc */
 static void sonypi_set(u8 fn, u8 v) {
-	int n = 100;
 	
-	while (n--)
-		if (sonypi_call3(0x90, fn, v) == 0) 
-			break;
+	wait_on_command(sonypi_call3(0x90, fn, v));
 }
 
 /* Tests if the camera is ready */
diff -uNr --exclude-from=dontdiff linux-2.4.6-ac5.orig/drivers/char/sonypi.h linux-2.4.6-ac5/drivers/char/sonypi.h
--- linux-2.4.6-ac5.orig/drivers/char/sonypi.h	Fri Jul 27 14:27:34 2001
+++ linux-2.4.6-ac5/drivers/char/sonypi.h	Fri Jul 27 14:29:55 2001
@@ -35,7 +35,7 @@
 #ifdef __KERNEL__
 
 #define SONYPI_DRIVER_MAJORVERSION	1
-#define SONYPI_DRIVER_MINORVERSION	3
+#define SONYPI_DRIVER_MINORVERSION	4
 
 #include <linux/types.h>
 #include <linux/pci.h>
@@ -222,6 +222,14 @@
 	int open_count;
 	int model;
 };
+
+#define wait_on_command(command) { \
+	unsigned int n = 10000; \
+	while (--n && (command)) \
+		udelay(1); \
+	if (!n) \
+		printk(KERN_WARNING "sonypi command failed at " __FILE__ " : " __FUNCTION__ "(line %d)\n", __LINE__); \
+}
 
 #endif /* __KERNEL__ */
 
-- 
Stelian Pop <stelian.pop@fr.alcove.com>
|---------------- Free Software Engineer -----------------|
| Alcôve - http://www.alcove.com - Tel: +33 1 49 22 68 00 |
|------------- Alcôve, liberating software ---------------|

                 reply	other threads:[~2001-07-27 13:23 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=20010727152250.C6860@come.alcove-fr \
    --to=stelian.pop@fr.alcove.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®