mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH v3 1/5] net/e1000: remove one level of indentation
Date: Fri, 26 Jan 2018 14:32:28 +0100	[thread overview]
Message-ID: <20180126133232.4992-1-l.stach@pengutronix.de> (raw)

By returning early if the MAC type isn't e1000_igb.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/net/e1000/eeprom.c | 121 +++++++++++++++++++++++----------------------
 1 file changed, 61 insertions(+), 60 deletions(-)

diff --git a/drivers/net/e1000/eeprom.c b/drivers/net/e1000/eeprom.c
index 748d8afe7922..ddac7de8a0e9 100644
--- a/drivers/net/e1000/eeprom.c
+++ b/drivers/net/e1000/eeprom.c
@@ -1551,79 +1551,80 @@ int e1000_eeprom_valid(struct e1000_hw *hw)
  */
 int e1000_register_eeprom(struct e1000_hw *hw)
 {
-	int ret = E1000_SUCCESS;
-
 	struct e1000_eeprom_info *eeprom = &hw->eeprom;
+	uint32_t eecd;
+	int ret;
 
-	if (hw->mac_type == e1000_igb) {
-		uint32_t eecd = e1000_read_reg(hw, E1000_EECD);
+	if (hw->mac_type != e1000_igb)
+		return E1000_SUCCESS;
 
-		hw->eepromcdev.dev = hw->dev;
-		hw->eepromcdev.ops = &e1000_eeprom_ops;
-		hw->eepromcdev.name = xasprintf("e1000-eeprom%d", hw->dev->id);
-		hw->eepromcdev.size = 0x1000;
+	eecd = e1000_read_reg(hw, E1000_EECD);
 
-		ret = devfs_create(&hw->eepromcdev);
-		if (ret < 0)
-			return ret;
+	hw->eepromcdev.dev = hw->dev;
+	hw->eepromcdev.ops = &e1000_eeprom_ops;
+	hw->eepromcdev.name = xasprintf("e1000-eeprom%d", hw->dev->id);
+	hw->eepromcdev.size = 0x1000;
+
+	ret = devfs_create(&hw->eepromcdev);
+	if (ret < 0)
+		return ret;
 
-		if (eecd & E1000_EECD_AUTO_RD) {
-			if (eecd & E1000_EECD_EE_PRES) {
-				if (eecd & E1000_EECD_FLASH_IN_USE) {
-					uint32_t fla = e1000_read_reg(hw, E1000_FLA);
-					dev_info(hw->dev,
-						 "Hardware programmed from flash (%ssecure)\n",
-						 fla & E1000_FLA_LOCKED ? "" : "un");
-				} else {
-					dev_info(hw->dev, "Hardware programmed from iNVM\n");
-				}
+	if (eecd & E1000_EECD_AUTO_RD) {
+		if (eecd & E1000_EECD_EE_PRES) {
+			if (eecd & E1000_EECD_FLASH_IN_USE) {
+				uint32_t fla = e1000_read_reg(hw, E1000_FLA);
+				dev_info(hw->dev,
+					 "Hardware programmed from flash (%ssecure)\n",
+					 fla & E1000_FLA_LOCKED ? "" : "un");
 			} else {
-				dev_warn(hw->dev, "Shadow RAM invalid\n");
+				dev_info(hw->dev, "Hardware programmed from iNVM\n");
 			}
 		} else {
-			/*
-			 * I never saw this case in practise and I'm unsure how
-			 * to handle that. Maybe just wait until the hardware is
-			 * up enough that this bit is set?
-			 */
-			dev_err(hw->dev, "Flash Auto-Read not done\n");
-		}
-
-		if (eecd & E1000_EECD_I210_FLASH_DETECTED) {
-			hw->mtd.parent = hw->dev;
-			hw->mtd.read = e1000_mtd_read;
-			hw->mtd.write = e1000_mtd_write;
-			hw->mtd.erase = e1000_mtd_erase;
-			hw->mtd.lock = e1000_mtd_lock;
-			hw->mtd.unlock = e1000_mtd_unlock;
-			hw->mtd.size = eeprom->word_size * 2;
-			hw->mtd.writesize = 1;
-			hw->mtd.subpage_sft = 0;
-
-			hw->mtd.eraseregions = xzalloc(sizeof(struct mtd_erase_region_info));
-			hw->mtd.erasesize = SZ_4K;
-			hw->mtd.eraseregions[0].erasesize = SZ_4K;
-			hw->mtd.eraseregions[0].numblocks = hw->mtd.size / SZ_4K;
-			hw->mtd.numeraseregions = 1;
-
-			hw->mtd.flags = MTD_CAP_NORFLASH;
-			hw->mtd.type = MTD_NORFLASH;
-
-			ret = add_mtd_device(&hw->mtd, "e1000-nor",
-					     DEVICE_ID_DYNAMIC);
-			if (ret) {
-				devfs_remove(&hw->eepromcdev);
-				return ret;
-			}
+			dev_warn(hw->dev, "Shadow RAM invalid\n");
 		}
+	} else {
+		/*
+		 * I never saw this case in practise and I'm unsure how
+		 * to handle that. Maybe just wait until the hardware is
+		 * up enough that this bit is set?
+		 */
+		dev_err(hw->dev, "Flash Auto-Read not done\n");
+	}
 
-		ret = e1000_register_invm(hw);
-		if (ret < 0) {
-			if (eecd & E1000_EECD_I210_FLASH_DETECTED)
-				del_mtd_device(&hw->mtd);
+	if (eecd & E1000_EECD_I210_FLASH_DETECTED) {
+		hw->mtd.parent = hw->dev;
+		hw->mtd.read = e1000_mtd_read;
+		hw->mtd.write = e1000_mtd_write;
+		hw->mtd.erase = e1000_mtd_erase;
+		hw->mtd.lock = e1000_mtd_lock;
+		hw->mtd.unlock = e1000_mtd_unlock;
+		hw->mtd.size = eeprom->word_size * 2;
+		hw->mtd.writesize = 1;
+		hw->mtd.subpage_sft = 0;
+
+		hw->mtd.eraseregions = xzalloc(sizeof(struct mtd_erase_region_info));
+		hw->mtd.erasesize = SZ_4K;
+		hw->mtd.eraseregions[0].erasesize = SZ_4K;
+		hw->mtd.eraseregions[0].numblocks = hw->mtd.size / SZ_4K;
+		hw->mtd.numeraseregions = 1;
+
+		hw->mtd.flags = MTD_CAP_NORFLASH;
+		hw->mtd.type = MTD_NORFLASH;
+
+		ret = add_mtd_device(&hw->mtd, "e1000-nor",
+				     DEVICE_ID_DYNAMIC);
+		if (ret) {
 			devfs_remove(&hw->eepromcdev);
+			return ret;
 		}
 	}
 
+	ret = e1000_register_invm(hw);
+	if (ret < 0) {
+		if (eecd & E1000_EECD_I210_FLASH_DETECTED)
+			del_mtd_device(&hw->mtd);
+		devfs_remove(&hw->eepromcdev);
+	}
+
 	return ret;
 }
-- 
2.15.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2018-01-26 13:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26 13:32 Lucas Stach [this message]
2018-01-26 13:32 ` [PATCH v3 2/5] net/e1000: use correct bit for flash detection Lucas Stach
2018-01-26 13:32 ` [PATCH v3 3/5] net/e1000: EEPROM isn't valid if only iNVM is available Lucas Stach
2018-01-26 13:32 ` [PATCH v3 4/5] net/e1000: don't check EEPROM signature if populated from iNVM Lucas Stach
2018-01-26 13:32 ` [PATCH v3 5/5] net/e1000: don't register EERPOM device if the content is invalid Lucas Stach
2018-01-30  6:54 ` [PATCH v3 1/5] net/e1000: remove one level of indentation Sascha Hauer

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=20180126133232.4992-1-l.stach@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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