summaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-mtk-nor.c
diff options
context:
space:
mode:
authorIkjoon Jang <ikjn@chromium.org>2020-08-26 11:18:52 +0200
committerMark Brown <broonie@kernel.org>2020-09-08 19:19:32 +0200
commita59b2c7c56bf795cc13139d2634e86a3da7a0314 (patch)
tree53a8ff7bd7ce7e4ff6c33d9afa923d4a5706492a /drivers/spi/spi-mtk-nor.c
parentspi: tegra20: Simplify with dev_err_probe() (diff)
downloadlinux-a59b2c7c56bf795cc13139d2634e86a3da7a0314.tar.xz
linux-a59b2c7c56bf795cc13139d2634e86a3da7a0314.zip
spi: spi-mtk-nor: support standard spi properties
Use default supports_op() to support spi-[rt]x-bus-width properties. And check dummy op's byte length instead of its bus width for output. Signed-off-by: Ikjoon Jang <ikjn@chromium.org> Link: https://lore.kernel.org/r/20200826091852.519138-1-ikjn@chromium.org Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to '')
-rw-r--r--drivers/spi/spi-mtk-nor.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/spi/spi-mtk-nor.c b/drivers/spi/spi-mtk-nor.c
index b08d8e9a8ee9..6e6ca2b8e6c8 100644
--- a/drivers/spi/spi-mtk-nor.c
+++ b/drivers/spi/spi-mtk-nor.c
@@ -211,25 +211,28 @@ static bool mtk_nor_supports_op(struct spi_mem *mem,
if (op->cmd.buswidth != 1)
return false;
- /* DTR ops not supported. */
- if (op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr)
- return false;
- if (op->cmd.nbytes != 1)
- return false;
-
if ((op->addr.nbytes == 3) || (op->addr.nbytes == 4)) {
- if ((op->data.dir == SPI_MEM_DATA_IN) && mtk_nor_match_read(op))
- return true;
- else if (op->data.dir == SPI_MEM_DATA_OUT)
- return (op->addr.buswidth == 1) &&
- (op->dummy.buswidth == 0) &&
- (op->data.buswidth == 1);
+ switch(op->data.dir) {
+ case SPI_MEM_DATA_IN:
+ if (!mtk_nor_match_read(op))
+ return false;
+ break;
+ case SPI_MEM_DATA_OUT:
+ if ((op->addr.buswidth != 1) ||
+ (op->dummy.nbytes != 0) ||
+ (op->data.buswidth != 1))
+ return false;
+ break;
+ default:
+ break;
+ }
}
len = op->cmd.nbytes + op->addr.nbytes + op->dummy.nbytes;
if ((len > MTK_NOR_PRG_MAX_SIZE) ||
((op->data.nbytes) && (len == MTK_NOR_PRG_MAX_SIZE)))
return false;
- return true;
+
+ return spi_mem_default_supports_op(mem, op);
}
static void mtk_nor_setup_bus(struct mtk_nor *sp, const struct spi_mem_op *op)