All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] sc423x's usage of schedule_timeout()
@ 2004-11-02  0:30 Nishanth Aravamudan
  2004-11-02 12:20 ` [KJ] Re: [Alsa-devel] " Clemens Ladisch
  2004-11-02 12:20 ` sc423x's usage of schedule_timeout() Clemens Ladisch
  0 siblings, 2 replies; 4+ messages in thread
From: Nishanth Aravamudan @ 2004-11-02  0:30 UTC (permalink / raw)
  To: kernel-janitors

[-- 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-02 19:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-02  0:30 [KJ] sc423x's usage of schedule_timeout() Nishanth Aravamudan
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
2004-11-02 12:20 ` sc423x's usage of schedule_timeout() Clemens Ladisch

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.