media: i2c: dw9768: Fix pm_runtime_set_suspended() with runtime pm enabled

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

 



From: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>

commit d6594d50761728d09f23238cf9c368bab6260ef3 upstream.

It is not valid to call pm_runtime_set_suspended() and
pm_runtime_set_active() for devices with runtime PM enabled because it
returns -EAGAIN if it is enabled already and working. So, adjust the
order to fix it.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 5f9a089b6de3 ("dw9768: Enable low-power probe on ACPI")
Suggested-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
Signed-off-by: Hans Verkuil <hverkuil@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/media/i2c/dw9768.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/drivers/media/i2c/dw9768.c
+++ b/drivers/media/i2c/dw9768.c
@@ -476,10 +476,9 @@ static int dw9768_probe(struct i2c_clien
 	 * to be powered on in an ACPI system. Similarly for power off in
 	 * remove.
 	 */
-	pm_runtime_enable(dev);
 	full_power = (is_acpi_node(dev_fwnode(dev)) &&
 		      acpi_dev_state_d0(dev)) ||
-		     (is_of_node(dev_fwnode(dev)) && !pm_runtime_enabled(dev));
+		     (is_of_node(dev_fwnode(dev)) && !IS_ENABLED(CONFIG_PM));
 	if (full_power) {
 		ret = dw9768_runtime_resume(dev);
 		if (ret < 0) {
@@ -489,6 +488,7 @@ static int dw9768_probe(struct i2c_clien
 		pm_runtime_set_active(dev);
 	}
 
+	pm_runtime_enable(dev);
 	ret = v4l2_async_register_subdev(&dw9768->sd);
 	if (ret < 0) {
 		dev_err(dev, "failed to register V4L2 subdev: %d", ret);
@@ -500,12 +500,12 @@ static int dw9768_probe(struct i2c_clien
 	return 0;
 
 err_power_off:
+	pm_runtime_disable(dev);
 	if (full_power) {
 		dw9768_runtime_suspend(dev);
 		pm_runtime_set_suspended(dev);
 	}
 err_clean_entity:
-	pm_runtime_disable(dev);
 	media_entity_cleanup(&dw9768->sd.entity);
 err_free_handler:
 	v4l2_ctrl_handler_free(&dw9768->ctrls);
@@ -522,12 +522,12 @@ static void dw9768_remove(struct i2c_cli
 	v4l2_async_unregister_subdev(&dw9768->sd);
 	v4l2_ctrl_handler_free(&dw9768->ctrls);
 	media_entity_cleanup(&dw9768->sd.entity);
+	pm_runtime_disable(dev);
 	if ((is_acpi_node(dev_fwnode(dev)) && acpi_dev_state_d0(dev)) ||
-	    (is_of_node(dev_fwnode(dev)) && !pm_runtime_enabled(dev))) {
+	    (is_of_node(dev_fwnode(dev)) && !IS_ENABLED(CONFIG_PM))) {
 		dw9768_runtime_suspend(dev);
 		pm_runtime_set_suspended(dev);
 	}
-	pm_runtime_disable(dev);
 }
 
 static const struct of_device_id dw9768_of_table[] = {


Patches currently in stable-queue which might be from ruanjinjie@xxxxxxxxxx are

queue-6.1/drm-imx-ipuv3-use-irqf_no_autoen-flag-in-request_irq.patch
queue-6.1/cpufreq-cppc-fix-possible-null-ptr-deref-for-cpufreq.patch
queue-6.1/apparmor-test-fix-memory-leak-for-aa_unpack_strdup.patch
queue-6.1/mfd-tps65010-use-irqf_no_autoen-flag-in-request_irq-.patch
queue-6.1/cpufreq-cppc-fix-possible-null-ptr-deref-for-cppc_ge.patch
queue-6.1/spi-spi-fsl-lpspi-use-irqf_no_autoen-flag-in-request.patch
queue-6.1/rtc-st-lpc-use-irqf_no_autoen-flag-in-request_irq.patch
queue-6.1/cpufreq-cppc-fix-wrong-return-value-in-cppc_get_cpu_.patch
queue-6.1/cpufreq-mediatek-hw-fix-wrong-return-value-in-mtk_cpufreq_get_cpu_power.patch
queue-6.1/wifi-mwifiex-use-irqf_no_autoen-flag-in-request_irq.patch
queue-6.1/drm-imx-dcss-use-irqf_no_autoen-flag-in-request_irq.patch
queue-6.1/drm-msm-adreno-use-irqf_no_autoen-flag-in-request_ir.patch
queue-6.1/media-i2c-dw9768-fix-pm_runtime_set_suspended-with-runtime-pm-enabled.patch
queue-6.1/cpufreq-cppc-fix-wrong-return-value-in-cppc_get_cpu_.patch-30306
queue-6.1/misc-apds990x-fix-missing-pm_runtime_disable.patch
queue-6.1/wifi-p54-use-irqf_no_autoen-flag-in-request_irq.patch
queue-6.1/spi-zynqmp-gqspi-undo-runtime-pm-changes-at-driver-e.patch
queue-6.1/soc-ti-smartreflex-use-irqf_no_autoen-flag-in-reques.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux