linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: jkosina@suse.cz, fengguang.wu@intel.com
Cc: kbuild-all@01.org, linux-input@vger.kernel.org,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH] HID: hid-sensor-hub: Fix sparse warning
Date: Thu, 26 Feb 2015 11:04:44 -0800	[thread overview]
Message-ID: <1424977484-31296-1-git-send-email-srinivas.pandruvada@linux.intel.com> (raw)

Address issue reported by kbuild test robot <fengguang.wu@intel.com>

sparse warnings: (new ones prefixed by >>)

>> drivers/hid/hid-sensor-hub.c:223:39: sparse: incorrect type in argument 3 (different base types)
   drivers/hid/hid-sensor-hub.c:223:39:    expected signed int [signed] [usertype] [explicitly-signed] <noident>
   drivers/hid/hid-sensor-hub.c:223:39:    got restricted __le32 [usertype] <noident>
>> drivers/hid/hid-sensor-hub.c:231:31: sparse: incorrect type in argument 3 (different base types)
   drivers/hid/hid-sensor-hub.c:231:31:    expected signed int [signed] [usertype] [explicitly-signed] <noident>
   drivers/hid/hid-sensor-hub.c:231:31:    got restricted __le32 [usertype] <noident>

vim +223 drivers/hid/hid-sensor-hub.c

   217          }
   218
   219          remaining_bytes = do_div(buffer_size, sizeof(__s32));
   220          if (buffer_size) {
   221                  for (i = 0; i < buffer_size; ++i) {
   222                          hid_set_field(report->field[field_index], i,
 > 223                                        cpu_to_le32(*buf32));
   224                          ++buf32;
   225                  }
   226          }
   227          if (remaining_bytes) {
   228                  value = 0;
   229                  memcpy(&value, (u8 *)buf32, remaining_bytes);
   230                  hid_set_field(report->field[field_index], i,
 > 231                                cpu_to_le32(value));
   232          }
   233          hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT);
   234          hid_hw_wait(hsdev->hdev);

Since I can't change the type of hid_set_field argument 3, using __force __s32 to remove
this warning.

---

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 drivers/hid/hid-sensor-hub.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 5eb338d..75f7ca1 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -222,7 +222,7 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
 	if (buffer_size) {
 		for (i = 0; i < buffer_size; ++i) {
 			hid_set_field(report->field[field_index], i,
-				      cpu_to_le32(*buf32));
+				      (__force __s32)cpu_to_le32(*buf32));
 			++buf32;
 		}
 	}
@@ -230,7 +230,7 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
 		value = 0;
 		memcpy(&value, (u8 *)buf32, remaining_bytes);
 		hid_set_field(report->field[field_index], i,
-			      cpu_to_le32(value));
+			      (__force __s32)cpu_to_le32(value));
 	}
 	hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT);
 	hid_hw_wait(hsdev->hdev);
-- 
1.9.1


             reply	other threads:[~2015-02-26 19:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26 19:04 Srinivas Pandruvada [this message]
2015-03-16 15:28 ` [PATCH] HID: hid-sensor-hub: Fix sparse warning Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1424977484-31296-1-git-send-email-srinivas.pandruvada@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=fengguang.wu@intel.com \
    --cc=jkosina@suse.cz \
    --cc=kbuild-all@01.org \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).