alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Tamaki Nishino <otamachan@gmail.com>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org, Tamaki Nishino <otamachan@gmail.com>
Subject: [PATCH] ALSA: usb-audio: Fix the enable parameter behavior
Date: Thu, 30 Nov 2017 00:27:47 +0900	[thread overview]
Message-ID: <1511969267-15431-1-git-send-email-otamachan@gmail.com> (raw)

The enable parameter doesn't seem to work as expected. Even when the
enable parameter is set to false in /etc/modprobe.d/alsa-base.conf like
"options snd-usb-audio index=-2 vid=0x1415 pid=0x1d27 enable=0",
the specified device is not disabled.

This patch fixes the enable parameter behavior to disable the device
correctly.

Signed-off-by: Tamaki Nishino <otamachan@gmail.com>
---
 sound/usb/card.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/sound/usb/card.c b/sound/usb/card.c
index 23d1d23..8018d56 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -585,15 +585,24 @@ static int usb_audio_probe(struct usb_interface *intf,
 		 * now look for an empty slot and create a new card instance
 		 */
 		for (i = 0; i < SNDRV_CARDS; i++)
-			if (enable[i] && ! usb_chip[i] &&
+			if (!usb_chip[i] &&
 			    (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) &&
 			    (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) {
-				err = snd_usb_audio_create(intf, dev, i, quirk,
-							   id, &chip);
-				if (err < 0)
+				if (enable[i]) {
+					err = snd_usb_audio_create(intf, dev, i, quirk,
+								   id, &chip);
+					if (err < 0)
+						goto __error;
+					chip->pm_intf = intf;
+					break;
+				} else if (vid[i] != -1 || pid[i] != -1) {
+					dev_info(&dev->dev,
+						 "device (%04x:%04x) is disabled\n",
+						 USB_ID_VENDOR(id),
+						 USB_ID_PRODUCT(id));
+					err = -ENOENT;
 					goto __error;
-				chip->pm_intf = intf;
-				break;
+				}
 			}
 		if (!chip) {
 			dev_err(&dev->dev, "no available usb audio device\n");
-- 
2.7.4

             reply	other threads:[~2017-11-29 15:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-29 15:27 Tamaki Nishino [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-11-29 21:43 [PATCH] ALSA: usb-audio: Fix the enable parameter behavior Tamaki Nishino
2017-11-29 22:26 Tamaki Nishino
2017-11-30  9:06 ` Takashi Iwai
2017-11-30 10:08   ` Tamaki Nishino

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=1511969267-15431-1-git-send-email-otamachan@gmail.com \
    --to=otamachan@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /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).