[alsa-devel] [PATCH] sscape: drop redundant fields from soundscape struct

Krzysztof Helt krzysztof.h1 at poczta.fm
Sun Feb 1 21:12:31 CET 2009


From: Krzysztof Helt <krzysztof.h1 at wp.pl>

The wss_base is disguised parameter for one function.
It is converted to a function parameter.

The code_type is only set but never read.
It is removed.

The midi_vol is set only to 0 so it does not work
as detection of change in midi volume. It is removed.

The xport variable is alias to the port[dev]. Use
the port[dev] directly to increase readability.

Signed-off-by: Krzysztof Helt <krzysztof.h1 at wp.pl>
---
 sound/isa/sscape.c |   42 ++++++++++++++----------------------------
 1 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c
index 681e223..c6a90f0 100644
--- a/sound/isa/sscape.c
+++ b/sound/isa/sscape.c
@@ -135,8 +135,6 @@ enum card_type {
 struct soundscape {
 	spinlock_t lock;
 	unsigned io_base;
-	unsigned wss_base;
-	int codec_type;
 	int ic_type;
 	enum card_type type;
 	struct resource *io_res;
@@ -152,7 +150,6 @@ struct soundscape {
 	spinlock_t fwlock;
 	int hw_in_use;
 	unsigned long midi_usage;
-	unsigned char midi_vol;
 };
 
 #define INVALID_IRQ  ((unsigned)-1)
@@ -760,14 +757,9 @@ static int sscape_midi_put(struct snd_kcontrol *kctl,
 	 * and then perform another volume-related command. Perhaps the
 	 * first command is an "open" and the second command is a "close"?
 	 */
-	if (s->midi_vol == ((unsigned char) uctl->value.integer. value[0] & 127)) {
-		change = 0;
-		goto __skip_change;
-	}
 	change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100)
 	          && host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100)
 	          && host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100));
-      __skip_change:
 
 	/*
 	 * Take the board out of HOST mode and back into MIDI mode ...
@@ -809,12 +801,11 @@ static unsigned __devinit get_irq_config(int irq)
  * Perform certain arcane port-checks to see whether there
  * is a SoundScape board lurking behind the given ports.
  */
-static int __devinit detect_sscape(struct soundscape *s)
+static int __devinit detect_sscape(struct soundscape *s, long wss_io)
 {
 	unsigned long flags;
 	unsigned d;
 	int retval = 0;
-	int codec = s->wss_base;
 
 	spin_lock_irqsave(&s->lock, flags);
 
@@ -830,13 +821,11 @@ static int __devinit detect_sscape(struct soundscape *s)
 	if ((d & 0x80) != 0)
 		goto _done;
 
-	if (d == 0) {
-		s->codec_type = 1;
+	if (d == 0)
 		s->ic_type = IC_ODIE;
-	} else if ((d & 0x60) != 0) {
-		s->codec_type = 2;
+	else if ((d & 0x60) != 0)
 		s->ic_type = IC_OPUS;
-	} else
+	else
 		goto _done;
 
 	outb(0xfa, ODIE_ADDR_IO(s->io_base));
@@ -856,10 +845,10 @@ static int __devinit detect_sscape(struct soundscape *s)
 	sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0);
 
 	if (s->type == SSCAPE_VIVO)
-		codec += 4;
+		wss_io += 4;
 	/* wait for WSS codec */
 	for (d = 0; d < 500; d++) {
-		if ((inb(codec) & 0x80) == 0)
+		if ((inb(wss_io) & 0x80) == 0)
 			break;
 		spin_unlock_irqrestore(&s->lock, flags);
 		msleep(1);
@@ -1057,7 +1046,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
 	unsigned dma_cfg;
 	unsigned irq_cfg;
 	unsigned mpu_irq_cfg;
-	unsigned xport;
 	struct resource *io_res;
 	struct resource *wss_res;
 	unsigned long flags;
@@ -1077,15 +1065,15 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
 		printk(KERN_ERR "sscape: Invalid IRQ %d\n", mpu_irq[dev]);
 		return -ENXIO;
 	}
-	xport = port[dev];
 
 	/*
 	 * Grab IO ports that we will need to probe so that we
 	 * can detect and control this hardware ...
 	 */
-	io_res = request_region(xport, 8, "SoundScape");
+	io_res = request_region(port[dev], 8, "SoundScape");
 	if (!io_res) {
-		snd_printk(KERN_ERR "sscape: can't grab port 0x%x\n", xport);
+		snd_printk(KERN_ERR
+			   "sscape: can't grab port 0x%lx\n", port[dev]);
 		return -EBUSY;
 	}
 	wss_res = NULL;
@@ -1112,10 +1100,9 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
 	spin_lock_init(&sscape->fwlock);
 	sscape->io_res = io_res;
 	sscape->wss_res = wss_res;
-	sscape->io_base = xport;
-	sscape->wss_base = wss_port[dev];
+	sscape->io_base = port[dev];
 
-	if (!detect_sscape(sscape)) {
+	if (!detect_sscape(sscape, wss_port[dev])) {
 		printk(KERN_ERR "sscape: hardware not detected at 0x%x\n", sscape->io_base);
 		err = -ENODEV;
 		goto _release_dma;
@@ -1188,11 +1175,11 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
 	}
 #define MIDI_DEVNUM  0
 	if (sscape->type != SSCAPE_VIVO) {
-		err = create_mpu401(card, MIDI_DEVNUM, xport, mpu_irq[dev]);
+		err = create_mpu401(card, MIDI_DEVNUM, port[dev], mpu_irq[dev]);
 		if (err < 0) {
 			printk(KERN_ERR "sscape: Failed to create "
-					"MPU-401 device at 0x%x\n",
-					xport);
+					"MPU-401 device at 0x%lx\n",
+					port[dev]);
 			goto _release_dma;
 		}
 
@@ -1204,7 +1191,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
 		/*
 		 * Initialize mixer
 		 */
-		sscape->midi_vol = 0;
 		host_write_ctrl_unsafe(sscape->io_base, CMD_SET_MIDI_VOL, 100);
 		host_write_ctrl_unsafe(sscape->io_base, 0, 100);
 		host_write_ctrl_unsafe(sscape->io_base, CMD_XXX_MIDI_VOL, 100);
-- 
1.5.2.2


----------------------------------------------------------------------
Doladuj telefon! 
Sprawdz >> http://link.interia.pl/f2047



More information about the Alsa-devel mailing list