Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd: spi-nor: swp: remove unnecessary else after return
@ 2026-10-23  9:24 Shuai Liu
  2026-10-23  9:29 ` Michael Walle
  0 siblings, 1 reply; 3+ messages in thread
From: Shuai Liu @ 2026-10-23  9:24 UTC (permalink / raw)
  To: linux-mtd; +Cc: pratyush, mwalle, takahiro.kuwano, linux-kernel

Drop the else branch following an if that always returns, and move
the trailing comment onto the fall-through path. Cosmetic only, no
functional change; silences a checkpatch WARNING.

Signed-off-by: Shuai Liu <847807867@qq.com>
---
 drivers/mtd/spi-nor/swp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi-nor/swp.c b/drivers/mtd/spi-nor/swp.c
index 235070b21..3b8176b9d 100644
--- a/drivers/mtd/spi-nor/swp.c
+++ b/drivers/mtd/spi-nor/swp.c
@@ -135,9 +135,9 @@ static bool spi_nor_check_lock_status_sr(struct spi_nor *nor, loff_t ofs,
 	if (locked)
 		/* Requested range is a sub-range of locked range */
 		return (offs_max <= lock_offs_max) && (ofs >= lock_offs);
-	else
-		/* Requested range does not overlap with locked range */
-		return (ofs >= lock_offs_max) || (offs_max <= lock_offs);
+
+	/* Requested range does not overlap with locked range */
+	return (ofs >= lock_offs_max) || (offs_max <= lock_offs);
 }
 
 bool spi_nor_is_locked_sr(struct spi_nor *nor, loff_t ofs, u64 len, const u8 *sr)
-- 
2.43.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: spi-nor: swp: remove unnecessary else after return
  2026-10-23  9:24 [PATCH] mtd: spi-nor: swp: remove unnecessary else after return Shuai Liu
@ 2026-10-23  9:29 ` Michael Walle
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Walle @ 2026-10-23  9:29 UTC (permalink / raw)
  To: Shuai Liu, linux-mtd; +Cc: pratyush, takahiro.kuwano, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1280 bytes --]

On Fri Oct 23, 2026 at 11:24 AM CEST, Shuai Liu wrote:
> Drop the else branch following an if that always returns, and move
> the trailing comment onto the fall-through path. Cosmetic only, no
> functional change; silences a checkpatch WARNING.

So what is the checkpatch warning? IMHO that change make the
readability worse.

-michael

>
> Signed-off-by: Shuai Liu <847807867@qq.com>
> ---
>  drivers/mtd/spi-nor/swp.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/swp.c b/drivers/mtd/spi-nor/swp.c
> index 235070b21..3b8176b9d 100644
> --- a/drivers/mtd/spi-nor/swp.c
> +++ b/drivers/mtd/spi-nor/swp.c
> @@ -135,9 +135,9 @@ static bool spi_nor_check_lock_status_sr(struct spi_nor *nor, loff_t ofs,
>  	if (locked)
>  		/* Requested range is a sub-range of locked range */
>  		return (offs_max <= lock_offs_max) && (ofs >= lock_offs);
> -	else
> -		/* Requested range does not overlap with locked range */
> -		return (ofs >= lock_offs_max) || (offs_max <= lock_offs);
> +
> +	/* Requested range does not overlap with locked range */
> +	return (ofs >= lock_offs_max) || (offs_max <= lock_offs);
>  }
>  
>  bool spi_nor_is_locked_sr(struct spi_nor *nor, loff_t ofs, u64 len, const u8 *sr)


[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]

[-- Attachment #2: Type: text/plain, Size: 144 bytes --]

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: spi-nor: swp: remove unnecessary else after return
       [not found] <20261023092445.3969055-1-847807867@qq.com>
@ 2026-10-23  9:34 ` Shuai Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Shuai Liu @ 2026-10-23  9:34 UTC (permalink / raw)
  To: Michael Walle; +Cc: Pratyush Yadav, Takahiro Kuwano, linux-mtd, linux-kernel

On Fri, Oct 23, 2026, Michael Walle wrote:
> So what is the checkpatch warning? IMHO that change make the
> readability worse.

It's the "else is not generally useful after a break or return"
check in checkpatch.pl.

Fair point. With the comments attached to both branches, the
symmetric if/else reads fine, and I agree this isn't worth
changing. Please drop this patch.

Sorry for the noise.

Best regards,
Shuai Liu


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2026-10-23  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-23  9:24 [PATCH] mtd: spi-nor: swp: remove unnecessary else after return Shuai Liu
2026-10-23  9:29 ` Michael Walle
     [not found] <20261023092445.3969055-1-847807867@qq.com>
2026-10-23  9:34 ` Shuai Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox