All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: perex@perex.cz, tiwai@suse.com
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: [PATCH 1/3] sound: usb: line6: Replace mdelay with msleep in line6_read_data
Date: Sun, 18 Mar 2018 22:51:33 +0800	[thread overview]
Message-ID: <1521384693-23336-1-git-send-email-baijiaju1990@gmail.com> (raw)

line6_read_data() is never called in atomic context.

The call chains ending up at line6_read_data() are:
[1] line6_read_data() <- line6_read_serial_number() -> pod_startup4()
[2] line6_read_data() <- line6_read_serial_number() <- 
	podhd_startup_workqueue()
[3] line6_read_data() <- podhd_dev_start() <- podhd_startup_workqueue()
[4] line6_read_data() <- line6_read_serial_number() <- toneport_init()
	<- line6_probe()
[5] line6_read_data() <- toneport_init() <- line6_probe()

pod_startup4() and podhd_startup_workqueue() are set in INIT_WORK().
line6_probe() is called in toneport_probe(), pod_probe(), podhd_probe() 
and variax_probe(), which are set as ".probe" in usb_driver structure.
These functions are not called in atomic context.

Despite never getting called from atomic context, line6_read_data()
calls mdelay for busy wait.
That is not necessary and can be replaced with msleep to 
avoid busy waiting.

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 sound/usb/line6/driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
index 0ff5a7d..af99e73 100644
--- a/sound/usb/line6/driver.c
+++ b/sound/usb/line6/driver.c
@@ -356,7 +356,7 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data,
 
 	/* Wait for data length. We'll get 0xff until length arrives. */
 	for (count = 0; count < LINE6_READ_WRITE_MAX_RETRIES; count++) {
-		mdelay(LINE6_READ_WRITE_STATUS_DELAY);
+		msleep(LINE6_READ_WRITE_STATUS_DELAY);
 
 		ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
 				      USB_TYPE_VENDOR | USB_RECIP_DEVICE |
-- 
1.9.1

             reply	other threads:[~2018-03-18 14:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-18 14:51 Jia-Ju Bai [this message]
2018-03-18 15:23 ` [alsa-devel] [PATCH 1/3] sound: usb: line6: Replace mdelay with msleep in line6_read_data Ladislav Michl
2018-03-18 15:23   ` Ladislav Michl

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=1521384693-23336-1-git-send-email-baijiaju1990@gmail.com \
    --to=baijiaju1990@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.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 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.