Skip to content

Commit 36f18ae

Browse files
ahunter6alexandrebelloni
authored andcommitted
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>
1 parent 58a9ae6 commit 36f18ae

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
#include <linux/acpi.h>
1010
#include <linux/idr.h>
11+
#include <linux/iopoll.h>
1112
#include <linux/kernel.h>
1213
#include <linux/module.h>
1314
#include <linux/pci.h>
@@ -24,11 +25,12 @@ static DEFINE_IDA(mipi_i3c_hci_pci_ida);
2425
#define INTEL_RESETS 0x04
2526
#define INTEL_RESETS_RESET BIT(0)
2627
#define INTEL_RESETS_RESET_DONE BIT(1)
28+
#define INTEL_RESETS_TIMEOUT_US (10 * USEC_PER_MSEC)
2729

2830
static int intel_i3c_init(struct pci_dev *pci)
2931
{
30-
unsigned long timeout;
3132
void __iomem *priv;
33+
u32 reg;
3234

3335
priv = devm_ioremap(&pci->dev,
3436
pci_resource_start(pci, 0) + INTEL_PRIV_OFFSET,
@@ -40,13 +42,9 @@ static int intel_i3c_init(struct pci_dev *pci)
4042

4143
/* Assert reset, wait for completion and release reset */
4244
writel(0, priv + INTEL_RESETS);
43-
timeout = jiffies + msecs_to_jiffies(10);
44-
while (!(readl(priv + INTEL_RESETS) &
45-
INTEL_RESETS_RESET_DONE)) {
46-
if (time_after(jiffies, timeout))
47-
break;
48-
cpu_relax();
49-
}
45+
readl_poll_timeout(priv + INTEL_RESETS, reg,
46+
reg & INTEL_RESETS_RESET_DONE, 0,
47+
INTEL_RESETS_TIMEOUT_US);
5048
writel(INTEL_RESETS_RESET, priv + INTEL_RESETS);
5149

5250
return 0;

0 commit comments

Comments
 (0)