All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Aravamudan <nacc@us.ibm.com>
To: kernel-janitors@vger.kernel.org
Subject: [KJ] sc423x's usage of schedule_timeout()
Date: Tue, 02 Nov 2004 00:30:31 +0000	[thread overview]
Message-ID: <20041102003031.GD4255@us.ibm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1260 bytes --]

Hi,

I am going through the kernel, as part of the Kernel-Janitors TODO and
replacing schedule_timeout() with msleep() and its variants. In this
process, I came across

sound/isa/cs423x/cs4231_lib.c

which contains the following code:

	timeout = HZ / 4 / 2;
	time = 2;
	while (snd_cs4231_in(chip, CS4231_TEST_INIT) & CS4231_CALIB_IN_PROGRESS) {
		set_current_state(TASK_INTERRUPTIBLE);
		time = schedule_timeout(time);
		if (time > 0)
			continue;
		time = 2;
		if (--timeout < 0) {
			snd_printk("mce_down - auto calibration time out (2)\n");
			return;
		}
	}

This code seems pretty strange, as the delay is in terms of time, which
seems to mean the loop (as long as the condition is true, of course)
sleeps for 2 jiffies, then sleeps for another 2, about HZ / 4 / 2 (HZ /
8) times. This results in a maximal delay of HZ / 4 jiffies...

This just seemed like a very strange coding style. Perhaps that is just
me, though.

My first concern, though, is whether perhaps here the time and timeout
values have been switched, as it's unusual to treat any variable whose
value is expressed in terms of HZ as a counter (or really anything
except a time variable).

Please let me know if this code should be left as is, or should be fixed
(and how?).

Thanks,
Nish

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

             reply	other threads:[~2004-11-02  0:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-02  0:30 Nishanth Aravamudan [this message]
2004-11-02 12:20 ` sc423x's usage of schedule_timeout() Clemens Ladisch
2004-11-02 12:20 ` [KJ] Re: [Alsa-devel] " Clemens Ladisch
2004-11-02 19:29   ` [PATCH] sound/cs4231_lib: replace schedule_timeout() with msleep() Nishanth Aravamudan

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=20041102003031.GD4255@us.ibm.com \
    --to=nacc@us.ibm.com \
    --cc=kernel-janitors@vger.kernel.org \
    /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.