public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Avri Altman <avri.altman@wdc.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: ufs: Do not open code read_poll_timeout
Date: Fri, 20 Sep 2024 11:23:37 -0700	[thread overview]
Message-ID: <ff33de4f-d111-4499-afff-231baaccf61c@acm.org> (raw)
In-Reply-To: <20240919112442.48491-1-avri.altman@wdc.com>

On 9/19/24 4:24 AM, Avri Altman wrote:
> ufshcd_wait_for_register practically does just that - replace with
> read_poll_timeout.
> 
> Signed-off-by: Avri Altman <avri.altman@wdc.com>
> ---
>   drivers/ufs/core/ufshcd.c | 22 ++++++----------------
>   1 file changed, 6 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 8ea5a82503a9..e9d06fab5f45 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -739,25 +739,15 @@ EXPORT_SYMBOL_GPL(ufshcd_delay_us);
>    * Return: -ETIMEDOUT on error, zero on success.
>    */
>   static int ufshcd_wait_for_register(struct ufs_hba *hba, u32 reg, u32 mask,
> -				u32 val, unsigned long interval_us,
> -				unsigned long timeout_ms)
> +				    u32 val, unsigned long interval_us,
> +				    unsigned long timeout_ms)
>   {
> -	int err = 0;
> -	unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
> -
> -	/* ignore bits that we don't intend to wait on */
> -	val = val & mask;
> +	u32 v;
>   
> -	while ((ufshcd_readl(hba, reg) & mask) != val) {
> -		usleep_range(interval_us, interval_us + 50);
> -		if (time_after(jiffies, timeout)) {
> -			if ((ufshcd_readl(hba, reg) & mask) != val)
> -				err = -ETIMEDOUT;
> -			break;
> -		}
> -	}
> +	val &= mask; /* ignore bits that we don't intend to wait on */
>   
> -	return err;
> +	return read_poll_timeout(ufshcd_readl, v, (v & mask) == val,
> +				 interval_us, timeout_ms * 1000, false, hba, reg);
>   }
>   
>   /**

Has it been considered to remove the ufshcd_wait_for_register() function
and to use read_poll_timeout() directly in the
ufshcd_wait_for_register() callers? The above patch makes
ufshcd_wait_for_register() so short that it's probably better to remove
this function entirely.

Thanks,

Bart.

  reply	other threads:[~2024-09-20 18:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-19 11:24 [PATCH] scsi: ufs: Do not open code read_poll_timeout Avri Altman
2024-09-20 18:23 ` Bart Van Assche [this message]
2024-09-20 19:00   ` Avri Altman
2024-09-20 19:38     ` Bart Van Assche
2024-09-20 19:38 ` Bart Van Assche
2024-10-04  1:49 ` Martin K. Petersen

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=ff33de4f-d111-4499-afff-231baaccf61c@acm.org \
    --to=bvanassche@acm.org \
    --cc=avri.altman@wdc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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