Mask read inputs for get_multiple callbacks
Subsystems (7)
cover Mask read inputs for get_multiple callbacks
The implementation for several drivers' get_multiple callbacks return additional input states that were not requested by the mask passed in. Although the current caller in the kernel does not care, it would be prudent to ensure the behavior of the get_multiple implementations is to return exactly the requested input states and not more. This patchset ensures such behavior by applying a final mask on the read inputs before setting the bits array.
William Breathitt Gray (6):
gpio: 104-dio-48e: Mask read inputs for get_multiple
gpio: 104-idi-48e: Mask the read inputs for get_multiple
gpio: gpio-mm: Mask read inputs for get_multiple
gpio: ws16c48: Mask read inputs for get_multiple
gpio: pci-idio-16: Mask read inputs for get_multiple
gpio: pcie-idio-24: Mask read inputs for get_multiple
drivers/gpio/gpio-104-dio-48e.c | 2 +- drivers/gpio/gpio-104-idi-48.c | 2 +- drivers/gpio/gpio-gpio-mm.c | 2 +- drivers/gpio/gpio-pci-idio-16.c | 2 +- drivers/gpio/gpio-pcie-idio-24.c | 2 +- drivers/gpio/gpio-ws16c48.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.19.1
PATCH 1/6 gpio: 104-dio-48e: Mask read inputs for get_multiple
This patch masks the read inputs with the word mask in order to ensure only requested input states are returned in the bits array.
--- drivers/gpio/gpio-104-dio-48e.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-104-dio-48e.c +1 -1
@@ -222,7 +222,7 @@ static int dio48e_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, port_state =inb (dio48egpio->base + ports[i]);/* store acquired bits at respective bits array offset */ - bits[word_index] |= port_state << word_offset; + bits[word_index] |= (port_state << word_offset) & word_mask; }return 0 ;
Signature · 1 line
2.19.1
PATCH 2/6 gpio: 104-idi-48e: Mask the read inputs for get_multiple
In reply to William Breathitt GrayThis patch masks the read inputs with the word mask in order to ensure only requested input states are returned in the bits array.
--- drivers/gpio/gpio-104-idi-48.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-104-idi-48.c +1 -1
@@ -128,7 +128,7 @@ static int idi_48_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, port_state =inb (idi48gpio->base + ports[i]);/* store acquired bits at respective bits array offset */ - bits[word_index] |= port_state << word_offset; + bits[word_index] |= (port_state << word_offset) & word_mask; }return 0 ;
Signature · 1 line
2.19.1
PATCH 3/6 gpio: gpio-mm: Mask read inputs for get_multiple
In reply to William Breathitt GrayThis patch masks the read inputs with the word mask in order to ensure only requested input states are returned in the bits array.
--- drivers/gpio/gpio-gpio-mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-gpio-mm.c +1 -1
@@ -211,7 +211,7 @@ static int gpiomm_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, port_state =inb (gpiommgpio->base + ports[i]);/* store acquired bits at respective bits array offset */ - bits[word_index] |= port_state << word_offset; + bits[word_index] |= (port_state << word_offset) & word_mask; }return 0 ;
Signature · 1 line
2.19.1
PATCH 4/6 gpio: ws16c48: Mask read inputs for get_multiple
In reply to William Breathitt GrayThis patch masks the read inputs with the word mask in order to ensure only requested input states are returned in the bits array.
--- drivers/gpio/gpio-ws16c48.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-ws16c48.c +1 -1
@@ -169,7 +169,7 @@ static int ws16c48_gpio_get_multiple(struct gpio_chip *chip, port_state =inb (ws16c48gpio->base + i);/* store acquired bits at respective bits array offset */ - bits[word_index] |= port_state << word_offset; + bits[word_index] |= (port_state << word_offset) & word_mask; }return 0 ;
Signature · 1 line
2.19.1
PATCH 5/6 gpio: pci-idio-16: Mask read inputs for get_multiple
In reply to William Breathitt GrayThis patch masks the read inputs with the word mask in order to ensure only requested input states are returned in the bits array.
--- drivers/gpio/gpio-pci-idio-16.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-pci-idio-16.c +1 -1
@@ -146,7 +146,7 @@ static int idio_16_gpio_get_multiple(struct gpio_chip *chip, port_state =ioread8 (ports[i]);/* store acquired bits at respective bits array offset */ - bits[word_index] |= port_state << word_offset; + bits[word_index] |= (port_state << word_offset) & word_mask; }return 0 ;
Signature · 1 line
2.19.1
PATCH 6/6 gpio: pcie-idio-24: Mask read inputs for get_multiple
In reply to William Breathitt GrayThis patch masks the read inputs with the word mask in order to ensure only requested input states are returned in the bits array.
--- drivers/gpio/gpio-pcie-idio-24.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-pcie-idio-24.c +1 -1
@@ -243,7 +243,7 @@ static int idio_24_gpio_get_multiple(struct gpio_chip *chip, port_state =ioread8 (&idio24gpio->reg->ttl_in0_7);/* store acquired bits at respective bits array offset */ - bits[word_index] |= port_state << word_offset; + bits[word_index] |= (port_state << word_offset) & word_mask; }return 0 ;
Signature · 1 line
2.19.1
Quoted 8 lines · William Breathitt Gray
The implementation for several drivers'
get_multiplecallbacks return additional input states that were not requested by the mask passed in. Although the current caller in the kernel does not care, it would be prudent to ensure the behavior of theget_multipleimplementations is to return exactly the requested input states and not more. This patchset ensures such behavior by applying a final mask on the read inputs before setting the bits array.
Quoted 7 lines
William Breathitt Gray (6):
gpio: 104-dio-48e: Mask read inputs forget_multiple
gpio: 104-idi-48e: Mask the read inputs forget_multiple
gpio: gpio-mm: Mask read inputs forget_multiple
gpio: ws16c48: Mask read inputs forget_multiple
gpio: pci-idio-16: Mask read inputs forget_multiple
gpio: pcie-idio-24: Mask read inputs forget_multiple
All patches applied for v4.21.
Yours,
Linus Walleij