From patchwork Wed Mar 29 03:42:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tasos Sahanidis X-Patchwork-Id: 668135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0BD93C6FD18 for ; Wed, 29 Mar 2023 03:44:25 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 492971F4; Wed, 29 Mar 2023 05:43:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 492971F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1680061463; bh=Z9MLbxN1y1FYQ3fpZDPrND5+9oADOQYOYfQSKEM29rQ=; h=To:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From:Reply-To:Cc:From; b=JnGmB9L0oN7XjzhlEhqoRwignQ5GJ4tWNICF0v1Tep8WUpUZegvTYv2szQie/vk0R jV68IBHXJ6Tkwnrrm8mDSfkJLmXiIzqV5NPbF46RFNgmcoLCgpYkP8bLoDFaSPLFtt t9wp8CbYowmX0EG5wr/quq/s6hLxud37bddTwm3M= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 93645F80272; Wed, 29 Mar 2023 05:43:08 +0200 (CEST) To: alsa-devel@alsa-project.org Subject: [PATCH] ALSA: ymfpci: Add error messages for abritrary IO ports on older chips Date: Wed, 29 Mar 2023 06:42:04 +0300 X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <168006138739.26.16436862701500259301@mailman-core.alsa-project.org> X-Patchwork-Original-From: Tasos Sahanidis via Alsa-devel From: Tasos Sahanidis Reply-To: Tasos Sahanidis Cc: tiwai@suse.com, tasos@tasossah.com Content-Disposition: inline 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 --- 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;