Re: Three drivers/i2c/ patches

Christoph Hellwig (hch@infradead.org)
Sun, 13 Jul 2003 10:24:07 +0100


> diff -urN -X exclude linux-bk/drivers/i2c/i2c-elektor.c 2.5.75-bk1/drivers/i2c/i2c-elektor.c
> --- linux-bk/drivers/i2c/i2c-elektor.c Sun Jun 15 14:04:13 2003
> +++ 2.5.75-bk1/drivers/i2c/i2c-elektor.c Sat Jul 12 11:51:34 2003
> @@ -59,6 +59,8 @@
> need to be rewriten - but for now just remove this for simpler reading */
>
> static wait_queue_head_t pcf_wait;
> +
> +spinlock_t pcf_pending_lock = SPIN_LOCK_UNLOCKED;
> static int pcf_pending;
>
> /* ----- global defines ----------------------------------------------- */
> @@ -120,12 +122,12 @@
> int timeout = 2;
>
> if (irq > 0) {
> - cli();
> + spin_lock_irq(&pcf_pending_lock);
> if (pcf_pending == 0) {
> interruptible_sleep_on_timeout(&pcf_wait, timeout*HZ );
> } else
> pcf_pending = 0;
> - sti();
> + spin_unlock_irq(&pcf_pending_lock);

Sleeping with interrupts disabled and a spinlock held still isn't exactly
a good idea. As is sleep_on..

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/