]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mtd: spinand: winbond: Create a helper to write the HS bit
authorMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 25 Mar 2026 14:01:40 +0000 (15:01 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 4 May 2026 13:25:12 +0000 (15:25 +0200)
Updating the HS bit is not complex but implies reading, setting/clearing
a bit and writing. Clean a bit this section by moving this logic in its
own helper.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
drivers/mtd/nand/spi/winbond.c

index 82383c8839f0d91670fb582b7277105d887206f2..97758f495c736a178e200e671d5c665cdc99c0e9 100644 (file)
@@ -404,13 +404,28 @@ static int w25w35nxxjw_ecc_get_status(struct spinand_device *spinand, u8 status)
        return -EINVAL;
 }
 
+static int w25n0xjw_set_sr4_hs(struct spinand_device *spinand, bool enable)
+{
+       int ret;
+       u8 sr4;
+
+       ret = spinand_read_reg_op(spinand, W25N0XJW_SR4, &sr4);
+       if (ret)
+               return ret;
+
+       if (enable)
+               sr4 |= W25N0XJW_SR4_HS;
+       else
+               sr4 &= ~W25N0XJW_SR4_HS;
+
+       return spinand_write_reg_op(spinand, W25N0XJW_SR4, sr4);
+}
+
 static int w25n0xjw_hs_cfg(struct spinand_device *spinand,
                           enum spinand_bus_interface iface)
 {
        const struct spi_mem_op *op;
        bool hs;
-       u8 sr4;
-       int ret;
 
        if (iface != SSDR)
                return -EOPNOTSUPP;
@@ -429,20 +444,7 @@ static int w25n0xjw_hs_cfg(struct spinand_device *spinand,
        else
                hs = true;
 
-       ret = spinand_read_reg_op(spinand, W25N0XJW_SR4, &sr4);
-       if (ret)
-               return ret;
-
-       if (hs)
-               sr4 |= W25N0XJW_SR4_HS;
-       else
-               sr4 &= ~W25N0XJW_SR4_HS;
-
-       ret = spinand_write_reg_op(spinand, W25N0XJW_SR4, sr4);
-       if (ret)
-               return ret;
-
-       return 0;
+       return w25n0xjw_set_sr4_hs(spinand, hs);
 }
 
 static int w35n0xjw_write_vcr(struct spinand_device *spinand, u8 reg, u8 val)