linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Bluetooth: btrtl: Let rtl_load_file() always return error code
@ 2019-01-24 15:23 Kai-Heng Feng
  2019-01-24 15:23 ` [PATCH 2/3] Bluetooth: btrtl: Let btrtl_initialize() " Kai-Heng Feng
  2019-01-24 15:23 ` [PATCH 3/3] Bluetooth: btrtl: Skip initialization if firmware is already loaded Kai-Heng Feng
  0 siblings, 2 replies; 5+ messages in thread
From: Kai-Heng Feng @ 2019-01-24 15:23 UTC (permalink / raw)
  To: marcel, johan.hedberg; +Cc: drake, linux-bluetooth, linux-kernel, Kai-Heng Feng

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@canonical.com>
---
 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


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

end of thread, other threads:[~2019-01-25 17:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-24 15:23 [PATCH 1/3] Bluetooth: btrtl: Let rtl_load_file() always return error code Kai-Heng Feng
2019-01-24 15:23 ` [PATCH 2/3] Bluetooth: btrtl: Let btrtl_initialize() " Kai-Heng Feng
2019-01-24 15:23 ` [PATCH 3/3] Bluetooth: btrtl: Skip initialization if firmware is already loaded Kai-Heng Feng
2019-01-25  0:55   ` Daniel Drake
2019-01-25 17:46     ` Kai-Heng Feng

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