[PATCH 1/3] Bluetooth: btrtl: Let rtl_load_file() always return error code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The return value of rtl_load_file() can be either firmware length or
error code.

For consistency, always return error code and pass firmware length via
another pointer.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@xxxxxxxxxxxxx>
---
 drivers/bluetooth/btrtl.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 41405de27d66..a134a79bf0ef 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -413,7 +413,8 @@ static int rtl_download_firmware(struct hci_dev *hdev,
 	return ret;
 }
 
-static int rtl_load_file(struct hci_dev *hdev, const char *name, u8 **buff)
+static int rtl_load_file(struct hci_dev *hdev, const char *name,
+			 u8 **buff, int *fw_size)
 {
 	const struct firmware *fw;
 	int ret;
@@ -422,8 +423,8 @@ static int rtl_load_file(struct hci_dev *hdev, const char *name, u8 **buff)
 	ret = request_firmware(&fw, name, &hdev->dev);
 	if (ret < 0)
 		return ret;
-	ret = fw->size;
-	*buff = kmemdup(fw->data, ret, GFP_KERNEL);
+	*fw_size = fw->size;
+	*buff = kmemdup(fw->data, fw->size, GFP_KERNEL);
 	if (!*buff)
 		ret = -ENOMEM;
 
@@ -564,12 +565,11 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
 			goto err_free;
 	}
 
-	btrtl_dev->fw_len = rtl_load_file(hdev, btrtl_dev->ic_info->fw_name,
-					  &btrtl_dev->fw_data);
-	if (btrtl_dev->fw_len < 0) {
+	ret = rtl_load_file(hdev, btrtl_dev->ic_info->fw_name,
+			    &btrtl_dev->fw_data, &btrtl_dev->fw_len);
+	if (ret || !btrtl_dev->fw_len) {
 		rtl_dev_err(hdev, "firmware file %s not found\n",
 			    btrtl_dev->ic_info->fw_name);
-		ret = btrtl_dev->fw_len;
 		goto err_free;
 	}
 
@@ -581,13 +581,12 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
 			snprintf(cfg_name, sizeof(cfg_name), "%s.bin",
 				 btrtl_dev->ic_info->cfg_name);
 		}
-		btrtl_dev->cfg_len = rtl_load_file(hdev, cfg_name,
-						   &btrtl_dev->cfg_data);
+		ret = rtl_load_file(hdev, cfg_name, &btrtl_dev->cfg_data,
+				    &btrtl_dev->cfg_len);
 		if (btrtl_dev->ic_info->config_needed &&
-		    btrtl_dev->cfg_len <= 0) {
+		    (ret || !btrtl_dev->cfg_len)) {
 			rtl_dev_err(hdev, "mandatory config file %s not found\n",
 				    btrtl_dev->ic_info->cfg_name);
-			ret = btrtl_dev->cfg_len;
 			goto err_free;
 		}
 	}
-- 
2.17.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux