Skip to contentSkip to conversation

mtd: rawnand: mark expected switch fall-throughs

PATCH Superseded Gustavo A. R. Silva 2 participants 7 messages Jan 28, 2019 – Apr 12, 2019

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mtd: rawnand: mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

This patch fixes the following warning:

drivers/mtd/nand/onenand/onenand_base.c:3264:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/onenand/onenand_base.c:3288:17: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_base.c:5538:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_base.c:5557:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_base.c:5595:13: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_legacy.c:332:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_legacy.c:483:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nandsim.c:2254:22: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:512:4: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:517:4: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:466:37: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:471:37: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nuc900_nand.c: In function ‘nuc900_nand_command_lp’:
./arch/x86/include/asm/io.h:91:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
#define __raw_writel __writel
drivers/mtd/nand/raw/nuc900_nand.c:52:2: note: in expansion of macro ‘__raw_writel’
__raw_writel((val), (dev)->reg + REG_SMCMD)
^~~~~~~~~~~~
drivers/mtd/nand/raw/nuc900_nand.c:196:3: note: in expansion of macro ‘write_cmd_reg’
write_cmd_reg(nand, NAND_CMD_READSTART);
^~~~~~~~~~~~~
drivers/mtd/nand/raw/nuc900_nand.c:197:2: note: here
default:
^~~~~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

This patch is part of the ongoing efforts to enabling -Wimplicit-fallthrough.

---
Changes in v2:
- Add extra /* fall through */ comment in nandsim.c file.

 drivers/mtd/nand/onenand/onenand_base.c | 2 ++
 drivers/mtd/nand/raw/diskonchip.c       | 1 +
 drivers/mtd/nand/raw/nand_base.c        | 3 +++
 drivers/mtd/nand/raw/nand_legacy.c      | 3 ++-
 drivers/mtd/nand/raw/nandsim.c          | 6 ++++--
 drivers/mtd/nand/raw/nuc900_nand.c      | 3 ++-
 drivers/mtd/nand/raw/omap_elm.c         | 4 ++++
 7 files changed, 18 insertions(+), 4 deletions(-)
drivers/mtd/nand/onenand/onenand_base.c +2 -0
index 4ca4b194e7d7..e9b71ad24f50 100644
@@ -3280,12 +3280,14 @@ static void onenand_check_features(struct mtd_info *mtd)
 			if ((this->version_id & 0xf) == 0xe)
 				this->options |= ONENAND_HAS_NOP_1;
 		}
+		/* fall through */
 
 	case ONENAND_DEVICE_DENSITY_2Gb:
 		/* 2Gb DDP does not have 2 plane */
 		if (!ONENAND_IS_DDP(this))
 			this->options |= ONENAND_HAS_2PLANE;
 		this->options |= ONENAND_HAS_UNLOCK_ALL;
+		/* fall through */
 
 	case ONENAND_DEVICE_DENSITY_1Gb:
 		/* A-Die has all block unlock */
drivers/mtd/nand/raw/diskonchip.c +1 -0
index 53f57e0f007e..ead54c90f2d1 100644
@@ -1477,6 +1477,7 @@ static int __init doc_probe(unsigned long physadr)
 			break;
 		case DOC_ChipID_DocMilPlus32:
 			pr_err("DiskOnChip Millennium Plus 32MB is not supported, ignoring.\n");
+			/* fall through */
 		default:
 			ret = -ENODEV;
 			goto notfound;
drivers/mtd/nand/raw/nand_base.c +3 -0
index 96cadead262e..e05ecf2e4269 100644
@@ -5537,6 +5537,7 @@ static int nand_scan_tail(struct nand_chip *chip)
 		}
 		if (!ecc->read_page)
 			ecc->read_page = nand_read_page_hwecc_oob_first;
+		/* fall through */
 
 	case NAND_ECC_HW:
 		/* Use standard hwecc read page function? */
@@ -5556,6 +5557,7 @@ static int nand_scan_tail(struct nand_chip *chip)
 			ecc->read_subpage = nand_read_subpage;
 		if (!ecc->write_subpage && ecc->hwctl && ecc->calculate)
 			ecc->write_subpage = nand_write_subpage_hwecc;
+		/* fall through */
 
 	case NAND_ECC_HW_SYNDROME:
 		if ((!ecc->calculate || !ecc->correct || !ecc->hwctl) &&
@@ -5593,6 +5595,7 @@ static int nand_scan_tail(struct nand_chip *chip)
 			ecc->size, mtd->writesize);
 		ecc->mode = NAND_ECC_SOFT;
 		ecc->algo = NAND_ECC_HAMMING;
+		/* fall through */
 
 	case NAND_ECC_SOFT:
 		ret = nand_set_ecc_soft_ops(chip);
drivers/mtd/nand/raw/nand_legacy.c +2 -1
index 43575943f13b..f2526ec616a6 100644
@@ -331,6 +331,7 @@ static void nand_command(struct nand_chip *chip, unsigned int command,
 		 */
 		if (column == -1 && page_addr == -1)
 			return;
+		/* fall through */
 
 	default:
 		/*
@@ -483,7 +484,7 @@ static void nand_command_lp(struct nand_chip *chip, unsigned int command,
 		chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
 				      NAND_NCE | NAND_CTRL_CHANGE);
 
-		/* This applies to read commands */
+		/* fall through - This applies to read commands */
 	default:
 		/*
 		 * If we don't have access to the busy pin, we apply the given
drivers/mtd/nand/raw/nandsim.c +4 -2
index 933d1a629c51..edf5fd3d5f07 100644
@@ -2251,9 +2251,11 @@ static int __init ns_init_module(void)
 
 	switch (bbt) {
 	case 2:
-		 chip->bbt_options |= NAND_BBT_NO_OOB;
+		chip->bbt_options |= NAND_BBT_NO_OOB;
+		/* fall through */
 	case 1:
-		 chip->bbt_options |= NAND_BBT_USE_FLASH;
+		chip->bbt_options |= NAND_BBT_USE_FLASH;
+		/* fall through */
 	case 0:
 		break;
 	default:
drivers/mtd/nand/raw/nuc900_nand.c +2 -1
index 38b1994e7ed3..56fa84029482 100644
@@ -192,8 +192,9 @@ static void nuc900_nand_command_lp(struct nand_chip *chip,
 		return;
 
 	case NAND_CMD_READ0:
-
 		write_cmd_reg(nand, NAND_CMD_READSTART);
+		/* fall through */
+
 	default:
 
 		if (!chip->legacy.dev_ready) {
drivers/mtd/nand/raw/omap_elm.c +4 -0
index a3f32f939cc1..94c6401ef32f 100644
@@ -465,11 +465,13 @@ static int elm_context_save(struct elm_info *info)
 					ELM_SYNDROME_FRAGMENT_5 + offset);
 			regs->elm_syndrome_fragment_4[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_4 + offset);
+			/* fall through */
 		case BCH8_ECC:
 			regs->elm_syndrome_fragment_3[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_3 + offset);
 			regs->elm_syndrome_fragment_2[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_2 + offset);
+			/* fall through */
 		case BCH4_ECC:
 			regs->elm_syndrome_fragment_1[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_1 + offset);
@@ -511,11 +513,13 @@ static int elm_context_restore(struct elm_info *info)
 					regs->elm_syndrome_fragment_5[i]);
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_4 + offset,
 					regs->elm_syndrome_fragment_4[i]);
+			/* fall through */
 		case BCH8_ECC:
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_3 + offset,
 					regs->elm_syndrome_fragment_3[i]);
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_2 + offset,
 					regs->elm_syndrome_fragment_2[i]);
+			/* fall through */
 		case BCH4_ECC:
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_1 + offset,
 					regs->elm_syndrome_fragment_1[i]);
Signature · 1 line
2.20.1
maintainer
#1 lore raw

Hi Gustavo,

"Gustavo A. R. Silva" <[email protected]> wrote on Mon, 28 Jan 2019 12:15:20 -0600:

drivers/mtd/nand/onenand/onenand_base.c

Quoted 53 lines

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

This patch fixes the following warning:

drivers/mtd/nand/onenand/onenand_base.c:3264:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/onenand/onenand_base.c:3288:17: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_base.c:5538:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_base.c:5557:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_base.c:5595:13: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_legacy.c:332:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_legacy.c:483:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nandsim.c:2254:22: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:512:4: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:517:4: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:466:37: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:471:37: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nuc900_nand.c: In function ‘nuc900_nand_command_lp’:
./arch/x86/include/asm/io.h:91:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
#define __raw_writel __writel
drivers/mtd/nand/raw/nuc900_nand.c:52:2: note: in expansion of macro ‘__raw_writel’
__raw_writel((val), (dev)->reg + REG_SMCMD)
^~~~~~~~~~~~
drivers/mtd/nand/raw/nuc900_nand.c:196:3: note: in expansion of macro ‘write_cmd_reg’

   write_cmd_reg(nand, NAND_CMD_READSTART);
   ^~~~~~~~~~~~~

drivers/mtd/nand/raw/nuc900_nand.c:197:2: note: here
default:
^~~~~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

This patch is part of the ongoing efforts to enabling -Wimplicit-fallthrough.

---
Changes in v2:
- Add extra /* fall through */ comment in nandsim.c file.

 drivers/mtd/nand/onenand/onenand_base.c | 2 ++
 drivers/mtd/nand/raw/diskonchip.c       | 1 +
 drivers/mtd/nand/raw/nand_base.c        | 3 +++
 drivers/mtd/nand/raw/nand_legacy.c      | 3 ++-
 drivers/mtd/nand/raw/nandsim.c          | 6 ++++--
 drivers/mtd/nand/raw/nuc900_nand.c      | 3 ++-
 drivers/mtd/nand/raw/omap_elm.c         | 4 ++++
 7 files changed, 18 insertions(+), 4 deletions(-)
drivers/mtd/nand/onenand/onenand_base.c +0 -0
index 4ca4b194e7d7..e9b71ad24f50 100644

onenand changes should probably be in a separate patch prefixed

mtd: onenand:

When you are unsure, please run

        git log --oneline --follow drivers/mtd/nand/onenand/

drivers/mtd/nand/onenand/onenand_base.c static void onenand_check_features(struct mtd_info *mtd) · line 3290

Quoted 12 lines
drivers/mtd/nand/onenand/onenand_base.c +2 -0
@@ -3280,12 +3280,14 @@ static void onenand_check_features(struct mtd_info *mtd)
 			if ((this->version_id & 0xf) == 0xe)
 				this->options |= ONENAND_HAS_NOP_1;
 		}
+		/* fall through */
 
 	case ONENAND_DEVICE_DENSITY_2Gb:
 		/* 2Gb DDP does not have 2 plane */
 		if (!ONENAND_IS_DDP(this))
 			this->options |= ONENAND_HAS_2PLANE;
 		this->options |= ONENAND_HAS_UNLOCK_ALL;
+		/* fall through */

This looks strange.

In ONENAND_DEVICE_DENSITY_2Gb:
ONENAND_HAS_UNLOCK_ALL is set unconditionally.

But then, under ONENAND_DEVICE_DENSITY_1Gb, the same option is set only if process is evaluated to true.

Same problem with ONENAND_HAS_2PLANE:
- it is set in ONENAND_DEVICE_DENSITY_4Gb only if ONENAND_IS_DDP()
- it is unset in ONENAND_DEVICE_DENSITY_2Gb only if !ONENAND_IS_DDP()

Maybe this portion should be reworked because I am unsure if this is a missing fall through or a bug.

Quoted 8 lines
drivers/mtd/nand/onenand/onenand_base.c +0 -0
 	case ONENAND_DEVICE_DENSITY_1Gb:
 		/* A-Die has all block unlock */
drivers/mtd/nand/raw/diskonchip.c +0 -0
index 53f57e0f007e..ead54c90f2d1 100644

drivers/mtd/nand/raw/diskonchip.c static int __init doc_probe(unsigned long physadr) · line 1483

Quoted 7 lines
drivers/mtd/nand/raw/diskonchip.c +1 -0
@@ -1477,6 +1477,7 @@ static int __init doc_probe(unsigned long physadr)
 			break;
 		case DOC_ChipID_DocMilPlus32:
 			pr_err("DiskOnChip Millennium Plus 32MB is not supported, ignoring.\n");
+			/* fall through */
 		default:
 			ret = -ENODEV;
 			goto notfound;

This is fine.

Quoted 21 lines
drivers/mtd/nand/raw/nand_base.c +2 -0
index 96cadead262e..e05ecf2e4269 100644
@@ -5537,6 +5537,7 @@ static int nand_scan_tail(struct nand_chip *chip)
 		}
 		if (!ecc->read_page)
 			ecc->read_page = nand_read_page_hwecc_oob_first;
+		/* fall through */
 
 	case NAND_ECC_HW:
 		/* Use standard hwecc read page function? */
@@ -5556,6 +5557,7 @@ static int nand_scan_tail(struct nand_chip *chip)
 			ecc->read_subpage = nand_read_subpage;
 		if (!ecc->write_subpage && ecc->hwctl && ecc->calculate)
 			ecc->write_subpage = nand_write_subpage_hwecc;
+		/* fall through */
 
 	case NAND_ECC_HW_SYNDROME:
 		if ((!ecc->calculate || !ecc->correct || !ecc->hwctl) &&

drivers/mtd/nand/raw/nand_base.c static int nand_scan_tail(struct nand_chip *chip) · line 5601

Quoted 7 lines
drivers/mtd/nand/raw/nand_base.c +1 -0
@@ -5593,6 +5595,7 @@ static int nand_scan_tail(struct nand_chip *chip)
 			ecc->size, mtd->writesize);
 		ecc->mode = NAND_ECC_SOFT;
 		ecc->algo = NAND_ECC_HAMMING;
+		/* fall through */
 
 	case NAND_ECC_SOFT:
 		ret = nand_set_ecc_soft_ops(chip);

These three already are in nand/next.

Quoted 13 lines
drivers/mtd/nand/raw/nand_legacy.c +1 -0
index 43575943f13b..f2526ec616a6 100644
@@ -331,6 +331,7 @@ static void nand_command(struct nand_chip *chip, unsigned int command,
 		 */
 		if (column == -1 && page_addr == -1)
 			return;
+		/* fall through */
 
 	default:
 		/*

drivers/mtd/nand/raw/nand_legacy.c static void nand_command_lp(struct nand_chip *chip, unsigned int command, · line 490

Quoted 8 lines
drivers/mtd/nand/raw/nand_legacy.c +1 -1
@@ -483,7 +484,7 @@ static void nand_command_lp(struct nand_chip *chip, unsigned int command,
 		chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
 				      NAND_NCE | NAND_CTRL_CHANGE);
 
-		/* This applies to read commands */
+		/* fall through - This applies to read commands */
 	default:
 		/*
 		 * If we don't have access to the busy pin, we apply the given

Already fixed in nand/next too.

Quoted 8 lines
drivers/mtd/nand/raw/nandsim.c +0 -0
index 933d1a629c51..edf5fd3d5f07 100644
@@ -2251,9 +2251,11 @@ static int __init ns_init_module(void)
 
 	switch (bbt) {
 	case 2:

drivers/mtd/nand/raw/nandsim.c static int __init ns_init_module(void) · line 2261

Quoted 10 lines
drivers/mtd/nand/raw/nandsim.c +4 -2
-		 chip->bbt_options |= NAND_BBT_NO_OOB;
+		chip->bbt_options |= NAND_BBT_NO_OOB;
+		/* fall through */
 	case 1:
-		 chip->bbt_options |= NAND_BBT_USE_FLASH;
+		chip->bbt_options |= NAND_BBT_USE_FLASH;
+		/* fall through */
 	case 0:
 		break;
 	default:

This is fine.

Quoted 5 lines
drivers/mtd/nand/raw/nuc900_nand.c +0 -0
index 38b1994e7ed3..56fa84029482 100644

drivers/mtd/nand/raw/nuc900_nand.c static void nuc900_nand_command_lp(struct nand_chip *chip, · line 200

Quoted 10 lines
drivers/mtd/nand/raw/nuc900_nand.c +2 -1
@@ -192,8 +192,9 @@ static void nuc900_nand_command_lp(struct nand_chip *chip,
 		return;
 
 	case NAND_CMD_READ0:
-
 		write_cmd_reg(nand, NAND_CMD_READSTART);
+		/* fall through */
+
 	default:
 
 		if (!chip->legacy.dev_ready) {

This is fine too.

Quoted 22 lines
drivers/mtd/nand/raw/omap_elm.c +2 -0
index a3f32f939cc1..94c6401ef32f 100644
@@ -465,11 +465,13 @@ static int elm_context_save(struct elm_info *info)
 					ELM_SYNDROME_FRAGMENT_5 + offset);
 			regs->elm_syndrome_fragment_4[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_4 + offset);
+			/* fall through */
 		case BCH8_ECC:
 			regs->elm_syndrome_fragment_3[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_3 + offset);
 			regs->elm_syndrome_fragment_2[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_2 + offset);
+			/* fall through */
 		case BCH4_ECC:
 			regs->elm_syndrome_fragment_1[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_1 + offset);
@@ -511,11 +513,13 @@ static int elm_context_restore(struct elm_info *info)
 					regs->elm_syndrome_fragment_5[i]);
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_4 + offset,
 					regs->elm_syndrome_fragment_4[i]);

drivers/mtd/nand/raw/omap_elm.c static int elm_context_restore(struct elm_info *info) · line 525

Quoted 10 lines
drivers/mtd/nand/raw/omap_elm.c +2 -0
+			/* fall through */
 		case BCH8_ECC:
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_3 + offset,
 					regs->elm_syndrome_fragment_3[i]);
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_2 + offset,
 					regs->elm_syndrome_fragment_2[i]);
+			/* fall through */
 		case BCH4_ECC:
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_1 + offset,
 					regs->elm_syndrome_fragment_1[i]);

And this is ok as well.

Thanks,
Miquèl

#2 lore raw

Hey Miquel,

Quoted 61 lines · Miquel Raynal

Hi Gustavo,

"Gustavo A. R. Silva" <[email protected]> wrote on Mon, 28 Jan 2019 12:15:20 -0600:

drivers/mtd/nand/onenand/onenand_base.c

Quoted 53 lines

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

This patch fixes the following warning:

drivers/mtd/nand/onenand/onenand_base.c:3264:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/onenand/onenand_base.c:3288:17: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_base.c:5538:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_base.c:5557:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_base.c:5595:13: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_legacy.c:332:6: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nand_legacy.c:483:3: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nandsim.c:2254:22: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:512:4: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:517:4: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:466:37: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/omap_elm.c:471:37: warning: this statement may fall through [-Wimplicit-fallthrough=] drivers/mtd/nand/raw/nuc900_nand.c: In function ‘nuc900_nand_command_lp’:
./arch/x86/include/asm/io.h:91:22: warning: this statement may fall through [-Wimplicit-fallthrough=]
#define __raw_writel __writel
drivers/mtd/nand/raw/nuc900_nand.c:52:2: note: in expansion of macro ‘__raw_writel’
__raw_writel((val), (dev)->reg + REG_SMCMD)
^~~~~~~~~~~~
drivers/mtd/nand/raw/nuc900_nand.c:196:3: note: in expansion of macro ‘write_cmd_reg’

   write_cmd_reg(nand, NAND_CMD_READSTART);
   ^~~~~~~~~~~~~

drivers/mtd/nand/raw/nuc900_nand.c:197:2: note: here
default:
^~~~~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

This patch is part of the ongoing efforts to enabling -Wimplicit-fallthrough.

---
Changes in v2:
- Add extra /* fall through */ comment in nandsim.c file.

 drivers/mtd/nand/onenand/onenand_base.c | 2 ++
 drivers/mtd/nand/raw/diskonchip.c       | 1 +
 drivers/mtd/nand/raw/nand_base.c        | 3 +++
 drivers/mtd/nand/raw/nand_legacy.c      | 3 ++-
 drivers/mtd/nand/raw/nandsim.c          | 6 ++++--
 drivers/mtd/nand/raw/nuc900_nand.c      | 3 ++-
 drivers/mtd/nand/raw/omap_elm.c         | 4 ++++
 7 files changed, 18 insertions(+), 4 deletions(-)
drivers/mtd/nand/onenand/onenand_base.c +0 -0
index 4ca4b194e7d7..e9b71ad24f50 100644

onenand changes should probably be in a separate patch prefixed

Quoted 6 lines

mtd: onenand:

When you are unsure, please run

        git log --oneline --follow drivers/mtd/nand/onenand/

OK. Got it.

Quoted 21 lines

drivers/mtd/nand/onenand/onenand_base.c static void onenand_check_features(struct mtd_info *mtd) · line 3290

Quoted 12 lines
drivers/mtd/nand/onenand/onenand_base.c +2 -0
@@ -3280,12 +3280,14 @@ static void onenand_check_features(struct mtd_info *mtd)
 			if ((this->version_id & 0xf) == 0xe)
 				this->options |= ONENAND_HAS_NOP_1;
 		}
+		/* fall through */
 
 	case ONENAND_DEVICE_DENSITY_2Gb:
 		/* 2Gb DDP does not have 2 plane */
 		if (!ONENAND_IS_DDP(this))
 			this->options |= ONENAND_HAS_2PLANE;
 		this->options |= ONENAND_HAS_UNLOCK_ALL;
+		/* fall through */

This looks strange.

In ONENAND_DEVICE_DENSITY_2Gb:
ONENAND_HAS_UNLOCK_ALL is set unconditionally.

But then, under ONENAND_DEVICE_DENSITY_1Gb, the same option is set only if process is evaluated to true.

Quoted 7 lines

Same problem with ONENAND_HAS_2PLANE:
- it is set in ONENAND_DEVICE_DENSITY_4Gb only if ONENAND_IS_DDP()
- it is unset in ONENAND_DEVICE_DENSITY_2Gb only if !ONENAND_IS_DDP()

Maybe this portion should be reworked because I am unsure if this is a missing fall through or a bug.

OK. Then, I should probably skip this file for now.

Quoted 44 lines
Quoted 8 lines
drivers/mtd/nand/onenand/onenand_base.c +0 -0
 	case ONENAND_DEVICE_DENSITY_1Gb:
 		/* A-Die has all block unlock */
drivers/mtd/nand/raw/diskonchip.c +0 -0
index 53f57e0f007e..ead54c90f2d1 100644

drivers/mtd/nand/raw/diskonchip.c static int __init doc_probe(unsigned long physadr) · line 1483

Quoted 7 lines
drivers/mtd/nand/raw/diskonchip.c +1 -0
@@ -1477,6 +1477,7 @@ static int __init doc_probe(unsigned long physadr)
 			break;
 		case DOC_ChipID_DocMilPlus32:
 			pr_err("DiskOnChip Millennium Plus 32MB is not supported, ignoring.\n");
+			/* fall through */
 		default:
 			ret = -ENODEV;
 			goto notfound;

This is fine.

Quoted 26 lines
drivers/mtd/nand/raw/nand_base.c +3 -0
index 96cadead262e..e05ecf2e4269 100644
@@ -5537,6 +5537,7 @@ static int nand_scan_tail(struct nand_chip *chip)
 		}
 		if (!ecc->read_page)
 			ecc->read_page = nand_read_page_hwecc_oob_first;
+		/* fall through */
 
 	case NAND_ECC_HW:
 		/* Use standard hwecc read page function? */
@@ -5556,6 +5557,7 @@ static int nand_scan_tail(struct nand_chip *chip)
 			ecc->read_subpage = nand_read_subpage;
 		if (!ecc->write_subpage && ecc->hwctl && ecc->calculate)
 			ecc->write_subpage = nand_write_subpage_hwecc;
+		/* fall through */
 
 	case NAND_ECC_HW_SYNDROME:
 		if ((!ecc->calculate || !ecc->correct || !ecc->hwctl) &&
@@ -5593,6 +5595,7 @@ static int nand_scan_tail(struct nand_chip *chip)
 			ecc->size, mtd->writesize);
 		ecc->mode = NAND_ECC_SOFT;
 		ecc->algo = NAND_ECC_HAMMING;
+		/* fall through */
 
Quoted 5 lines

drivers/mtd/nand/raw/nand_base.c static int nand_scan_tail(struct nand_chip *chip) · line 5601

Quoted 2 lines
drivers/mtd/nand/raw/nand_base.c +0 -0
 	case NAND_ECC_SOFT:
 		ret = nand_set_ecc_soft_ops(chip);

These three already are in nand/next.

Great.

Quoted 16 lines
Quoted 16 lines
drivers/mtd/nand/raw/nand_legacy.c +1 -0
index 43575943f13b..f2526ec616a6 100644
@@ -331,6 +331,7 @@ static void nand_command(struct nand_chip *chip, unsigned int command,
 		 */
 		if (column == -1 && page_addr == -1)
 			return;
+		/* fall through */
 
 	default:
 		/*
@@ -483,7 +484,7 @@ static void nand_command_lp(struct nand_chip *chip, unsigned int command,
 		chip->legacy.cmd_ctrl(chip, NAND_CMD_NONE,
 				      NAND_NCE | NAND_CTRL_CHANGE);
 
Quoted 8 lines

drivers/mtd/nand/raw/nand_legacy.c static void nand_command_lp(struct nand_chip *chip, unsigned int command, · line 490

Quoted 5 lines
drivers/mtd/nand/raw/nand_legacy.c +1 -1
-		/* This applies to read commands */
+		/* fall through - This applies to read commands */
 	default:
 		/*
 		 * If we don't have access to the busy pin, we apply the given

Already fixed in nand/next too.

OK. Great.

Quoted 65 lines
Quoted 8 lines
drivers/mtd/nand/raw/nandsim.c +0 -0
index 933d1a629c51..edf5fd3d5f07 100644
@@ -2251,9 +2251,11 @@ static int __init ns_init_module(void)
 
 	switch (bbt) {
 	case 2:

drivers/mtd/nand/raw/nandsim.c static int __init ns_init_module(void) · line 2261

Quoted 10 lines
drivers/mtd/nand/raw/nandsim.c +4 -2
-		 chip->bbt_options |= NAND_BBT_NO_OOB;
+		chip->bbt_options |= NAND_BBT_NO_OOB;
+		/* fall through */
 	case 1:
-		 chip->bbt_options |= NAND_BBT_USE_FLASH;
+		chip->bbt_options |= NAND_BBT_USE_FLASH;
+		/* fall through */
 	case 0:
 		break;
 	default:

This is fine.

Quoted 5 lines
drivers/mtd/nand/raw/nuc900_nand.c +0 -0
index 38b1994e7ed3..56fa84029482 100644

drivers/mtd/nand/raw/nuc900_nand.c static void nuc900_nand_command_lp(struct nand_chip *chip, · line 200

Quoted 10 lines
drivers/mtd/nand/raw/nuc900_nand.c +2 -1
@@ -192,8 +192,9 @@ static void nuc900_nand_command_lp(struct nand_chip *chip,
 		return;
 
 	case NAND_CMD_READ0:
-
 		write_cmd_reg(nand, NAND_CMD_READSTART);
+		/* fall through */
+
 	default:
 
 		if (!chip->legacy.dev_ready) {

This is fine too.

Quoted 26 lines
drivers/mtd/nand/raw/omap_elm.c +3 -0
index a3f32f939cc1..94c6401ef32f 100644
@@ -465,11 +465,13 @@ static int elm_context_save(struct elm_info *info)
 					ELM_SYNDROME_FRAGMENT_5 + offset);
 			regs->elm_syndrome_fragment_4[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_4 + offset);
+			/* fall through */
 		case BCH8_ECC:
 			regs->elm_syndrome_fragment_3[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_3 + offset);
 			regs->elm_syndrome_fragment_2[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_2 + offset);
+			/* fall through */
 		case BCH4_ECC:
 			regs->elm_syndrome_fragment_1[i] = elm_read_reg(info,
 					ELM_SYNDROME_FRAGMENT_1 + offset);
@@ -511,11 +513,13 @@ static int elm_context_restore(struct elm_info *info)
 					regs->elm_syndrome_fragment_5[i]);
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_4 + offset,
 					regs->elm_syndrome_fragment_4[i]);
+			/* fall through */
 		case BCH8_ECC:
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_3 + offset,
 					regs->elm_syndrome_fragment_3[i]);
Quoted 9 lines

drivers/mtd/nand/raw/omap_elm.c static int elm_context_restore(struct elm_info *info) · line 525

Quoted 6 lines
drivers/mtd/nand/raw/omap_elm.c +1 -0
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_2 + offset,
 					regs->elm_syndrome_fragment_2[i]);
+			/* fall through */
 		case BCH4_ECC:
 			elm_write_reg(info, ELM_SYNDROME_FRAGMENT_1 + offset,
 					regs->elm_syndrome_fragment_1[i]);

And this is ok as well.

I'll leave out the files that have already been addressed and send v3 shortly.

I appreciate your feedback.

Thanks
--
Gustavo

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#3 lore raw
In reply to Miquel Raynal

Hi Miquel,

On 2/5/19 6:55 AM, Miquel Raynal wrote:
[..]

Quoted 21 lines

drivers/mtd/nand/onenand/onenand_base.c static void onenand_check_features(struct mtd_info *mtd) · line 3290

Quoted 12 lines
drivers/mtd/nand/onenand/onenand_base.c +2 -0
@@ -3280,12 +3280,14 @@ static void onenand_check_features(struct mtd_info *mtd)
 			if ((this->version_id & 0xf) == 0xe)
 				this->options |= ONENAND_HAS_NOP_1;
 		}
+		/* fall through */
 
 	case ONENAND_DEVICE_DENSITY_2Gb:
 		/* 2Gb DDP does not have 2 plane */
 		if (!ONENAND_IS_DDP(this))
 			this->options |= ONENAND_HAS_2PLANE;
 		this->options |= ONENAND_HAS_UNLOCK_ALL;
+		/* fall through */

This looks strange.

In ONENAND_DEVICE_DENSITY_2Gb:
ONENAND_HAS_UNLOCK_ALL is set unconditionally.

But then, under ONENAND_DEVICE_DENSITY_1Gb, the same option is set only if process is evaluated to true.

Quoted 7 lines

Same problem with ONENAND_HAS_2PLANE:
- it is set in ONENAND_DEVICE_DENSITY_4Gb only if ONENAND_IS_DDP()
- it is unset in ONENAND_DEVICE_DENSITY_2Gb only if !ONENAND_IS_DDP()

Maybe this portion should be reworked because I am unsure if this is a missing fall through or a bug.

I wonder if you had the chance to take a look into this piece of code.

Thanks
--
Gustavo

maintainer
#4 lore raw

Hi Gustavo,

"Gustavo A. R. Silva" <[email protected]> wrote on Thu, 11 Apr 2019 13:30:31 -0500:

Quoted 33 lines

Hi Miquel,

On 2/5/19 6:55 AM, Miquel Raynal wrote:
[..]

Quoted 21 lines

drivers/mtd/nand/onenand/onenand_base.c static void onenand_check_features(struct mtd_info *mtd) · line 3290

Quoted 12 lines
drivers/mtd/nand/onenand/onenand_base.c +2 -0
@@ -3280,12 +3280,14 @@ static void onenand_check_features(struct mtd_info *mtd)
 			if ((this->version_id & 0xf) == 0xe)
 				this->options |= ONENAND_HAS_NOP_1;
 		}
+		/* fall through */
 
 	case ONENAND_DEVICE_DENSITY_2Gb:
 		/* 2Gb DDP does not have 2 plane */
 		if (!ONENAND_IS_DDP(this))
 			this->options |= ONENAND_HAS_2PLANE;
 		this->options |= ONENAND_HAS_UNLOCK_ALL;
+		/* fall through */  

This looks strange.

In ONENAND_DEVICE_DENSITY_2Gb:
ONENAND_HAS_UNLOCK_ALL is set unconditionally.

But then, under ONENAND_DEVICE_DENSITY_1Gb, the same option is set only if process is evaluated to true.

Quoted 7 lines

Same problem with ONENAND_HAS_2PLANE:
- it is set in ONENAND_DEVICE_DENSITY_4Gb only if ONENAND_IS_DDP()
- it is unset in ONENAND_DEVICE_DENSITY_2Gb only if !ONENAND_IS_DDP()

Maybe this portion should be reworked because I am unsure if this is a missing fall through or a bug.

Quoted 5 lines

I wonder if you had the chance to take a look into this piece of code.

Thanks
--
Gustavo

What do you mean?

Thanks,
Miquèl

#5 lore raw
Quoted 38 lines · Miquel Raynal

Hi Gustavo,

"Gustavo A. R. Silva" <[email protected]> wrote on Thu, 11 Apr 2019 13:30:31 -0500:

Quoted 33 lines

Hi Miquel,

On 2/5/19 6:55 AM, Miquel Raynal wrote:
[..]

Quoted 28 lines

drivers/mtd/nand/onenand/onenand_base.c static void onenand_check_features(struct mtd_info *mtd) · line 3290

Quoted 12 lines
drivers/mtd/nand/onenand/onenand_base.c +2 -0
@@ -3280,12 +3280,14 @@ static void onenand_check_features(struct mtd_info *mtd)
 			if ((this->version_id & 0xf) == 0xe)
 				this->options |= ONENAND_HAS_NOP_1;
 		}
+		/* fall through */
 
 	case ONENAND_DEVICE_DENSITY_2Gb:
 		/* 2Gb DDP does not have 2 plane */
 		if (!ONENAND_IS_DDP(this))
 			this->options |= ONENAND_HAS_2PLANE;
 		this->options |= ONENAND_HAS_UNLOCK_ALL;
+		/* fall through */  

This looks strange.

In ONENAND_DEVICE_DENSITY_2Gb:
ONENAND_HAS_UNLOCK_ALL is set unconditionally.

But then, under ONENAND_DEVICE_DENSITY_1Gb, the same option is set only if process is evaluated to true.

Same problem with ONENAND_HAS_2PLANE:
- it is set in ONENAND_DEVICE_DENSITY_4Gb only if ONENAND_IS_DDP()
- it is unset in ONENAND_DEVICE_DENSITY_2Gb only if !ONENAND_IS_DDP()

Maybe this portion should be reworked because I am unsure if this is a missing fall through or a bug.

Quoted 8 lines
Quoted 5 lines

I wonder if you had the chance to take a look into this piece of code.

Thanks
--
Gustavo

What do you mean?

You commented that the piece of code above should be reworked. So, it wasn't clear to me who was going to do that; and that's why I'm asking if you took a look into it and finally determine whether we are dealing with an actual bug or a false positive.

Thanks
--
Gustavo

maintainer
#6 lore raw

Hi Gustavo,

"Gustavo A. R. Silva" <[email protected]> wrote on Thu, 11 Apr 2019 17:20:31 -0500:

Quoted 45 lines · Miquel Raynal
Quoted 44 lines

Hi Gustavo,

"Gustavo A. R. Silva" <[email protected]> wrote on Thu, 11 Apr 2019 13:30:31 -0500:

Quoted 38 lines

Hi Miquel,

On 2/5/19 6:55 AM, Miquel Raynal wrote:
[..]

Quoted 21 lines

drivers/mtd/nand/onenand/onenand_base.c static void onenand_check_features(struct mtd_info *mtd) · line 3290

Quoted 12 lines
drivers/mtd/nand/onenand/onenand_base.c +2 -0
@@ -3280,12 +3280,14 @@ static void onenand_check_features(struct mtd_info *mtd)
 			if ((this->version_id & 0xf) == 0xe)
 				this->options |= ONENAND_HAS_NOP_1;
 		}
+		/* fall through */
 
 	case ONENAND_DEVICE_DENSITY_2Gb:
 		/* 2Gb DDP does not have 2 plane */
 		if (!ONENAND_IS_DDP(this))
 			this->options |= ONENAND_HAS_2PLANE;
 		this->options |= ONENAND_HAS_UNLOCK_ALL;
+		/* fall through */    

This looks strange.

In ONENAND_DEVICE_DENSITY_2Gb:
ONENAND_HAS_UNLOCK_ALL is set unconditionally.

But then, under ONENAND_DEVICE_DENSITY_1Gb, the same option is set only if process is evaluated to true.

Quoted 7 lines

Same problem with ONENAND_HAS_2PLANE:
- it is set in ONENAND_DEVICE_DENSITY_4Gb only if ONENAND_IS_DDP()
- it is unset in ONENAND_DEVICE_DENSITY_2Gb only if !ONENAND_IS_DDP()

Maybe this portion should be reworked because I am unsure if this is a missing fall through or a bug.

I wonder if you had the chance to take a look into this piece of code.

Thanks
--
Gustavo

Quoted 7 lines
Quoted 2 lines

What do you mean?

You commented that the piece of code above should be reworked. So, it wasn't clear to me who was going to do that; and that's why I'm asking if you took a look into it and finally determine whether we are dealing with an actual bug or a false positive.

Yes please do it, I don't have the time and I don't plan to do it myself.

Thanks,
Miquèl