* [PATCH v2] serial: sh-sci: Fix warnings due to improper casts and printk formats
@ 2013-11-27 10:10 Laurent Pinchart
  2013-11-28  7:27 ` Simon Horman
  2013-12-03 18:45 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 5+ messages in thread
From: Laurent Pinchart @ 2013-11-27 10:10 UTC (permalink / raw)
  To: linux-sh; +Cc: Greg Kroah-Hartman, linux-serial
Use the %zu printk specifier to print size_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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-serial@vger.kernel.org
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/tty/serial/sh-sci.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
Changes compared to v1:
- Cast to uintptr_t instead of unsigned long
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 7d8103c..680e0d9 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -557,7 +557,7 @@ static inline int sci_rxd_in(struct uart_port *port)
 		return 1;
 
 	/* Cast for ARM damage */
-	return !!__raw_readb((void __iomem *)s->cfg->port_reg);
+	return !!__raw_readb((void __iomem *)(uintptr_t)s->cfg->port_reg);
 }
 
 /* ********************************************************************** *
@@ -1309,7 +1309,7 @@ static int sci_dma_rx_push(struct sci_port *s, size_t count)
 	}
 
 	if (room < count)
-		dev_warn(port->dev, "Rx overrun: dropping %u bytes\n",
+		dev_warn(port->dev, "Rx overrun: dropping %zu bytes\n",
 			 count - room);
 	if (!room)
 		return room;
@@ -1442,7 +1442,7 @@ static void work_fn_rx(struct work_struct *work)
 		int count;
 
 		chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
-		dev_dbg(port->dev, "Read %u bytes with cookie %d\n",
+		dev_dbg(port->dev, "Read %zu bytes with cookie %d\n",
 			sh_desc->partial, sh_desc->cookie);
 
 		spin_lock_irqsave(&port->lock, flags);
@@ -1691,16 +1691,17 @@ static void sci_request_dma(struct uart_port *port)
 		s->chan_tx = chan;
 		sg_init_table(&s->sg_tx, 1);
 		/* UART circular tx buffer is an aligned page. */
-		BUG_ON((int)port->state->xmit.buf & ~PAGE_MASK);
+		BUG_ON((uintptr_t)port->state->xmit.buf & ~PAGE_MASK);
 		sg_set_page(&s->sg_tx, virt_to_page(port->state->xmit.buf),
-			    UART_XMIT_SIZE, (int)port->state->xmit.buf & ~PAGE_MASK);
+			    UART_XMIT_SIZE,
+			    (uintptr_t)port->state->xmit.buf & ~PAGE_MASK);
 		nent = dma_map_sg(port->dev, &s->sg_tx, 1, DMA_TO_DEVICE);
 		if (!nent)
 			sci_tx_dma_release(s, false);
 		else
-			dev_dbg(port->dev, "%s: mapped %d@%p to %x\n", __func__,
-				sg_dma_len(&s->sg_tx),
-				port->state->xmit.buf, sg_dma_address(&s->sg_tx));
+			dev_dbg(port->dev, "%s: mapped %d@%p to %lx\n", __func__,
+				sg_dma_len(&s->sg_tx), port->state->xmit.buf,
+				(uintptr_t)sg_dma_address(&s->sg_tx));
 
 		s->sg_len_tx = nent;
 
@@ -1740,7 +1741,7 @@ static void sci_request_dma(struct uart_port *port)
 
 			sg_init_table(sg, 1);
 			sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx,
-				    (int)buf[i] & ~PAGE_MASK);
+				    (uintptr_t)buf[i] & ~PAGE_MASK);
 			sg_dma_address(sg) = dma[i];
 		}
 
-- 
1.8.3.2
^ permalink raw reply related	[flat|nested] 5+ messages in thread
* Re: [PATCH v2] serial: sh-sci: Fix warnings due to improper casts and printk formats
  2013-11-27 10:10 [PATCH v2] serial: sh-sci: Fix warnings due to improper casts and printk formats Laurent Pinchart
@ 2013-11-28  7:27 ` Simon Horman
  2013-11-28 14:00   ` Laurent Pinchart
  2013-12-03 18:45 ` Greg Kroah-Hartman
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Horman @ 2013-11-28  7:27 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-sh, Greg Kroah-Hartman, linux-serial
On Wed, Nov 27, 2013 at 11:10:37AM +0100, Laurent Pinchart wrote:
> Use the %zu printk specifier to print size_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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-serial@vger.kernel.org
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Laurent, I am assuming that you would like Greg to take this one.
> ---
>  drivers/tty/serial/sh-sci.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> Changes compared to v1:
> 
> - Cast to uintptr_t instead of unsigned long
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 7d8103c..680e0d9 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -557,7 +557,7 @@ static inline int sci_rxd_in(struct uart_port *port)
>  		return 1;
>  
>  	/* Cast for ARM damage */
> -	return !!__raw_readb((void __iomem *)s->cfg->port_reg);
> +	return !!__raw_readb((void __iomem *)(uintptr_t)s->cfg->port_reg);
>  }
>  
>  /* ********************************************************************** *
> @@ -1309,7 +1309,7 @@ static int sci_dma_rx_push(struct sci_port *s, size_t count)
>  	}
>  
>  	if (room < count)
> -		dev_warn(port->dev, "Rx overrun: dropping %u bytes\n",
> +		dev_warn(port->dev, "Rx overrun: dropping %zu bytes\n",
>  			 count - room);
>  	if (!room)
>  		return room;
> @@ -1442,7 +1442,7 @@ static void work_fn_rx(struct work_struct *work)
>  		int count;
>  
>  		chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
> -		dev_dbg(port->dev, "Read %u bytes with cookie %d\n",
> +		dev_dbg(port->dev, "Read %zu bytes with cookie %d\n",
>  			sh_desc->partial, sh_desc->cookie);
>  
>  		spin_lock_irqsave(&port->lock, flags);
> @@ -1691,16 +1691,17 @@ static void sci_request_dma(struct uart_port *port)
>  		s->chan_tx = chan;
>  		sg_init_table(&s->sg_tx, 1);
>  		/* UART circular tx buffer is an aligned page. */
> -		BUG_ON((int)port->state->xmit.buf & ~PAGE_MASK);
> +		BUG_ON((uintptr_t)port->state->xmit.buf & ~PAGE_MASK);
>  		sg_set_page(&s->sg_tx, virt_to_page(port->state->xmit.buf),
> -			    UART_XMIT_SIZE, (int)port->state->xmit.buf & ~PAGE_MASK);
> +			    UART_XMIT_SIZE,
> +			    (uintptr_t)port->state->xmit.buf & ~PAGE_MASK);
>  		nent = dma_map_sg(port->dev, &s->sg_tx, 1, DMA_TO_DEVICE);
>  		if (!nent)
>  			sci_tx_dma_release(s, false);
>  		else
> -			dev_dbg(port->dev, "%s: mapped %d@%p to %x\n", __func__,
> -				sg_dma_len(&s->sg_tx),
> -				port->state->xmit.buf, sg_dma_address(&s->sg_tx));
> +			dev_dbg(port->dev, "%s: mapped %d@%p to %lx\n", __func__,
> +				sg_dma_len(&s->sg_tx), port->state->xmit.buf,
> +				(uintptr_t)sg_dma_address(&s->sg_tx));
>  
>  		s->sg_len_tx = nent;
>  
> @@ -1740,7 +1741,7 @@ static void sci_request_dma(struct uart_port *port)
>  
>  			sg_init_table(sg, 1);
>  			sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx,
> -				    (int)buf[i] & ~PAGE_MASK);
> +				    (uintptr_t)buf[i] & ~PAGE_MASK);
>  			sg_dma_address(sg) = dma[i];
>  		}
>  
> -- 
> 1.8.3.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [PATCH v2] serial: sh-sci: Fix warnings due to improper casts and printk formats
  2013-11-28  7:27 ` Simon Horman
@ 2013-11-28 14:00   ` Laurent Pinchart
  2013-11-29  0:12     ` Simon Horman
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2013-11-28 14:00 UTC (permalink / raw)
  To: Simon Horman; +Cc: Laurent Pinchart, linux-sh, Greg Kroah-Hartman, linux-serial
Hi Simon,
On Thursday 28 November 2013 16:27:31 Simon Horman wrote:
> On Wed, Nov 27, 2013 at 11:10:37AM +0100, Laurent Pinchart wrote:
> > Use the %zu printk specifier to print size_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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: linux-serial@vger.kernel.org
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> 
> Acked-by: Simon Horman <horms+renesas@verge.net.au>
> 
> Laurent, I am assuming that you would like Greg to take this one.
Actually, as we have quite a few pending sh-sci patches interleaved with 
arch/arm patches, it would be easier if all sh-sci patches went through your 
tree for this kernel version. That's if Greg agrees of course.
> > ---
> > 
> >  drivers/tty/serial/sh-sci.c | 19 ++++++++++---------
> >  1 file changed, 10 insertions(+), 9 deletions(-)
> > 
> > Changes compared to v1:
> > 
> > - Cast to uintptr_t instead of unsigned long
> > 
> > diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> > index 7d8103c..680e0d9 100644
> > --- a/drivers/tty/serial/sh-sci.c
> > +++ b/drivers/tty/serial/sh-sci.c
> > @@ -557,7 +557,7 @@ static inline int sci_rxd_in(struct uart_port *port)
> > 
> >  		return 1;
> >  	
> >  	/* Cast for ARM damage */
> > 
> > -	return !!__raw_readb((void __iomem *)s->cfg->port_reg);
> > +	return !!__raw_readb((void __iomem *)(uintptr_t)s->cfg->port_reg);
> > 
> >  }
> >  
> >  /* **********************************************************************
> >  *
> > 
> > @@ -1309,7 +1309,7 @@ static int sci_dma_rx_push(struct sci_port *s,
> > size_t count)> 
> >  	}
> >  	
> >  	if (room < count)
> > 
> > -		dev_warn(port->dev, "Rx overrun: dropping %u bytes\n",
> > +		dev_warn(port->dev, "Rx overrun: dropping %zu bytes\n",
> > 
> >  			 count - room);
> >  	
> >  	if (!room)
> >  	
> >  		return room;
> > 
> > @@ -1442,7 +1442,7 @@ static void work_fn_rx(struct work_struct *work)
> > 
> >  		int count;
> >  		
> >  		chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
> > 
> > -		dev_dbg(port->dev, "Read %u bytes with cookie %d\n",
> > +		dev_dbg(port->dev, "Read %zu bytes with cookie %d\n",
> > 
> >  			sh_desc->partial, sh_desc->cookie);
> >  		
> >  		spin_lock_irqsave(&port->lock, flags);
> > 
> > @@ -1691,16 +1691,17 @@ static void sci_request_dma(struct uart_port
> > *port)
> > 
> >  		s->chan_tx = chan;
> >  		sg_init_table(&s->sg_tx, 1);
> >  		/* UART circular tx buffer is an aligned page. */
> > 
> > -		BUG_ON((int)port->state->xmit.buf & ~PAGE_MASK);
> > +		BUG_ON((uintptr_t)port->state->xmit.buf & ~PAGE_MASK);
> > 
> >  		sg_set_page(&s->sg_tx, virt_to_page(port->state->xmit.buf),
> > 
> > -			    UART_XMIT_SIZE, (int)port->state->xmit.buf & ~PAGE_MASK);
> > +			    UART_XMIT_SIZE,
> > +			    (uintptr_t)port->state->xmit.buf & ~PAGE_MASK);
> > 
> >  		nent = dma_map_sg(port->dev, &s->sg_tx, 1, DMA_TO_DEVICE);
> >  		if (!nent)
> >  		
> >  			sci_tx_dma_release(s, false);
> >  		
> >  		else
> > 
> > -			dev_dbg(port->dev, "%s: mapped %d@%p to %x\n", __func__,
> > -				sg_dma_len(&s->sg_tx),
> > -				port->state->xmit.buf, sg_dma_address(&s->sg_tx));
> > +			dev_dbg(port->dev, "%s: mapped %d@%p to %lx\n", __func__,
> > +				sg_dma_len(&s->sg_tx), port->state->xmit.buf,
> > +				(uintptr_t)sg_dma_address(&s->sg_tx));
> > 
> >  		s->sg_len_tx = nent;
> > 
> > @@ -1740,7 +1741,7 @@ static void sci_request_dma(struct uart_port *port)
> > 
> >  			sg_init_table(sg, 1);
> >  			sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx,
> > 
> > -				    (int)buf[i] & ~PAGE_MASK);
> > +				    (uintptr_t)buf[i] & ~PAGE_MASK);
> > 
> >  			sg_dma_address(sg) = dma[i];
> >  		
> >  		}
-- 
Regards,
Laurent Pinchart
^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [PATCH v2] serial: sh-sci: Fix warnings due to improper casts and printk formats
  2013-11-28 14:00   ` Laurent Pinchart
@ 2013-11-29  0:12     ` Simon Horman
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2013-11-29  0:12 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Laurent Pinchart, linux-sh, Greg Kroah-Hartman, linux-serial
On Thu, Nov 28, 2013 at 03:00:35PM +0100, Laurent Pinchart wrote:
> Hi Simon,
> 
> On Thursday 28 November 2013 16:27:31 Simon Horman wrote:
> > On Wed, Nov 27, 2013 at 11:10:37AM +0100, Laurent Pinchart wrote:
> > > Use the %zu printk specifier to print size_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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > Cc: linux-serial@vger.kernel.org
> > > Signed-off-by: Laurent Pinchart
> > > <laurent.pinchart+renesas@ideasonboard.com>
> > 
> > Acked-by: Simon Horman <horms+renesas@verge.net.au>
> > 
> > Laurent, I am assuming that you would like Greg to take this one.
> 
> Actually, as we have quite a few pending sh-sci patches interleaved with 
> arch/arm patches, it would be easier if all sh-sci patches went through your 
> tree for this kernel version. That's if Greg agrees of course.
Thanks, that is fine by me so long as its fine by Greg and I get
an Ack from him for each of the sh-sci that go into my tree.
^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [PATCH v2] serial: sh-sci: Fix warnings due to improper casts and printk formats
  2013-11-27 10:10 [PATCH v2] serial: sh-sci: Fix warnings due to improper casts and printk formats Laurent Pinchart
  2013-11-28  7:27 ` Simon Horman
@ 2013-12-03 18:45 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2013-12-03 18:45 UTC (permalink / raw)
  To: Laurent Pinchart; +Cc: linux-sh, linux-serial
On Wed, Nov 27, 2013 at 11:10:37AM +0100, Laurent Pinchart wrote:
> Use the %zu printk specifier to print size_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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-serial@vger.kernel.org
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/tty/serial/sh-sci.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply	[flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-03 18:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-27 10:10 [PATCH v2] serial: sh-sci: Fix warnings due to improper casts and printk formats Laurent Pinchart
2013-11-28  7:27 ` Simon Horman
2013-11-28 14:00   ` Laurent Pinchart
2013-11-29  0:12     ` Simon Horman
2013-12-03 18:45 ` Greg Kroah-Hartman
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).