[OPW,kernel,v2,2/2] Staging: btmtk_usb: Fix Sparse Warning of incorrect type in assignment
diff mbox

Message ID b2ab9deecfef3819d880c6aac08ff246d2e12594.1381847193.git.rashika.kheria@gmail.com
State Changes Requested
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:676:39: warning: incorrect type in assignment (different base types)
drivers/staging/btmtk_usb/btmtk_usb.c:676:39:    expected unsigned int [unsigned] [usertype] packet_header
drivers/staging/btmtk_usb/btmtk_usb.c:676:39:    got restricted __le32 [usertype] <noident>

drivers/staging/btmtk_usb/btmtk_usb.c:736:31: warning: incorrect type in assignment (different base types)
drivers/staging/btmtk_usb/btmtk_usb.c:736:31:    expected unsigned int [unsigned] [addressable] [usertype] packet_header
drivers/staging/btmtk_usb/btmtk_usb.c:736:31:    got restricted __le32 [usertype] <noident>

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

This revision fixes the following issues of the previous revision-
Incorrect correction in fixing the warning

 drivers/staging/btmtk_usb/btmtk_usb.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Greg Kroah-Hartman Oct. 15, 2013, 3:40 p.m. UTC | #1
On Tue, Oct 15, 2013 at 08:07:51PM +0530, Rashika Kheria wrote:
> This patch fixes the following Sparse Warnings in btmtk_usb.c:
> 
> drivers/staging/btmtk_usb/btmtk_usb.c:676:39: warning: incorrect type in assignment (different base types)
> drivers/staging/btmtk_usb/btmtk_usb.c:676:39:    expected unsigned int [unsigned] [usertype] packet_header
> drivers/staging/btmtk_usb/btmtk_usb.c:676:39:    got restricted __le32 [usertype] <noident>
> 
> drivers/staging/btmtk_usb/btmtk_usb.c:736:31: warning: incorrect type in assignment (different base types)
> drivers/staging/btmtk_usb/btmtk_usb.c:736:31:    expected unsigned int [unsigned] [addressable] [usertype] packet_header
> drivers/staging/btmtk_usb/btmtk_usb.c:736:31:    got restricted __le32 [usertype] <noident>
> 
> Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
> ---
> 
> This revision fixes the following issues of the previous revision-
> Incorrect correction in fixing the warning
> 
>  drivers/staging/btmtk_usb/btmtk_usb.c |   15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/btmtk_usb/btmtk_usb.c b/drivers/staging/btmtk_usb/btmtk_usb.c
> index cb315b5..813a770 100644
> --- a/drivers/staging/btmtk_usb/btmtk_usb.c
> +++ b/drivers/staging/btmtk_usb/btmtk_usb.c
> @@ -565,7 +565,8 @@ static int btmtk_usb_load_fw(struct btmtk_usb_data *data)
>  	struct urb *urb;
>  	void *buf;
>  	u32 cur_len = 0;
> -	u32 packet_header = 0;
> +	__le32 packet_header = 0;
> +	u32 packet_header_int = le32_to_cpu(packet_header);

Why use "_int" as a suffix for the variable?  That implies it is an
integer, which isn't true.  I'm guessing you mean "internal"?  How about
a different name?

thanks,

greg k-h
Rashika Oct. 15, 2013, 3:49 p.m. UTC | #2
On Tue, Oct 15, 2013 at 9:10 PM, Greg KH <gregkh@linuxfoundation.org> wrote:

> On Tue, Oct 15, 2013 at 08:07:51PM +0530, Rashika Kheria wrote:
> > This patch fixes the following Sparse Warnings in btmtk_usb.c:
> >
> > drivers/staging/btmtk_usb/btmtk_usb.c:676:39: warning: incorrect type in
> assignment (different base types)
> > drivers/staging/btmtk_usb/btmtk_usb.c:676:39:    expected unsigned int
> [unsigned] [usertype] packet_header
> > drivers/staging/btmtk_usb/btmtk_usb.c:676:39:    got restricted __le32
> [usertype] <noident>
> >
> > drivers/staging/btmtk_usb/btmtk_usb.c:736:31: warning: incorrect type in
> assignment (different base types)
> > drivers/staging/btmtk_usb/btmtk_usb.c:736:31:    expected unsigned int
> [unsigned] [addressable] [usertype] packet_header
> > drivers/staging/btmtk_usb/btmtk_usb.c:736:31:    got restricted __le32
> [usertype] <noident>
> >
> > Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
> > ---
> >
> > This revision fixes the following issues of the previous revision-
> > Incorrect correction in fixing the warning
> >
> >  drivers/staging/btmtk_usb/btmtk_usb.c |   15 ++++++++-------
> >  1 file changed, 8 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/staging/btmtk_usb/btmtk_usb.c
> b/drivers/staging/btmtk_usb/btmtk_usb.c
> > index cb315b5..813a770 100644
> > --- a/drivers/staging/btmtk_usb/btmtk_usb.c
> > +++ b/drivers/staging/btmtk_usb/btmtk_usb.c
> > @@ -565,7 +565,8 @@ static int btmtk_usb_load_fw(struct btmtk_usb_data
> *data)
> >       struct urb *urb;
> >       void *buf;
> >       u32 cur_len = 0;
> > -     u32 packet_header = 0;
> > +     __le32 packet_header = 0;
> > +     u32 packet_header_int = le32_to_cpu(packet_header);
>
> Why use "_int" as a suffix for the variable?  That implies it is an
> integer, which isn't true.  I'm guessing you mean "internal"?  How about
> a different name?
>
> thanks,
>
> greg k-h
>
>
> I will change the name and resend the patch.


Thanks,

Patch
diff mbox

diff --git a/drivers/staging/btmtk_usb/btmtk_usb.c b/drivers/staging/btmtk_usb/btmtk_usb.c
index cb315b5..813a770 100644
--- a/drivers/staging/btmtk_usb/btmtk_usb.c
+++ b/drivers/staging/btmtk_usb/btmtk_usb.c
@@ -565,7 +565,8 @@  static int btmtk_usb_load_fw(struct btmtk_usb_data *data)
 	struct urb *urb;
 	void *buf;
 	u32 cur_len = 0;
-	u32 packet_header = 0;
+	__le32 packet_header = 0;
+	u32 packet_header_int = le32_to_cpu(packet_header);
 	u32 value;
 	u32 ilm_len = 0, dlm_len = 0;
 	u16 fw_ver, build_ver;
@@ -677,9 +678,9 @@  loadfw_protect:
 		sent_len = min_t(s32, (ilm_len - cur_len), 14336);
 
 		if (sent_len > 0) {
-			packet_header &= ~(0xffffffff);
-			packet_header |= (sent_len << 16);
-			packet_header = cpu_to_le32(packet_header);
+			packet_header_int &= ~(0xffffffff);
+			packet_header_int |= (sent_len << 16);
+			packet_header = cpu_to_le32(packet_header_int);
 
 			memmove(buf, &packet_header, 4);
 			memmove(buf + 4, data->firmware->data + 32 + cur_len,
@@ -737,9 +738,9 @@  loadfw_protect:
 		if (sent_len <= 0)
 			break;
 
-		packet_header &= ~(0xffffffff);
-		packet_header |= (sent_len << 16);
-		packet_header = cpu_to_le32(packet_header);
+		packet_header_int &= ~(0xffffffff);
+		packet_header_int |= (sent_len << 16);
+		packet_header = cpu_to_le32(packet_header_int);
 
 		memmove(buf, &packet_header, 4);
 		memmove(buf + 4,