]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: light: opt4060: use = { } instead of memset()
authorDavid Lechner <dlechner@baylibre.com>
Wed, 11 Jun 2025 22:39:12 +0000 (17:39 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 26 Jun 2025 18:32:57 +0000 (19:32 +0100)
Use { } instead of memset() to zero-initialize stack memory to simplify
the code.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250611-iio-zero-init-stack-with-instead-of-memset-v1-20-ebb2d0a24302@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/opt4060.c

index 88ed85cf1844a626531de6bb3070176fc4fd6ee4..566f1bb8fe2a1cb4169e31773e49456dd74398c2 100644 (file)
@@ -1083,7 +1083,7 @@ static irqreturn_t opt4060_trigger_handler(int irq, void *p)
        struct  {
                u32 chan[OPT4060_NUM_CHANS];
                aligned_s64 ts;
-       } raw;
+       } raw = { };
        int i = 0;
        int chan, ret;
 
@@ -1091,8 +1091,6 @@ static irqreturn_t opt4060_trigger_handler(int irq, void *p)
        if (iio_trigger_validate_own_device(idev->trig, idev))
                opt4060_trigger_new_samples(idev);
 
-       memset(&raw, 0, sizeof(raw));
-
        iio_for_each_active_channel(idev, chan) {
                if (chan == OPT4060_ILLUM)
                        ret = opt4060_calc_illuminance(chip, &raw.chan[i++]);