Em Wed, 12 May 2021 15:22:43 +0200 Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx> escreveu: > Em Sun, 9 May 2021 12:33:27 +0100 > Jonathan Cameron <jic23@xxxxxxxxxx> escreveu: > > > From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> > > > > In both the probe() error path and remove() pm_runtime_put_noidle() > > is called which will decrement the runtime pm reference count. > > However, there is no matching function to have raised the reference count. > > Not this isn't a fix as the runtime pm core will stop the reference count > > going negative anyway. > > > > An alternative would have been to raise the count in these paths, but > > it is not clear why that would be necessary. > > > > Whilst we are here replace some boilerplate with pm_runtime_resume_and_get() > > Found using coccicheck script under review at: > > https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@xxxxxxxx/ > > > > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> > > Cc: Rui Miguel Silva <rui.silva@xxxxxxxxxx> > > LGTM. > > Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx> Hmm...not quite... > > diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c > > index 5af7b48ff01a..539585b0d300 100644 > > --- a/drivers/iio/gyro/fxas21002c_core.c > > +++ b/drivers/iio/gyro/fxas21002c_core.c > > @@ -366,14 +366,7 @@ static int fxas21002c_write(struct fxas21002c_data *data, > > > > static int fxas21002c_pm_get(struct fxas21002c_data *data) > > { > > - struct device *dev = regmap_get_device(data->regmap); > > - int ret; > > - > > - ret = pm_runtime_get_sync(dev); > > - if (ret < 0) > > - pm_runtime_put_noidle(dev); > > - > > - return ret; > > + return pm_runtime_resume_and_get(regmap_get_device(data->regmap)); > > } fxas21002c_temp_get() and fxas21002c_axis_get() seem to be missing a pm_runtime_put*() if something gets wrong at regmap_field_read(), e. g.: static int fxas21002c_axis_get(struct fxas21002c_data *data, int index, int *val) { struct device *dev = regmap_get_device(data->regmap); __be16 axis_be; int ret; mutex_lock(&data->lock); ret = fxas21002c_pm_get(data); if (ret < 0) goto data_unlock; ret = regmap_bulk_read(data->regmap, FXAS21002C_AXIS_TO_REG(index), &axis_be, sizeof(axis_be)); if (ret < 0) { dev_err(dev, "failed to read axis: %d: %d\n", index, ret); + fxas21002c_pm_put(data); goto data_unlock; } *val = sign_extend32(be16_to_cpu(axis_be), 15); ret = fxas21002c_pm_put(data); if (ret < 0) goto data_unlock; ret = IIO_VAL_INT; data_unlock: mutex_unlock(&data->lock); return ret; } Thanks, Mauro