ata: pata_pxa: convert not to use dma_request_slave_channel()

Message ID f177835b7f0db810a132916c8a281bbdaf47f9d3.1699801657.git.christophe.jaillet@wanadoo.fr
State New
Headers
Series ata: pata_pxa: convert not to use dma_request_slave_channel() |

Commit Message

Christophe JAILLET Nov. 12, 2023, 3:07 p.m. UTC
  dma_request_slave_channel() is deprecated. dma_request_chan() should
be used directly instead.

Switch to the preferred function and update the error handling accordingly.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/ata/pata_pxa.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
  

Comments

Niklas Cassel Nov. 13, 2023, 8:05 a.m. UTC | #1
Hello Christophe,

On Sun, Nov 12, 2023 at 04:07:59PM +0100, Christophe JAILLET wrote:
> dma_request_slave_channel() is deprecated. dma_request_chan() should
> be used directly instead.
> 
> Switch to the preferred function and update the error handling accordingly.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/ata/pata_pxa.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
> index 5275c6464f57..0c9c9cf63d36 100644
> --- a/drivers/ata/pata_pxa.c
> +++ b/drivers/ata/pata_pxa.c
> @@ -274,9 +274,8 @@ static int pxa_ata_probe(struct platform_device *pdev)
>  	/*
>  	 * Request the DMA channel
>  	 */
> -	data->dma_chan =
> -		dma_request_slave_channel(&pdev->dev, "data");
> -	if (!data->dma_chan)
> +	data->dma_chan = dma_request_chan(&pdev->dev, "data");

While the previous API could only return NULL on failure, the new API can
return an actual error.

I think we should return the actual error instead of -EBUSY.

i.e.:

if (IS_ERR(data->dma_chan))
	return PTR_ERR(data->dma_chan);


> +	if (IS_ERR(data->dma_chan))
>  		return -EBUSY;
>  	ret = dmaengine_slave_config(data->dma_chan, &config);
>  	if (ret < 0) {
> -- 
> 2.34.1
> 


Kind regards,
Niklas
  
Sergey Shtylyov Nov. 13, 2023, 10:17 a.m. UTC | #2
On 11/13/23 11:05 AM, Niklas Cassel wrote:
[...]
>> dma_request_slave_channel() is deprecated. dma_request_chan() should
>> be used directly instead.
>>
>> Switch to the preferred function and update the error handling accordingly.
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>  drivers/ata/pata_pxa.c | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
>> index 5275c6464f57..0c9c9cf63d36 100644
>> --- a/drivers/ata/pata_pxa.c
>> +++ b/drivers/ata/pata_pxa.c
>> @@ -274,9 +274,8 @@ static int pxa_ata_probe(struct platform_device *pdev)
>>  	/*
>>  	 * Request the DMA channel
>>  	 */
>> -	data->dma_chan =
>> -		dma_request_slave_channel(&pdev->dev, "data");
>> -	if (!data->dma_chan)
>> +	data->dma_chan = dma_request_chan(&pdev->dev, "data");
> 
> While the previous API could only return NULL on failure, the new API can
> return an actual error.
> 
> I think we should return the actual error instead of -EBUSY.
> 
> i.e.:
> 
> if (IS_ERR(data->dma_chan))
> 	return PTR_ERR(data->dma_chan);

   Agreed. Christophe, please fix.

[...]
>> +	if (IS_ERR(data->dma_chan))
>>  		return -EBUSY;
>>  	ret = dmaengine_slave_config(data->dma_chan, &config);
>>  	if (ret < 0) {
[...]

> Kind regards,
> Niklas

MBR, Sergey
  
Christophe JAILLET Nov. 13, 2023, 7:14 p.m. UTC | #3
Le 13/11/2023 à 11:17, Sergey Shtylyov a écrit :
> On 11/13/23 11:05 AM, Niklas Cassel wrote:
> [...]
>>> dma_request_slave_channel() is deprecated. dma_request_chan() should
>>> be used directly instead.
>>>
>>> Switch to the preferred function and update the error handling accordingly.
>>>
>>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>>> ---
>>>   drivers/ata/pata_pxa.c | 5 ++---
>>>   1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
>>> index 5275c6464f57..0c9c9cf63d36 100644
>>> --- a/drivers/ata/pata_pxa.c
>>> +++ b/drivers/ata/pata_pxa.c
>>> @@ -274,9 +274,8 @@ static int pxa_ata_probe(struct platform_device *pdev)
>>>   	/*
>>>   	 * Request the DMA channel
>>>   	 */
>>> -	data->dma_chan =
>>> -		dma_request_slave_channel(&pdev->dev, "data");
>>> -	if (!data->dma_chan)
>>> +	data->dma_chan = dma_request_chan(&pdev->dev, "data");
>>
>> While the previous API could only return NULL on failure, the new API can
>> return an actual error.
>>
>> I think we should return the actual error instead of -EBUSY.
>>
>> i.e.:
>>
>> if (IS_ERR(data->dma_chan))
>> 	return PTR_ERR(data->dma_chan);
> 
>     Agreed. Christophe, please fix.

Will do.

Thx for both of you for the review.

CJ

> 
> [...]
>>> +	if (IS_ERR(data->dma_chan))
>>>   		return -EBUSY;
>>>   	ret = dmaengine_slave_config(data->dma_chan, &config);
>>>   	if (ret < 0) {
> [...]
> 
>> Kind regards,
>> Niklas
> 
> MBR, Sergey
>
  

Patch

diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c
index 5275c6464f57..0c9c9cf63d36 100644
--- a/drivers/ata/pata_pxa.c
+++ b/drivers/ata/pata_pxa.c
@@ -274,9 +274,8 @@  static int pxa_ata_probe(struct platform_device *pdev)
 	/*
 	 * Request the DMA channel
 	 */
-	data->dma_chan =
-		dma_request_slave_channel(&pdev->dev, "data");
-	if (!data->dma_chan)
+	data->dma_chan = dma_request_chan(&pdev->dev, "data");
+	if (IS_ERR(data->dma_chan))
 		return -EBUSY;
 	ret = dmaengine_slave_config(data->dma_chan, &config);
 	if (ret < 0) {