[bug report] mtd: rawnand: qcom: Implement exec_op()

Dan Carpenter dan.carpenter at linaro.org
Mon Jul 17 00:40:08 PDT 2023


Hello Md Sadre Alam,

The patch 5c6a9518447e: "mtd: rawnand: qcom: Implement exec_op()"
from Jul 10, 2023 (linux-next), leads to the following Smatch static
checker warning:

	drivers/mtd/nand/raw/qcom_nandc.c:3018 qcom_check_op()
	warn: was && intended here instead of ||?

drivers/mtd/nand/raw/qcom_nandc.c
    3007 static int qcom_check_op(struct nand_chip *chip,
    3008                          const struct nand_operation *op)
    3009 {
    3010         const struct nand_op_instr *instr;
    3011         int op_id;
    3012 
    3013         for (op_id = 0; op_id < op->ninstrs; op_id++) {
    3014                 instr = &op->instrs[op_id];
    3015 
    3016                 switch (instr->type) {
    3017                 case NAND_OP_CMD_INSTR:
--> 3018                         if (instr->ctx.cmd.opcode != NAND_CMD_RESET ||
    3019                             instr->ctx.cmd.opcode != NAND_CMD_READID ||
    3020                             instr->ctx.cmd.opcode != NAND_CMD_PARAM ||
    3021                             instr->ctx.cmd.opcode != NAND_CMD_ERASE1 ||
    3022                             instr->ctx.cmd.opcode != NAND_CMD_ERASE2 ||
    3023                             instr->ctx.cmd.opcode != NAND_CMD_STATUS ||
    3024                             instr->ctx.cmd.opcode != NAND_CMD_PAGEPROG)
    3025                                 return -ENOTSUPP;

All the || should be &&.  It suggests that this patch needs more
testing.

    3026                         break;
    3027                 default:
    3028                         break;
    3029                 }
    3030         }
    3031 
    3032         return 0;
    3033 }

regards,
dan carpenter



More information about the linux-mtd mailing list