From patchwork Mon Oct 31 17:50:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 13373 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2456147wru; Mon, 31 Oct 2022 10:56:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM76WuerQdtSR4ZIGgOu1B+tLTh9TA/MTSFJGWQV4mNjDvGGYqdmml61Muku/F8q5xpfIu8H X-Received: by 2002:aa7:ce09:0:b0:461:5406:20e4 with SMTP id d9-20020aa7ce09000000b00461540620e4mr15173896edv.5.1667238977904; Mon, 31 Oct 2022 10:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667238977; cv=none; d=google.com; s=arc-20160816; b=YTSf7KSMQyI+QwvO8JogWkv19xtFeUMvsLkeyLoC7RIvCNsmoksETsTZK8ZU5hIQAh 8of+xpkEJrgY4n2uKSwc5xdbZGxQ1ezVWUkSfu1/dfJZitwZzOHdAEjSA+UcM0MZ68iw 3NoDhot7wvngTvtwqI1dvyAFrkdPriWYGFInK0vj3rwWzmWp0eAGTvKG4HxrSY0KqU3n AZ/stoRjQObKzNxat22uDUktwFWOdP8cT2ULzWb/7DfTYqjf+oXj2ws1bo6cVqWTC6OZ TjYWclOBnD2X4U5+Muf70P0I62AFHHc0uZHyoDuuCnaYX3yVcjn/pBRFR0REMhEOPw5E 8zdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QVYC0Xjt2esZZGe4uYJUetAUDQ8+B42xaWG4ucyBv6c=; b=kW/mgAY8r4UyLOOnaJvnsqBJsFSlfbkr1dqKj2L7GkUpYkdVV6VczWs3XcRqNrEnC1 cSmshFFfvbhgs5lxut9mLtjQI9UUsXxG2+yq3KgwoTuM+HmnmGnl2J2P/FopF7aYy5u9 iOQmHpnTron8Huc0wrCdnhidYvKK3o8IqJtMTkUsan4YdATIOiDZF4Ey9EndBCd+uyFE FheM7dYinkvy5MlC5CYf5gHTgFZLofYAFkQkBonCbeq7baSyqIobTNTWuM9X74v8+l7+ ibXIcxcgXqaAabxRila1plKCRYv8bGNjhrApCcuTgAVSAo9WJfw7k6sItoM7HG1UxLcj KPcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WwSB0Vi3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id my15-20020a1709065a4f00b0079e925b0200si6992242ejc.59.2022.10.31.10.55.52; Mon, 31 Oct 2022 10:56:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=WwSB0Vi3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231540AbiJaRva (ORCPT + 99 others); Mon, 31 Oct 2022 13:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231888AbiJaRvL (ORCPT ); Mon, 31 Oct 2022 13:51:11 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58E1C63BA; Mon, 31 Oct 2022 10:51:09 -0700 (PDT) Received: from jupiter.universe (dyndsl-095-033-157-181.ewe-ip-backbone.de [95.33.157.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8817B6602948; Mon, 31 Oct 2022 17:51:03 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1667238663; bh=kGeCW1YTwGhNttEL0JAP5rbTFVI1UH3AbwhQ1VzHwhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WwSB0Vi3Lb7nP++iI7kmLX9IXeF6EV96YGvhOgFlyjostnFF9O5UvudkathyoVGND SPrk/qjwdnYvvBIThFino+OiEGBADYgwxoQVajMf8omGdWS6wWfKuuDdCIq9+fCkvE PsGjpcwVSNRWHjIlyTkPIXGgfnB9Fjg8oIFa4+2/Z0xe5M62ayZYHIa3AKI/btVlri IBuhp5kMLvNfbhde3lLuunzXrxKmpgh0ezM2UyKP7BYGSSAJEHTWXvFba1Id5u7P6Q RAUOQ/YT0ctizL/yP4b7NCbK17hpIh1tpkl5AGazB8/RZc3gh06NvIn1xllZckkoBG IfX8WAPKDOqng== Received: by jupiter.universe (Postfix, from userid 1000) id 5529F4801D1; Mon, 31 Oct 2022 18:50:59 +0100 (CET) From: Sebastian Reichel To: Heiko Stuebner , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui Cc: Rob Herring , Krzysztof Kozlowski , linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , kernel@collabora.com Subject: [PATCH 5/7] thermal: rockchip: Support dynamic sized sensor array Date: Mon, 31 Oct 2022 18:50:56 +0100 Message-Id: <20221031175058.175698-6-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221031175058.175698-1-sebastian.reichel@collabora.com> References: <20221031175058.175698-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748226778202136385?= X-GMAIL-MSGID: =?utf-8?q?1748226778202136385?= Dynamically allocate the sensors array based on the amount of platform sensors in preparation for rk3588 support, which needs 7 sensors. Signed-off-by: Sebastian Reichel Reviewed-by: Heiko Stuebner --- drivers/thermal/rockchip_thermal.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index a547e44e2b64..c9d04b58a1e5 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; @@ -1367,6 +1361,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; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); thermal->regs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(thermal->regs))