Re: [PATCH v4 4/5] iio: adc: ad7380: add alert support

Jonathan Cameron
2025-01-12T11:50:01Z

On Wed, 8 Jan 2025 09:17:32 -0600
David Lechner <dlechner@baylibre.com> wrote:

> On 1/8/25 6:49 AM, Julien Stephan wrote:
> > The alert functionality is an out of range indicator and can be used as
> > an early indicator of an out of bounds conversion result.
> >
>
> ...
>
> > +static int ad7380_get_alert_th(struct ad7380_state *st,
> > + enum iio_event_direction dir,
> > + int *val)
> > +{
> > + int ret, tmp;
> > +
> > + switch (dir) {
> > + case IIO_EV_DIR_RISING:
> > + ret = regmap_read(st->regmap,
> > + AD7380_REG_ADDR_ALERT_HIGH_TH,
> > + &tmp);
> > + if (ret)
> > + return ret;
> > +
> > + *val = FIELD_GET(AD7380_ALERT_HIGH_TH, tmp);
> > + ret = IIO_VAL_INT;
> > + break;
> > + case IIO_EV_DIR_FALLING:
> > + ret = regmap_read(st->regmap,
> > + AD7380_REG_ADDR_ALERT_LOW_TH,
> > + &tmp);
> > + if (ret)
> > + return ret;
> > +
> > + *val = FIELD_GET(AD7380_ALERT_LOW_TH, tmp);
> > + ret = IIO_VAL_INT;
> > + break;
> > + default:
> > + ret = -EINVAL;
> > + break;
> > + }
> > +
> > + return ret;
>
> We can just return directly in each case instead of using break (preferred
> style in IIO).
>
> > +}
> > +
>
> Reviewed-by: David Lechner <dlechner@baylibre.com>
>

I tweaked it whilst applying.