Skip to contentSkip to conversation

drivers:bluetooth:ath3k.c: Fixed sparse warning for cast to restricted __le32

PATCH In review Surendra Patil 3 participants 4 messages Mar 25, 2014 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers:bluetooth:ath3k.c: Fixed sparse warning for cast to restricted __le32

This patch fixes below Sparse warnings - drivers/bluetooth/ath3k.c:370:17: warning: cast to restricted __le32 drivers/bluetooth/ath3k.c:432:17: warning: cast to restricted __le32

---
 drivers/bluetooth/ath3k.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bluetooth/ath3k.c +2 -2
index be571fe..badacbc 100644
@@ -367,7 +367,7 @@ static int ath3k_load_patch(struct usb_device *udev)
 	}
 
 	snprintf(filename, ATH3K_NAME_LEN, "ar3k/AthrBT_0x%08x.dfu",
-		le32_to_cpu(fw_version.rom_version));
+		fw_version.rom_version);
 
 	ret = request_firmware(&firmware, filename, &udev->dev);
 	if (ret < 0) {
@@ -429,7 +429,7 @@ static int ath3k_load_syscfg(struct usb_device *udev)
 	}
 
 	snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
-		le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
+		 fw_version.rom_version, clk_value, ".dfu");
 
 	ret = request_firmware(&firmware, filename, &udev->dev);
 	if (ret < 0) {
Signature · 1 line
1.8.3.2
#1 lore raw
Quoted 3 lines · Surendra Patil

This patch fixes below Sparse warnings - drivers/bluetooth/ath3k.c:370:17: warning: cast to restricted __le32 drivers/bluetooth/ath3k.c:432:17: warning: cast to restricted __le32

You are changing output here.

I suspect rom_version should be marked __le32 instead of unsigned int in "struct ath3k_version" instead.

Quoted 27 lines
---
 drivers/bluetooth/ath3k.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bluetooth/ath3k.c +2 -2
index be571fe..badacbc 100644
@@ -367,7 +367,7 @@ static int ath3k_load_patch(struct usb_device *udev)
 	}
 
 	snprintf(filename, ATH3K_NAME_LEN, "ar3k/AthrBT_0x%08x.dfu",
-		le32_to_cpu(fw_version.rom_version));
+		fw_version.rom_version);
 
 	ret = request_firmware(&firmware, filename, &udev->dev);
 	if (ret < 0) {
@@ -429,7 +429,7 @@ static int ath3k_load_syscfg(struct usb_device *udev)
 	}
 
 	snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
-		le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
+		 fw_version.rom_version, clk_value, ".dfu");
 
 	ret = request_firmware(&firmware, filename, &udev->dev);
 	if (ret < 0) {
#2 lore raw
In reply to Surendra Patil

Hi,

Quoted 23 lines · Surendra Patil

This patch fixes below Sparse warnings - drivers/bluetooth/ath3k.c:370:17: warning: cast to restricted __le32 drivers/bluetooth/ath3k.c:432:17: warning: cast to restricted __le32

---
 drivers/bluetooth/ath3k.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bluetooth/ath3k.c +1 -1
index be571fe..badacbc 100644
@@ -367,7 +367,7 @@ static int ath3k_load_patch(struct usb_device *udev)
 	}
 
 	snprintf(filename, ATH3K_NAME_LEN, "ar3k/AthrBT_0x%08x.dfu",
-		le32_to_cpu(fw_version.rom_version));
+		fw_version.rom_version);
 
 	ret = request_firmware(&firmware, filename, &udev->dev);
 	if (ret < 0) {

drivers/bluetooth/ath3k.c static int ath3k_load_syscfg(struct usb_device *udev) · line 435

Quoted 8 lines
drivers/bluetooth/ath3k.c +1 -1
@@ -429,7 +429,7 @@ static int ath3k_load_syscfg(struct usb_device *udev)
 	}
 
 	snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
-		le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
+		 fw_version.rom_version, clk_value, ".dfu");
 
 	ret = request_firmware(&firmware, filename, &udev->dev);
 	if (ret < 0) {

Are you sure this doesn't introduce a bug on big endian systems? We just recently applied commit b9e2535acad8f52a17e2aa843d45a6b756b59592 which adds this le32_to_cpu conversion. Probably the correct fix is to update this fw_version struct definition to use __le32 for any member that's expected to be in little endian format?

Johan

#3 lore raw

thanks for reviews.
will work on it .

Quoted 43 lines · Johan Hedberg

Hi,

Quoted 23 lines · Surendra Patil

This patch fixes below Sparse warnings - drivers/bluetooth/ath3k.c:370:17: warning: cast to restricted __le32 drivers/bluetooth/ath3k.c:432:17: warning: cast to restricted __le32

---
 drivers/bluetooth/ath3k.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/bluetooth/ath3k.c +1 -1
index be571fe..badacbc 100644
@@ -367,7 +367,7 @@ static int ath3k_load_patch(struct usb_device *udev)
      }
 
      snprintf(filename, ATH3K_NAME_LEN, "ar3k/AthrBT_0x%08x.dfu",
-             le32_to_cpu(fw_version.rom_version));
+             fw_version.rom_version);
 
      ret = request_firmware(&firmware, filename, &udev->dev);
      if (ret < 0) {

drivers/bluetooth/ath3k.c static int ath3k_load_syscfg(struct usb_device *udev) · line 435

Quoted 8 lines
drivers/bluetooth/ath3k.c +1 -1
@@ -429,7 +429,7 @@ static int ath3k_load_syscfg(struct usb_device *udev)
      }
 
      snprintf(filename, ATH3K_NAME_LEN, "ar3k/ramps_0x%08x_%d%s",
-             le32_to_cpu(fw_version.rom_version), clk_value, ".dfu");
+              fw_version.rom_version, clk_value, ".dfu");
 
      ret = request_firmware(&firmware, filename, &udev->dev);
      if (ret < 0) {

Are you sure this doesn't introduce a bug on big endian systems? We just recently applied commit b9e2535acad8f52a17e2aa843d45a6b756b59592 which adds this le32_to_cpu conversion. Probably the correct fix is to update this fw_version struct definition to use __le32 for any member that's expected to be in little endian format?

Johan

Signature · 2 lines
Best,
Surendra Patil