[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190312100257.4fa142d1@collabora.com>
Date: Tue, 12 Mar 2019 10:02:57 +0100
From: Boris Brezillon <boris.brezillon@...labora.com>
To: Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc: linux-mtd@...ts.infradead.org,
Miquel Raynal <miquel.raynal@...tlin.com>,
Boris Brezillon <bbrezillon@...nel.org>,
Brian Norris <computersforpeace@...il.com>,
linux-kernel@...r.kernel.org, Marek Vasut <marek.vasut@...il.com>,
Richard Weinberger <richard@....at>,
David Woodhouse <dwmw2@...radead.org>
Subject: Re: [PATCH v3 4/9] mtd: rawnand: denali: switch over to ->exec_op()
from legacy hooks
On Tue, 12 Mar 2019 17:44:45 +0900
Masahiro Yamada <yamada.masahiro@...ionext.com> wrote:
> +
> +static int denali_exec_instr(struct nand_chip *chip,
> + const struct nand_op_instr *instr)
> +{
> + struct denali_nand_info *denali = to_denali(chip);
> + bool width16 = chip->options & NAND_BUSWIDTH_16;
> +
> + switch (instr->type) {
> + case NAND_OP_CMD_INSTR:
> + denali_exec_out8(denali, DENALI_MAP11_CMD,
> + &instr->ctx.cmd.opcode, 1);
> + return 0;
> + case NAND_OP_ADDR_INSTR:
> + denali_exec_out8(denali, DENALI_MAP11_ADDR,
> + instr->ctx.addr.addrs,
> + instr->ctx.addr.naddrs);
> + return 0;
> + case NAND_OP_DATA_IN_INSTR:
> + (!instr->ctx.data.force_8bit && width16 ?
> + denali_exec_in16 :
> + denali_exec_in8)(denali, DENALI_MAP11_DATA,
> + instr->ctx.data.buf.in,
> + instr->ctx.data.len);
I agree with Miquel, this statement tends to obfuscate the code, and
it's not like an extra if will make a huge difference in term of LOC.
> + return 0;
> + case NAND_OP_DATA_OUT_INSTR:
> + (!instr->ctx.data.force_8bit && width16 ?
> + denali_exec_out16 :
> + denali_exec_out8)(denali, DENALI_MAP11_DATA,
> + instr->ctx.data.buf.out,
> + instr->ctx.data.len);
Ditto.
> + return 0;
> + case NAND_OP_WAITRDY_INSTR:
> + return denali_exec_waitrdy(denali);
> + default:
> + WARN_ONCE(1, "unsupported NAND instruction type: %d\n",
> + instr->type);
> +
> + return -EINVAL;
> + }
> +}
Powered by blists - more mailing lists