]> Gentwo Git Trees - linux/.git/commitdiff
pwm: mediatek: Make use of struct_size macro
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Thu, 30 Oct 2025 22:25:27 +0000 (23:25 +0100)
committerUwe Kleine-König <ukleinek@kernel.org>
Fri, 14 Nov 2025 10:56:14 +0000 (11:56 +0100)
struct_size provides the size of a struct with a flexible array member.
Use that instead of open-coding it (with less checks than the global
macro).

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@inria.fr>
Closes: https://lore.kernel.org/r/202510301753.iqGmTwae-lkp@intel.com/
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20251030222528.632836-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
drivers/pwm/pwm-mediatek.c

index fecc1b91e14c9ebc45eaac54580f0d317de9309b..9d206303404af91e6bfc6f6c65d0362ae91c21ae 100644 (file)
@@ -444,7 +444,7 @@ static int pwm_mediatek_probe(struct platform_device *pdev)
        soc = of_device_get_match_data(&pdev->dev);
 
        chip = devm_pwmchip_alloc(&pdev->dev, soc->num_pwms,
-                                 sizeof(*pc) + soc->num_pwms * sizeof(*pc->clk_pwms));
+                                 struct_size(pc, clk_pwms, soc->num_pwms));
        if (IS_ERR(chip))
                return PTR_ERR(chip);
        pc = to_pwm_mediatek_chip(chip);