diff mbox

[v3,1/3] DMA: shdma: Fix warnings due to improper casts and printk formats

Message ID 1386765786-1926-1-git-send-email-laurent.pinchart+renesas@ideasonboard.com (mailing list archive)
State Superseded
Delegated to: Vinod Koul
Headers show

Commit Message

Laurent Pinchart Dec. 11, 2013, 12:43 p.m. UTC
Use the %zu and %pad printk specifiers to print size_t and dma_addr_t
variables, and cast pointers to uintptr_t instead of unsigned int where
applicable. This fixes warnings on platforms where pointers and/or
dma_addr_t have a different size than int

Cc: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: dmaengine@vger.kernel.org
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/dma/sh/shdma-base.c | 8 ++++----
 drivers/dma/sh/shdma-of.c   | 3 ++-
 drivers/dma/sh/sudmac.c     | 4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

Comments

Andy Shevchenko Dec. 11, 2013, 12:59 p.m. UTC | #1
On Wed, 2013-12-11 at 13:43 +0100, Laurent Pinchart wrote:
> Use the %zu and %pad printk specifiers to print size_t and dma_addr_t

> variables, and cast pointers to uintptr_t instead of unsigned int where

> applicable. This fixes warnings on platforms where pointers and/or

> dma_addr_t have a different size than int


Thanks for an updated version. Now looks better with those %pad.
One comment below.

> @@ -555,7 +555,7 @@ static struct dma_async_tx_descriptor *shdma_prep_sg(struct shdma_chan *schan,

>  			goto err_get_desc;

>  

>  		do {

> -			dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n",

> +			dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %llx\n",

>  				i, sg, len, (unsigned long long)sg_addr);


sg_addr -> %pad as well ?

-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy
---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
Laurent Pinchart Dec. 11, 2013, 2:27 p.m. UTC | #2
On Wednesday 11 December 2013 12:59:34 Shevchenko, Andriy wrote:
> On Wed, 2013-12-11 at 13:43 +0100, Laurent Pinchart wrote:
> 
> > Use the %zu and %pad printk specifiers to print size_t and dma_addr_t
> > variables, and cast pointers to uintptr_t instead of unsigned int where
> > applicable. This fixes warnings on platforms where pointers and/or
> > dma_addr_t have a different size than int
> 
> Thanks for an updated version. Now looks better with those %pad.
> One comment below.
> 
> > @@ -555,7 +555,7 @@ static struct dma_async_tx_descriptor
> > *shdma_prep_sg(struct shdma_chan *schan,
> >  			goto err_get_desc;
> >  
> >  		do {
> > -			dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n",
> > +			dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %llx\n",
> >  				i, sg, len, (unsigned long long)sg_addr);
> 
> sg_addr -> %pad as well ?

Indeed. I'll repost this patch.
Laurent Pinchart Jan. 7, 2014, 3:08 p.m. UTC | #3
Hello,

Ping ? Could this patch series (with patches v3.1 1/3, v3 2/3 and v3 3/3) be 
applied for v3.14 ? Same question for "DMA: shdma: Enable driver compilation 
with COMPILE_TEST".

On Wednesday 11 December 2013 13:43:04 Laurent Pinchart wrote:
> Use the %zu and %pad printk specifiers to print size_t and dma_addr_t
> variables, and cast pointers to uintptr_t instead of unsigned int where
> applicable. This fixes warnings on platforms where pointers and/or
> dma_addr_t have a different size than int
> 
> Cc: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> Cc: Vinod Koul <vinod.koul@intel.com>
> Cc: dmaengine@vger.kernel.org
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/dma/sh/shdma-base.c | 8 ++++----
>  drivers/dma/sh/shdma-of.c   | 3 ++-
>  drivers/dma/sh/sudmac.c     | 4 ++--
>  3 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
> index 2e7b394..5367e01 100644
> --- a/drivers/dma/sh/shdma-base.c
> +++ b/drivers/dma/sh/shdma-base.c
> @@ -227,7 +227,7 @@ bool shdma_chan_filter(struct dma_chan *chan, void *arg)
> struct shdma_chan *schan = to_shdma_chan(chan);
>  	struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
>  	const struct shdma_ops *ops = sdev->ops;
> -	int match = (int)arg;
> +	int match = (long)arg;
>  	int ret;
> 
>  	if (match < 0)
> @@ -491,8 +491,8 @@ static struct shdma_desc *shdma_add_desc(struct
> shdma_chan *schan, }
> 
>  	dev_dbg(schan->dev,
> -		"chaining (%u/%u)@%x -> %x with %p, cookie %d\n",
> -		copy_size, *len, *src, *dst, &new->async_tx,
> +		"chaining (%zu/%zu)@%pad -> %pad with %p, cookie %d\n",
> +		copy_size, *len, src, dst, &new->async_tx,
>  		new->async_tx.cookie);
> 
>  	new->mark = DESC_PREPARED;
> @@ -555,7 +555,7 @@ static struct dma_async_tx_descriptor
> *shdma_prep_sg(struct shdma_chan *schan, goto err_get_desc;
> 
>  		do {
> -			dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n",
> +			dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %llx\n",
>  				i, sg, len, (unsigned long long)sg_addr);
> 
>  			if (direction == DMA_DEV_TO_MEM)
> diff --git a/drivers/dma/sh/shdma-of.c b/drivers/dma/sh/shdma-of.c
> index 06473a0..b4ff9d3 100644
> --- a/drivers/dma/sh/shdma-of.c
> +++ b/drivers/dma/sh/shdma-of.c
> @@ -33,7 +33,8 @@ static struct dma_chan *shdma_of_xlate(struct
> of_phandle_args *dma_spec, /* Only slave DMA channels can be allocated via
> DT */
>  	dma_cap_set(DMA_SLAVE, mask);
> 
> -	chan = dma_request_channel(mask, shdma_chan_filter, (void *)id);
> +	chan = dma_request_channel(mask, shdma_chan_filter,
> +				   (void *)(uintptr_t)id);
>  	if (chan)
>  		to_shdma_chan(chan)->hw_req = id;
> 
> diff --git a/drivers/dma/sh/sudmac.c b/drivers/dma/sh/sudmac.c
> index c7e9cdf..4e7df43 100644
> --- a/drivers/dma/sh/sudmac.c
> +++ b/drivers/dma/sh/sudmac.c
> @@ -178,8 +178,8 @@ static int sudmac_desc_setup(struct shdma_chan *schan,
>  	struct sudmac_chan *sc = to_chan(schan);
>  	struct sudmac_desc *sd = to_desc(sdesc);
> 
> -	dev_dbg(sc->shdma_chan.dev, "%s: src=%x, dst=%x, len=%d\n",
> -		__func__, src, dst, *len);
> +	dev_dbg(sc->shdma_chan.dev, "%s: src=%pad, dst=%pad, len=%zu\n",
> +		__func__, &src, &dst, *len);
> 
>  	if (*len > schan->max_xfer_len)
>  		*len = schan->max_xfer_len;
Laurent Pinchart Jan. 21, 2014, 12:10 p.m. UTC | #4
On Tuesday 07 January 2014 16:08:37 Laurent Pinchart wrote:
> Hello,
> 
> Ping ? Could this patch series (with patches v3.1 1/3, v3 2/3 and v3 3/3) be
> applied for v3.14 ? Same question for "DMA: shdma: Enable driver
> compilation with COMPILE_TEST".

PING ?

> On Wednesday 11 December 2013 13:43:04 Laurent Pinchart wrote:
> > Use the %zu and %pad printk specifiers to print size_t and dma_addr_t
> > variables, and cast pointers to uintptr_t instead of unsigned int where
> > applicable. This fixes warnings on platforms where pointers and/or
> > dma_addr_t have a different size than int
> > 
> > Cc: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> > Cc: Vinod Koul <vinod.koul@intel.com>
> > Cc: dmaengine@vger.kernel.org
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >  drivers/dma/sh/shdma-base.c | 8 ++++----
> >  drivers/dma/sh/shdma-of.c   | 3 ++-
> >  drivers/dma/sh/sudmac.c     | 4 ++--
> >  3 files changed, 8 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
> > index 2e7b394..5367e01 100644
> > --- a/drivers/dma/sh/shdma-base.c
> > +++ b/drivers/dma/sh/shdma-base.c
> > @@ -227,7 +227,7 @@ bool shdma_chan_filter(struct dma_chan *chan, void
> > *arg) struct shdma_chan *schan = to_shdma_chan(chan);
> > 
> >  	struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
> >  	const struct shdma_ops *ops = sdev->ops;
> > 
> > -	int match = (int)arg;
> > +	int match = (long)arg;
> > 
> >  	int ret;
> >  	
> >  	if (match < 0)
> > 
> > @@ -491,8 +491,8 @@ static struct shdma_desc *shdma_add_desc(struct
> > shdma_chan *schan, }
> > 
> >  	dev_dbg(schan->dev,
> > 
> > -		"chaining (%u/%u)@%x -> %x with %p, cookie %d\n",
> > -		copy_size, *len, *src, *dst, &new->async_tx,
> > +		"chaining (%zu/%zu)@%pad -> %pad with %p, cookie %d\n",
> > +		copy_size, *len, src, dst, &new->async_tx,
> > 
> >  		new->async_tx.cookie);
> >  	
> >  	new->mark = DESC_PREPARED;
> > 
> > @@ -555,7 +555,7 @@ static struct dma_async_tx_descriptor
> > *shdma_prep_sg(struct shdma_chan *schan, goto err_get_desc;
> > 
> >  		do {
> > 
> > -			dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n",
> > +			dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %llx\n",
> > 
> >  				i, sg, len, (unsigned long long)sg_addr);
> >  			
> >  			if (direction == DMA_DEV_TO_MEM)
> > 
> > diff --git a/drivers/dma/sh/shdma-of.c b/drivers/dma/sh/shdma-of.c
> > index 06473a0..b4ff9d3 100644
> > --- a/drivers/dma/sh/shdma-of.c
> > +++ b/drivers/dma/sh/shdma-of.c
> > @@ -33,7 +33,8 @@ static struct dma_chan *shdma_of_xlate(struct
> > of_phandle_args *dma_spec, /* Only slave DMA channels can be allocated via
> > DT */
> > 
> >  	dma_cap_set(DMA_SLAVE, mask);
> > 
> > -	chan = dma_request_channel(mask, shdma_chan_filter, (void *)id);
> > +	chan = dma_request_channel(mask, shdma_chan_filter,
> > +				   (void *)(uintptr_t)id);
> > 
> >  	if (chan)
> >  	
> >  		to_shdma_chan(chan)->hw_req = id;
> > 
> > diff --git a/drivers/dma/sh/sudmac.c b/drivers/dma/sh/sudmac.c
> > index c7e9cdf..4e7df43 100644
> > --- a/drivers/dma/sh/sudmac.c
> > +++ b/drivers/dma/sh/sudmac.c
> > @@ -178,8 +178,8 @@ static int sudmac_desc_setup(struct shdma_chan *schan,
> > 
> >  	struct sudmac_chan *sc = to_chan(schan);
> >  	struct sudmac_desc *sd = to_desc(sdesc);
> > 
> > -	dev_dbg(sc->shdma_chan.dev, "%s: src=%x, dst=%x, len=%d\n",
> > -		__func__, src, dst, *len);
> > +	dev_dbg(sc->shdma_chan.dev, "%s: src=%pad, dst=%pad, len=%zu\n",
> > +		__func__, &src, &dst, *len);
> > 
> >  	if (*len > schan->max_xfer_len)
> >  	
> >  		*len = schan->max_xfer_len;
Laurent Pinchart March 4, 2014, 11:42 a.m. UTC | #5
On Tuesday 21 January 2014 13:10:30 Laurent Pinchart wrote:
> On Tuesday 07 January 2014 16:08:37 Laurent Pinchart wrote:
> > Hello,
> > 
> > Ping ? Could this patch series (with patches v3.1 1/3, v3 2/3 and v3 3/3)
> > be applied for v3.14 ? Same question for "DMA: shdma: Enable driver
> > compilation with COMPILE_TEST".
> 
> PING ?

HELLO ? ANYONE THERE ? This is v3.14 material.

> > On Wednesday 11 December 2013 13:43:04 Laurent Pinchart wrote:
> > > Use the %zu and %pad printk specifiers to print size_t and dma_addr_t
> > > variables, and cast pointers to uintptr_t instead of unsigned int where
> > > applicable. This fixes warnings on platforms where pointers and/or
> > > dma_addr_t have a different size than int
> > > 
> > > Cc: Guennadi Liakhovetski <g.liakhovetski+renesas@gmail.com>
> > > Cc: Vinod Koul <vinod.koul@intel.com>
> > > Cc: dmaengine@vger.kernel.org
> > > Signed-off-by: Laurent Pinchart
> > > <laurent.pinchart+renesas@ideasonboard.com>
> > > ---
> > > 
> > >  drivers/dma/sh/shdma-base.c | 8 ++++----
> > >  drivers/dma/sh/shdma-of.c   | 3 ++-
> > >  drivers/dma/sh/sudmac.c     | 4 ++--
> > >  3 files changed, 8 insertions(+), 7 deletions(-)
> > > 
> > > diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
> > > index 2e7b394..5367e01 100644
> > > --- a/drivers/dma/sh/shdma-base.c
> > > +++ b/drivers/dma/sh/shdma-base.c
> > > @@ -227,7 +227,7 @@ bool shdma_chan_filter(struct dma_chan *chan, void
> > > *arg) struct shdma_chan *schan = to_shdma_chan(chan);
> > > 
> > >  	struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
> > >  	const struct shdma_ops *ops = sdev->ops;
> > > 
> > > -	int match = (int)arg;
> > > +	int match = (long)arg;
> > > 
> > >  	int ret;
> > >  	
> > >  	if (match < 0)
> > > 
> > > @@ -491,8 +491,8 @@ static struct shdma_desc *shdma_add_desc(struct
> > > shdma_chan *schan, }
> > > 
> > >  	dev_dbg(schan->dev,
> > > 
> > > -		"chaining (%u/%u)@%x -> %x with %p, cookie %d\n",
> > > -		copy_size, *len, *src, *dst, &new->async_tx,
> > > +		"chaining (%zu/%zu)@%pad -> %pad with %p, cookie %d\n",
> > > +		copy_size, *len, src, dst, &new->async_tx,
> > > 
> > >  		new->async_tx.cookie);
> > >  	
> > >  	new->mark = DESC_PREPARED;
> > > 
> > > @@ -555,7 +555,7 @@ static struct dma_async_tx_descriptor
> > > *shdma_prep_sg(struct shdma_chan *schan, goto err_get_desc;
> > > 
> > >  		do {
> > > 
> > > -			dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n",
> > > +			dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %llx\n",
> > > 
> > >  				i, sg, len, (unsigned long long)sg_addr);
> > >  			
> > >  			if (direction == DMA_DEV_TO_MEM)
> > > 
> > > diff --git a/drivers/dma/sh/shdma-of.c b/drivers/dma/sh/shdma-of.c
> > > index 06473a0..b4ff9d3 100644
> > > --- a/drivers/dma/sh/shdma-of.c
> > > +++ b/drivers/dma/sh/shdma-of.c
> > > @@ -33,7 +33,8 @@ static struct dma_chan *shdma_of_xlate(struct
> > > of_phandle_args *dma_spec, /* Only slave DMA channels can be allocated
> > > via
> > > DT */
> > > 
> > >  	dma_cap_set(DMA_SLAVE, mask);
> > > 
> > > -	chan = dma_request_channel(mask, shdma_chan_filter, (void *)id);
> > > +	chan = dma_request_channel(mask, shdma_chan_filter,
> > > +				   (void *)(uintptr_t)id);
> > > 
> > >  	if (chan)
> > >  	
> > >  		to_shdma_chan(chan)->hw_req = id;
> > > 
> > > diff --git a/drivers/dma/sh/sudmac.c b/drivers/dma/sh/sudmac.c
> > > index c7e9cdf..4e7df43 100644
> > > --- a/drivers/dma/sh/sudmac.c
> > > +++ b/drivers/dma/sh/sudmac.c
> > > @@ -178,8 +178,8 @@ static int sudmac_desc_setup(struct shdma_chan
> > > *schan,
> > > 
> > >  	struct sudmac_chan *sc = to_chan(schan);
> > >  	struct sudmac_desc *sd = to_desc(sdesc);
> > > 
> > > -	dev_dbg(sc->shdma_chan.dev, "%s: src=%x, dst=%x, len=%d\n",
> > > -		__func__, src, dst, *len);
> > > +	dev_dbg(sc->shdma_chan.dev, "%s: src=%pad, dst=%pad, len=%zu\n",
> > > +		__func__, &src, &dst, *len);
> > > 
> > >  	if (*len > schan->max_xfer_len)
> > >  	
> > >  		*len = schan->max_xfer_len;
diff mbox

Patch

diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
index 2e7b394..5367e01 100644
--- a/drivers/dma/sh/shdma-base.c
+++ b/drivers/dma/sh/shdma-base.c
@@ -227,7 +227,7 @@  bool shdma_chan_filter(struct dma_chan *chan, void *arg)
 	struct shdma_chan *schan = to_shdma_chan(chan);
 	struct shdma_dev *sdev = to_shdma_dev(schan->dma_chan.device);
 	const struct shdma_ops *ops = sdev->ops;
-	int match = (int)arg;
+	int match = (long)arg;
 	int ret;
 
 	if (match < 0)
@@ -491,8 +491,8 @@  static struct shdma_desc *shdma_add_desc(struct shdma_chan *schan,
 	}
 
 	dev_dbg(schan->dev,
-		"chaining (%u/%u)@%x -> %x with %p, cookie %d\n",
-		copy_size, *len, *src, *dst, &new->async_tx,
+		"chaining (%zu/%zu)@%pad -> %pad with %p, cookie %d\n",
+		copy_size, *len, src, dst, &new->async_tx,
 		new->async_tx.cookie);
 
 	new->mark = DESC_PREPARED;
@@ -555,7 +555,7 @@  static struct dma_async_tx_descriptor *shdma_prep_sg(struct shdma_chan *schan,
 			goto err_get_desc;
 
 		do {
-			dev_dbg(schan->dev, "Add SG #%d@%p[%d], dma %llx\n",
+			dev_dbg(schan->dev, "Add SG #%d@%p[%zu], dma %llx\n",
 				i, sg, len, (unsigned long long)sg_addr);
 
 			if (direction == DMA_DEV_TO_MEM)
diff --git a/drivers/dma/sh/shdma-of.c b/drivers/dma/sh/shdma-of.c
index 06473a0..b4ff9d3 100644
--- a/drivers/dma/sh/shdma-of.c
+++ b/drivers/dma/sh/shdma-of.c
@@ -33,7 +33,8 @@  static struct dma_chan *shdma_of_xlate(struct of_phandle_args *dma_spec,
 	/* Only slave DMA channels can be allocated via DT */
 	dma_cap_set(DMA_SLAVE, mask);
 
-	chan = dma_request_channel(mask, shdma_chan_filter, (void *)id);
+	chan = dma_request_channel(mask, shdma_chan_filter,
+				   (void *)(uintptr_t)id);
 	if (chan)
 		to_shdma_chan(chan)->hw_req = id;
 
diff --git a/drivers/dma/sh/sudmac.c b/drivers/dma/sh/sudmac.c
index c7e9cdf..4e7df43 100644
--- a/drivers/dma/sh/sudmac.c
+++ b/drivers/dma/sh/sudmac.c
@@ -178,8 +178,8 @@  static int sudmac_desc_setup(struct shdma_chan *schan,
 	struct sudmac_chan *sc = to_chan(schan);
 	struct sudmac_desc *sd = to_desc(sdesc);
 
-	dev_dbg(sc->shdma_chan.dev, "%s: src=%x, dst=%x, len=%d\n",
-		__func__, src, dst, *len);
+	dev_dbg(sc->shdma_chan.dev, "%s: src=%pad, dst=%pad, len=%zu\n",
+		__func__, &src, &dst, *len);
 
 	if (*len > schan->max_xfer_len)
 		*len = schan->max_xfer_len;