Re: [RFC 2.6.28 1/2] gpiolib: add set/get batch v4

From: Uwe Kleine-König
Date: Mon Jan 19 2009 - 12:27:30 EST

Hi Jaya,

> >> +[OPTIONAL] Spinlock-Safe GPIO Batch access
> > Is it really spinlock safe in general? Or only if gpio_cansleep(gpio)
> > if false for each gpio to get or set?
> You are correct to raise this issue. It is only spinlock safe if
> chip->cansleep is false. Initially, I wasn't sure what to do. The
> original gpio set/get_value() just does;
> WARN_ON(extra_checks && chip->can_sleep);
> and it is documented as:
> "
> Spinlock-Safe GPIO access
> -------------------------
> <snip>
> return zero. Also, using these calls for GPIOs that can't safely be accessed
> without sleeping (see below) is an error.
> "
> I will change this in the batch code to return an error if can_sleep
> is detected on any involved gpio_chip.
Wait, I got it wrong. I thought gpio_set_value might sleep if
chip->cansleep is true, but there are extra API functions for
cansleep-chips. So I'd do it the same way as for the non-batch
functions and just WARN_ON(extra_checks && chip->cansleep) for each
involved chip.

Later it might make sense to add the _cansleep variants.

Best regards
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | |
Peiner Strasse 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at