Commit 267f5965 authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Daniel Lezcano

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: default avatarHeiko Stuebner <heiko@sntech.de>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20230308112253.15659-6-sebastian.reichel@collabora.com
parent f7cef1b7
...@@ -51,12 +51,6 @@ enum adc_sort_mode { ...@@ -51,12 +51,6 @@ enum adc_sort_mode {
#include "thermal_hwmon.h" #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 * struct chip_tsadc_table - hold information about chip-specific differences
* @id: conversion table * @id: conversion table
...@@ -147,7 +141,7 @@ struct rockchip_thermal_data { ...@@ -147,7 +141,7 @@ struct rockchip_thermal_data {
struct platform_device *pdev; struct platform_device *pdev;
struct reset_control *reset; struct reset_control *reset;
struct rockchip_thermal_sensor sensors[SOC_MAX_SENSORS]; struct rockchip_thermal_sensor *sensors;
struct clk *clk; struct clk *clk;
struct clk *pclk; struct clk *pclk;
...@@ -1363,6 +1357,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) ...@@ -1363,6 +1357,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev)
if (!thermal->chip) if (!thermal->chip)
return -EINVAL; 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); thermal->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL);
if (IS_ERR(thermal->regs)) if (IS_ERR(thermal->regs))
return PTR_ERR(thermal->regs); return PTR_ERR(thermal->regs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment