gpiolib: Add init_valid_mask exported function

Add a function that allows initializing the valid_mask from
gpiochip_add_data.

This prevents race conditions during gpiochip initialization.

If the function is not exported, then the old behaviour is respected,
this is, set all gpios as valid.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Tested-by: Jeffrey Hugo <jhugo@codeaurora.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Ricardo Ribalda Delgado
2018-10-05 08:52:58 +02:00
committed by Linus Walleij
parent 2505c7b012
commit f8ec92a9f6
2 changed files with 20 additions and 3 deletions

View File

@@ -280,6 +280,9 @@ struct gpio_chip {
void (*dbg_show)(struct seq_file *s,
struct gpio_chip *chip);
int (*init_valid_mask)(struct gpio_chip *chip);
int base;
u16 ngpio;
const char *const *names;
@@ -318,7 +321,9 @@ struct gpio_chip {
/**
* @need_valid_mask:
*
* If set core allocates @valid_mask with all bits set to one.
* If set core allocates @valid_mask with all its values initialized
* with init_valid_mask() or set to one if init_valid_mask() is not
* defined
*/
bool need_valid_mask;