mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Sven Peter <sven@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH] usb: typec: tipd: Fix error handling in cd321x_read_data_status
Date: Mon, 22 Sep 2025 16:52:51 +0300	[thread overview]
Message-ID: <aNFUs9CqtLq7ozOV@kuha.fi.intel.com> (raw)
In-Reply-To: <20250920-tipd-fix-v1-1-49886d4f081d@kernel.org>

On Sat, Sep 20, 2025 at 12:28:03PM +0000, Sven Peter wrote:
> Right now cd321x_read_data_status always returns true even if it
> encounters any errors: tps6598x_read_data_status returns a boolean but
> we treated it as an errno and then we have a bunch of dev_errs in case
> tps6598x_block_read fails but just continue along and return true.
> Fix that to correctly report errors to the callee.
> 
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/linux-usb/aMvWJo3IkClmFoAA@stanley.mountain/
> Signed-off-by: Sven Peter <sven@kernel.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tipd/core.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 2b1049c9a6f3c4300f4a25a97fe502c47e82a134..d0c86347251c5cc19a9b377550c00c27966f8329 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -577,30 +577,36 @@ static bool cd321x_read_data_status(struct tps6598x *tps)
>  	int ret;
>  
>  	ret = tps6598x_read_data_status(tps);
> -	if (ret < 0)
> +	if (!ret)
>  		return false;
>  
>  	if (tps->data_status & TPS_DATA_STATUS_DP_CONNECTION) {
>  		ret = tps6598x_block_read(tps, TPS_REG_DP_SID_STATUS,
>  				&cd321x->dp_sid_status, sizeof(cd321x->dp_sid_status));
> -		if (ret)
> +		if (ret) {
>  			dev_err(tps->dev, "Failed to read DP SID Status: %d\n",
>  				ret);
> +			return false;
> +		}
>  	}
>  
>  	if (tps->data_status & TPS_DATA_STATUS_TBT_CONNECTION) {
>  		ret = tps6598x_block_read(tps, TPS_REG_INTEL_VID_STATUS,
>  				&cd321x->intel_vid_status, sizeof(cd321x->intel_vid_status));
> -		if (ret)
> +		if (ret) {
>  			dev_err(tps->dev, "Failed to read Intel VID Status: %d\n", ret);
> +			return false;
> +		}
>  	}
>  
>  	if (tps->data_status & CD321X_DATA_STATUS_USB4_CONNECTION) {
>  		ret = tps6598x_block_read(tps, TPS_REG_USB4_STATUS,
>  				&cd321x->usb4_status, sizeof(cd321x->usb4_status));
> -		if (ret)
> +		if (ret) {
>  			dev_err(tps->dev,
>  				"Failed to read USB4 Status: %d\n", ret);
> +			return false;
> +		}
>  	}
>  
>  	return true;
> 
> ---
> base-commit: a4e143636d5def935dd461539b67b61287a8dfef
> change-id: 20250920-tipd-fix-0c50f9f99a5a
> 
> Best regards,
> -- 
> Sven Peter <sven@kernel.org>
> 

-- 
heikki

      reply	other threads:[~2025-09-22 13:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-20 12:28 Sven Peter
2025-09-22 13:52 ` Heikki Krogerus [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=aNFUs9CqtLq7ozOV@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sven@kernel.org \
    /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

all inboxes | Powered by JetHome®