From: sashiko-bot@kernel.org
To: "Abdurrahman Hussain via B4 Relay"
<devnull+abdurrahman.nexthop.ai@kernel.org>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 6/7] hwmon: (pmbus/adm1266) register rtc_class device backed by SET_RTC
Date: Sat, 09 May 2026 02:26:16 +0000 [thread overview]
Message-ID: <20260509022617.35752C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508-adm1266-v1-6-ec08bf29e0ce@nexthop.ai>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] 64-bit division using the `/` operator will cause a build failure on 32-bit architectures.
- [High] RTC operations bypass mandatory subsystem locking rules.
- [Medium] Unchecked arithmetic truncation of 64-bit system time during device probe.
--
commit 8d9788960851cdc09e1d770587afd7363eaefe26
Author: Abdurrahman Hussain <abdurrahman@nexthop.ai>
hwmon: (pmbus/adm1266) register rtc_class device backed by SET_RTC
This commit registers an rtc_class device backed by the SET_RTC block-R/W
register to allow userspace to frequently synchronize the ADM1266 UNIX
time. It maps the standard /dev/rtcN ->set_time and ->read_time operations
to the 6-byte SET_RTC frame. The probe-time wall-clock seed is also
preserved.
> diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c
> index a058616d42156..07c20746f0831 100644
> --- a/drivers/hwmon/pmbus/adm1266.c
> +++ b/drivers/hwmon/pmbus/adm1266.c
> @@ -513,28 +514,85 @@ static int adm1266_config_nvmem(struct adm1266_data *data)
> return 0;
> }
>
> -static int adm1266_set_rtc(struct adm1266_data *data)
> +/*
> + * SET_RTC frame layout (datasheet Rev. D, Table 84):
> + * bytes [1:0] = fractional seconds, LSB = 1/65536 s
> + * bytes [5:2] = seconds since 1970-01-01 UTC
> + */
> +static int adm1266_write_rtc(struct i2c_client *client, const struct timespec64 *ts)
> {
> - struct timespec64 ts;
> - char write_buf[6];
> + u8 buf[6];
> u16 frac;
> int i;
>
> + frac = (u16)(((u64)ts->tv_nsec << 16) / NSEC_PER_SEC);
Will this 64-bit division cause a link error on 32-bit architectures?
Using the / operator on a 64-bit integer can lead to undefined references to
__udivdi3 on 32-bit builds. Could this use div_u64() instead?
> + for (i = 0; i < 2; i++)
> + buf[i] = (frac >> (i * 8)) & 0xFF;
> + for (i = 0; i < 4; i++)
> + buf[2 + i] = (ts->tv_sec >> (i * 8)) & 0xFF;
Since ts->tv_sec is a 64-bit value, does this loop silently truncate values
exceeding 32 bits when called during probe?
adm1266_probe()
adm1266_set_rtc()
adm1266_write_rtc()
The hwmon subsystem guidelines ask to check for overflows in arithmetic
calculations.
> +
> + return i2c_smbus_write_block_data(client, ADM1266_SET_RTC, sizeof(buf), buf);
> +}
[ ... ]
> +static int adm1266_rtc_read_time(struct device *dev, struct rtc_time *tm)
> +{
> + struct i2c_client *client = to_i2c_client(dev);
> + u8 buf[I2C_SMBUS_BLOCK_MAX];
> + u32 secs;
> + int ret;
> + int i;
> +
> + ret = i2c_smbus_read_block_data(client, ADM1266_SET_RTC, buf);
The hardware monitoring subsystem guidelines state that drivers must implement
locking for attributes registered by any other means.
Are these callbacks missing a call to hwmon_lock() (or pmbus_lock())?
If an RTC class device implicitly exposes time attributes to userspace, could
these concurrent I2C accesses risk disrupting stateful hardware transactions?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260508-adm1266-v1-0-ec08bf29e0ce@nexthop.ai?part=6
next prev parent reply other threads:[~2026-05-09 2:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 23:33 [PATCH 0/7] hwmon: (pmbus/adm1266) RTC fix, blackbox, FW rev, rtc_class Abdurrahman Hussain via B4 Relay
2026-05-08 23:33 ` [PATCH 1/7] hwmon: (pmbus/adm1266) use wall-clock seconds for SET_RTC Abdurrahman Hussain via B4 Relay
2026-05-08 23:48 ` sashiko-bot
2026-05-08 23:33 ` [PATCH 2/7] hwmon: (pmbus/adm1266) write fractional-seconds field of SET_RTC Abdurrahman Hussain via B4 Relay
2026-05-09 0:06 ` sashiko-bot
2026-05-08 23:33 ` [PATCH 3/7] hwmon: (pmbus/adm1266) add firmware_revision debugfs entry Abdurrahman Hussain via B4 Relay
2026-05-09 0:38 ` sashiko-bot
2026-05-08 23:33 ` [PATCH 4/7] hwmon: (pmbus/adm1266) add clear_blackbox " Abdurrahman Hussain via B4 Relay
2026-05-09 1:10 ` sashiko-bot
2026-05-08 23:33 ` [PATCH 5/7] hwmon: (pmbus/adm1266) add powerup_counter " Abdurrahman Hussain via B4 Relay
2026-05-09 1:48 ` sashiko-bot
2026-05-08 23:33 ` [PATCH 6/7] hwmon: (pmbus/adm1266) register rtc_class device backed by SET_RTC Abdurrahman Hussain via B4 Relay
2026-05-09 2:26 ` sashiko-bot [this message]
2026-05-08 23:33 ` [PATCH 7/7] hwmon: (pmbus/adm1266) include adapter number in GPIO line label Abdurrahman Hussain via B4 Relay
2026-05-09 2:39 ` sashiko-bot
2026-05-09 14:14 ` [PATCH 0/7] hwmon: (pmbus/adm1266) RTC fix, blackbox, FW rev, rtc_class Guenter Roeck
2026-05-09 21:58 ` Abdurrahman Hussain
2026-05-09 23:49 ` Guenter Roeck
2026-05-11 3:46 ` Abdurrahman Hussain
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=20260509022617.35752C2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=devnull+abdurrahman.nexthop.ai@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox