Re: [PATCH v6 2/2] iio: light: Add support for ltrf216a sensor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Shreeya,

On 6/15/22 16:51, Shreeya Patel wrote:
> +static int ltrf216a_set_power_state(struct ltrf216a_data *data, bool on)
> +{
> +	struct device *dev = &data->client->dev;
> +	int ret, suspended;
> +
> +	if (on) {
> +		suspended = pm_runtime_suspended(dev);
> +		ret = pm_runtime_get_sync(dev);

The pm_runtime_get_sync() returns 1 if device was already resumed and as
Andy said there is no reason not to handle the RPM error. Hence we can
rewrite it like this:

if (on) {
	ret = pm_runtime_resume_and_get(dev);
	if (ret < 0) {
		dev_err(&data->client->dev, "failed to resume runtime PM: %d\n", ret);
		return ret;
	}

	/* Allow one integration cycle before allowing a reading */
	if (!ret)
		msleep(ltrf216a_int_time_reg[0][0]);
} else {
	pm_runtime_mark_last_busy(dev);
	ret = pm_runtime_put_autosuspend(dev);
}

-- 
Best regards,
Dmitry



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux