Commit 80f2bfde authored by Chekhov Ma's avatar Chekhov Ma Committed by Anas Nashif
Browse files

drivers: gpio_adp5585: fix non-contiguous pin layout issue



Fixes #90988. The pin gap handling is wrong in the original code.

Signed-off-by: default avatarChekhov Ma <chekhov.ma@nxp.com>
(cherry picked from commit 41950cab)
parent ae52d17a
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -76,8 +76,7 @@ static int gpio_adp5585_config(const struct device *dev, gpio_pin_t pin, gpio_fl
	uint8_t reg_value;

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

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

	/* ADP5585 has non-contiguous gpio pin layouts, account for this */
	if ((mask & cfg->common.port_pin_mask) == 0) {
		return -ENOTSUP;
	}

	/* Can't do I2C bus operations from an ISR */
	if (k_is_in_isr()) {
		return -EWOULDBLOCK;
@@ -288,8 +292,7 @@ static int gpio_adp5585_pin_interrupt_configure(const struct device *dev, gpio_p
	}

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