All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Johan Dahlin" <jdahlin@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 5/5] hwmon: (nct6683) Enable pwm control on ASRock B850 Steel Legend WiFi
Date: Tue, 25 Aug 2026 09:38:12 +0000	[thread overview]
Message-ID: <20260825093812.ECD761F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825092546.669450-6-jdahlin@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The sysfs show/store callbacks for 'pwm' and 'pwm_enable' attributes incorrectly cast the incoming attribute pointer to `struct sensor_device_attribute_2`, causing broken behavior on Big Endian systems.
--

--- Patch [5]: [PATCH 5/5] hwmon: (nct6683) Enable pwm control on ASRock B850 Steel Legend WiFi ---
commit 098ac72f5515df05870f944950a3f04a964252c2
Author: Johan Dahlin <jdahlin@gmail.com>

hwmon: (nct6683) Enable pwm control on ASRock B850 Steel Legend WiFi

Fan control has been measured on this board: with a fan in manual mode the
applied pwm value tracks what is written, and the fan responds
proportionally from 337 RPM at pwm 60 to 933 RPM at pwm 255.

Allow pwm writes on this board.

> diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c
> index 6825e6c3af34f..df28055b1a1c4 100644
> --- a/drivers/hwmon/nct6683.c
> +++ b/drivers/hwmon/nct6683.c
> @@ -972,7 +972,8 @@ SENSOR_TEMPLATE(pwm, "pwm%d", S_IRUGO, show_pwm, store_pwm, 0);

[Severity: High]
This is a pre-existing issue, but since this patch enables PWM writes for
a new board, is there a type punning bug in the PWM sysfs callbacks?

SENSOR_TEMPLATE defines these attributes as struct sensor_device_attribute,
which has an 'int index' field (4 bytes). However, the callbacks like
show_pwm() and store_pwm() cast this attribute to
struct sensor_device_attribute_2:

drivers/hwmon/nct6683.c:show_pwm() {
    struct sensor_device_attribute_2 *sattr = to_sensor_dev_attr_2(attr);
    int index = sattr->index;
    ...
}

struct sensor_device_attribute_2 uses a 'u8 index' (1 byte). On Big Endian
systems, reading the 1-byte u8 from a 4-byte int will yield 0 instead of
the true index, so all PWM attribute accesses will incorrectly target
channel 0.

Does this need to be fixed to use to_sensor_dev_attr(attr) instead?

>   */
>  static bool nct6683_has_fan_control(struct nct6683_data *data)
>  {
> -	return data->customer_id == NCT6683_CUSTOMER_ID_MITAC;
> +	return data->customer_id == NCT6683_CUSTOMER_ID_MITAC ||
> +	       data->customer_id == NCT6683_CUSTOMER_ID_ASROCK8;
>  }
>  
>  /*

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260825092546.669450-1-jdahlin@gmail.com?part=5

  reply	other threads:[~2026-08-25  9:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  9:25 [PATCH 0/5] hwmon: (nct6683) Fan control for ASRock B850 Steel Legend WiFi Johan Dahlin
2026-08-25  9:25 ` [PATCH 1/5] hwmon: (nct6683) Retry pwm writes until they take effect Johan Dahlin
2026-08-25  9:34   ` sashiko-bot
2026-08-25  9:25 ` [PATCH 2/5] hwmon: (nct6683) Add customer ID for ASRock B850 Steel Legend WiFi Johan Dahlin
2026-08-25  9:28   ` sashiko-bot
2026-08-25  9:25 ` [PATCH 3/5] hwmon: (nct6683) Add pwm[1-8]_enable Johan Dahlin
2026-08-25  9:44   ` sashiko-bot
2026-08-28 16:17     ` Guenter Roeck
2026-08-25  9:25 ` [PATCH 4/5] hwmon: (nct6683) Restore fan control mode on driver removal Johan Dahlin
2026-08-25  9:33   ` sashiko-bot
2026-08-25  9:25 ` [PATCH 5/5] hwmon: (nct6683) Enable pwm control on ASRock B850 Steel Legend WiFi Johan Dahlin
2026-08-25  9:38   ` sashiko-bot [this message]
2026-09-17 17:35   ` Fabio Baltieri
2026-09-17 20:03     ` Guenter Roeck

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=20260825093812.ECD761F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jdahlin@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.