public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-i2c@vger.kernel.org
Subject: Re: [PATCH] i2c: complain loudly if __i2c_transfer has no proper callback
Date: Sat, 8 Jun 2024 09:24:28 +0200	[thread overview]
Message-ID: <20240608092428.20e1d609@endymion.delvare> (raw)
In-Reply-To: <20240606203657.22286-2-wsa+renesas@sang-engineering.com>

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

      reply	other threads:[~2024-06-08  7:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=20240608092428.20e1d609@endymion.delvare \
    --to=jdelvare@suse.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    /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