diff mbox series

spi: stm32-ospi: Fix an error handling path in stm32_ospi_probe()

Message ID 2674c8df1d05ab312826b69bfe9559f81d125a0b.1744975624.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State New
Headers show
Series spi: stm32-ospi: Fix an error handling path in stm32_ospi_probe() | expand

Commit Message

Christophe JAILLET April 18, 2025, 11:27 a.m. UTC
If an error occurs after a successful stm32_ospi_dma_setup() call, some
dma_release_channel() calls are needed to release some resources, as
already done in the remove function.

Fixes: 79b8a705e26c ("spi: stm32: Add OSPI driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested-only
---
 drivers/spi/spi-stm32-ospi.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Mukesh Kumar Savaliya April 18, 2025, 12:09 p.m. UTC | #1
On 4/18/2025 4:57 PM, Christophe JAILLET wrote:
[...]
> diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
> index 668022098b1e..9ec9823409cc 100644
> --- a/drivers/spi/spi-stm32-ospi.c
> +++ b/drivers/spi/spi-stm32-ospi.c
> @@ -960,6 +960,10 @@ static int stm32_ospi_probe(struct platform_device *pdev)
>   err_pm_enable:
>   	pm_runtime_force_suspend(ospi->dev);
>   	mutex_destroy(&ospi->lock);
> +	if (ospi->dma_chtx)
> +		dma_release_channel(ospi->dma_chtx);
why can't you move to devm_dma_request_chan ? No need to cleanup.
> +	if (ospi->dma_chrx)
> +		dma_release_channel(ospi->dma_chrx);
>   
>   	return ret;
>   }
Christophe JAILLET April 18, 2025, 12:20 p.m. UTC | #2
Le 18/04/2025 à 14:09, Mukesh Kumar Savaliya a écrit :
> 
> 
> On 4/18/2025 4:57 PM, Christophe JAILLET wrote:
> [...]
>> diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
>> index 668022098b1e..9ec9823409cc 100644
>> --- a/drivers/spi/spi-stm32-ospi.c
>> +++ b/drivers/spi/spi-stm32-ospi.c
>> @@ -960,6 +960,10 @@ static int stm32_ospi_probe(struct 
>> platform_device *pdev)
>>   err_pm_enable:
>>       pm_runtime_force_suspend(ospi->dev);
>>       mutex_destroy(&ospi->lock);
>> +    if (ospi->dma_chtx)
>> +        dma_release_channel(ospi->dma_chtx);
> why can't you move to devm_dma_request_chan ? No need to cleanup.

Unless I miss something obvious, this function does not exist.

CJ

>> +    if (ospi->dma_chrx)
>> +        dma_release_channel(ospi->dma_chrx);
>>       return ret;
>>   }
> 
> 
>
Mukesh Kumar Savaliya April 18, 2025, 1:16 p.m. UTC | #3
On 4/18/2025 5:50 PM, Christophe JAILLET wrote:
> Le 18/04/2025 à 14:09, Mukesh Kumar Savaliya a écrit :
>>
>>
>> On 4/18/2025 4:57 PM, Christophe JAILLET wrote:
>> [...]
>>> diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
>>> index 668022098b1e..9ec9823409cc 100644
>>> --- a/drivers/spi/spi-stm32-ospi.c
>>> +++ b/drivers/spi/spi-stm32-ospi.c
>>> @@ -960,6 +960,10 @@ static int stm32_ospi_probe(struct 
>>> platform_device *pdev)
>>>   err_pm_enable:
>>>       pm_runtime_force_suspend(ospi->dev);
>>>       mutex_destroy(&ospi->lock);
>>> +    if (ospi->dma_chtx)
>>> +        dma_release_channel(ospi->dma_chtx);
>> why can't you move to devm_dma_request_chan ? No need to cleanup.
> 
> Unless I miss something obvious, this function does not exist.
> 
> CJ
> 
Yes, You are right. Seems the patch is yet not merged.

https://lore.kernel.org/all/20250115160244.1102881-1-csokas.bence@prolan.hu/T/ 

dma: Add devm_dma_request_chan()

Can ignore it for now.
>>> +    if (ospi->dma_chrx)
>>> +        dma_release_channel(ospi->dma_chrx);
>>>       return ret;
>>>   }
>>
>>
>>
>
diff mbox series

Patch

diff --git a/drivers/spi/spi-stm32-ospi.c b/drivers/spi/spi-stm32-ospi.c
index 668022098b1e..9ec9823409cc 100644
--- a/drivers/spi/spi-stm32-ospi.c
+++ b/drivers/spi/spi-stm32-ospi.c
@@ -960,6 +960,10 @@  static int stm32_ospi_probe(struct platform_device *pdev)
 err_pm_enable:
 	pm_runtime_force_suspend(ospi->dev);
 	mutex_destroy(&ospi->lock);
+	if (ospi->dma_chtx)
+		dma_release_channel(ospi->dma_chtx);
+	if (ospi->dma_chrx)
+		dma_release_channel(ospi->dma_chrx);
 
 	return ret;
 }