mtd: spi-nor: improve macronix_quad_enable()
authorCyrille Pitchen <cyrille.pitchen@atmel.com>
Tue, 6 Dec 2016 16:01:41 +0000 (17:01 +0100)
committerCyrille Pitchen <cyrille.pitchen@atmel.com>
Fri, 10 Feb 2017 12:54:52 +0000 (13:54 +0100)
The patch checks whether the Quad Enable bit is already set in the Status
Register. If so, the function exits immediately with a successful return
code.

Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Reviewed-by: Jagan Teki <jagan@openedev.com>
Acked-by: Marek Vasut <marek.vasut@gmail.com>
drivers/mtd/spi-nor/spi-nor.c

index be1d41d..4e35917 100644 (file)
@@ -1305,6 +1305,9 @@ static int macronix_quad_enable(struct spi_nor *nor)
        val = read_sr(nor);
        if (val < 0)
                return val;
+       if (val & SR_QUAD_EN_MX)
+               return 0;
+
        write_enable(nor);
 
        write_sr(nor, val | SR_QUAD_EN_MX);