dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size()
@ 2024-04-23 14:32 Ma Ke
  2024-04-24  4:07 ` Frank Li
  0 siblings, 1 reply; 3+ messages in thread
From: Ma Ke @ 2024-04-23 14:32 UTC (permalink / raw)
  To: vkoul, shawnguo, s.hauer, kernel, festevam
  Cc: dmaengine, imx, linux-arm-kernel, linux-kernel, Ma Ke

To avoid the failure of dma_set_max_seg_size(), we should check the
return value of the dma_set_max_seg_size().

Signed-off-by: Ma Ke <make_ruc2021@163.com>
---
 drivers/dma/mxs-dma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index cfb9962417ef..90cbb9b04b02 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -798,7 +798,9 @@ static int mxs_dma_probe(struct platform_device *pdev)
 	mxs_dma->dma_device.dev = &pdev->dev;
 
 	/* mxs_dma gets 65535 bytes maximum sg size */
-	dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
+	ret = dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
+	if (ret)
+		return ret;
 
 	mxs_dma->dma_device.device_alloc_chan_resources = mxs_dma_alloc_chan_resources;
 	mxs_dma->dma_device.device_free_chan_resources = mxs_dma_free_chan_resources;
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size()
  2024-04-23 14:32 [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size() Ma Ke
@ 2024-04-24  4:07 ` Frank Li
  2024-04-25  9:04   ` Vinod Koul
  0 siblings, 1 reply; 3+ messages in thread
From: Frank Li @ 2024-04-24  4:07 UTC (permalink / raw)
  To: Ma Ke
  Cc: vkoul, shawnguo, s.hauer, kernel, festevam, dmaengine, imx,
	linux-arm-kernel, linux-kernel

On Tue, Apr 23, 2024 at 10:32:05PM +0800, Ma Ke wrote:
> To avoid the failure of dma_set_max_seg_size(), we should check the
> return value of the dma_set_max_seg_size().

Check return value of dma_set_max_seg_size() in case it return error.

> 
> Signed-off-by: Ma Ke <make_ruc2021@163.com>
> ---
>  drivers/dma/mxs-dma.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
> index cfb9962417ef..90cbb9b04b02 100644
> --- a/drivers/dma/mxs-dma.c
> +++ b/drivers/dma/mxs-dma.c
> @@ -798,7 +798,9 @@ static int mxs_dma_probe(struct platform_device *pdev)
>  	mxs_dma->dma_device.dev = &pdev->dev;
>  
>  	/* mxs_dma gets 65535 bytes maximum sg size */
> -	dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
> +	ret = dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
> +	if (ret)
> +		return ret;

How error happen? 

static inline int dma_set_max_seg_size(struct device *dev, unsigned int size)
{
	if (dev->dma_parms) {
		dev->dma_parms->max_segment_size = size;
		return 0;
	}
	return -EIO;
}

Only possible dev->dma_parms is null. but mxs-dma is platform device, it
point to platform's dma_parms field. Look like impossible it is null.

Frank 



>  
>  	mxs_dma->dma_device.device_alloc_chan_resources = mxs_dma_alloc_chan_resources;
>  	mxs_dma->dma_device.device_free_chan_resources = mxs_dma_free_chan_resources;
> -- 
> 2.37.2
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size()
  2024-04-24  4:07 ` Frank Li
@ 2024-04-25  9:04   ` Vinod Koul
  0 siblings, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2024-04-25  9:04 UTC (permalink / raw)
  To: Frank Li
  Cc: Ma Ke, shawnguo, s.hauer, kernel, festevam, dmaengine, imx,
	linux-arm-kernel, linux-kernel

On 24-04-24, 00:07, Frank Li wrote:
> On Tue, Apr 23, 2024 at 10:32:05PM +0800, Ma Ke wrote:

> > -	dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
> > +	ret = dma_set_max_seg_size(mxs_dma->dma_device.dev, MAX_XFER_BYTES);
> > +	if (ret)
> > +		return ret;
> 
> How error happen? 
> 
> static inline int dma_set_max_seg_size(struct device *dev, unsigned int size)
> {
> 	if (dev->dma_parms) {
> 		dev->dma_parms->max_segment_size = size;
> 		return 0;
> 	}
> 	return -EIO;
> }
> 
> Only possible dev->dma_parms is null. but mxs-dma is platform device, it
> point to platform's dma_parms field. Look like impossible it is null.

Yep, checking for the sake of checking is bad. It needs to be logical

-- 
~Vinod

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-25  9:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-23 14:32 [PATCH] dmaengine: mxs-dma: Add check for dma_set_max_seg_size() Ma Ke
2024-04-24  4:07 ` Frank Li
2024-04-25  9:04   ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).