linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: hid-sensor-hub: Fix sparse warning
@ 2015-02-26 19:04 Srinivas Pandruvada
  2015-03-16 15:28 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Srinivas Pandruvada @ 2015-02-26 19:04 UTC (permalink / raw)
  To: jkosina, fengguang.wu; +Cc: kbuild-all, linux-input, Srinivas Pandruvada

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-16 15:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-26 19:04 [PATCH] HID: hid-sensor-hub: Fix sparse warning Srinivas Pandruvada
2015-03-16 15:28 ` Jiri Kosina

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).