lkml.org 
[lkml]   [2019]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 4/9] mtd: rawnand: denali: switch over to ->exec_op() from legacy hooks
On Tue, Mar 12, 2019 at 6:03 PM Boris Brezillon
<boris.brezillon@collabora.com> wrote:
>
> On Tue, 12 Mar 2019 17:44:45 +0900
> Masahiro Yamada <yamada.masahiro@socionext.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.


OK, I will add the following helpers. Before sending v4, I will wait
for more comments.



static void denali_exec_in(struct denali_controller *denali, u32 type,
u8 *buf, unsigned int len, bool width16)
{
if (width16)
denali_exec_in16(denali, type, buf, len);
else
denali_exec_in8(denali, type, buf, len);
}


static void denali_exec_out(struct denali_controller *denali, u32 type,
const u8 *buf, unsigned int len)
{
if (width16)
denali_exec_out16(denali, type, buf, len);
else
denali_exec_out8(denali, type, buf, len);
}




>
> > + 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;
> > + }
> > +}
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/



--
Best Regards
Masahiro Yamada

\
 
 \ /
  Last update: 2019-03-12 10:49    [W:0.047 / U:0.500 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site