i3c: mipi-i3c-hci-pci: Use readl_poll_timeout()

Use readl_poll_timeout() instead of open-coding the polling loop.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20251128064038.55158-5-adrian.hunter@intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
This commit is contained in:
Adrian Hunter 2025-11-28 08:40:30 +02:00 committed by Alexandre Belloni
parent 58a9ae6371
commit 36f18ae15c

View File

@ -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;