125 lines
3.5 KiB
Diff
125 lines
3.5 KiB
Diff
From 3462ae48d7dd80fffd0f61a8cd885a7a9016931a Mon Sep 17 00:00:00 2001
|
|
From: Tudor Ambarus <tudor.ambarus@microchip.com>
|
|
Date: Tue, 29 Oct 2019 11:16:54 +0000
|
|
Subject: [PATCH 07/39] mtd: spi-nor: Stop compare with negative in Reg Ops
|
|
methods
|
|
|
|
mainline inclusion
|
|
from mainline-v5.5-rc1
|
|
commit ebe04bfe26dd816839d3d24fdeb5f6bed430a3df
|
|
category: bugfix
|
|
bugzilla: https://gitee.com/openeuler/kernel/issues/I8CSBP
|
|
CVE: NA
|
|
|
|
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ebe04bfe26dd816839d3d24fdeb5f6bed430a3df
|
|
|
|
----------------------------------------------------------------------------
|
|
|
|
spi_mem_exec_op()
|
|
nor->controller_ops->write_reg()
|
|
nor->controller_ops->read_reg()
|
|
spi_nor_wait_till_ready()
|
|
Return 0 on success, -errno otherwise.
|
|
|
|
Stop compare with negative and compare with zero in all the register
|
|
operations methods.
|
|
|
|
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
|
|
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
|
|
Signed-off-by: YunYi Yang <yangyunyi2@huawei.com>
|
|
|
|
Conflicts:
|
|
drivers/mtd/spi-nor/spi-nor.c
|
|
---
|
|
drivers/mtd/spi-nor/spi-nor.c | 21 ++++++++++++---------
|
|
1 file changed, 12 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
|
|
index 0809018daf4c..0c9f58d8819c 100644
|
|
--- a/drivers/mtd/spi-nor/spi-nor.c
|
|
+++ b/drivers/mtd/spi-nor/spi-nor.c
|
|
@@ -267,7 +267,7 @@ static int spi_nor_read_sr(struct spi_nor *nor)
|
|
ret = nor->read_reg(nor, SPINOR_OP_RDSR, nor->bouncebuf, 1);
|
|
}
|
|
|
|
- if (ret < 0) {
|
|
+ if (ret) {
|
|
pr_err("error %d reading SR\n", (int) ret);
|
|
return ret;
|
|
}
|
|
@@ -296,7 +296,7 @@ static int spi_nor_read_fsr(struct spi_nor *nor)
|
|
ret = nor->read_reg(nor, SPINOR_OP_RDFSR, nor->bouncebuf, 1);
|
|
}
|
|
|
|
- if (ret < 0) {
|
|
+ if (ret) {
|
|
pr_err("error %d reading FSR\n", ret);
|
|
return ret;
|
|
}
|
|
@@ -325,7 +325,7 @@ static int spi_nor_read_cr(struct spi_nor *nor)
|
|
ret = nor->read_reg(nor, SPINOR_OP_RDCR, nor->bouncebuf, 1);
|
|
}
|
|
|
|
- if (ret < 0) {
|
|
+ if (ret) {
|
|
dev_err(nor->dev, "error %d reading CR\n", ret);
|
|
return ret;
|
|
}
|
|
@@ -584,7 +584,7 @@ static int s3an_sr_ready(struct spi_nor *nor)
|
|
int ret;
|
|
|
|
ret = spi_nor_xread_sr(nor, nor->bouncebuf);
|
|
- if (ret < 0) {
|
|
+ if (ret) {
|
|
dev_err(nor->dev, "error %d reading XRDSR\n", (int) ret);
|
|
return ret;
|
|
}
|
|
@@ -1640,7 +1640,7 @@ static const struct flash_info *spi_nor_read_id(struct spi_nor *nor)
|
|
tmp = nor->read_reg(nor, SPINOR_OP_RDID, id,
|
|
SPI_NOR_MAX_ID_LEN);
|
|
}
|
|
- if (tmp < 0) {
|
|
+ if (tmp) {
|
|
dev_dbg(nor->dev, "error %d reading JEDEC ID\n", tmp);
|
|
return ERR_PTR(tmp);
|
|
}
|
|
@@ -2080,20 +2080,23 @@ static int sr2_bit7_quad_enable(struct spi_nor *nor)
|
|
spi_nor_write_enable(nor);
|
|
|
|
ret = spi_nor_write_sr2(nor, sr2);
|
|
- if (ret < 0) {
|
|
+ if (ret) {
|
|
dev_err(nor->dev, "error while writing status register 2\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
ret = spi_nor_wait_till_ready(nor);
|
|
- if (ret < 0) {
|
|
+ if (ret) {
|
|
dev_err(nor->dev, "timeout while writing status register 2\n");
|
|
return ret;
|
|
}
|
|
|
|
/* Read back and check it. */
|
|
ret = spi_nor_read_sr2(nor, sr2);
|
|
- if (!(ret > 0 && (*sr2 & SR2_QUAD_EN_BIT7))) {
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ if (!(*sr2 & SR2_QUAD_EN_BIT7)) {
|
|
dev_err(nor->dev, "SR2 Quad bit not set\n");
|
|
return -EINVAL;
|
|
}
|
|
@@ -2119,7 +2122,7 @@ static int s3an_nor_scan(const struct flash_info *info, struct spi_nor *nor)
|
|
int ret;
|
|
|
|
ret = spi_nor_xread_sr(nor, nor->bouncebuf);
|
|
- if (ret < 0) {
|
|
+ if (ret) {
|
|
dev_err(nor->dev, "error %d reading XRDSR\n", (int) ret);
|
|
return ret;
|
|
}
|
|
--
|
|
2.27.0
|
|
|