Re: [PATCH 25/28] staging: wilc1000: change cast type from pointer to uintptr_t

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Greg,

I'm scheduled to send new patch not using casting between a pointer and integer type.

Rewriting the driver to change how to communicate with the firmware has been already started for the second patch but it takes more days.

Thanks for your advice,

Tony.


On 2015년 08월 01일 05:50, Greg KH wrote:
On Fri, Jul 31, 2015 at 04:38:33PM +0900, Tony Cho wrote:
From: glen lee <glen.lee@xxxxxxxxx>

To use drvHandler as integer operation, cast type to uintptr_t.

Here is the build warning.
drivers/staging/wilc1000/wilc_wlan.c:1871:23: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
   int driver_handler = (u32)drvHandler;

Signed-off-by: glen lee <glen.lee@xxxxxxxxx>
Signed-off-by: Tony Cho <tony.cho@xxxxxxxxx>
---
  drivers/staging/wilc1000/linux_wlan.c | 2 +-
  drivers/staging/wilc1000/wilc_wlan.c  | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index ec80849..14c2071 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -1056,7 +1056,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
  		goto _fail_;
  	}
- *(int *)c_val = (u32)pstrWFIDrv;
+	*(int *)c_val = (uintptr_t)pstrWFIDrv;
Why is the cast needed at all?

if (!g_linux_wlan->oup.wlan_cfg_set(1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
  		goto _fail_;
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
index f5075b26..2cc23d5 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1868,7 +1868,7 @@ static int wilc_wlan_cfg_commit(int type, WILC_WFIDrvHandle drvHandler)
  	wilc_cfg_frame_t *cfg = &p->cfg_frame;
  	int total_len = p->cfg_frame_offset + 4 + DRIVER_HANDLER_SIZE;
  	int seq_no = p->cfg_seq_no % 256;
-	int driver_handler = (u32)drvHandler;
+	int driver_handler = (uintptr_t)drvHandler;
You can't cast a pointer to an integer, it does not work on all systems,
which is what the compiler warnings is telling you.

If this really is a pointer, use a pointer, otherwise, use an integer,
but don't cast between the two.

thanks,

greg k-h

--
Cho, Tony
Manager, Staff Engineer | Connectivity System Software Team | Atmel Korea (Wireless solutions BU)
#409, Kins Tower, Jeongja-Dong, Bundang-Gu, Seongnam-Si, Gyeonggi-Do, 463-782, Korea
Phone:82 31 784 8400(Ext. 317); Mobile: 82 10 7232 1523
email: tony.cho@xxxxxxxxx

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux