[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220412090600.2533461-1-chi.minghao@zte.com.cn>
Date: Tue, 12 Apr 2022 09:06:00 +0000
From: cgel.zte@...il.com
To: zbr@...emap.net
Cc: linux-kernel@...r.kernel.org, Minghao Chi <chi.minghao@....com.cn>,
Zeal Robot <zealci@....com.cn>
Subject: [PATCH] w1: omap-hdq: using pm_runtime_resume_and_get instead of pm_runtime_get_sync
From: Minghao Chi <chi.minghao@....com.cn>
Using pm_runtime_resume_and_get is more appropriate
for simplifing code
Reported-by: Zeal Robot <zealci@....com.cn>
Signed-off-by: Minghao Chi <chi.minghao@....com.cn>
---
drivers/w1/masters/omap_hdq.c | 38 ++++++++++-------------------------
1 file changed, 11 insertions(+), 27 deletions(-)
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index bf2ec59c1f9d..f325fe35a8f7 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -372,12 +372,9 @@ static u8 omap_w1_triplet(void *_hdq, u8 bdir)
OMAP_HDQ_CTRL_STATUS_INTERRUPTMASK;
u8 mask = ctrl | OMAP_HDQ_CTRL_STATUS_DIR;
- err = pm_runtime_get_sync(hdq_data->dev);
- if (err < 0) {
- pm_runtime_put_noidle(hdq_data->dev);
-
+ err = pm_runtime_resume_and_get(hdq_data->dev);
+ if (err < 0)
return err;
- }
err = mutex_lock_interruptible(&hdq_data->hdq_mutex);
if (err < 0) {
@@ -463,12 +460,9 @@ static u8 omap_w1_reset_bus(void *_hdq)
struct hdq_data *hdq_data = _hdq;
int err;
- err = pm_runtime_get_sync(hdq_data->dev);
- if (err < 0) {
- pm_runtime_put_noidle(hdq_data->dev);
-
+ err = pm_runtime_resume_and_get(hdq_data->dev);
+ if (err < 0)
return err;
- }
omap_hdq_break(hdq_data);
@@ -485,12 +479,9 @@ static u8 omap_w1_read_byte(void *_hdq)
u8 val = 0;
int ret;
- ret = pm_runtime_get_sync(hdq_data->dev);
- if (ret < 0) {
- pm_runtime_put_noidle(hdq_data->dev);
-
+ ret = pm_runtime_resume_and_get(hdq_data->dev);
+ if (ret < 0)
return -1;
- }
ret = hdq_read_byte(hdq_data, &val);
if (ret)
@@ -509,12 +500,9 @@ static void omap_w1_write_byte(void *_hdq, u8 byte)
int ret;
u8 status;
- ret = pm_runtime_get_sync(hdq_data->dev);
- if (ret < 0) {
- pm_runtime_put_noidle(hdq_data->dev);
-
+ ret = pm_runtime_resume_and_get(hdq_data->dev);
+ if (ret < 0)
return;
- }
/*
* We need to reset the slave before
@@ -605,10 +593,9 @@ static int omap_hdq_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev);
pm_runtime_use_autosuspend(&pdev->dev);
pm_runtime_set_autosuspend_delay(&pdev->dev, 300);
- ret = pm_runtime_get_sync(&pdev->dev);
+ ret = pm_runtime_resume_and_get(&pdev->dev);
if (ret < 0) {
- pm_runtime_put_noidle(&pdev->dev);
- dev_dbg(&pdev->dev, "pm_runtime_get_sync failed\n");
+ dev_dbg(&pdev->dev, "pm_runtime_resume_and_get failed\n");
goto err_w1;
}
@@ -659,10 +646,7 @@ static int omap_hdq_remove(struct platform_device *pdev)
{
int active;
- active = pm_runtime_get_sync(&pdev->dev);
- if (active < 0)
- pm_runtime_put_noidle(&pdev->dev);
-
+ active = pm_runtime_resume_and_get(&pdev->dev);
w1_remove_master_device(&omap_w1_master);
pm_runtime_dont_use_autosuspend(&pdev->dev);
--
2.25.1
Powered by blists - more mailing lists