Skip to content

Commit a3c6eab

Browse files
claudiubezneajic23
authored andcommitted
iio: adc: rzg2l: Cleanup suspend/resume path
There is no need to manually track the runtime PM status in the driver. The pm_runtime_force_suspend() and pm_runtime_force_resume() functions already call pm_runtime_status_suspended() to check the runtime PM state. Additionally, avoid calling pm_runtime_put_autosuspend() during the suspend/resume path, as this would decrease the usage counter of a potential user that had the ADC open before the suspend/resume cycle. Fixes: 563cf94 ("iio: adc: rzg2l_adc: Add suspend/resume support") Reviewed-by: Ulf Hansson <[email protected]> Reviewed-by: Lad Prabhakar <[email protected]> Signed-off-by: Claudiu Beznea <[email protected]> Link: https://patch.msgid.link/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent b04e455 commit a3c6eab

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

drivers/iio/adc/rzg2l_adc.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ struct rzg2l_adc {
8989
struct completion completion;
9090
struct mutex lock;
9191
u16 last_val[RZG2L_ADC_MAX_CHANNELS];
92-
bool was_rpm_active;
9392
};
9493

9594
/**
@@ -541,14 +540,9 @@ static int rzg2l_adc_suspend(struct device *dev)
541540
};
542541
int ret;
543542

544-
if (pm_runtime_suspended(dev)) {
545-
adc->was_rpm_active = false;
546-
} else {
547-
ret = pm_runtime_force_suspend(dev);
548-
if (ret)
549-
return ret;
550-
adc->was_rpm_active = true;
551-
}
543+
ret = pm_runtime_force_suspend(dev);
544+
if (ret)
545+
return ret;
552546

553547
ret = reset_control_bulk_assert(ARRAY_SIZE(resets), resets);
554548
if (ret)
@@ -557,9 +551,7 @@ static int rzg2l_adc_suspend(struct device *dev)
557551
return 0;
558552

559553
rpm_restore:
560-
if (adc->was_rpm_active)
561-
pm_runtime_force_resume(dev);
562-
554+
pm_runtime_force_resume(dev);
563555
return ret;
564556
}
565557

@@ -577,11 +569,9 @@ static int rzg2l_adc_resume(struct device *dev)
577569
if (ret)
578570
return ret;
579571

580-
if (adc->was_rpm_active) {
581-
ret = pm_runtime_force_resume(dev);
582-
if (ret)
583-
goto resets_restore;
584-
}
572+
ret = pm_runtime_force_resume(dev);
573+
if (ret)
574+
goto resets_restore;
585575

586576
ret = rzg2l_adc_hw_init(dev, adc);
587577
if (ret)
@@ -590,10 +580,7 @@ static int rzg2l_adc_resume(struct device *dev)
590580
return 0;
591581

592582
rpm_restore:
593-
if (adc->was_rpm_active) {
594-
pm_runtime_mark_last_busy(dev);
595-
pm_runtime_put_autosuspend(dev);
596-
}
583+
pm_runtime_force_suspend(dev);
597584
resets_restore:
598585
reset_control_bulk_assert(ARRAY_SIZE(resets), resets);
599586
return ret;

0 commit comments

Comments
 (0)