[PATCH V2 04/13] i3c: mipi-i3c-hci-pci: Use readl_poll_timeout()

Frank Li Frank.li at nxp.com
Fri Nov 14 11:44:51 PST 2025


On Fri, Nov 14, 2025 at 08:13:47PM +0200, Adrian Hunter wrote:
> Use readl_poll_timeout() instead of open-coding the polling loop.
>
> Signed-off-by: Adrian Hunter <adrian.hunter at intel.com>
> ---

Reviewed-by: Frank Li <Frank.Li at nxp.com>

>
>
> Changes in V2:
>
> 	Change 10000 to (10 * USEC_PER_MSEC)
>
>
>  drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c b/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
> index d434e2962740..30915d78045e 100644
> --- a/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
> +++ b/drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
> @@ -8,6 +8,7 @@
>   */
>  #include <linux/acpi.h>
>  #include <linux/idr.h>
> +#include <linux/iopoll.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/pci.h>
> @@ -24,11 +25,12 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
>  #define INTEL_RESETS			0x04
>  #define INTEL_RESETS_RESET		BIT(0)
>  #define INTEL_RESETS_RESET_DONE		BIT(1)
> +#define INTEL_RESETS_TIMEOUT_US		(10 * USEC_PER_MSEC)
>
>  static int intel_i3c_init(struct pci_dev *pci)
>  {
> -	unsigned long timeout;
>  	void __iomem *priv;
> +	u32 reg;
>
>  	priv = devm_ioremap(&pci->dev,
>  			    pci_resource_start(pci, 0) + INTEL_PRIV_OFFSET,
> @@ -40,13 +42,9 @@ static int intel_i3c_init(struct pci_dev *pci)
>
>  	/* Assert reset, wait for completion and release reset */
>  	writel(0, priv + INTEL_RESETS);
> -	timeout = jiffies + msecs_to_jiffies(10);
> -	while (!(readl(priv + INTEL_RESETS) &
> -		 INTEL_RESETS_RESET_DONE)) {
> -		if (time_after(jiffies, timeout))
> -			break;
> -		cpu_relax();
> -	}
> +	readl_poll_timeout(priv + INTEL_RESETS, reg,
> +			   reg & INTEL_RESETS_RESET_DONE, 0,
> +			   INTEL_RESETS_TIMEOUT_US);
>  	writel(INTEL_RESETS_RESET, priv + INTEL_RESETS);
>
>  	return 0;
> --
> 2.51.0
>
>
> --
> linux-i3c mailing list
> linux-i3c at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-i3c



More information about the linux-i3c mailing list