Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

backlight: mp3309c: Initialize backlight properties without memset

Assigning values to a struct using a compound literal (since C99) also
guarantees that all unspecified struct members are empty-initialized, so
it properly replaces the memset to zero.

The code looks a bit nicer and more idiomatic (though that might be
subjective?). The resulting binary is a bit smaller. On ARCH=arm with
an allnoconfig + minimal changes to enable the mp3309c driver the
difference is 12 bytes.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Tested-by: Flavio Suligoi <f.suligoi@asem.it>
Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>
Link: https://lore.kernel.org/r/14514a1b0d3df6438aa10bb74f1c4fc2367d9987.1751361465.git.u.kleine-koenig@baylibre.com
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Uwe Kleine-König and committed by
Lee Jones
fe85a39d 2720c87b

+7 -6
+7 -6
drivers/video/backlight/mp3309c.c
··· 352 352 chip->pdata = pdata; 353 353 354 354 /* Backlight properties */ 355 - memset(&props, 0, sizeof(struct backlight_properties)); 356 - props.brightness = pdata->default_brightness; 357 - props.max_brightness = pdata->max_brightness; 358 - props.scale = BACKLIGHT_SCALE_LINEAR; 359 - props.type = BACKLIGHT_RAW; 360 - props.power = BACKLIGHT_POWER_ON; 355 + props = (typeof(props)){ 356 + .brightness = pdata->default_brightness, 357 + .max_brightness = pdata->max_brightness, 358 + .scale = BACKLIGHT_SCALE_LINEAR, 359 + .type = BACKLIGHT_RAW, 360 + .power = BACKLIGHT_POWER_ON, 361 + }; 361 362 chip->bl = devm_backlight_device_register(dev, "mp3309c", dev, chip, 362 363 &mp3309c_bl_ops, &props); 363 364 if (IS_ERR(chip->bl))