Commit 760c435e authored by Miquel Raynal's avatar Miquel Raynal

mtd: rawnand: make subop helpers return unsigned values

A report from Colin Ian King pointed a CoverityScan issue where error
values on these helpers where not checked in the drivers. These
helpers can error out only in case of a software bug in driver code,
not because of a runtime/hardware error. Hence, let's WARN_ON() in this
case and return 0 which is harmless anyway.

Fixes: 8878b126 ("mtd: nand: add ->exec_op() implementation")
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent d166541e
...@@ -2668,7 +2668,7 @@ static bool nand_subop_instr_is_valid(const struct nand_subop *subop, ...@@ -2668,7 +2668,7 @@ static bool nand_subop_instr_is_valid(const struct nand_subop *subop,
return subop && instr_idx < subop->ninstrs; return subop && instr_idx < subop->ninstrs;
} }
static int nand_subop_get_start_off(const struct nand_subop *subop, static unsigned int nand_subop_get_start_off(const struct nand_subop *subop,
unsigned int instr_idx) unsigned int instr_idx)
{ {
if (instr_idx) if (instr_idx)
...@@ -2688,12 +2688,12 @@ static int nand_subop_get_start_off(const struct nand_subop *subop, ...@@ -2688,12 +2688,12 @@ static int nand_subop_get_start_off(const struct nand_subop *subop,
* *
* Given an address instruction, returns the offset of the first cycle to issue. * Given an address instruction, returns the offset of the first cycle to issue.
*/ */
int nand_subop_get_addr_start_off(const struct nand_subop *subop, unsigned int nand_subop_get_addr_start_off(const struct nand_subop *subop,
unsigned int instr_idx) unsigned int instr_idx)
{ {
if (!nand_subop_instr_is_valid(subop, instr_idx) || if (WARN_ON(!nand_subop_instr_is_valid(subop, instr_idx) ||
subop->instrs[instr_idx].type != NAND_OP_ADDR_INSTR) subop->instrs[instr_idx].type != NAND_OP_ADDR_INSTR))
return -EINVAL; return 0;
return nand_subop_get_start_off(subop, instr_idx); return nand_subop_get_start_off(subop, instr_idx);
} }
...@@ -2710,14 +2710,14 @@ EXPORT_SYMBOL_GPL(nand_subop_get_addr_start_off); ...@@ -2710,14 +2710,14 @@ EXPORT_SYMBOL_GPL(nand_subop_get_addr_start_off);
* *
* Given an address instruction, returns the number of address cycle to issue. * Given an address instruction, returns the number of address cycle to issue.
*/ */
int nand_subop_get_num_addr_cyc(const struct nand_subop *subop, unsigned int nand_subop_get_num_addr_cyc(const struct nand_subop *subop,
unsigned int instr_idx) unsigned int instr_idx)
{ {
int start_off, end_off; int start_off, end_off;
if (!nand_subop_instr_is_valid(subop, instr_idx) || if (WARN_ON(!nand_subop_instr_is_valid(subop, instr_idx) ||
subop->instrs[instr_idx].type != NAND_OP_ADDR_INSTR) subop->instrs[instr_idx].type != NAND_OP_ADDR_INSTR))
return -EINVAL; return 0;
start_off = nand_subop_get_addr_start_off(subop, instr_idx); start_off = nand_subop_get_addr_start_off(subop, instr_idx);
...@@ -2742,12 +2742,12 @@ EXPORT_SYMBOL_GPL(nand_subop_get_num_addr_cyc); ...@@ -2742,12 +2742,12 @@ EXPORT_SYMBOL_GPL(nand_subop_get_num_addr_cyc);
* *
* Given a data instruction, returns the offset to start from. * Given a data instruction, returns the offset to start from.
*/ */
int nand_subop_get_data_start_off(const struct nand_subop *subop, unsigned int nand_subop_get_data_start_off(const struct nand_subop *subop,
unsigned int instr_idx) unsigned int instr_idx)
{ {
if (!nand_subop_instr_is_valid(subop, instr_idx) || if (WARN_ON(!nand_subop_instr_is_valid(subop, instr_idx) ||
!nand_instr_is_data(&subop->instrs[instr_idx])) !nand_instr_is_data(&subop->instrs[instr_idx])))
return -EINVAL; return 0;
return nand_subop_get_start_off(subop, instr_idx); return nand_subop_get_start_off(subop, instr_idx);
} }
...@@ -2764,14 +2764,14 @@ EXPORT_SYMBOL_GPL(nand_subop_get_data_start_off); ...@@ -2764,14 +2764,14 @@ EXPORT_SYMBOL_GPL(nand_subop_get_data_start_off);
* *
* Returns the length of the chunk of data to send/receive. * Returns the length of the chunk of data to send/receive.
*/ */
int nand_subop_get_data_len(const struct nand_subop *subop, unsigned int nand_subop_get_data_len(const struct nand_subop *subop,
unsigned int instr_idx) unsigned int instr_idx)
{ {
int start_off = 0, end_off; int start_off = 0, end_off;
if (!nand_subop_instr_is_valid(subop, instr_idx) || if (WARN_ON(!nand_subop_instr_is_valid(subop, instr_idx) ||
!nand_instr_is_data(&subop->instrs[instr_idx])) !nand_instr_is_data(&subop->instrs[instr_idx])))
return -EINVAL; return 0;
start_off = nand_subop_get_data_start_off(subop, instr_idx); start_off = nand_subop_get_data_start_off(subop, instr_idx);
......
...@@ -1007,13 +1007,13 @@ struct nand_subop { ...@@ -1007,13 +1007,13 @@ struct nand_subop {
unsigned int last_instr_end_off; unsigned int last_instr_end_off;
}; };
int nand_subop_get_addr_start_off(const struct nand_subop *subop, unsigned int nand_subop_get_addr_start_off(const struct nand_subop *subop,
unsigned int op_id); unsigned int op_id);
int nand_subop_get_num_addr_cyc(const struct nand_subop *subop, unsigned int nand_subop_get_num_addr_cyc(const struct nand_subop *subop,
unsigned int op_id); unsigned int op_id);
int nand_subop_get_data_start_off(const struct nand_subop *subop, unsigned int nand_subop_get_data_start_off(const struct nand_subop *subop,
unsigned int op_id); unsigned int op_id);
int nand_subop_get_data_len(const struct nand_subop *subop, unsigned int nand_subop_get_data_len(const struct nand_subop *subop,
unsigned int op_id); unsigned int op_id);
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment