diff --git a/target/linux/mvebu/patches-6.12/903-drivers-hwmon-Add-the-IEI-WT61P803-PUZZLE-HWMON-driv.patch b/target/linux/mvebu/patches-6.12/903-drivers-hwmon-Add-the-IEI-WT61P803-PUZZLE-HWMON-driv.patch index d83683363c..7b72c4f1ba 100644 --- a/target/linux/mvebu/patches-6.12/903-drivers-hwmon-Add-the-IEI-WT61P803-PUZZLE-HWMON-driv.patch +++ b/target/linux/mvebu/patches-6.12/903-drivers-hwmon-Add-the-IEI-WT61P803-PUZZLE-HWMON-driv.patch @@ -53,7 +53,7 @@ Cc: Robert Marko obj-$(CONFIG_SENSORS_IBMPOWERNV)+= ibmpowernv.o --- /dev/null +++ b/drivers/hwmon/iei-wt61p803-puzzle-hwmon.c -@@ -0,0 +1,447 @@ +@@ -0,0 +1,444 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* IEI WT61P803 PUZZLE MCU HWMON Driver + * @@ -83,18 +83,18 @@ Cc: Robert Marko + * @tcdev: Thermal cooling device pointer + * @name: Thermal cooling device name + * @pwm_channel: Controlled PWM channel (0 or 1) -+ * @cooling_levels: Thermal cooling device cooling levels (DT) + * @cur_level: Current cooling level + * @num_levels: Number of cooling levels ++ * @cooling_levels: Thermal cooling device cooling levels (DT) + */ +struct iei_wt61p803_puzzle_thermal_cooling_device { + struct iei_wt61p803_puzzle_hwmon *mcu_hwmon; + struct thermal_cooling_device *tcdev; + char name[THERMAL_NAME_LENGTH]; + int pwm_channel; -+ u32 *cooling_levels; + int cur_level; + u8 num_levels; ++ u32 cooling_levels[] __counted_by(num_levels); +}; + +/** @@ -401,13 +401,11 @@ Cc: Robert Marko + if (!num_levels) + return -EINVAL; + -+ cdev = devm_kzalloc(dev, sizeof(*cdev), GFP_KERNEL); ++ cdev = devm_kzalloc(dev, struct_size(cdev, cooling_levels, num_levels), GFP_KERNEL); + if (!cdev) + return -ENOMEM; + -+ cdev->cooling_levels = devm_kmalloc_array(dev, num_levels, sizeof(u32), GFP_KERNEL); -+ if (!cdev->cooling_levels) -+ return -ENOMEM; ++ cdev->num_levels = num_levels; + + ret = fwnode_property_read_u32_array(child, "cooling-levels", + cdev->cooling_levels, @@ -429,7 +427,6 @@ Cc: Robert Marko + + cdev->mcu_hwmon = mcu_hwmon; + cdev->pwm_channel = pwm_channel; -+ cdev->num_levels = num_levels; + cdev->cur_level = -1; + mcu_hwmon->cdev[pwm_channel] = cdev; +