[PATCH 06/16] fpga: machxo2-spi: factor out status check for readability

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We have the same sequence at two different places, so factor it out
into a helper to improve readability.

Signed-off-by: Johannes Zink <j.zink@xxxxxxxxxxxxxx>
---
 drivers/fpga/machxo2-spi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/fpga/machxo2-spi.c b/drivers/fpga/machxo2-spi.c
index 39dd62359821..5e12612c7289 100644
--- a/drivers/fpga/machxo2-spi.c
+++ b/drivers/fpga/machxo2-spi.c
@@ -167,14 +167,19 @@ static int machxo2_cleanup(struct fpga_manager *mgr)
 	return ret;
 }
 
+static bool machxo2_status_done(unsigned long status)
+{
+	return !test_bit(BUSY, &status) && test_bit(DONE, &status) &&
+		get_err(&status) == ENOERR;
+}
+
 static enum fpga_mgr_states machxo2_spi_state(struct fpga_manager *mgr)
 {
 	struct spi_device *spi = mgr->priv;
 	unsigned long status;
 
 	get_status(spi, &status);
-	if (!test_bit(BUSY, &status) && test_bit(DONE, &status) &&
-	    get_err(&status) == ENOERR)
+	if (machxo2_status_done(status))
 		return FPGA_MGR_STATE_OPERATING;
 
 	return FPGA_MGR_STATE_UNKNOWN;
@@ -329,8 +334,7 @@ static int machxo2_write_complete(struct fpga_manager *mgr,
 		/* check refresh status */
 		get_status(spi, &status);
 		dump_status_reg(&status);
-		if (!test_bit(BUSY, &status) && test_bit(DONE, &status) &&
-		    get_err(&status) == ENOERR)
+		if (machxo2_status_done(status))
 			break;
 		if (++refreshloop == MACHXO2_MAX_REFRESH_LOOP) {
 			machxo2_cleanup(mgr);
-- 
2.30.2




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux