All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: ymfpci: Add error messages for abritrary IO ports on older chips
@ 2023-03-29  3:42 Tasos Sahanidis via Alsa-devel
  0 siblings, 0 replies; 2+ messages in thread
From: Tasos Sahanidis via Alsa-devel @ 2023-03-29  3:42 UTC (permalink / raw)
  To: alsa-devel; +Cc: tiwai, tasos


[-- Attachment #0: Type: message/rfc822, Size: 6755 bytes --]

From: Tasos Sahanidis <tasos@tasossah.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.com, tasos@tasossah.com
Subject: [PATCH] ALSA: ymfpci: Add error messages for abritrary IO ports on older chips
Date: Wed, 29 Mar 2023 06:42:04 +0300
Message-ID: <20230329034204.171901-1-tasos@tasossah.com>

As an end user, it can be confusing to request an arbitrary IO port be
used only to find out that it doesn't work without an obvious reason,
especially since /sys/module/snd_ymfpci/parameters/{fm,joystick,mpu}_port
indicate 0 after the module has been loaded.

In my case, I was unaware that the YMF724 did not support such usage, and
thus ended up spending time attempting to debug the issue.

Now, when a user attempts to request an IO port that isn't supported by
the hardware, the following message is printed:

[   25.549530] snd_ymfpci 0000:06:05.0: The Yamaha DS-1 (YMF724F) does not support arbitrary IO ports for FM (requested 0x1234)

Signed-off-by: Tasos Sahanidis <tasos@tasossah.com>
---
 sound/pci/ymfpci/ymfpci.c | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c
index 1e198e4d5..de5dc5337 100644
--- a/sound/pci/ymfpci/ymfpci.c
+++ b/sound/pci/ymfpci/ymfpci.c
@@ -98,8 +98,10 @@ static int snd_ymfpci_create_gameport(struct snd_ymfpci *chip, int dev,
 		case 0x204: legacy_ctrl2 |= 2 << 6; break;
 		case 0x205: legacy_ctrl2 |= 3 << 6; break;
 		default:
-			dev_err(chip->card->dev,
-				"invalid joystick port %#x", io_port);
+			if (io_port > 0)
+				dev_err(chip->card->dev,
+					"The %s does not support arbitrary IO ports for the game port (requested 0x%x)\n",
+					chip->card->shortname, (unsigned int)io_port);
 			return -EINVAL;
 		}
 	}
@@ -186,6 +188,13 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,
 	default: model = str = "???"; break;
 	}
 
+	strcpy(card->driver, str);
+	sprintf(card->shortname, "Yamaha %s (%s)", model, str);
+	sprintf(card->longname, "%s at 0x%lx, irq %i",
+		card->shortname,
+		chip->reg_area_phys,
+		chip->irq);
+
 	legacy_ctrl = 0;
 	legacy_ctrl2 = 0x0800;	/* SBEN = 0, SMOD = 01, LAD = 0 */
 
@@ -218,7 +227,13 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,
 		case 0x398: legacy_ctrl2 |= 1; break;
 		case 0x3a0: legacy_ctrl2 |= 2; break;
 		case 0x3a8: legacy_ctrl2 |= 3; break;
-		default: fm_port[dev] = 0; break;
+		default:
+			if (fm_port[dev] > 0)
+				dev_err(card->dev,
+					"The %s does not support arbitrary IO ports for FM (requested 0x%x)\n",
+					card->shortname, (unsigned int)fm_port[dev]);
+			fm_port[dev] = 0;
+			break;
 		}
 		if (fm_port[dev] > 0)
 			fm_res = devm_request_region(&pci->dev, fm_port[dev],
@@ -234,7 +249,13 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,
 		case 0x300: legacy_ctrl2 |= 1 << 4; break;
 		case 0x332: legacy_ctrl2 |= 2 << 4; break;
 		case 0x334: legacy_ctrl2 |= 3 << 4; break;
-		default: mpu_port[dev] = 0; break;
+		default:
+			if (mpu_port[dev] > 0)
+				dev_err(card->dev,
+					"The %s does not support arbitrary IO ports for MPU-401 (requested 0x%x)\n",
+					card->shortname, (unsigned int)mpu_port[dev]);
+			mpu_port[dev] = 0;
+			break;
 		}
 		if (mpu_port[dev] > 0)
 			mpu_res = devm_request_region(&pci->dev, mpu_port[dev],
@@ -257,12 +278,6 @@ static int snd_card_ymfpci_probe(struct pci_dev *pci,
 	if (err  < 0)
 		return err;
 
-	strcpy(card->driver, str);
-	sprintf(card->shortname, "Yamaha %s (%s)", model, str);
-	sprintf(card->longname, "%s at 0x%lx, irq %i",
-		card->shortname,
-		chip->reg_area_phys,
-		chip->irq);
 	err = snd_ymfpci_pcm(chip, 0);
 	if (err < 0)
 		return err;
-- 
2.25.1


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

* Re: [PATCH] ALSA: ymfpci: Add error messages for abritrary IO ports on older chips
       [not found] <20230329034204.171901-1-tasos@tasossah.com>
@ 2023-03-29  6:40 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2023-03-29  6:40 UTC (permalink / raw)
  To: Tasos Sahanidis; +Cc: alsa-devel, tiwai

On Wed, 29 Mar 2023 05:42:04 +0200,
Tasos Sahanidis wrote:
> 
> As an end user, it can be confusing to request an arbitrary IO port be
> used only to find out that it doesn't work without an obvious reason,
> especially since /sys/module/snd_ymfpci/parameters/{fm,joystick,mpu}_port
> indicate 0 after the module has been loaded.
> 
> In my case, I was unaware that the YMF724 did not support such usage, and
> thus ended up spending time attempting to debug the issue.
> 
> Now, when a user attempts to request an IO port that isn't supported by
> the hardware, the following message is printed:
> 
> [   25.549530] snd_ymfpci 0000:06:05.0: The Yamaha DS-1 (YMF724F) does not support arbitrary IO ports for FM (requested 0x1234)
> 
> Signed-off-by: Tasos Sahanidis <tasos@tasossah.com>

As this is no urgent bug, I applied to for-next branch for 6.4.


thanks,

Takashi

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

end of thread, other threads:[~2023-03-29  6:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230329034204.171901-1-tasos@tasossah.com>
2023-03-29  6:40 ` [PATCH] ALSA: ymfpci: Add error messages for abritrary IO ports on older chips Takashi Iwai
2023-03-29  3:42 Tasos Sahanidis via Alsa-devel

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.