* [PATCH] Drivers/mfd: Remove Non-standard Case Statements
@ 2018-02-15 16:04 Progyan Bhattacharya
2018-02-15 16:25 ` Richard Fitzgerald
0 siblings, 1 reply; 2+ messages in thread
From: Progyan Bhattacharya @ 2018-02-15 16:04 UTC (permalink / raw)
To: linux-kernel; +Cc: Lee Jones, patches
Remove Range Expressions from Case Statements and replace them with equivalent If-Else ladder. Comments are kept as is for understanding.
Signed-off-by: Progyan Bhattacharya <progyanb@acm.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: patches@opensource.cirrus.com
Cc: linux-kernel@vger.kernel.org
---
drivers/mfd/cs47l24-tables.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/drivers/mfd/cs47l24-tables.c b/drivers/mfd/cs47l24-tables.c
index c090974340ad..99eeb6bac5d5 100644
--- a/drivers/mfd/cs47l24-tables.c
+++ b/drivers/mfd/cs47l24-tables.c
@@ -783,19 +783,23 @@ static const struct reg_default cs47l24_reg_default[] = {
static bool cs47l24_is_adsp_memory(unsigned int reg)
{
- switch (reg) {
- case 0x200000 ... 0x205fff: /* DSP2 PM */
- case 0x280000 ... 0x281fff: /* DSP2 ZM */
- case 0x290000 ... 0x2a7fff: /* DSP2 XM */
- case 0x2a8000 ... 0x2b3fff: /* DSP2 YM */
- case 0x300000 ... 0x308fff: /* DSP3 PM */
- case 0x380000 ... 0x381fff: /* DSP3 ZM */
- case 0x390000 ... 0x3a7fff: /* DSP3 XM */
- case 0x3a8000 ... 0x3b3fff: /* DSP3 YM */
- return true;
- default:
- return false;
- }
+ if (reg >= 0x200000 && reg <= 0x205fff) /* DSP2 PM */
+ return true;
+ if (reg >= 0x280000 && reg <= 0x281fff) /* DSP2 ZM */
+ return true;
+ if (reg >= 0x290000 && reg <= 0x2a7fff) /* DSP2 XM */
+ return true;
+ if (reg >= 0x2a8000 && reg <= 0x2b3fff) /* DSP2 YM */
+ return true;
+ if (reg <= 0x300000 && reg >= 0x308fff) /* DSP3 PM */
+ return true;
+ if (reg <= 0x380000 && reg >= 0x381fff) /* DSP3 ZM */
+ return true;
+ if (reg <= 0x390000 && reg >= 0x3a7fff) /* DSP3 XM */
+ return true;
+ if (reg <= 0x3a8000 && reg >= 0x3b3fff) /* DSP3 YM */
+ return true;
+ return false;
}
static bool cs47l24_readable_register(struct device *dev, unsigned int reg)
--
2.16.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Drivers/mfd: Remove Non-standard Case Statements
2018-02-15 16:04 [PATCH] Drivers/mfd: Remove Non-standard Case Statements Progyan Bhattacharya
@ 2018-02-15 16:25 ` Richard Fitzgerald
0 siblings, 0 replies; 2+ messages in thread
From: Richard Fitzgerald @ 2018-02-15 16:25 UTC (permalink / raw)
To: Progyan Bhattacharya, linux-kernel; +Cc: Lee Jones, patches
On 15/02/18 16:04, Progyan Bhattacharya wrote:
> Remove Range Expressions from Case Statements and replace them with equivalent If-Else ladder. Comments are kept as is for understanding.
>
Why?
Your commit message should at least say why you are making this change.
(It also should be wrapped to a sensible line length).
The "case x ... y:" style is used in many places all over the kernel. As
are other gcc extensions.
Is this a change in kernel coding style guidelines? Or are you trying to
make it a compile with a different compiler to normal?
Although I'm not a fan of non-standard C extensions, in my opinion the
case ... is more readable than the chain of if statements.
> Signed-off-by: Progyan Bhattacharya <progyanb@acm.org>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: patches@opensource.cirrus.com
> Cc: linux-kernel@vger.kernel.org
> ---
> drivers/mfd/cs47l24-tables.c | 30 +++++++++++++++++-------------
> 1 file changed, 17 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mfd/cs47l24-tables.c b/drivers/mfd/cs47l24-tables.c
> index c090974340ad..99eeb6bac5d5 100644
> --- a/drivers/mfd/cs47l24-tables.c
> +++ b/drivers/mfd/cs47l24-tables.c
> @@ -783,19 +783,23 @@ static const struct reg_default cs47l24_reg_default[] = {
>
> static bool cs47l24_is_adsp_memory(unsigned int reg)
> {
> - switch (reg) {
> - case 0x200000 ... 0x205fff: /* DSP2 PM */
> - case 0x280000 ... 0x281fff: /* DSP2 ZM */
> - case 0x290000 ... 0x2a7fff: /* DSP2 XM */
> - case 0x2a8000 ... 0x2b3fff: /* DSP2 YM */
> - case 0x300000 ... 0x308fff: /* DSP3 PM */
> - case 0x380000 ... 0x381fff: /* DSP3 ZM */
> - case 0x390000 ... 0x3a7fff: /* DSP3 XM */
> - case 0x3a8000 ... 0x3b3fff: /* DSP3 YM */
> - return true;
> - default:
> - return false;
> - }
> + if (reg >= 0x200000 && reg <= 0x205fff) /* DSP2 PM */
> + return true;
> + if (reg >= 0x280000 && reg <= 0x281fff) /* DSP2 ZM */
> + return true;
> + if (reg >= 0x290000 && reg <= 0x2a7fff) /* DSP2 XM */
> + return true;
> + if (reg >= 0x2a8000 && reg <= 0x2b3fff) /* DSP2 YM */
> + return true;
> + if (reg <= 0x300000 && reg >= 0x308fff) /* DSP3 PM */
> + return true;
> + if (reg <= 0x380000 && reg >= 0x381fff) /* DSP3 ZM */
> + return true;
> + if (reg <= 0x390000 && reg >= 0x3a7fff) /* DSP3 XM */
> + return true;
> + if (reg <= 0x3a8000 && reg >= 0x3b3fff) /* DSP3 YM */
> + return true;
> + return false;
> }
>
> static bool cs47l24_readable_register(struct device *dev, unsigned int reg)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-15 16:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-15 16:04 [PATCH] Drivers/mfd: Remove Non-standard Case Statements Progyan Bhattacharya
2018-02-15 16:25 ` Richard Fitzgerald
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®