On Fri, 11 Oct 2024 21:02:32 +0200 Vasileios Aoiridis <vassilisamir@xxxxxxxxx> wrote: > On Fri, Oct 11, 2024 at 01:10:20PM +0300, Andy Shevchenko wrote: > > On Thu, Oct 10, 2024 at 11:00:25PM +0200, vamoirid wrote: > > > From: Vasileios Amoiridis <vassilisamir@xxxxxxxxx> > > > > > > Add runtime power management to the device. To facilitate this, add also > > > a struct dev * inside the bme680_data structure to have the device > > > accesible from the data structure. > > > > ... > > > > > --- a/drivers/iio/chemical/bme680.h > > > +++ b/drivers/iio/chemical/bme680.h > > > @@ -75,6 +75,7 @@ > > > #define BME680_CALIB_RANGE_3_LEN 5 > > > > > > extern const struct regmap_config bme680_regmap_config; > > > +extern const struct dev_pm_ops bmp280_dev_pm_ops; > > > > Is pm.h being included already in this header? Otherwise you need to add it. > > > > No it is not, and indeed I need to add it. Probably because it was > included by some other file I didn't get an error from gcc? > > > ... > > > > > struct regmap *regmap; > > > struct bme680_calib bme680; > > > struct mutex lock; /* Protect multiple serial R/W ops to device. */ > > > + struct device *dev; > > > > Is it the same that you may get wia regmap_get_device()? > > > > Yes it is the same. Maybe I can try and see if I can use the following > > regmap_get_device(data->regmap) > > in the places where the pm functions are used in order to not declare a > new value inside the struct bme680_data. But in general, is this approach > prefered? slightly by me. I tend not to poke on that if people have chosen a local variable, but it is a little neater. This patch might get caught up in an effort to simplify the autosuspend handling but if it is we'll deal with that whilst merging. There 'should' be a clean path to transition from this style to the proposed new one where a simple pm_runtime_put() without the mark_last_busy stuff is enough for autosuspend cases. Jonathan