netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Whitten <ben.whitten@gmail.com>
To: afaerber@suse.de
Cc: starnight@g.ncu.edu.tw, hasnain.virk@arm.com,
	netdev@vger.kernel.org, liuxuenetmail@gmail.com,
	shess@hessware.de, Ben Whitten <ben.whitten@lairdtech.com>
Subject: [PATCH lora-next v2 5/8] net: lora: sx1301: remove duplicate firmware size checks
Date: Thu,  9 Aug 2018 13:33:35 +0100	[thread overview]
Message-ID: <1533818018-29005-5-git-send-email-ben.whitten@lairdtech.com> (raw)
In-Reply-To: <1533818018-29005-1-git-send-email-ben.whitten@lairdtech.com>

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) {
+		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)
-- 
2.7.4

  parent reply	other threads:[~2018-08-09 14:59 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-09 12:33 [PATCH lora-next v2 1/8] net: lora: add methods for devm registration Ben Whitten
2018-08-09 12:33 ` [PATCH lora-next v2 2/8] net: lora: sx1301: convert to devm registration of netdev Ben Whitten
2018-08-09 19:27   ` Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 3/8] net: lora: sx1301: convert to passing priv data throughout Ben Whitten
2018-08-09 20:43   ` Andreas Färber
2018-08-09 21:06     ` Ben Whitten
2018-08-09 21:21       ` Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 4/8] net: lora: sx1301: convert load_firmware to take firmware directly Ben Whitten
2018-08-09 20:48   ` Andreas Färber
2018-08-09 12:33 ` Ben Whitten [this message]
2018-08-09 20:58   ` [PATCH lora-next v2 5/8] net: lora: sx1301: remove duplicate firmware size checks Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 6/8] net: lora: sx1301: replace version and size magic numbers with defines Ben Whitten
2018-08-09 21:11   ` Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 7/8] net: lora: sx1301: add initial registration for regmap Ben Whitten
2018-08-09 21:58   ` Andreas Färber
2018-08-09 12:33 ` [PATCH lora-next v2 8/8] net: lora: sx1301: convert driver over to regmap reads and writes Ben Whitten
2018-08-09 22:34   ` Andreas Färber
2018-08-09 22:47     ` Ben Whitten
2018-08-10  0:17       ` Andreas Färber
2018-08-09 19:18 ` [PATCH lora-next v2 1/8] net: lora: add methods for devm registration Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1533818018-29005-5-git-send-email-ben.whitten@lairdtech.com \
    --to=ben.whitten@gmail.com \
    --cc=afaerber@suse.de \
    --cc=ben.whitten@lairdtech.com \
    --cc=hasnain.virk@arm.com \
    --cc=liuxuenetmail@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=shess@hessware.de \
    --cc=starnight@g.ncu.edu.tw \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).