diff options
author | Sebastian Reichel <sebastian.reichel@collabora.com> | 2023-03-08 12:22:51 +0100 |
---|---|---|
committer | Daniel Lezcano <daniel.lezcano@linaro.org> | 2023-04-07 10:31:33 +0200 |
commit | 267f596585abc78efbdda51a80dd36c65c0f6ad0 (patch) | |
tree | 1e8f59bb9379e299a0f62ced217ef606887247bf | |
parent | thermal/drivers/rockchip: Simplify channel id logic (diff) | |
download | linux-267f596585abc78efbdda51a80dd36c65c0f6ad0.tar.xz linux-267f596585abc78efbdda51a80dd36c65c0f6ad0.zip |
thermal/drivers/rockchip: Support dynamic sized sensor array
Dynamically allocate the sensors array based on the amount
of platform sensors in preparation for rk3588 support, which
needs 7 sensors.
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230308112253.15659-6-sebastian.reichel@collabora.com
-rw-r--r-- | drivers/thermal/rockchip_thermal.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index d3d9a8f9b055..dcbc5d22cbc9 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -51,12 +51,6 @@ enum adc_sort_mode { #include "thermal_hwmon.h" -/* - * The max sensors is two in rockchip SoCs. - * Two sensors: CPU and GPU sensor. - */ -#define SOC_MAX_SENSORS 2 - /** * struct chip_tsadc_table - hold information about chip-specific differences * @id: conversion table @@ -147,7 +141,7 @@ struct rockchip_thermal_data { struct platform_device *pdev; struct reset_control *reset; - struct rockchip_thermal_sensor sensors[SOC_MAX_SENSORS]; + struct rockchip_thermal_sensor *sensors; struct clk *clk; struct clk *pclk; @@ -1363,6 +1357,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) if (!thermal->chip) return -EINVAL; + thermal->sensors = devm_kcalloc(&pdev->dev, thermal->chip->chn_num, + sizeof(*thermal->sensors), GFP_KERNEL); + if (!thermal->sensors) + return -ENOMEM; + thermal->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); if (IS_ERR(thermal->regs)) return PTR_ERR(thermal->regs); |