On Sat, 1 Jan 2022 13:12:48 +0530 Apurva Nandan <a-nandan@xxxxxx> wrote: > Add implementation of change_mode() for Winbond's manufacturer_ops, > that executes octal_dtr_enable() and octal_dtr_disable() according > to requested protocol. > > Datasheet: https://www.winbond.com/export/sites/winbond/datasheet/W35N01JW_Datasheet_Brief.pdf > > Signed-off-by: Apurva Nandan <a-nandan@xxxxxx> > --- > drivers/mtd/nand/spi/winbond.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/drivers/mtd/nand/spi/winbond.c b/drivers/mtd/nand/spi/winbond.c > index c7478faf6cee..d8eccb40c80f 100644 > --- a/drivers/mtd/nand/spi/winbond.c > +++ b/drivers/mtd/nand/spi/winbond.c > @@ -242,8 +242,33 @@ static int winbond_spinand_octal_dtr_disable(struct spinand_device *spinand) > return 0; > } > > +static int winbond_change_spi_mode(struct spinand_device *spinand, > + const enum spinand_protocol protocol) > +{ > + if (spinand->protocol == protocol) > + return 0; > + > + switch (spinand->protocol) { > + case SPINAND_1S_1S_1S: > + if (protocol == SPINAND_8D_8D_8D) > + return winbond_spinand_octal_dtr_enable(spinand); > + break; > + > + case SPINAND_8D_8D_8D: > + if (protocol == SPINAND_1S_1S_1S) > + return winbond_spinand_octal_dtr_disable(spinand); > + break; > + > + default: > + return -EOPNOTSUPP; > + } > + > + return -EOPNOTSUPP; This version is slightly more concise: if (spinand->protocol == protocol) return 0; else if (spinand->protocol == SPINAND_1S && protocol == SPINAND_8D) return winbond_spinand_octal_dtr_enable(spinand); else if (spinand->protocol == SPINAND_8D && protocol == SPINAND_1S) return winbond_spinand_octal_dtr_disable(spinand); return -EOPNOTSUPP; > +} > + > static const struct spinand_manufacturer_ops winbond_spinand_manuf_ops = { > .init = winbond_spinand_init, > + .change_mode = winbond_change_spi_mode, > }; > > const struct spinand_manufacturer winbond_spinand_manufacturer = {