The valid_mask member of the struct gpio_chip is unconditionally written by the GPIO core at driver registration. Current documentation does not mention this but just says the valid_mask is used if it's not NULL. This lured me to try populating it directly in the GPIO driver probe instead of using the init_valid_mask() callback. It took some retries with different bitmaps and eventually a bit of code-reading to understand why the valid_mask was not obeyed. I could've avoided this trial and error if it was mentioned in the documentation. Help the next developer who decides to directly populate the valid_mask in struct gpio_chip by documenting the valid_mask as internal to the GPIO core. Signed-off-by: Matti Vaittinen <mazziesaccount@xxxxxxxxx> --- Alternative approach would be to check whether the valid_mask is NULL at gpio_chip registration and touch it only if it is NULL. This, however, might cause problems if any of the existing drivers pass the struct gpio_chip with uninitialized valid_mask field to the registration. In order to avoid this I decided to keep current behaviour while documenting it a bit better. --- include/linux/gpio/driver.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 2dd7cb9cc270..fe80c65dacb0 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -503,7 +503,8 @@ struct gpio_chip { * @valid_mask: * * If not %NULL, holds bitmask of GPIOs which are valid to be used - * from the chip. + * from the chip. Internal to GPIO core. Chip drivers should populate + * init_valid_mask instead. */ unsigned long *valid_mask; base-commit: d082ecbc71e9e0bf49883ee4afd435a77a5101b6 -- 2.48.1
Attachment:
signature.asc
Description: PGP signature