Skip to content

Commit 3b29c7b

Browse files
andy-shevlag-linaro
authored andcommitted
leds: sun50i-a100: Use match_string() helper to simplify the code
match_string() returns the array index of a matching string. Use it instead of the open-coded implementation. Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 974afcc commit 3b29c7b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

drivers/leds/leds-sun50i-a100.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,16 @@ static int sun50i_a100_ledc_parse_format(struct device *dev,
252252
struct sun50i_a100_ledc *priv)
253253
{
254254
const char *format = "grb";
255-
u32 i;
255+
int i;
256256

257257
device_property_read_string(dev, "allwinner,pixel-format", &format);
258258

259-
for (i = 0; i < ARRAY_SIZE(sun50i_a100_ledc_formats); i++) {
260-
if (!strcmp(format, sun50i_a100_ledc_formats[i])) {
261-
priv->format = i;
262-
return 0;
263-
}
264-
}
259+
i = match_string(sun50i_a100_ledc_formats, ARRAY_SIZE(sun50i_a100_ledc_formats), format);
260+
if (i < 0)
261+
return dev_err_probe(dev, i, "Bad pixel format '%s'\n", format);
265262

266-
return dev_err_probe(dev, -EINVAL, "Bad pixel format '%s'\n", format);
263+
priv->format = i;
264+
return 0;
267265
}
268266

269267
static void sun50i_a100_ledc_set_format(struct sun50i_a100_ledc *priv)

0 commit comments

Comments
 (0)