From af722062c17793fc1c197ebd2bf1990b6995e299 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 2 Nov 2022 16:41:38 +0100 Subject: [PATCH] drivers: sensor: ina23x: s/irq-gpios/alert-gpios The sensor uses the ALERT terminology (pin can be configured to trigger on certain events such as conversion ready or overvoltage alerts). The "IRQ" name is not clear. Signed-off-by: Gerard Marull-Paretas --- drivers/sensor/ina23x/ina230.c | 4 ++-- drivers/sensor/ina23x/ina230.h | 2 +- drivers/sensor/ina23x/ina230_trigger.c | 10 +++++----- drivers/sensor/ina23x/ina237.c | 4 ++-- drivers/sensor/ina23x/ina237.h | 2 +- drivers/sensor/ina23x/ina23x_trigger.c | 12 ++++++------ drivers/sensor/ina23x/ina23x_trigger.h | 2 +- dts/bindings/sensor/ti,ina230.yaml | 5 ----- dts/bindings/sensor/ti,ina237.yaml | 5 ----- dts/bindings/sensor/ti,ina23x-common.yaml | 5 +++++ tests/drivers/build_all/sensor/i2c.dtsi | 6 +++--- 11 files changed, 26 insertions(+), 31 deletions(-) diff --git a/drivers/sensor/ina23x/ina230.c b/drivers/sensor/ina23x/ina230.c index 03e6e19cf2d8..7c7357e4c221 100644 --- a/drivers/sensor/ina23x/ina230.c +++ b/drivers/sensor/ina23x/ina230.c @@ -265,7 +265,7 @@ static const struct sensor_driver_api ina230_driver_api = { .trig_enabled = true, \ .mask = DT_INST_PROP(inst, mask), \ .alert_limit = DT_INST_PROP(inst, alert_limit), \ - .gpio_alert = GPIO_DT_SPEC_INST_GET(inst, irq_gpios) + .alert_gpio = GPIO_DT_SPEC_INST_GET(inst, alert_gpios) #else #define INA230_CFG_IRQ(inst) #endif /* CONFIG_INA230_TRIGGER */ @@ -277,7 +277,7 @@ static const struct sensor_driver_api ina230_driver_api = { .config = DT_INST_PROP(inst, config), \ .current_lsb = DT_INST_PROP(inst, current_lsb_microamps),\ .rshunt = DT_INST_PROP(inst, rshunt_milliohms), \ - COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \ + COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, alert_gpios),\ (INA230_CFG_IRQ(inst)), ()) \ }; \ SENSOR_DEVICE_DT_INST_DEFINE(inst, \ diff --git a/drivers/sensor/ina23x/ina230.h b/drivers/sensor/ina23x/ina230.h index 1d5ac5479cb7..c5d80b0fe558 100644 --- a/drivers/sensor/ina23x/ina230.h +++ b/drivers/sensor/ina23x/ina230.h @@ -53,7 +53,7 @@ struct ina230_config { #ifdef CONFIG_INA230_TRIGGER bool trig_enabled; uint16_t mask; - const struct gpio_dt_spec gpio_alert; + const struct gpio_dt_spec alert_gpio; uint16_t alert_limit; #endif /* CONFIG_INA230_TRIGGER */ }; diff --git a/drivers/sensor/ina23x/ina230_trigger.c b/drivers/sensor/ina23x/ina230_trigger.c index 7d5397ad8394..89a59f00c008 100644 --- a/drivers/sensor/ina23x/ina230_trigger.c +++ b/drivers/sensor/ina23x/ina230_trigger.c @@ -50,14 +50,14 @@ int ina230_trigger_mode_init(const struct device *dev) int ret; /* setup alert gpio interrupt */ - if (!device_is_ready(config->gpio_alert.port)) { + if (!device_is_ready(config->alert_gpio.port)) { LOG_ERR("Alert GPIO device not ready"); return -ENODEV; } ina230->dev = dev; - ret = gpio_pin_configure_dt(&config->gpio_alert, GPIO_INPUT); + ret = gpio_pin_configure_dt(&config->alert_gpio, GPIO_INPUT); if (ret < 0) { LOG_ERR("Could not configure gpio"); return ret; @@ -65,14 +65,14 @@ int ina230_trigger_mode_init(const struct device *dev) gpio_init_callback(&ina230->gpio_cb, ina230_gpio_callback, - BIT(config->gpio_alert.pin)); + BIT(config->alert_gpio.pin)); - ret = gpio_add_callback(config->gpio_alert.port, &ina230->gpio_cb); + ret = gpio_add_callback(config->alert_gpio.port, &ina230->gpio_cb); if (ret < 0) { LOG_ERR("Could not set gpio callback"); return ret; } - return gpio_pin_interrupt_configure_dt(&config->gpio_alert, + return gpio_pin_interrupt_configure_dt(&config->alert_gpio, GPIO_INT_EDGE_BOTH); } diff --git a/drivers/sensor/ina23x/ina237.c b/drivers/sensor/ina23x/ina237.c index 61186d7c0b32..6f5c296a9ac3 100644 --- a/drivers/sensor/ina23x/ina237.c +++ b/drivers/sensor/ina23x/ina237.c @@ -333,7 +333,7 @@ static int ina237_init(const struct device *dev) k_work_init(&data->trigger.conversion_work, ina237_trigger_work_handler); - ret = ina23x_trigger_mode_init(&data->trigger, &config->gpio_alert); + ret = ina23x_trigger_mode_init(&data->trigger, &config->alert_gpio); if (ret < 0) { LOG_ERR("Failed to init trigger mode"); return ret; @@ -382,7 +382,7 @@ static const struct sensor_driver_api ina237_driver_api = { .current_lsb = DT_INST_PROP(inst, current_lsb_microamps), \ .rshunt = DT_INST_PROP(inst, rshunt_milliohms), \ .alert_config = DT_INST_PROP_OR(inst, alert_config, 0x01), \ - .gpio_alert = GPIO_DT_SPEC_INST_GET_OR(inst, irq_gpios, {0}), \ + .alert_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, alert_gpios, {0}), \ }; \ SENSOR_DEVICE_DT_INST_DEFINE(inst, \ &ina237_init, \ diff --git a/drivers/sensor/ina23x/ina237.h b/drivers/sensor/ina23x/ina237.h index 39369d1d4d72..7b9bd95ef5e1 100644 --- a/drivers/sensor/ina23x/ina237.h +++ b/drivers/sensor/ina23x/ina237.h @@ -50,7 +50,7 @@ struct ina237_config { uint16_t adc_config; uint32_t current_lsb; uint16_t rshunt; - const struct gpio_dt_spec gpio_alert; + const struct gpio_dt_spec alert_gpio; uint16_t alert_config; }; diff --git a/drivers/sensor/ina23x/ina23x_trigger.c b/drivers/sensor/ina23x/ina23x_trigger.c index 06d2fcdc4316..0e9eb9fed112 100644 --- a/drivers/sensor/ina23x/ina23x_trigger.c +++ b/drivers/sensor/ina23x/ina23x_trigger.c @@ -20,16 +20,16 @@ static void ina23x_gpio_callback(const struct device *port, k_work_submit(&trigg->conversion_work); } -int ina23x_trigger_mode_init(struct ina23x_trigger *trigg, const struct gpio_dt_spec *gpio_alert) +int ina23x_trigger_mode_init(struct ina23x_trigger *trigg, const struct gpio_dt_spec *alert_gpio) { int ret; - if (!device_is_ready(gpio_alert->port)) { + if (!device_is_ready(alert_gpio->port)) { LOG_ERR("Alert GPIO device not ready"); return -ENODEV; } - ret = gpio_pin_configure_dt(gpio_alert, GPIO_INPUT); + ret = gpio_pin_configure_dt(alert_gpio, GPIO_INPUT); if (ret < 0) { LOG_ERR("Could not configure gpio"); return ret; @@ -37,14 +37,14 @@ int ina23x_trigger_mode_init(struct ina23x_trigger *trigg, const struct gpio_dt_ gpio_init_callback(&trigg->gpio_cb, ina23x_gpio_callback, - BIT(gpio_alert->pin)); + BIT(alert_gpio->pin)); - ret = gpio_add_callback(gpio_alert->port, &trigg->gpio_cb); + ret = gpio_add_callback(alert_gpio->port, &trigg->gpio_cb); if (ret < 0) { LOG_ERR("Could not set gpio callback"); return ret; } - return gpio_pin_interrupt_configure_dt(gpio_alert, + return gpio_pin_interrupt_configure_dt(alert_gpio, GPIO_INT_EDGE_FALLING); } diff --git a/drivers/sensor/ina23x/ina23x_trigger.h b/drivers/sensor/ina23x/ina23x_trigger.h index 91c631472313..d13c885ac9e5 100644 --- a/drivers/sensor/ina23x/ina23x_trigger.h +++ b/drivers/sensor/ina23x/ina23x_trigger.h @@ -18,6 +18,6 @@ struct ina23x_trigger { }; int ina23x_trigger_mode_init(struct ina23x_trigger *trigg, - const struct gpio_dt_spec *gpio_alert); + const struct gpio_dt_spec *alert_gpio); #endif /* ZEPHYR_DRIVERS_SENSOR_INA23X_TRIGGER_H_ */ diff --git a/dts/bindings/sensor/ti,ina230.yaml b/dts/bindings/sensor/ti,ina230.yaml index 5cecb5c60197..8b46d5976dc9 100644 --- a/dts/bindings/sensor/ti,ina230.yaml +++ b/dts/bindings/sensor/ti,ina230.yaml @@ -29,8 +29,3 @@ properties: default: 0 # default alert limit is 0V description: Alert register, default matches the power-on reset value - - irq-gpios: - type: phandle-array - required: false - description: IRQ Alert pin diff --git a/dts/bindings/sensor/ti,ina237.yaml b/dts/bindings/sensor/ti,ina237.yaml index 8949c04fecf3..f615aab27d87 100644 --- a/dts/bindings/sensor/ti,ina237.yaml +++ b/dts/bindings/sensor/ti,ina237.yaml @@ -26,8 +26,3 @@ properties: type: int required: false description: Diag alert register, default matches the power-on reset value - - irq-gpios: - type: phandle-array - required: false - description: IRQ Alert pin diff --git a/dts/bindings/sensor/ti,ina23x-common.yaml b/dts/bindings/sensor/ti,ina23x-common.yaml index 9230e51a5dc1..00f65eaaab4d 100644 --- a/dts/bindings/sensor/ti,ina23x-common.yaml +++ b/dts/bindings/sensor/ti,ina23x-common.yaml @@ -38,3 +38,8 @@ properties: type: int required: true description: Shunt resistor value in milliohms + + alert-gpios: + type: phandle-array + required: false + description: Alert pin diff --git a/tests/drivers/build_all/sensor/i2c.dtsi b/tests/drivers/build_all/sensor/i2c.dtsi index aa46a89e063e..8ea0859e5024 100644 --- a/tests/drivers/build_all/sensor/i2c.dtsi +++ b/tests/drivers/build_all/sensor/i2c.dtsi @@ -595,7 +595,7 @@ test_i2c_ina230: ina230@4f { rshunt-milliohms = <0>; mask = <0>; alert-limit = <0>; - irq-gpios = <&test_gpio 0 0>; + alert-gpios = <&test_gpio 0 0>; }; test_i2c_lm77: lm77@50 { @@ -612,7 +612,7 @@ test_i2c_ina231: ina231@51 { rshunt-milliohms = <0>; mask = <0>; alert-limit = <0>; - irq-gpios = <&test_gpio 0 0>; + alert-gpios = <&test_gpio 0 0>; }; test_i2c_ina237: ina237@52 { @@ -623,7 +623,7 @@ test_i2c_ina237: ina237@52 { adc-config = <0>; rshunt-milliohms = <0>; alert-config = <0>; - irq-gpios = <&test_gpio 0 0>; + alert-gpios = <&test_gpio 0 0>; }; test_i2c_max31875: max31875@53 {