linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Staging: comedi: s626: Remove unnecessary cast on void pointer
@ 2016-01-20 23:48 Lucas Tanure
  2016-01-21  9:38 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Lucas Tanure @ 2016-01-20 23:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Ian Abbott; +Cc: devel, linux-kernel

The conversion from void pointer to any other pointer type is guaranteed by
the C programming language.

Signed-off-by: Lucas Tanure <tanure@linux.com>
---
 drivers/staging/comedi/drivers/s626.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
index 35f0f67..13259f0 100644
--- a/drivers/staging/comedi/drivers/s626.c
+++ b/drivers/staging/comedi/drivers/s626.c
@@ -1476,7 +1476,7 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev)
 	 * first uint16_t in the buffer because it contains junk data
 	 * from the final ADC of the previous poll list scan.
 	 */
-	uint32_t *readaddr = (uint32_t *)devpriv->ana_buf.logical_base + 1;
+	uint32_t *readaddr = devpriv->ana_buf.logical_base + 1;
 	int i;
 
 	/* get the data and hand it over to comedi */
@@ -1567,7 +1567,7 @@ static void s626_reset_adc(struct comedi_device *dev, uint8_t *ppl)
 	s626_mc_disable(dev, S626_MC1_ERPS1, S626_P_MC1);
 
 	/* Set starting logical address to write RPS commands. */
-	rps = (uint32_t *)devpriv->rps_buf.logical_base;
+	rps = devpriv->rps_buf.logical_base;
 
 	/* Initialize RPS instruction pointer */
 	writel((uint32_t)devpriv->rps_buf.physical_base,
@@ -1772,7 +1772,7 @@ static int s626_ai_rinsn(struct comedi_device *dev,
 	 * first uint16_t in the buffer because it contains junk data from
 	 * the final ADC of the previous poll list scan.
 	 */
-	readaddr = (uint32_t *)devpriv->ana_buf.logical_base + 1;
+	readaddr = devpriv->ana_buf.logical_base + 1;
 
 	/*
 	 * Convert ADC data to 16-bit integer values and
@@ -2643,7 +2643,7 @@ static int s626_initialize(struct comedi_device *dev)
 	 * Cache Audio2's output DMA buffer logical address.  This is
 	 * where DAC data is buffered for A2 output DMA transfers.
 	 */
-	devpriv->dac_wbuf = (uint32_t *)devpriv->ana_buf.logical_base +
+	devpriv->dac_wbuf = devpriv->ana_buf.logical_base +
 			    S626_DAC_WDMABUF_OS;
 
 	/*
-- 
2.7.0

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

* Re: [PATCH] Staging: comedi: s626: Remove unnecessary cast on void pointer
  2016-01-20 23:48 [PATCH] Staging: comedi: s626: Remove unnecessary cast on void pointer Lucas Tanure
@ 2016-01-21  9:38 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2016-01-21  9:38 UTC (permalink / raw)
  To: Lucas Tanure; +Cc: Greg Kroah-Hartman, Ian Abbott, devel, linux-kernel

On Wed, Jan 20, 2016 at 09:48:39PM -0200, Lucas Tanure wrote:
> The conversion from void pointer to any other pointer type is guaranteed by
> the C programming language.
> 
> Signed-off-by: Lucas Tanure <tanure@linux.com>
> ---
>  drivers/staging/comedi/drivers/s626.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c
> index 35f0f67..13259f0 100644
> --- a/drivers/staging/comedi/drivers/s626.c
> +++ b/drivers/staging/comedi/drivers/s626.c
> @@ -1476,7 +1476,7 @@ static bool s626_handle_eos_interrupt(struct comedi_device *dev)
>  	 * first uint16_t in the buffer because it contains junk data
>  	 * from the final ADC of the previous poll list scan.
>  	 */
> -	uint32_t *readaddr = (uint32_t *)devpriv->ana_buf.logical_base + 1;
> +	uint32_t *readaddr = devpriv->ana_buf.logical_base + 1;


No.  This is a bug.  We need the cast for the pointer math to work.
The original code increments by sizeof(uint32_t) the new code by
sizeof(char).

regards,
dan carpenter

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

end of thread, other threads:[~2016-01-21  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-20 23:48 [PATCH] Staging: comedi: s626: Remove unnecessary cast on void pointer Lucas Tanure
2016-01-21  9:38 ` Dan Carpenter

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).