Skip to content

Commit 6329b6b

Browse files
CkovMkgithub-actions[bot]
authored andcommitted
drivers: gpio_adp5585: fix non-contiguous pin layout issue
Fixes #90988. The pin gap handling is wrong in the original code. Signed-off-by: Chekhov Ma <[email protected]> (cherry picked from commit 41950ca)
1 parent 34b5268 commit 6329b6b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/gpio/gpio_adp5585.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ static int gpio_adp5585_config(const struct device *dev, gpio_pin_t pin, gpio_fl
7676
uint8_t reg_value;
7777

7878
/* ADP5585 has non-contiguous gpio pin layouts, account for this */
79-
if ((pin & cfg->common.port_pin_mask) == 0) {
80-
LOG_ERR("pin %d is invalid for this device", pin);
79+
if ((BIT(pin) & cfg->common.port_pin_mask) == 0) {
8180
return -ENOTSUP;
8281
}
8382

@@ -225,6 +224,11 @@ static int gpio_adp5585_port_write(const struct device *dev, gpio_port_pins_t ma
225224
uint8_t reg_value;
226225
int ret;
227226

227+
/* ADP5585 has non-contiguous gpio pin layouts, account for this */
228+
if ((mask & cfg->common.port_pin_mask) == 0) {
229+
return -ENOTSUP;
230+
}
231+
228232
/* Can't do I2C bus operations from an ISR */
229233
if (k_is_in_isr()) {
230234
return -EWOULDBLOCK;
@@ -288,8 +292,7 @@ static int gpio_adp5585_pin_interrupt_configure(const struct device *dev, gpio_p
288292
}
289293

290294
/* ADP5585 has non-contiguous gpio pin layouts, account for this */
291-
if ((pin & cfg->common.port_pin_mask) == 0) {
292-
LOG_ERR("pin %d is invalid for this device", pin);
295+
if ((BIT(pin) & cfg->common.port_pin_mask) == 0) {
293296
return -ENOTSUP;
294297
}
295298

0 commit comments

Comments
 (0)