fpga: microchip-spi: rewrite status polling in a time measurable way
authorIvan Bornyakov <i.bornyakov@metrotek.ru>
Fri, 30 Dec 2022 09:29:21 +0000 (12:29 +0300)
committerXu Yilun <yilun.xu@intel.com>
Sat, 28 Jan 2023 15:20:30 +0000 (23:20 +0800)
commit88e705697e801299a13ecaf2ba54599964fe711c
treed531ba682ac458b2a7cf59335a2b00a5c71b72ee
parent1da53d23a41c5f77963984d8da5623ed56918ada
fpga: microchip-spi: rewrite status polling in a time measurable way

Original busy loop with retries count in mpf_poll_status() is not too
reliable, as it takes different times on different systems. Replace it
with read_poll_timeout() macro.

While at it, fix polling stop condition to met function's original
intention declared in the comment. The issue with original polling stop
condition is that it stops if any of mask bits is set, while intention
was to stop if all mask bits is set. This was not noticible because only
MPF_STATUS_READY is passed as mask argument and it is BIT(1).

Fixes: 5f8d4a900830 ("fpga: microchip-spi: add Microchip MPF FPGA manager")
Signed-off-by: Ivan Bornyakov <i.bornyakov@metrotek.ru>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
Link: https://lore.kernel.org/r/20221230092922.18822-3-i.bornyakov@metrotek.ru
Signed-off-by: Xu Yilun <yilun.xu@intel.com>
drivers/fpga/microchip-spi.c