diff mbox series

spi: spi-stm32-qspi: using pm_runtime_resume_and_get instead of pm_runtime_get_sync

Message ID 20220412070906.2532091-1-chi.minghao@zte.com.cn (mailing list archive)
State Accepted
Commit c6cf1fafb65dda10f3babcec76991cbc304d02b9
Headers show
Series spi: spi-stm32-qspi: using pm_runtime_resume_and_get instead of pm_runtime_get_sync | expand

Commit Message

CGEL April 12, 2022, 7:09 a.m. UTC
From: Minghao Chi <chi.minghao@zte.com.cn>

Using pm_runtime_resume_and_get is more appropriate
for simplifing code

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
---
 drivers/spi/spi-stm32-qspi.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

Comments

Patrice CHOTARD April 12, 2022, 9:32 a.m. UTC | #1
Hi 

On 4/12/22 09:09, cgel.zte@gmail.com wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
> 
> Using pm_runtime_resume_and_get is more appropriate
> for simplifing code
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
> ---
>  drivers/spi/spi-stm32-qspi.c | 30 ++++++++++--------------------
>  1 file changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
> index ffdc55f87e82..b3586521d08e 100644
> --- a/drivers/spi/spi-stm32-qspi.c
> +++ b/drivers/spi/spi-stm32-qspi.c
> @@ -463,11 +463,9 @@ static int stm32_qspi_poll_status(struct spi_mem *mem, const struct spi_mem_op *
>  	if (!spi_mem_supports_op(mem, op))
>  		return -EOPNOTSUPP;
>  
> -	ret = pm_runtime_get_sync(qspi->dev);
> -	if (ret < 0) {
> -		pm_runtime_put_noidle(qspi->dev);
> +	ret = pm_runtime_resume_and_get(qspi->dev);
> +	if (ret < 0)
>  		return ret;
> -	}
>  
>  	mutex_lock(&qspi->lock);
>  
> @@ -490,11 +488,9 @@ static int stm32_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
>  	struct stm32_qspi *qspi = spi_controller_get_devdata(mem->spi->master);
>  	int ret;
>  
> -	ret = pm_runtime_get_sync(qspi->dev);
> -	if (ret < 0) {
> -		pm_runtime_put_noidle(qspi->dev);
> +	ret = pm_runtime_resume_and_get(qspi->dev);
> +	if (ret < 0)
>  		return ret;
> -	}
>  
>  	mutex_lock(&qspi->lock);
>  	if (op->data.dir == SPI_MEM_DATA_IN && op->data.nbytes)
> @@ -536,11 +532,9 @@ static ssize_t stm32_qspi_dirmap_read(struct spi_mem_dirmap_desc *desc,
>  	u32 addr_max;
>  	int ret;
>  
> -	ret = pm_runtime_get_sync(qspi->dev);
> -	if (ret < 0) {
> -		pm_runtime_put_noidle(qspi->dev);
> +	ret = pm_runtime_resume_and_get(qspi->dev);
> +	if (ret < 0)
>  		return ret;
> -	}
>  
>  	mutex_lock(&qspi->lock);
>  	/* make a local copy of desc op_tmpl and complete dirmap rdesc
> @@ -583,11 +577,9 @@ static int stm32_qspi_setup(struct spi_device *spi)
>  	if (!spi->max_speed_hz)
>  		return -EINVAL;
>  
> -	ret = pm_runtime_get_sync(qspi->dev);
> -	if (ret < 0) {
> -		pm_runtime_put_noidle(qspi->dev);
> +	ret = pm_runtime_resume_and_get(qspi->dev);
> +	if (ret < 0)
>  		return ret;
> -	}
>  
>  	presc = DIV_ROUND_UP(qspi->clk_rate, spi->max_speed_hz) - 1;
>  
> @@ -851,11 +843,9 @@ static int __maybe_unused stm32_qspi_resume(struct device *dev)
>  
>  	pinctrl_pm_select_default_state(dev);
>  
> -	ret = pm_runtime_get_sync(dev);
> -	if (ret < 0) {
> -		pm_runtime_put_noidle(dev);
> +	ret = pm_runtime_resume_and_get(dev);
> +	if (ret < 0)
>  		return ret;
> -	}
>  
>  	writel_relaxed(qspi->cr_reg, qspi->io_base + QSPI_CR);
>  	writel_relaxed(qspi->dcr_reg, qspi->io_base + QSPI_DCR);

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice
Mark Brown April 12, 2022, 8:43 p.m. UTC | #2
On Tue, 12 Apr 2022 07:09:06 +0000, cgel.zte@gmail.com wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
> 
> Using pm_runtime_resume_and_get is more appropriate
> for simplifing code
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: spi-stm32-qspi: using pm_runtime_resume_and_get instead of pm_runtime_get_sync
      commit: c6cf1fafb65dda10f3babcec76991cbc304d02b9

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index ffdc55f87e82..b3586521d08e 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -463,11 +463,9 @@  static int stm32_qspi_poll_status(struct spi_mem *mem, const struct spi_mem_op *
 	if (!spi_mem_supports_op(mem, op))
 		return -EOPNOTSUPP;
 
-	ret = pm_runtime_get_sync(qspi->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(qspi->dev);
+	ret = pm_runtime_resume_and_get(qspi->dev);
+	if (ret < 0)
 		return ret;
-	}
 
 	mutex_lock(&qspi->lock);
 
@@ -490,11 +488,9 @@  static int stm32_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 	struct stm32_qspi *qspi = spi_controller_get_devdata(mem->spi->master);
 	int ret;
 
-	ret = pm_runtime_get_sync(qspi->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(qspi->dev);
+	ret = pm_runtime_resume_and_get(qspi->dev);
+	if (ret < 0)
 		return ret;
-	}
 
 	mutex_lock(&qspi->lock);
 	if (op->data.dir == SPI_MEM_DATA_IN && op->data.nbytes)
@@ -536,11 +532,9 @@  static ssize_t stm32_qspi_dirmap_read(struct spi_mem_dirmap_desc *desc,
 	u32 addr_max;
 	int ret;
 
-	ret = pm_runtime_get_sync(qspi->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(qspi->dev);
+	ret = pm_runtime_resume_and_get(qspi->dev);
+	if (ret < 0)
 		return ret;
-	}
 
 	mutex_lock(&qspi->lock);
 	/* make a local copy of desc op_tmpl and complete dirmap rdesc
@@ -583,11 +577,9 @@  static int stm32_qspi_setup(struct spi_device *spi)
 	if (!spi->max_speed_hz)
 		return -EINVAL;
 
-	ret = pm_runtime_get_sync(qspi->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(qspi->dev);
+	ret = pm_runtime_resume_and_get(qspi->dev);
+	if (ret < 0)
 		return ret;
-	}
 
 	presc = DIV_ROUND_UP(qspi->clk_rate, spi->max_speed_hz) - 1;
 
@@ -851,11 +843,9 @@  static int __maybe_unused stm32_qspi_resume(struct device *dev)
 
 	pinctrl_pm_select_default_state(dev);
 
-	ret = pm_runtime_get_sync(dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(dev);
+	ret = pm_runtime_resume_and_get(dev);
+	if (ret < 0)
 		return ret;
-	}
 
 	writel_relaxed(qspi->cr_reg, qspi->io_base + QSPI_CR);
 	writel_relaxed(qspi->dcr_reg, qspi->io_base + QSPI_DCR);