mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
mtd: spi-nor: Make sure nor->spimem and nor->controller_ops are mutually exclusive
Expand the spi_nor_check() to make sure that nor->spimem and
nor->controller_ops are mutually exclusive.
Fixes: b35b9a1036
("mtd: spi-nor: Move m25p80 code in spi-nor.c")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
This commit is contained in:
parent
658488ed21
commit
ac82229d4e
1 changed files with 6 additions and 0 deletions
|
@ -2878,6 +2878,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
|
|||
static int spi_nor_check(struct spi_nor *nor)
|
||||
{
|
||||
if (!nor->dev ||
|
||||
(!nor->spimem && !nor->controller_ops) ||
|
||||
(!nor->spimem && nor->controller_ops &&
|
||||
(!nor->controller_ops->read ||
|
||||
!nor->controller_ops->write ||
|
||||
|
@ -2887,6 +2888,11 @@ static int spi_nor_check(struct spi_nor *nor)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (nor->spimem && nor->controller_ops) {
|
||||
dev_err(nor->dev, "nor->spimem and nor->controller_ops are mutually exclusive, please set just one of them.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue