Re: [PATCH 3/8] iio: magnetometer: ak8975: switch to using managed resources

From: Andy Shevchenko

Date: Fri May 08 2026 - 05:58:36 EST


On Thu, May 07, 2026 at 04:35:52PM +0200, Joshua Crofts via B4 Relay wrote:

> Switch the driver to use managed resources (devm_*) which simplifier
> error handling and allows removing ak8975_remove() method from
> the driver.
>
> Note, on error path we now also set mode to POWER_DOWN state which is
> fine. Even if the device is in that mode, there is no problem to set
> that mode again, it should be no-op.
>
> Additionally, remove any pm_runtime_get/put*() function calls that
> dummy cycled the counter to autosuspend the device.

...

> +static void devm_ak8975_power_off(void *data)
> +{
> + struct ak8975_data *ak = data;
> + struct device *dev = &ak->client->dev;
> +
> + /* Only power down if currently active */
> + if (pm_runtime_status_suspended(dev))

Is this one a correct one?
We also have pm_runtime_suspended(), which is different.

> + return;
> +
> + /* Soft-stop the chip before hard-stopping the regulators */
> + ak8975_set_mode(data, POWER_DOWN);
> + ak8975_power_off(data);
> +}

--
With Best Regards,
Andy Shevchenko