/* Write both port 0 and port 1 registers of certain register function. 
Given the register in reg, write the pair of port 0 and port 1. */
static int write_port_regs(const struct device *dev, uint8_t reg, uint16_t *cache, uint16_t value)
/* Write both port 0 and port 1 registers of certain register function. 
Given the register in reg, write the pair of port 0 and port 1. */
static int write_port_regs(const struct device *dev, uint8_t reg, uint16_t *cache, uint16_t value)
{
	const struct gpio_pca95xx_config * const config = dev->config;
	uint8_t buf[3];
	int ret;
	LOG_DBG("PCA95XX[0x%X]: Write: REG[0x%X] = 0x%X, REG[0x%X] = "
		"0x%X", config->bus.addr, reg, (value & 0xFF),
		(reg + 1), (value >> 8));
	buf[0] = reg;
	sys_put_le16(value, &buf[1]);
	ret = i2c_write_dt(&config->bus, buf, sizeof(buf));
	if (ret == 0) {
		*cache = value;
	} else {
		LOG_ERR("PCA95XX[0x%X]: error writing to register 0x%X "
			"(%d)", config->bus.addr, reg, ret);
	}
	return ret;
}