Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Larisa Grigore" <larisa.grigore@oss.nxp.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org,
	linux-scsi@vger.kernel.org, imx@lists.linux.dev,
	Frank.Li@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 01/12] scsi: ufs: dwc: Return a negative error if the link is down
Date: Tue, 22 Sep 2026 07:47:56 +0000	[thread overview]
Message-ID: <20260922074757.264A51F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922073009.1449688-2-larisa.grigore@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] scsi: ufs: dwc: ufshcd_dwc_link_is_up() propagates positive error values
--

commit bbaf6092d07a94b81e19b83041bbd45bc5f8771f
Author: Larisa Grigore <larisa.grigore@oss.nxp.com>

scsi: ufs: dwc: Return a negative error if the link is down

This commit updates ufshcd_dwc_link_is_up() to return -ENOLINK when the link
is down, rather than returning 1. It also propagates any errors returned by
ufshcd_dme_get() to the caller.

> diff --git a/drivers/ufs/host/ufshcd-dwc.c b/drivers/ufs/host/ufshcd-dwc.c
> index 21b1cf912dcc6..ccf785fce6cc6 100644
> --- a/drivers/ufs/host/ufshcd-dwc.c
> +++ b/drivers/ufs/host/ufshcd-dwc.c
> @@ -48,20 +48,23 @@ static void ufshcd_dwc_program_clk_div(struct ufs_hba *hba, u32 divider_val)
>   * ufshcd_dwc_link_is_up() - check if link is up.
>   * @hba: private structure pointer
>   *
> - * Return: 0 on success, non-zero value on failure.
> + * Return: 0 on success, a negative errno value on failure.
>   */
>  static int ufshcd_dwc_link_is_up(struct ufs_hba *hba)
>  {
>  	int dme_result = 0;
> +	int ret;
>  
> -	ufshcd_dme_get(hba, UIC_ARG_MIB(VS_POWERSTATE), &dme_result);
> +	ret = ufshcd_dme_get(hba, UIC_ARG_MIB(VS_POWERSTATE), &dme_result);
> +	if (ret)
> +		return ret;

[Severity: Low]
Are we propagating a positive error code here?

Looking at ufshcd_wait_for_uic_cmd() in drivers/ufs/core/ufshcd.c, when a DME
hardware command fails, it extracts the positive error code from the UIC
registers:

	ret = uic_cmd->argument2 & MASK_UIC_COMMAND_RESULT;

Since this value propagates up through ufshcd_dme_get(), returning it directly
means ufshcd_dwc_link_is_up() can still return positive error codes. Does this
violate the updated API contract to return a negative errno value on failure?

While upstream callers evaluate the result as a truthy value (if (err)) and the
probe safely fails without crashing, returning positive error codes violates
standard Linux driver conventions.

>  
>  	if (dme_result == UFSHCD_LINK_IS_UP) {
>  		ufshcd_set_link_active(hba);
>  		return 0;
>  	}
>  
> -	return 1;
> +	return -ENOLINK;
>  }
>  
>  /**

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260922073009.1449688-1-larisa.grigore@oss.nxp.com?part=1

  reply	other threads:[~2026-09-22  7:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  7:29 [PATCH v5 00/12] Add S32N79RDB UFS support Larisa Grigore
2026-09-22  7:29 ` [PATCH v5 01/12] scsi: ufs: dwc: Return a negative error if the link is down Larisa Grigore
2026-09-22  7:47   ` sashiko-bot [this message]
2026-09-22  7:29 ` [PATCH v5 02/12] ufs: unipro: Move Tx/Rx FSM state definitions to unipro.h Larisa Grigore
2026-09-22  7:30 ` [PATCH v5 03/12] ufs: unipro: Add TX/RX FSM state attributes Larisa Grigore
2026-09-22  7:30 ` [PATCH v5 04/12] ufs: host: Add common Hibern8 TX FSM polling helper Larisa Grigore
2026-09-22  7:30 ` [PATCH v5 05/12] scsi: ufs: Move Versal2 M-PHY CREG access helpers into ufshcd-dwc Larisa Grigore
2026-09-22  7:30 ` [PATCH v5 06/12] scsi: ufs: dwc: Export common clock divider and link status helpers Larisa Grigore
2026-09-22  7:30 ` [PATCH v5 07/12] dt-bindings: ufs: Add NXP S32N79 UFS host controller Larisa Grigore
2026-09-22  7:30 ` [PATCH v5 08/12] scsi: ufs: dwc: Sort CBCRCTRL and CBREFCLKCTRL2 by offset Larisa Grigore
2026-09-22 18:40   ` Frank Li
2026-09-22  7:30 ` [PATCH v5 09/12] scsi: ufs: Add NXP S32N79 UFS host controller driver Larisa Grigore
2026-09-22 18:51   ` Frank Li
2026-09-22  7:30 ` [PATCH v5 10/12] arm64: dts: freescale: s32n79: Add UFS host controller Larisa Grigore
2026-09-22  7:30 ` [PATCH v5 11/12] arm64: dts: freescale: s32n79-rdb: Enable UFS Larisa Grigore
2026-09-22  7:30 ` [PATCH v5 12/12] MAINTAINERS: Add NXP S32N7 UFS host controller entry Larisa Grigore

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=20260922074757.264A51F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=larisa.grigore@oss.nxp.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=robh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox