* [PATCH] i2c: complain loudly if __i2c_transfer has no proper callback
@ 2024-06-06 20:36 Wolfram Sang
2024-06-08 7:24 ` Jean Delvare
0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2024-06-06 20:36 UTC (permalink / raw)
To: linux-i2c; +Cc: Jean Delvare, Wolfram Sang
In a discussion we concluded that having no working callback in
__i2c_transfer is a serious bug, so dev_dbg() is not enough. Turn it
into a WARN.
Link: https://lore.kernel.org/r/20240604171113.232628f9@endymion.delvare
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/i2c/i2c-core-base.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index db0d1ac82910..e5fd899c28c3 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -2207,10 +2207,8 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
unsigned long orig_jiffies;
int ret, try;
- if (!adap->algo->master_xfer) {
- dev_dbg(&adap->dev, "I2C level transfers not supported\n");
+ if (WARN_ON_ONCE(!adap->algo->master_xfer))
return -EOPNOTSUPP;
- }
if (WARN_ON(!msgs || num < 1))
return -EINVAL;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i2c: complain loudly if __i2c_transfer has no proper callback
2024-06-06 20:36 [PATCH] i2c: complain loudly if __i2c_transfer has no proper callback Wolfram Sang
@ 2024-06-08 7:24 ` Jean Delvare
0 siblings, 0 replies; 2+ messages in thread
From: Jean Delvare @ 2024-06-08 7:24 UTC (permalink / raw)
To: Wolfram Sang; +Cc: linux-i2c
Hi Wolfram,
On Thu, 6 Jun 2024 22:36:58 +0200, Wolfram Sang wrote:
> In a discussion we concluded that having no working callback in
> __i2c_transfer is a serious bug, so dev_dbg() is not enough. Turn it
> into a WARN.
>
> Link: https://lore.kernel.org/r/20240604171113.232628f9@endymion.delvare
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> drivers/i2c/i2c-core-base.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
> index db0d1ac82910..e5fd899c28c3 100644
> --- a/drivers/i2c/i2c-core-base.c
> +++ b/drivers/i2c/i2c-core-base.c
> @@ -2207,10 +2207,8 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
> unsigned long orig_jiffies;
> int ret, try;
>
> - if (!adap->algo->master_xfer) {
> - dev_dbg(&adap->dev, "I2C level transfers not supported\n");
> + if (WARN_ON_ONCE(!adap->algo->master_xfer))
> return -EOPNOTSUPP;
> - }
>
> if (WARN_ON(!msgs || num < 1))
> return -EINVAL;
Then you'll have to add a check on I2C_FUNC_I2C (or
adapter->algo->master_xfer, whatever you prefer) before calling
i2c_smbus_xfer_emulated(). Otherwise using i2c-dev on a slave-only
adapter will trigger the WARN_ON_ONCE immediately.
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-08 7:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-06 20:36 [PATCH] i2c: complain loudly if __i2c_transfer has no proper callback Wolfram Sang
2024-06-08 7:24 ` Jean Delvare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox