Skip to content

Commit

Permalink
drivers: sensor: ina23x: s/irq-gpios/alert-gpios
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gmarull authored and carlescufi committed Nov 15, 2022
1 parent d5734bc commit af72206
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 31 deletions.
4 changes: 2 additions & 2 deletions drivers/sensor/ina23x/ina230.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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, \
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/ina23x/ina230.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
};
Expand Down
10 changes: 5 additions & 5 deletions drivers/sensor/ina23x/ina230_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,29 @@ 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;
}

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);
}
4 changes: 2 additions & 2 deletions drivers/sensor/ina23x/ina237.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, \
Expand Down
2 changes: 1 addition & 1 deletion drivers/sensor/ina23x/ina237.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
12 changes: 6 additions & 6 deletions drivers/sensor/ina23x/ina23x_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,31 @@ 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;
}

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);
}
2 changes: 1 addition & 1 deletion drivers/sensor/ina23x/ina23x_trigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
5 changes: 0 additions & 5 deletions dts/bindings/sensor/ti,ina230.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 0 additions & 5 deletions dts/bindings/sensor/ti,ina237.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions dts/bindings/sensor/ti,ina23x-common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions tests/drivers/build_all/sensor/i2c.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit af72206

Please sign in to comment.