linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Rabel <pavel@web.sajt.cz>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] mad16 MPU probing
Date: Thu, 23 Nov 2000 12:32:45 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.21.0011231158350.25032-100000@web.sajt.cz> (raw)


Small cleanup in mad16.c MPU probing code. Against any 2.4 kernel.
Replacing mad loops with readable switches. Removing unnecessary array
declarations. Removing variable 'with secret power'. Removing double
declaration (tmp).

Is there a maintainer for this stuff? 
Whom to feed with this kind of cleanup patches? 

Pavel Rabel


--- drivers/sound/mad16.c.old	Wed Sep 27 20:53:56 2000
+++ drivers/sound/mad16.c	Thu Nov 23 11:00:47 2000
@@ -718,13 +718,7 @@
 static int __init probe_mad16_mpu(struct address_info *hw_config)
 {
 	static int mpu_attached = 0;
-	static int valid_ports[] = {
-		0x330, 0x320, 0x310, 0x300
-	};
-	
-	static short valid_irqs[] = {9, 10, 5, 7};
 	unsigned char tmp;
-	int i;				/* A variable with secret power */
 
 	if (!already_initialized)	/* The MSS port must be initialized first */
 		return 0;
@@ -737,7 +731,6 @@
 	{
 
 #ifdef CONFIG_MAD16_OLDCARD
-		unsigned char   tmp;
 
 		tmp = mad_read(MC3_PORT);
 
@@ -787,9 +780,6 @@
 		 * to set MPU register. TODO - add probing
 		 */
 
-		
-		unsigned char tmp;
-
 		tmp = mad_read(MC8_PORT);
 
 		switch (hw_config->irq)
@@ -840,42 +830,50 @@
 	tmp = mad_read(MC6_PORT) & 0x83;
 	tmp |= 0x80;		/* MPU-401 enable */
 
-/*
- * Set the MPU base bits
- */
+	/* Set the MPU base bits */
 
-	for (i = 0; i < 5; i++)
+	switch (hw_config->io_base)
 	{
-		if (i > 3)	/* Out of array bounds */
-		{
-			printk(KERN_ERR "MAD16 / Mozart: Invalid MIDI port 0x%x\n", hw_config->io_base);
-			return 0;
-		}
-		if (valid_ports[i] == hw_config->io_base)
-		{
-			tmp |= i << 5;
+		case 0x300:
+			tmp |= 0x60;
 			break;
-		}
+		case 0x310:
+			tmp |= 0x40;
+			break;
+		case 0x320:
+			tmp |= 0x20;
+			break;
+		case 0x330:
+			tmp |= 0x00;
+			break;
+		default:
+			printk(KERN_ERR "MAD16: Invalid MIDI port 0x%x\n", hw_config->io_base);
+			return 0;
 	}
 
-/*
- * Set the MPU IRQ bits
- */
+	/* Set the MPU IRQ bits */
 
-	for (i = 0; i < 5; i++)
+	switch (hw_config->irq)
 	{
-		if (i > 3)	/* Out of array bounds */
-		{
-			printk(KERN_ERR "MAD16 / Mozart: Invalid MIDI IRQ %d\n", hw_config->irq);
-			return 0;
-		}
-		if (valid_irqs[i] == hw_config->irq)
-		{
-			tmp |= i << 3;
+		case 5:
+			tmp |= 0x10;
+			break;
+		case 7:
+			tmp |= 0x18;
+			break;
+		case 9:
+			tmp |= 0x00;
+			break;
+		case 10:
+			tmp |= 0x08;
+			break;
+		default:
+			printk(KERN_ERR "MAD16: Invalid MIDI IRQ %d\n", hw_config->irq);
 			break;
-		}
 	}
+			
 	mad_write(MC6_PORT, tmp);	/* Write MPU401 config */
+
 #ifndef CONFIG_MAD16_OLDCARD
 probe_401:
 #endif

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

                 reply	other threads:[~2000-11-23 12:04 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=Pine.LNX.4.21.0011231158350.25032-100000@web.sajt.cz \
    --to=pavel@web.sajt.cz \
    --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;
as well as URLs for NNTP newsgroup(s).