> > Hi Igor > > err = readx_poll_timeout(hw_atl_itr_res_irq_get, self, alt_itr_res, > alt_itr_res == 0, 10, 1000); > > The advantage of using readx_poll_timeout is that it is used by lots > of other drivers and works. It is much better to use core > infrastructure, then build your own.
Hi Andrew, agreed, but driver have more incompatible places with constructs like AQ_HW_WAIT_FOR(orig_stats_val != (aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE2_ADDR) & BIT(CAPS_HI_STATISTICS)), 1U, 10000U); For this only the following hack comes to my mind: err = readx_poll_timeout_atomic(, val, val, orig_stats_val != (aq_hw_read_reg(self, HW_ATL_FW2X_MPI_STATE2_ADDR) & BIT(CAPS_HI_STATISTICS)), 1, 10000); That way it may be better to do the following declaration then: #define do_poll_timeout_atomic(cond, sleep_us, timeout_us) \ ({ \ int _val; /* to make macro happy */ readx_poll_timeout_atomic(, _val, _val, cond, sleep_us, timeout_us); }) Another way would be just to remove AQ_HW_WAIT_FOR macro for all the hard cases and rewrite it with explicit `for` loop. But that'll reduce readability I guess. PS Found duplicating readl_poll_timeout declaration here: https://elixir.bootlin.com/linux/latest/source/drivers/phy/qualcomm/phy-qcom-ufs-i.h#L27 Not sure what's the reason, but may worth cleaning it up. Regards, Igor