From 71873c8a16f34ae7f905e4e666f7d943666e3d04 Mon Sep 17 00:00:00 2001 From: Peter Bigot Date: Wed, 11 Dec 2019 11:03:58 -0600 Subject: [PATCH] drivers: gpio_pca95xx: add support for pin validation Add the common config structure as a prefix of the driver-specific config structure and use the devicetree GPIO pin counts to initialize it. Signed-off-by: Peter Bigot --- drivers/gpio/gpio_pca95xx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpio_pca95xx.c b/drivers/gpio/gpio_pca95xx.c index 096c5bc98a6..ebee8438802 100644 --- a/drivers/gpio/gpio_pca95xx.c +++ b/drivers/gpio/gpio_pca95xx.c @@ -52,6 +52,9 @@ LOG_MODULE_REGISTER(gpio_pca95xx); /** Configuration data */ struct gpio_pca95xx_config { + /* gpio_driver_config needs to be first */ + struct gpio_driver_config common; + /** The master I2C device's name */ const char * const i2c_master_dev_name; @@ -589,6 +592,9 @@ static int gpio_pca95xx_init(struct device *dev) #define GPIO_PCA95XX_DEVICE_INSTANCE(inst) \ static const struct gpio_pca95xx_config gpio_pca95xx_##inst##_cfg = { \ + .common = { \ + .port_pin_mask = GPIO_PORT_PIN_MASK_FROM_NGPIOS(DT_INST_##inst##_NXP_PCA95XX_NGPIOS), \ + }, \ .i2c_master_dev_name = DT_INST_##inst##_NXP_PCA95XX_BUS_NAME, \ .i2c_slave_addr = DT_INST_##inst##_NXP_PCA95XX_BASE_ADDRESS, \ .capabilities = \