Re: [PATCH v2 2/5] iio: pressure: bmp280: Add preinit callback

Angel Iglesias
2023-01-01T11:06:18Z

On Tue, 2022-12-27 at 23:41 +0200, Andy Shevchenko wrote:
> On Mon, Dec 26, 2022 at 03:29:21PM +0100, Angel Iglesias wrote:
> > Adds preinit callback to execute operations on probe before applying
> > initial configuration.
>
> ...
>
> > @@ -935,6 +936,7 @@ static const struct bmp280_chip_info bmp280_chip_info =
> > {
> >         .read_temp = bmp280_read_temp,
> >         .read_press = bmp280_read_press,
> >         .read_calib = bmp280_read_calib,
> > +       .preinit = NULL,
> >  };
> >
> >  static int bme280_chip_config(struct bmp280_data *data)
> > @@ -979,6 +981,7 @@ static const struct bmp280_chip_info bme280_chip_info =
> > {
> >         .read_press = bmp280_read_press,
> >         .read_humid = bmp280_read_humid,
> >         .read_calib = bme280_read_calib,
> > +       .preinit = NULL,
> >  };
>
> Useless changes.
>
> ...
>
> > @@ -1604,6 +1614,7 @@ static const struct bmp280_chip_info bmp180_chip_info
> > = {
> >         .read_temp = bmp180_read_temp,
> >         .read_press = bmp180_read_press,
> >         .read_calib = bmp180_read_calib,
> > +       .preinit = NULL,
> >  };
>
> Ditto.
>
> ...
>
> > +       /*
> > +        * Some chips like the BMP3xx have preinit tasks to run
> > +        * before applying the initial configuration.
> > +        */
> > +       if (data->chip_info->preinit) {
> > +               ret = data->chip_info->preinit(data);
>
> > +               dev_err(dev, "error running preinit tasks");
>
> Huh?! I guess you wanted

The dangers of copying paste and rushing things etc. Sorry for this brain fart!

Thanks for your time,
Angel

> >                 if (ret < 0)
> >                         return ret;
>
>         if (ret < 0)
>                 return dev_err_probe(...);
>
> >         }
>