Skip to contentSkip to conversation

: hpilo: fix pointer warning in ilo_ccb_setup

PATCH In review Prarit Bhargava 4 participants 5 messages May 22, 2010 – May 25, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : hpilo: fix pointer warning in ilo_ccb_setup

Fixes warning:

drivers/misc/hpilo.c: In function ‘ilo_ccb_setup’:
drivers/misc/hpilo.c:274: warning: cast to pointer from integer of different size

drivers/misc/hpilo.c +1 -1
index 98ad012..b07a541 100644
@@ -272,7 +272,7 @@ static int ilo_ccb_setup(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
 		return -ENOMEM;
 
 	dma_va = (char *)data->dma_va;
-	dma_pa = (char *)data->dma_pa;
+	dma_pa = (char *)(&data->dma_pa);
 
 	memset(dma_va, 0, data->dma_size);
 
#1 lore raw
Quoted 12 lines · On Fri, 21 May 2010 20:50:41 -0400 Prarit Bhargava <[email protected]> wrote:

Fixes warning:

drivers/misc/hpilo.c: In function ___ilo_ccb_setup___:
drivers/misc/hpilo.c:274: warning: cast to pointer from integer of different size

drivers/misc/hpilo.c +0 -0
index 98ad012..b07a541 100644

drivers/misc/hpilo.c static int ilo_ccb_setup(struct ilo_hwinfo *hw, struct ccb_data *data, int slot) · line 277

Quoted 7 lines
drivers/misc/hpilo.c +1 -1
@@ -272,7 +272,7 @@ static int ilo_ccb_setup(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
 		return -ENOMEM;
 
 	dma_va = (char *)data->dma_va;
-	dma_pa = (char *)data->dma_pa;
+	dma_pa = (char *)(&data->dma_pa);
 
 	memset(dma_va, 0, data->dma_size);

Seems very wrong - writes to *dmp_pa will now scribble over the `struct ccb_data'.

Probably local variable dma_pa should have type dma_addr_t.

#2 lore raw
Quoted 22 lines · Andrew Morton
Quoted 18 lines · On Fri, 21 May 2010 20:50:41 -0400 Prarit Bhargava<[email protected]> wrote:

Fixes warning:

drivers/misc/hpilo.c: In function ___ilo_ccb_setup___:
drivers/misc/hpilo.c:274: warning: cast to pointer from integer of different size

drivers/misc/hpilo.c +1 -1
index 98ad012..b07a541 100644
@@ -272,7 +272,7 @@ static int ilo_ccb_setup(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
  		return -ENOMEM;
 
  	dma_va = (char *)data->dma_va;
-	dma_pa = (char *)data->dma_pa;
+	dma_pa = (char *)(&data->dma_pa);
 
Quoted 7 lines

drivers/misc/hpilo.c static int ilo_ccb_setup(struct ilo_hwinfo *hw, struct ccb_data *data, int slot) · line 278

Quoted 2 lines
drivers/misc/hpilo.c +0 -0
  	memset(dma_va, 0, data->dma_size);
 

Seems very wrong - writes to *dmp_pa will now scribble over the `struct ccb_data'.

Probably local variable dma_pa should have type dma_addr_t.

Ugh ... I even passed this by a colleague at HP :/. I'll fix it up and repost.

P.

#3 lore raw

I guess it would have helped if I asked David what the code did, first. ":|

-----Original Message-----
From: Prarit Bhargava [mailto:[email protected]]
Sent: Tuesday, May 25, 2010 6:10 PM
To: Andrew Morton
Cc: [email protected]; [email protected]; Altobelli, David; Camuso, Tony
Subject: Re: [PATCH]: hpilo: fix pointer warning in ilo_ccb_setup

Quoted 22 lines · Andrew Morton
Quoted 18 lines · On Fri, 21 May 2010 20:50:41 -0400 Prarit Bhargava<[email protected]> wrote:

Fixes warning:

drivers/misc/hpilo.c: In function ___ilo_ccb_setup___:
drivers/misc/hpilo.c:274: warning: cast to pointer from integer of different size

drivers/misc/hpilo.c +1 -1
index 98ad012..b07a541 100644
@@ -272,7 +272,7 @@ static int ilo_ccb_setup(struct ilo_hwinfo *hw, struct ccb_data *data, int slot)
  		return -ENOMEM;
 
  	dma_va = (char *)data->dma_va;
-	dma_pa = (char *)data->dma_pa;
+	dma_pa = (char *)(&data->dma_pa);
 
Quoted 7 lines

drivers/misc/hpilo.c static int ilo_ccb_setup(struct ilo_hwinfo *hw, struct ccb_data *data, int slot) · line 278

Quoted 2 lines
drivers/misc/hpilo.c +0 -0
  	memset(dma_va, 0, data->dma_size);
 

Seems very wrong - writes to *dmp_pa will now scribble over the `struct ccb_data'.

Probably local variable dma_pa should have type dma_addr_t.

Ugh ... I even passed this by a colleague at HP :/. I'll fix it up and repost.

P.

#4 lore raw
In reply to Andrew Morton
Quoted 2 lines

Seems very wrong - writes to *dmp_pa will now scribble over the `struct ccb_data'.

Yeah. The dma_pa variable is used to track the physical address of the DMA memory, and it is written to the device. We don't want a kernel pointer, we want the actual physical addr, plus the various offsets.

Quoted 1 line

Probably local variable dma_pa should have type dma_addr_t.

I feel like I tried that, and I had trouble setting or using the send_fifobar/recv_fifobar variables. But I probably didn't try too hard.