Re: [PATCH v3 4/9] mtd: rawnand: denali: switch over to ->exec_op() from legacy hooks

From: Boris Brezillon
Date: Tue Mar 12 2019 - 05:03:05 EST


On Tue, 12 Mar 2019 17:44:45 +0900
Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx> 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;
> + }
> +}