[PATCH 1/3] firmware: arm_scmi: quirk: Improve quirk range parsing

Geert Uytterhoeven
2026-04-03T08:41:47Z

When a range contains only an end ("-X"), the number string is parsed
twice, as both "sep == first" and "sep != last" are true. Fix this by
dropping the superfluous number parsing for "sep == first".

This does have a harmless functional impact for the unbounded range:
"-" is now accepted, while it was rejected before.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/firmware/arm_scmi/quirks.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/arm_scmi/quirks.c b/drivers/firmware/arm_scmi/quirks.c
index 03848283c2a07b72..b1d9cd9fa2427879 100644
--- a/drivers/firmware/arm_scmi/quirks.c
+++ b/drivers/firmware/arm_scmi/quirks.c
@@ -238,16 +238,15 @@ static int scmi_quirk_range_parse(struct scmi_quirk *quirk)
if (sep)
*sep = '\0';

- if (sep == first) /* -X */
- ret = kstrtouint(first + 1, 0, &quirk->end_range);
- else /* X OR X- OR X-y */
+ if (sep != first) /* X OR X- OR X-y */ {
ret = kstrtouint(first, 0, &quirk->start_range);
- if (ret)
- return ret;
+ if (ret)
+ return ret;
+ }

if (!sep)
quirk->end_range = quirk->start_range;
- else if (sep != last) /* x-Y */
+ else if (sep != last) /* -X OR x-Y */
ret = kstrtouint(sep + 1, 0, &quirk->end_range);

if (quirk->start_range > quirk->end_range)
--
2.43.0