From: Dan Carpenter <dan.carpenter@linaro.org>
To: James Calligeros <jcalligeros99@gmail.com>
Cc: Sven Peter <sven@kernel.org>, Janne Grunau <j@jannau.net>,
Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Neal Gompa <neal@gompa.dev>, Lee Jones <lee@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rtc@vger.kernel.org, linux-hwmon@vger.kernel.org,
linux-input@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v5 06/11] hwmon: Add Apple Silicon SMC hwmon driver
Date: Fri, 28 Nov 2025 11:10:39 +0300 [thread overview]
Message-ID: <aSlY_w-nXA38PrBO@stanley.mountain> (raw)
In-Reply-To: <20251112-macsmc-subdevs-v5-6-728e4b91fe81@gmail.com>
On Wed, Nov 12, 2025 at 09:16:52PM +1000, James Calligeros wrote:
> +static int macsmc_hwmon_populate_sensors(struct macsmc_hwmon *hwmon,
> + struct device_node *hwmon_node)
> +{
> + struct device_node *key_node __maybe_unused;
The for_each_child_of_node_with_prefix() macros declare key_node so this
declaration is never used so far as I can see. I thought Sparse had a
warning where we declared shadow variables where two variables have the
same name but it doesn't complain here. #strange
> + struct macsmc_hwmon_sensor *sensor;
> + u32 n_current = 0, n_fan = 0, n_power = 0, n_temperature = 0, n_voltage = 0;
> +
> + for_each_child_of_node_with_prefix(hwmon_node, key_node, "current-") {
^^^^^^^^
regards,
dan carpenter
> + n_current++;
> + }
> +
> + if (n_current) {
> + hwmon->curr.sensors = devm_kcalloc(hwmon->dev, n_current,
> + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL);
> + if (!hwmon->curr.sensors)
> + return -ENOMEM;
> +
> + for_each_child_of_node_with_prefix(hwmon_node, key_node, "current-") {
> + sensor = &hwmon->curr.sensors[hwmon->curr.count];
> + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) {
> + sensor->attrs = HWMON_C_INPUT;
> +
> + if (*sensor->label)
> + sensor->attrs |= HWMON_C_LABEL;
> +
> + hwmon->curr.count++;
> + }
> + }
> + }
> +
> + for_each_child_of_node_with_prefix(hwmon_node, key_node, "fan-") {
> + n_fan++;
> + }
> +
> + if (n_fan) {
> + hwmon->fan.fans = devm_kcalloc(hwmon->dev, n_fan,
> + sizeof(struct macsmc_hwmon_fan), GFP_KERNEL);
> + if (!hwmon->fan.fans)
> + return -ENOMEM;
> +
> + for_each_child_of_node_with_prefix(hwmon_node, key_node, "fan-") {
> + if (!macsmc_hwmon_create_fan(hwmon->dev, hwmon->smc, key_node,
> + &hwmon->fan.fans[hwmon->fan.count]))
> + hwmon->fan.count++;
> + }
> + }
> +
> + for_each_child_of_node_with_prefix(hwmon_node, key_node, "power-") {
> + n_power++;
> + }
> +
> + if (n_power) {
> + hwmon->power.sensors = devm_kcalloc(hwmon->dev, n_power,
> + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL);
> + if (!hwmon->power.sensors)
> + return -ENOMEM;
> +
> + for_each_child_of_node_with_prefix(hwmon_node, key_node, "power-") {
> + sensor = &hwmon->power.sensors[hwmon->power.count];
> + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) {
> + sensor->attrs = HWMON_P_INPUT;
> +
> + if (*sensor->label)
> + sensor->attrs |= HWMON_P_LABEL;
> +
> + hwmon->power.count++;
> + }
> + }
> + }
> +
> + for_each_child_of_node_with_prefix(hwmon_node, key_node, "temperature-") {
> + n_temperature++;
> + }
> +
> + if (n_temperature) {
> + hwmon->temp.sensors = devm_kcalloc(hwmon->dev, n_temperature,
> + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL);
> + if (!hwmon->temp.sensors)
> + return -ENOMEM;
> +
> + for_each_child_of_node_with_prefix(hwmon_node, key_node, "temperature-") {
> + sensor = &hwmon->temp.sensors[hwmon->temp.count];
> + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) {
> + sensor->attrs = HWMON_T_INPUT;
> +
> + if (*sensor->label)
> + sensor->attrs |= HWMON_T_LABEL;
> +
> + hwmon->temp.count++;
> + }
> + }
> + }
> +
> + for_each_child_of_node_with_prefix(hwmon_node, key_node, "voltage-") {
> + n_voltage++;
> + }
> +
> + if (n_voltage) {
> + hwmon->volt.sensors = devm_kcalloc(hwmon->dev, n_voltage,
> + sizeof(struct macsmc_hwmon_sensor), GFP_KERNEL);
> + if (!hwmon->volt.sensors)
> + return -ENOMEM;
> +
> + for_each_child_of_node_with_prefix(hwmon_node, key_node, "volt-") {
> + sensor = &hwmon->temp.sensors[hwmon->temp.count];
> + if (!macsmc_hwmon_create_sensor(hwmon->dev, hwmon->smc, key_node, sensor)) {
> + sensor->attrs = HWMON_I_INPUT;
> +
> + if (*sensor->label)
> + sensor->attrs |= HWMON_I_LABEL;
> +
> + hwmon->volt.count++;
> + }
> + }
> + }
> +
> + return 0;
> +}
next prev parent reply other threads:[~2025-11-28 8:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 11:16 [PATCH v5 00/11] mfd: macsmc: add rtc, hwmon and hid subdevices James Calligeros
2025-11-12 11:16 ` [PATCH v5 01/11] dt-bindings: rtc: Add Apple SMC RTC James Calligeros
2025-11-12 11:16 ` [PATCH v5 02/11] dt-bindings: hwmon: Add Apple System Management Controller hwmon schema James Calligeros
2025-11-12 11:16 ` [PATCH v5 03/11] rtc: Add new rtc-macsmc driver for Apple Silicon Macs James Calligeros
2025-11-12 11:16 ` [PATCH v5 04/11] mfd: macsmc: Wire up Apple SMC RTC subdevice James Calligeros
2025-11-12 11:16 ` [PATCH v5 05/11] mfd: macsmc: Add new __SMC_KEY macro James Calligeros
2025-11-20 13:44 ` Lee Jones
2025-11-28 10:36 ` James Calligeros
2025-11-12 11:16 ` [PATCH v5 06/11] hwmon: Add Apple Silicon SMC hwmon driver James Calligeros
2025-11-17 19:00 ` Guenter Roeck
2025-11-28 8:10 ` Dan Carpenter [this message]
2025-11-12 11:16 ` [PATCH v5 07/11] mfd: macsmc: Wire up Apple SMC hwmon subdevice James Calligeros
2025-11-12 11:16 ` [PATCH v5 08/11] input: macsmc-input: New driver to handle the Apple Mac SMC buttons/lid James Calligeros
2025-11-12 11:16 ` [PATCH v5 09/11] mfd: macsmc: Wire up Apple SMC input subdevice James Calligeros
2025-11-12 11:16 ` [PATCH v5 10/11] arm64: dts: apple: t8103,t60xx,t8112: Add SMC RTC node James Calligeros
2025-11-12 11:16 ` [PATCH v5 11/11] arm64: dts: apple: t8103, t8112, t60xx: Add hwmon SMC subdevice James Calligeros
2025-11-20 13:47 ` [PATCH v5 00/11] mfd: macsmc: add rtc, hwmon and hid subdevices Lee Jones
2025-12-08 22:09 ` (subset) " Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aSlY_w-nXA38PrBO@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=alexandre.belloni@bootlin.com \
--cc=alyssa@rosenzweig.io \
--cc=asahi@lists.linux.dev \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=j@jannau.net \
--cc=jcalligeros99@gmail.com \
--cc=jdelvare@suse.com \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=neal@gompa.dev \
--cc=robh@kernel.org \
--cc=sven@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).