linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mtd: mtdconcat: Check existence of _read|_write from subdev'master device before assigning
@ 2021-08-17  2:45 Zhihao Cheng
  2021-08-17  2:45 ` Zhihao Cheng
  0 siblings, 1 reply; 3+ messages in thread
From: Zhihao Cheng @ 2021-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, bbrezillon
  Cc: linux-mtd, linux-kernel, chengzhihao1, yukuai3

Since 2431c4f5b46c3 ("mtd: Implement mtd_{read,write}() as wrappers
around mtd_{read,write}_oob()") don't allow _write|_read and
_write_oob|_read_oob existing at the same time. We should check the
existence of callbacks "_read and _write" from subdev's master device
(We can trust master device since it has been registered) before
assigning, otherwise following warning occurs while making
concatenated device:

  WARNING: CPU: 2 PID: 6728 at drivers/mtd/mtdcore.c:595
  add_mtd_device+0x7f/0x7b0

Fixes: 2431c4f5b46c3 ("mtd: Implement mtd_{read,write}() around ...")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
---
 drivers/mtd/mtdconcat.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index af51eee6b5e8..f685a581df48 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -694,6 +694,10 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[],	/* subdevices to c
 		concat->mtd._block_markbad = concat_block_markbad;
 	if (subdev_master->_panic_write)
 		concat->mtd._panic_write = concat_panic_write;
+	if (subdev_master->_read)
+		concat->mtd._read = concat_read;
+	if (subdev_master->_write)
+		concat->mtd._write = concat_write;
 
 	concat->mtd.ecc_stats.badblocks = subdev[0]->ecc_stats.badblocks;
 
@@ -755,8 +759,6 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[],	/* subdevices to c
 	concat->mtd.name = name;
 
 	concat->mtd._erase = concat_erase;
-	concat->mtd._read = concat_read;
-	concat->mtd._write = concat_write;
 	concat->mtd._sync = concat_sync;
 	concat->mtd._lock = concat_lock;
 	concat->mtd._unlock = concat_unlock;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mtd: mtdconcat: Check existence of _read|_write from subdev'master device before assigning
  2021-08-17  2:45 [PATCH v2] mtd: mtdconcat: Check existence of _read|_write from subdev'master device before assigning Zhihao Cheng
@ 2021-08-17  2:45 ` Zhihao Cheng
  2021-08-17 10:04   ` Miquel Raynal
  0 siblings, 1 reply; 3+ messages in thread
From: Zhihao Cheng @ 2021-08-17  2:45 UTC (permalink / raw)
  To: miquel.raynal, richard, vigneshr, bbrezillon
  Cc: linux-mtd, linux-kernel, yukuai3, sfr

在 2021/8/17 10:45, Zhihao Cheng 写道:
Hi Miquel,
I found a better way to fix the "WARNING" on _read|_read_oob checking. 
Since sub-mtd device has been registered successfully, we can check 
against the existence of _read|_read_oob callbacks by subdev's master 
device.
BTW, fix missing space between the SHA1 and the subject suggested by 
Stephen.
> Since 2431c4f5b46c3 ("mtd: Implement mtd_{read,write}() as wrappers
> around mtd_{read,write}_oob()") don't allow _write|_read and
> _write_oob|_read_oob existing at the same time. We should check the
> existence of callbacks "_read and _write" from subdev's master device
> (We can trust master device since it has been registered) before
> assigning, otherwise following warning occurs while making
> concatenated device:
>
>    WARNING: CPU: 2 PID: 6728 at drivers/mtd/mtdcore.c:595
>    add_mtd_device+0x7f/0x7b0
>
> Fixes: 2431c4f5b46c3 ("mtd: Implement mtd_{read,write}() around ...")
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> ---
>   drivers/mtd/mtdconcat.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
> index af51eee6b5e8..f685a581df48 100644
> --- a/drivers/mtd/mtdconcat.c
> +++ b/drivers/mtd/mtdconcat.c
> @@ -694,6 +694,10 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[],	/* subdevices to c
>   		concat->mtd._block_markbad = concat_block_markbad;
>   	if (subdev_master->_panic_write)
>   		concat->mtd._panic_write = concat_panic_write;
> +	if (subdev_master->_read)
> +		concat->mtd._read = concat_read;
> +	if (subdev_master->_write)
> +		concat->mtd._write = concat_write;
>   
>   	concat->mtd.ecc_stats.badblocks = subdev[0]->ecc_stats.badblocks;
>   
> @@ -755,8 +759,6 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[],	/* subdevices to c
>   	concat->mtd.name = name;
>   
>   	concat->mtd._erase = concat_erase;
> -	concat->mtd._read = concat_read;
> -	concat->mtd._write = concat_write;
>   	concat->mtd._sync = concat_sync;
>   	concat->mtd._lock = concat_lock;
>   	concat->mtd._unlock = concat_unlock;



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] mtd: mtdconcat: Check existence of _read|_write from subdev'master device before assigning
  2021-08-17  2:45 ` Zhihao Cheng
@ 2021-08-17 10:04   ` Miquel Raynal
  0 siblings, 0 replies; 3+ messages in thread
From: Miquel Raynal @ 2021-08-17 10:04 UTC (permalink / raw)
  To: Zhihao Cheng
  Cc: richard, vigneshr, bbrezillon, linux-mtd, linux-kernel, yukuai3, sfr

Hi Zhihao,

Zhihao Cheng <chengzhihao1@huawei.com> wrote on Tue, 17 Aug 2021
10:45:55 +0800:

> 在 2021/8/17 10:45, Zhihao Cheng 写道:
> Hi Miquel,
> I found a better way to fix the "WARNING" on _read|_read_oob checking. Since sub-mtd device has been registered successfully, we can check against the existence of _read|_read_oob callbacks by subdev's master device.
> BTW, fix missing space between the SHA1 and the subject suggested by Stephen.

I am a bit lost, I need to see the big picture again. I will drop the
current patches that applied, please resend the full series with a
changelog.

> > Since 2431c4f5b46c3 ("mtd: Implement mtd_{read,write}() as wrappers
> > around mtd_{read,write}_oob()") don't allow _write|_read and
> > _write_oob|_read_oob existing at the same time. We should check the

                                                  , we

> > existence of callbacks "_read and _write" from subdev's master device
> > (We can trust master device since it has been registered) before
> > assigning, otherwise following warning occurs while making
> > concatenated device:
> >
> >    WARNING: CPU: 2 PID: 6728 at drivers/mtd/mtdcore.c:595
> >    add_mtd_device+0x7f/0x7b0
> >
> > Fixes: 2431c4f5b46c3 ("mtd: Implement mtd_{read,write}() around ...")

                                                             ^
Wrong commit message

> > Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> > ---

Also, please shorten a bit the two commit titles, like:

mtd: mtdconcat: Judge callback existence based on the master

Finally, in the other patch, there is a typo in the example
reproduce.c (combine misspelled).

> >   drivers/mtd/mtdconcat.c | 6 ++++--
> >   1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
> > index af51eee6b5e8..f685a581df48 100644
> > --- a/drivers/mtd/mtdconcat.c
> > +++ b/drivers/mtd/mtdconcat.c
> > @@ -694,6 +694,10 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[],	/* subdevices to c
> >   		concat->mtd._block_markbad = concat_block_markbad;
> >   	if (subdev_master->_panic_write)
> >   		concat->mtd._panic_write = concat_panic_write;
> > +	if (subdev_master->_read)
> > +		concat->mtd._read = concat_read;
> > +	if (subdev_master->_write)
> > +		concat->mtd._write = concat_write;  
> >   >   	concat->mtd.ecc_stats.badblocks = subdev[0]->ecc_stats.badblocks;
> >   > @@ -755,8 +759,6 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[],	/* subdevices to c  
> >   	concat->mtd.name = name;  
> >   >   	concat->mtd._erase = concat_erase;  
> > -	concat->mtd._read = concat_read;
> > -	concat->mtd._write = concat_write;
> >   	concat->mtd._sync = concat_sync;
> >   	concat->mtd._lock = concat_lock;
> >   	concat->mtd._unlock = concat_unlock;  
> 
> 

Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-08-17 10:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17  2:45 [PATCH v2] mtd: mtdconcat: Check existence of _read|_write from subdev'master device before assigning Zhihao Cheng
2021-08-17  2:45 ` Zhihao Cheng
2021-08-17 10:04   ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).