diff mbox series

[lora-next,v2,5/8] net: lora: sx1301: remove duplicate firmware size checks

Message ID 1533818018-29005-5-git-send-email-ben.whitten@lairdtech.com
State Not Applicable, archived
Delegated to: David Miller
Headers show
Series [lora-next,v2,1/8] net: lora: add methods for devm registration | expand

Commit Message

Ben Whitten Aug. 9, 2018, 12:33 p.m. UTC
No need to check the size of the firmware multiple times, just do it once
in the function responsible for loading as the firmwares are the same size.

Signed-off-by: Ben Whitten <ben.whitten@lairdtech.com>
---
 drivers/net/lora/sx1301.c | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

Comments

Andreas Färber Aug. 9, 2018, 8:58 p.m. UTC | #1
Am 09.08.2018 um 14:33 schrieb Ben Whitten:
> No need to check the size of the firmware multiple times, just do it once
> in the function responsible for loading as the firmwares are the same size.
> 
> Signed-off-by: Ben Whitten <ben.whitten@lairdtech.com>
> ---
>  drivers/net/lora/sx1301.c | 21 +++------------------
>  1 file changed, 3 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/lora/sx1301.c b/drivers/net/lora/sx1301.c
> index 3f2a532..916ee40 100644
> --- a/drivers/net/lora/sx1301.c
> +++ b/drivers/net/lora/sx1301.c
> @@ -293,8 +293,10 @@ static int sx1301_load_firmware(struct sx1301_priv *priv, int mcu, const struct
>  	u8 val, rst, select_mux;
>  	int ret;
>  
> -	if (fw->size > 8192)
> +	if (fw->size != 8192) {

Note the original intention here was to allow loading firmware smaller
than the maximum size, but we can revisit that later if we ever have
such a firmware.

Applied.

Thanks,
Andreas
diff mbox series

Patch

diff --git a/drivers/net/lora/sx1301.c b/drivers/net/lora/sx1301.c
index 3f2a532..916ee40 100644
--- a/drivers/net/lora/sx1301.c
+++ b/drivers/net/lora/sx1301.c
@@ -293,8 +293,10 @@  static int sx1301_load_firmware(struct sx1301_priv *priv, int mcu, const struct
 	u8 val, rst, select_mux;
 	int ret;
 
-	if (fw->size > 8192)
+	if (fw->size != 8192) {
+		dev_err(priv->dev, "Unexpected firmware size\n");
 		return -EINVAL;
+	}
 
 	switch (mcu) {
 	case 0:
@@ -390,11 +392,6 @@  static int sx1301_agc_calibrate(struct sx1301_priv *priv)
 		return ret;
 	}
 
-	if (fw->size != 8192) {
-		dev_err(priv->dev, "unexpected agc cal firmware size\n");
-		return -EINVAL;
-	}
-
 	ret = sx1301_load_firmware(priv, 1, fw);
 	release_firmware(fw);
 	if (ret) {
@@ -517,12 +514,6 @@  static int sx1301_load_all_firmware(struct sx1301_priv *priv)
 		return ret;
 	}
 
-	if (fw->size != 8192) {
-		dev_err(priv->dev, "unexpected arb firmware size\n");
-		release_firmware(fw);
-		return -EINVAL;
-	}
-
 	ret = sx1301_load_firmware(priv, 0, fw);
 	release_firmware(fw);
 	if (ret)
@@ -534,12 +525,6 @@  static int sx1301_load_all_firmware(struct sx1301_priv *priv)
 		return ret;
 	}
 
-	if (fw->size != 8192) {
-		dev_err(priv->dev, "unexpected agc firmware size\n");
-		release_firmware(fw);
-		return -EINVAL;
-	}
-
 	ret = sx1301_load_firmware(priv, 1, fw);
 	release_firmware(fw);
 	if (ret)