[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251127225848-GYA1797866@gentoo.org>
Date: Fri, 28 Nov 2025 06:58:48 +0800
From: Yixun Lan <dlan@...too.org>
To: Shuwei Wu <shuweiwoo@....com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Zhang Rui <rui.zhang@...el.com>, Lukasz Luba <lukasz.luba@....com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Philipp Zabel <p.zabel@...gutronix.de>,
Paul Walmsley <pjw@...nel.org>, Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>, Alexandre Ghiti <alex@...ti.fr>,
linux-pm@...r.kernel.org, devicetree@...r.kernel.org,
linux-riscv@...ts.infradead.org, spacemit@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] thermal: K1: Add driver for K1 SoC thermal sensor
Hi Shuwei,
for the title, you could simplify it by adding short prefix/annotation with
my previous comments
thermal: K1: Add driver for K1 SoC thermal sensor
-> thermal: spacemit: k1: Add thermal sensor support
On 02:44 Thu 27 Nov , Shuwei Wu wrote:
> The thermal sensor unit (TSU) on K1 supports monitoring five temperature
> zones. The driver registers these sensors with the thermal framework
> and supports standard operations:
> - Reading temperature (millidegree Celsius)
> - Setting high/low thresholds for interrupts
>
> Signed-off-by: Shuwei Wu <shuweiwoo@....com>
> ---
> drivers/thermal/Kconfig | 14 ++
> drivers/thermal/Makefile | 1 +
> drivers/thermal/k1_thermal.c | 307 +++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 322 insertions(+)
>
> +}
[snip]..
> +
> +static int k1_thermal_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct k1_thermal_priv *priv;
> + int i, irq, ret;
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->dev = dev;
> + platform_set_drvdata(pdev, priv);
> +
> + priv->base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(priv->base))
> + return PTR_ERR(priv->base);
> +
> + priv->reset = devm_reset_control_get_exclusive_deasserted(dev, NULL);
> + if (IS_ERR(priv->reset))
> + return dev_err_probe(dev, PTR_ERR(priv->reset),
> + "Failed to get/deassert reset control\n");
no need to break the line, it's ok to have 100 column per line
https://elixir.bootlin.com/linux/v6.18-rc7/source/Documentation/dev-tools/checkpatch.rst#L688
P.S: this isn't hard rule and may still up to maintainer..
> +
> + priv->clk = devm_clk_get_enabled(dev, "core");
> + if (IS_ERR(priv->clk))
> + return dev_err_probe(dev, PTR_ERR(priv->clk),
> + "Failed to get core clock\n");
ditto
> +
> + priv->bus_clk = devm_clk_get_enabled(dev, "bus");
> + if (IS_ERR(priv->bus_clk))
> + return dev_err_probe(dev, PTR_ERR(priv->bus_clk),
> + "Failed to get bus clock\n");
ditto
> +
> + irq = platform_get_irq(pdev, 0);
> + if (irq < 0)
> + return irq;
I suggest to group this with dev_request_threaded_irq(), since both of them
are taking care of IRQ related operation
> +
> + ret = k1_init_sensors(pdev);
> +
> + for (i = 0; i < MAX_SENSOR_NUMBER; ++i) {
> + priv->sensors[i].id = i;
> + priv->sensors[i].priv = priv;
> + priv->sensors[i].tzd = devm_thermal_of_zone_register(dev,
> + i, priv->sensors + i,
> + &k1_thermal_ops);
~~~~~~~~
here is wrong, alignment should match open parentheses, didn't checkpatch.pl warn about this?
> + if (IS_ERR(priv->sensors[i].tzd))
> + return dev_err_probe(dev, PTR_ERR(priv->sensors[i].tzd),
> + "Failed to register thermal zone: %d\n", i);
I'd say, no need to do the verbose print, almost every error path has
print message already
> +
> + /* Attach sysfs hwmon attributes for userspace monitoring */
> + ret = devm_thermal_add_hwmon_sysfs(dev, priv->sensors[i].tzd);
> + if (ret)
> + dev_warn(dev, "Failed to add hwmon sysfs attributes\n");
> +
> + k1_enable_sensor_irq(priv->sensors + i);
> + }
> +
> + ret = devm_request_threaded_irq(dev, irq, NULL,
> + k1_thermal_irq_thread,
> + IRQF_ONESHOT, "k1_thermal", priv);
> + if (ret < 0)
> + return dev_err_probe(dev, ret, "Failed to request IRQ\n");
no need to print extra error message, please refer to:
https://lore.kernel.org/all/20250805092922.135500-2-panchuang@vivo.com
https://github.com/torvalds/linux/commit/55b48e23f5c4b6f5ca9b7ab09599b17dcf501c10
--
Yixun Lan (dlan)
Powered by blists - more mailing lists