mtd: spi-nor: fix spi_nor_lock_and_prep() usage
Subsystems (2)
PATCH 1/2 mtd: spi-nor: fix spi_nor_lock_and_prep() usage
lock_and_prep() and unlock_and_unprep() are asymmetrical. The second argument should be the same and represents the operation. This was correct before commit 8cc7f33aadc8 ("mtd: spi-nor: factor out replace-able flash_{lock,unlock}").
--- drivers/mtd/spi-nor/spi-nor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/spi-nor.c +2 -2
@@ -2047,7 +2047,7 @@ static int spi_nor_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) ret = nor->params.locking_ops->lock (nor, ofs, len); -spi_nor_unlock_and_unprep (nor,SPI_NOR_OPS_UNLOCK ); +spi_nor_unlock_and_unprep (nor,SPI_NOR_OPS_LOCK );return ret; }
@@ -2062,7 +2062,7 @@ static int spi_nor_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) ret = nor->params.locking_ops->unlock (nor, ofs, len); -spi_nor_unlock_and_unprep (nor,SPI_NOR_OPS_LOCK ); +spi_nor_unlock_and_unprep (nor,SPI_NOR_OPS_UNLOCK );return ret; }
Signature · 1 line
2.20.1
PATCH 2/2 mtd: spi-nor: fix locking argument in spi_nor_is_locked()
The second argument represents the operation which takes the lock. Add a new SPI_NOR_OPS_IS_LOCKED and use it.
--- drivers/mtd/spi-nor/spi-nor.c | 4 ++-- include/linux/mtd/spi-nor.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/mtd/spi-nor/spi-nor.c +2 -2
@@ -2071,13 +2071,13 @@ static int spi_nor_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)struct spi_nor *nor =mtd_to_spi_nor (mtd);int ret; - ret =spi_nor_lock_and_prep (nor,SPI_NOR_OPS_UNLOCK ); + ret =spi_nor_lock_and_prep (nor,SPI_NOR_OPS_IS_LOCKED );if (ret)return ret; ret = nor->params.locking_ops->is_locked (nor, ofs, len); -spi_nor_unlock_and_unprep (nor,SPI_NOR_OPS_LOCK ); +spi_nor_unlock_and_unprep (nor,SPI_NOR_OPS_IS_LOCKED );return ret; }
include/linux/mtd/spi-nor.h +1 -0
@@ -235,6 +235,7 @@ enum spi_nor_ops {SPI_NOR_OPS_ERASE ,SPI_NOR_OPS_LOCK ,SPI_NOR_OPS_UNLOCK , + SPI_NOR_OPS_IS_LOCKED, }; enum spi_nor_option_flags {
Signature · 1 line
2.20.1
Re: [PATCH 2/2] mtd: spi-nor: fix locking argument in spi_nor_is_locked()
Hi, Michael,
include/linux/mtd/spi-nor.h enum spi_nor_ops { · line 239
Quoted 10 lines · EET Michael Walle
include/linux/mtd/spi-nor.h +1
-0@@ -235,6 +235,7 @@ enum spi_nor_ops {SPI_NOR_OPS_ERASE ,SPI_NOR_OPS_LOCK ,SPI_NOR_OPS_UNLOCK , + SPI_NOR_OPS_IS_LOCKED, };
There is no NOR controller that uses this enum, can we get rid of it?
Cheers,
ta
Re: [PATCH 2/2] mtd: spi-nor: fix locking argument in spi_nor_is_locked()
Am 2020-01-13 11:10, schrieb [email protected]:
Quoted 15 lines
Hi, Michael,
include/linux/mtd/spi-nor.h enum spi_nor_ops { · line 239
Quoted 10 lines · EET Michael Walle
include/linux/mtd/spi-nor.h +1
-0@@ -235,6 +235,7 @@ enum spi_nor_ops {SPI_NOR_OPS_ERASE ,SPI_NOR_OPS_LOCK ,SPI_NOR_OPS_UNLOCK , + SPI_NOR_OPS_IS_LOCKED, };There is no NOR controller that uses this enum, can we get rid of it?
you mean the second argument of the spi_nor_lock_and_prep() and spi_nor_unlock_and_unprep()? sure. But it removes information from the prepare() callback. like in "prepare what?". From what I see its only used for locking. Maybe then rename it to prepare_lock and prepare_unlock.
-michael
Re: [PATCH 2/2] mtd: spi-nor: fix locking argument in spi_nor_is_locked()
Quoted 16 lines · EET Michael Walle
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Am 2020-01-13 11:10, schrieb [email protected]:Quoted 13 lines
Hi, Michael,
Quoted 10 lines · EET Michael Walle
include/linux/mtd/spi-nor.h +0
-0@@ -235,6 +235,7 @@ enum spi_nor_ops {SPI_NOR_OPS_ERASE ,SPI_NOR_OPS_LOCK , SPI_NOR_OPS_UNLOCK,
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
include/linux/mtd/spi-nor.h +1
-0+ SPI_NOR_OPS_IS_LOCKED,};
There is no NOR controller that uses this enum, can we get rid of it?
you mean the second argument of the
spi_nor_lock_and_prep()andspi_nor_unlock_and_unprep()? sure. But it removes information from the
yes
Quoted 1 line
prepare()callback. like in "prepare what?". From what I see its only
Prepare the controller for whatever op. As I see, it is used for taking a bus mutex and for enabling some clock.
Quoted 3 lines
used for locking. Maybe then rename it to
prepare_lockandprepare_unlock.
I would keep the function name as it is. Maybe Vignesh has some other opinion on this?
Cheers,
ta