All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Florian Fainelli" <f.fainelli@gmail.com>
Cc: "open list:REAL TIME CLOCK (RTC) SUBSYSTEM"
	<linux-rtc@vger.kernel.org>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Subject: Re: [PATCH RFC] rtc: m41t80: Support SMBus adapters without I2C block transfers
Date: Tue, 03 Nov 2026 23:00:48 +0000	[thread overview]
Message-ID: <sashiko-outbox-196169@kernel.org> (raw)
In-Reply-To: <20261103225027.1248035-1-f.fainelli@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] rtc: m41t80: raw i2c_transfer() in wdt_ping() and wdt_disable() fails on SMBus
--

commit b3f3c10491b061e74e177e35683431f79685d1f4
Author: Florian Fainelli <f.fainelli@gmail.com>

rtc: m41t80: Support SMBus adapters without I2C block transfers

This commit allows rtc-m41t80 to probe on SMBus adapters that only support
SMBus byte and word transactions (such as the SiByte SMBus controller with an
M41T81) by falling back to byte writes and emulated block reads, with a
seconds recheck loop when block reads are unavailable.

Link: https://lkml.rescloud.iu.edu/hypermail/linux/kernel/0805.1/1778.html
Link: https://lkml.rescloud.iu.edu/1811.1/07408.html

> diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
> index 1385cb43864ba..23d02b95a606b 100644
> --- a/drivers/rtc/rtc-m41t80.c
> +++ b/drivers/rtc/rtc-m41t80.c

[ ... ]

> @@ -906,9 +949,9 @@ static int m41t80_probe(struct i2c_client *client)
>  	struct m41t80_data *m41t80_data = NULL;
>  	bool wakeup_source = false;
>  
> -	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK |
> +	if (!i2c_check_functionality(client->adapter,
>  				     I2C_FUNC_SMBUS_BYTE_DATA)) {
> -		dev_err(&adapter->dev, "doesn't support I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_I2C_BLOCK\n");
> +		dev_err(&adapter->dev, "doesn't support I2C_FUNC_SMBUS_BYTE_DATA\n");
>  		return -ENODEV;
>  	}

[Severity: Medium]
With m41t80_probe() now accepting SMBus-only adapters that only support
I2C_FUNC_SMBUS_BYTE_DATA and lack master_xfer (such as i2c-sibyte), what
happens when CONFIG_RTC_DRV_M41T80_WDT is enabled on an M41T80_FEATURE_HT
chip like the M41T81?

Later in m41t80_probe(), the watchdog miscdevice and reboot notifier are
still registered unconditionally for M41T80_FEATURE_HT devices:

drivers/rtc/rtc-m41t80.c:m41t80_probe() {
	...
#ifdef CONFIG_RTC_DRV_M41T80_WDT
	if (m41t80_data->features & M41T80_FEATURE_HT) {
		save_client = client;
		rc = misc_register(&wdt_dev);
		if (rc)
			return rc;
		rc = register_reboot_notifier(&wdt_notifier);
	...
}

However, wdt_ping() and wdt_disable() in drivers/rtc/rtc-m41t80.c still use
raw i2c_transfer() messages to access register 0x09 and ignore the return
value:

drivers/rtc/rtc-m41t80.c:wdt_ping() {
	...
	i2c_data[0] = 0x09;		/* watchdog register */
	...
	i2c_transfer(save_client->adapter, msgs1, 1);
}

drivers/rtc/rtc-m41t80.c:wdt_disable() {
	...
	i2c_data[0] = 0x09;
	i2c_transfer(save_client->adapter, msgs0, 2);

	i2c_data[0] = 0x09;
	i2c_data[1] = 0x00;
	i2c_transfer(save_client->adapter, msgs1, 1);
}

On an SMBus-only adapter where adapter->algo->master_xfer is NULL,
i2c_transfer() fails with -EOPNOTSUPP, so watchdog keepalives, ioctl
operations, and reboot/shutdown disable notifications via wdt_notify_sys() ->
wdt_disable() will silently fail to reach the hardware.

Should wdt_ping() and wdt_disable() be converted to use
i2c_smbus_write_byte_data() and i2c_smbus_read_byte_data() as well?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103225027.1248035-1-f.fainelli@gmail.com?part=1

  reply	other threads:[~2026-11-03 23:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 22:50 [PATCH RFC] rtc: m41t80: Support SMBus adapters without I2C block transfers Florian Fainelli
2026-11-03 23:00 ` sashiko-bot [this message]
2026-11-04  2:13 ` Maciej W. Rozycki

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=sashiko-outbox-196169@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=f.fainelli@gmail.com \
    --cc=linux-rtc@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.