Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Adrian Hunter and committed by
Alexandre Belloni
36f18ae1 58a9ae63

+6 -8
+6 -8
drivers/i3c/master/mipi-i3c-hci/mipi-i3c-hci-pci.c
··· 8 8 */ 9 9 #include <linux/acpi.h> 10 10 #include <linux/idr.h> 11 + #include <linux/iopoll.h> 11 12 #include <linux/kernel.h> 12 13 #include <linux/module.h> 13 14 #include <linux/pci.h> ··· 25 24 #define INTEL_RESETS 0x04 26 25 #define INTEL_RESETS_RESET BIT(0) 27 26 #define INTEL_RESETS_RESET_DONE BIT(1) 27 + #define INTEL_RESETS_TIMEOUT_US (10 * USEC_PER_MSEC) 28 28 29 29 static int intel_i3c_init(struct pci_dev *pci) 30 30 { 31 - unsigned long timeout; 32 31 void __iomem *priv; 32 + u32 reg; 33 33 34 34 priv = devm_ioremap(&pci->dev, 35 35 pci_resource_start(pci, 0) + INTEL_PRIV_OFFSET, ··· 42 40 43 41 /* Assert reset, wait for completion and release reset */ 44 42 writel(0, priv + INTEL_RESETS); 45 - timeout = jiffies + msecs_to_jiffies(10); 46 - while (!(readl(priv + INTEL_RESETS) & 47 - INTEL_RESETS_RESET_DONE)) { 48 - if (time_after(jiffies, timeout)) 49 - break; 50 - cpu_relax(); 51 - } 43 + readl_poll_timeout(priv + INTEL_RESETS, reg, 44 + reg & INTEL_RESETS_RESET_DONE, 0, 45 + INTEL_RESETS_TIMEOUT_US); 52 46 writel(INTEL_RESETS_RESET, priv + INTEL_RESETS); 53 47 54 48 return 0;