public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@amd.com>
To: marc.ferland@gmail.com
Cc: andi.shyti@kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	Marc Ferland <marc.ferland@sonatest.com>
Subject: Re: [PATCH v2] i2c: xiic: improve error message when transfer fails to start
Date: Fri, 24 May 2024 11:35:38 +0200	[thread overview]
Message-ID: <88d22b96-2754-40ba-a8d2-dcf4880446d6@amd.com> (raw)
In-Reply-To: <20240513160324.3761564-1-marc.ferland@sonatest.com>



On 5/13/24 18:03, marc.ferland@gmail.com wrote:
> From: Marc Ferland <marc.ferland@sonatest.com>
> 
> xiic_start_xfer can fail for different reasons:
> 
> - EBUSY: bus is busy or i2c messages still in tx_msg or rx_msg
> - ETIMEDOUT: timed-out trying to clear the RX fifo
> - EINVAL: wrong clock settings
> 
> Both EINVAL and ETIMEDOUT will currently print a specific error
> message followed by a generic one, for example:
> 
>      Failed to clear rx fifo
>      Error xiic_start_xfer
> 
> however EBUSY will simply output the generic message:
> 
>      Error xiic_start_xfer
> 
> which is not really helpful.
> 
> This commit adds a new error message when a busy condition is detected
> and also removes the generic message since it does not provide any
> relevant information to the user.
> 
> Signed-off-by: Marc Ferland <marc.ferland@sonatest.com>
> ---
> Changes in v2:
>   - add a message where the error actually occurs (suggested by
>     Andi Shyti)
>   - remove the generic message completely (Andi Shyti)
> 
>   drivers/i2c/busses/i2c-xiic.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
> index b9ad935d7ff3..afb242be456d 100644
> --- a/drivers/i2c/busses/i2c-xiic.c
> +++ b/drivers/i2c/busses/i2c-xiic.c
> @@ -1114,8 +1114,11 @@ static int xiic_start_xfer(struct xiic_i2c *i2c, struct i2c_msg *msgs, int num)
>   	mutex_lock(&i2c->lock);
>   
>   	ret = xiic_busy(i2c);
> -	if (ret)
> +	if (ret) {
> +		dev_err(i2c->adap.dev.parent,
> +			"cannot start a transfer while busy\n");
>   		goto out;
> +	}
>   
>   	i2c->tx_msg = msgs;
>   	i2c->rx_msg = NULL;
> @@ -1173,10 +1176,8 @@ static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
>   		return err;
>   
>   	err = xiic_start_xfer(i2c, msgs, num);
> -	if (err < 0) {
> -		dev_err(adap->dev.parent, "Error xiic_start_xfer\n");
> +	if (err < 0)
>   		goto out;
> -	}
>   
>   	err = wait_for_completion_timeout(&i2c->completion, XIIC_XFER_TIMEOUT);
>   	mutex_lock(&i2c->lock);


Acked-by: Michal Simek <michal.simek@amd.com>

Thanks,
Michal

  reply	other threads:[~2024-05-24  9:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-13 16:03 [PATCH v2] i2c: xiic: improve error message when transfer fails to start marc.ferland
2024-05-24  9:35 ` Michal Simek [this message]
2024-07-04  3:43   ` Wolfram Sang
2024-07-04  6:27 ` Andi Shyti

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=88d22b96-2754-40ba-a8d2-dcf4880446d6@amd.com \
    --to=michal.simek@amd.com \
    --cc=andi.shyti@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.ferland@gmail.com \
    --cc=marc.ferland@sonatest.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