[OPW,kernel,v2,1/2] Staging: btmtk_usb: Fix Sparse Warning of incorrect casting
diff mbox

Message ID 8df3c5309985b0bb83929e29eb4963e7991ea532.1381847193.git.rashika.kheria@gmail.com
State Accepted
Headers show

Commit Message

Rashika Oct. 15, 2013, 2:37 p.m. UTC
This patch fixes the following Sparse Warnings in btmtk_usb.c:

drivers/staging/btmtk_usb/btmtk_usb.c:110:16: warning: cast to restricted __le32
drivers/staging/btmtk_usb/btmtk_usb.c:299:23: warning: cast to restricted __le16

Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
---

This revision fixes the following issues from the previous revision-
Incorrect Casting correction

 drivers/staging/btmtk_usb/btmtk_usb.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Greg Kroah-Hartman Oct. 15, 2013, 3:41 p.m. UTC | #1
On Tue, Oct 15, 2013 at 08:07:00PM +0530, Rashika Kheria wrote:
> This patch fixes the following Sparse Warnings in btmtk_usb.c:
> 
> drivers/staging/btmtk_usb/btmtk_usb.c:110:16: warning: cast to restricted __le32
> drivers/staging/btmtk_usb/btmtk_usb.c:299:23: warning: cast to restricted __le16
> 
> Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>

Very nice job, now applied.

greg k-h

Patch
diff mbox

diff --git a/drivers/staging/btmtk_usb/btmtk_usb.c b/drivers/staging/btmtk_usb/btmtk_usb.c
index 1b0f993..cb315b5 100644
--- a/drivers/staging/btmtk_usb/btmtk_usb.c
+++ b/drivers/staging/btmtk_usb/btmtk_usb.c
@@ -93,6 +93,7 @@  static int btmtk_usb_io_read32(struct btmtk_usb_data *data, u32 reg, u32 *val)
 	u8 request = data->r_request;
 	struct usb_device *udev = data->udev;
 	int ret;
+	__le32 val_le;
 
 	ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), request,
 			DEVICE_VENDOR_REQUEST_IN, 0x0, reg, data->io_buf,
@@ -105,9 +106,9 @@  static int btmtk_usb_io_read32(struct btmtk_usb_data *data, u32 reg, u32 *val)
 		return ret;
 	}
 
-	memmove(val, data->io_buf, 4);
+	memmove(&val_le, data->io_buf, 4);
 
-	*val = le32_to_cpu(*val);
+	*val = le32_to_cpu(val_le);
 
 	if (ret > 0)
 		ret = 0;
@@ -280,6 +281,7 @@  static u16 btmtk_usb_get_crc(struct btmtk_usb_data *data)
 	int ret = 0;
 	struct usb_device *udev = data->udev;
 	u16 crc, count = 0;
+	__le16 crc_le;
 
 	BT_DBG("%s\n", __func__);
 
@@ -294,9 +296,9 @@  static u16 btmtk_usb_get_crc(struct btmtk_usb_data *data)
 			BT_ERR("%s error(%d)\n", __func__, ret);
 		}
 
-		memmove(&crc, data->io_buf, 2);
+		memmove(&crc_le, data->io_buf, 2);
 
-		crc = le16_to_cpu(crc);
+		crc = le16_to_cpu(crc_le);
 
 		if (crc != 0xFFFF)
 			break;