Commit df3f0347 authored by Jia-Ju Bai's avatar Jia-Ju Bai Committed by Takashi Iwai

ALSA: usb-audio: quirks: Replace mdelay() with msleep() and usleep_range()

snd_usb_select_mode_quirk(), snd_usb_set_interface_quirk() and
snd_usb_ctl_msg_quirk() are never called in atomic context.
They call mdelay() to busily wait, which is not necessary.
mdelay() can be replaced with msleep() and usleep_range().

This is found by a static analysis tool named DCNS written by myself.
Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 13e9a3ed
...@@ -1213,7 +1213,7 @@ int snd_usb_select_mode_quirk(struct snd_usb_substream *subs, ...@@ -1213,7 +1213,7 @@ int snd_usb_select_mode_quirk(struct snd_usb_substream *subs,
if (err < 0) if (err < 0)
return err; return err;
mdelay(20); /* Delay needed after setting the interface */ msleep(20); /* Delay needed after setting the interface */
/* Vendor mode switch cmd is required. */ /* Vendor mode switch cmd is required. */
if (fmt->formats & SNDRV_PCM_FMTBIT_DSD_U32_BE) { if (fmt->formats & SNDRV_PCM_FMTBIT_DSD_U32_BE) {
...@@ -1234,7 +1234,7 @@ int snd_usb_select_mode_quirk(struct snd_usb_substream *subs, ...@@ -1234,7 +1234,7 @@ int snd_usb_select_mode_quirk(struct snd_usb_substream *subs,
return err; return err;
} }
mdelay(20); msleep(20);
} }
return 0; return 0;
} }
...@@ -1281,7 +1281,7 @@ void snd_usb_set_interface_quirk(struct usb_device *dev) ...@@ -1281,7 +1281,7 @@ void snd_usb_set_interface_quirk(struct usb_device *dev)
switch (USB_ID_VENDOR(chip->usb_id)) { switch (USB_ID_VENDOR(chip->usb_id)) {
case 0x23ba: /* Playback Design */ case 0x23ba: /* Playback Design */
case 0x0644: /* TEAC Corp. */ case 0x0644: /* TEAC Corp. */
mdelay(50); msleep(50);
break; break;
} }
} }
...@@ -1301,7 +1301,7 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, ...@@ -1301,7 +1301,7 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
*/ */
if (USB_ID_VENDOR(chip->usb_id) == 0x23ba && if (USB_ID_VENDOR(chip->usb_id) == 0x23ba &&
(requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
mdelay(20); msleep(20);
/* /*
* "TEAC Corp." products need a 20ms delay after each * "TEAC Corp." products need a 20ms delay after each
...@@ -1309,14 +1309,14 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, ...@@ -1309,14 +1309,14 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
*/ */
if (USB_ID_VENDOR(chip->usb_id) == 0x0644 && if (USB_ID_VENDOR(chip->usb_id) == 0x0644 &&
(requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
mdelay(20); msleep(20);
/* ITF-USB DSD based DACs functionality need a delay /* ITF-USB DSD based DACs functionality need a delay
* after each class compliant request * after each class compliant request
*/ */
if (is_itf_usb_dsd_dac(chip->usb_id) if (is_itf_usb_dsd_dac(chip->usb_id)
&& (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
mdelay(20); msleep(20);
/* Zoom R16/24, Logitech H650e, Jabra 550a needs a tiny delay here, /* Zoom R16/24, Logitech H650e, Jabra 550a needs a tiny delay here,
* otherwise requests like get/set frequency return as failed despite * otherwise requests like get/set frequency return as failed despite
...@@ -1326,7 +1326,7 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, ...@@ -1326,7 +1326,7 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
chip->usb_id == USB_ID(0x046d, 0x0a46) || chip->usb_id == USB_ID(0x046d, 0x0a46) ||
chip->usb_id == USB_ID(0x0b0e, 0x0349)) && chip->usb_id == USB_ID(0x0b0e, 0x0349)) &&
(requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
mdelay(1); usleep_range(1000, 2000);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment