* [PATCH] ubi: Fix seq_file usage in detailed_erase_block_info debugfs file
@ 2020-05-02 12:48 Richard Weinberger
2020-05-17 21:39 ` Richard Weinberger
0 siblings, 1 reply; 2+ messages in thread
From: Richard Weinberger @ 2020-05-02 12:48 UTC (permalink / raw)
To: linux-mtd; +Cc: linux-kernel, ben.shelton, zach.brown, Richard Weinberger
3bfa7e141b0b ("fs/seq_file.c: seq_read(): add info message about buggy .next functions")
showed that we don't use seq_file correctly.
So make sure that our ->next function always updates the position.
Fixes: 7bccd12d27b7 ("ubi: Add debugfs file for tracking PEB state")
Signed-off-by: Richard Weinberger <richard@nod.at>
---
drivers/mtd/ubi/debug.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index 54646c2c2744..ac2bdba8bb1a 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -393,9 +393,6 @@ static void *eraseblk_count_seq_start(struct seq_file *s, loff_t *pos)
{
struct ubi_device *ubi = s->private;
- if (*pos == 0)
- return SEQ_START_TOKEN;
-
if (*pos < ubi->peb_count)
return pos;
@@ -409,8 +406,6 @@ static void *eraseblk_count_seq_next(struct seq_file *s, void *v, loff_t *pos)
{
struct ubi_device *ubi = s->private;
- if (v == SEQ_START_TOKEN)
- return pos;
(*pos)++;
if (*pos < ubi->peb_count)
@@ -432,11 +427,8 @@ static int eraseblk_count_seq_show(struct seq_file *s, void *iter)
int err;
/* If this is the start, print a header */
- if (iter == SEQ_START_TOKEN) {
- seq_puts(s,
- "physical_block_number\terase_count\tblock_status\tread_status\n");
- return 0;
- }
+ if (*block_number == 0)
+ seq_puts(s, "physical_block_number\terase_count\n");
err = ubi_io_is_bad(ubi, *block_number);
if (err)
--
2.16.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ubi: Fix seq_file usage in detailed_erase_block_info debugfs file
2020-05-02 12:48 [PATCH] ubi: Fix seq_file usage in detailed_erase_block_info debugfs file Richard Weinberger
@ 2020-05-17 21:39 ` Richard Weinberger
0 siblings, 0 replies; 2+ messages in thread
From: Richard Weinberger @ 2020-05-17 21:39 UTC (permalink / raw)
To: Richard Weinberger; +Cc: linux-mtd, ben.shelton, LKML, zach.brown
On Sat, May 2, 2020 at 2:48 PM Richard Weinberger <richard@nod.at> wrote:
>
> 3bfa7e141b0b ("fs/seq_file.c: seq_read(): add info message about buggy .next functions")
> showed that we don't use seq_file correctly.
> So make sure that our ->next function always updates the position.
>
> Fixes: 7bccd12d27b7 ("ubi: Add debugfs file for tracking PEB state")
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> drivers/mtd/ubi/debug.c | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
> index 54646c2c2744..ac2bdba8bb1a 100644
> --- a/drivers/mtd/ubi/debug.c
> +++ b/drivers/mtd/ubi/debug.c
> @@ -393,9 +393,6 @@ static void *eraseblk_count_seq_start(struct seq_file *s, loff_t *pos)
> {
> struct ubi_device *ubi = s->private;
>
> - if (*pos == 0)
> - return SEQ_START_TOKEN;
> -
> if (*pos < ubi->peb_count)
> return pos;
>
> @@ -409,8 +406,6 @@ static void *eraseblk_count_seq_next(struct seq_file *s, void *v, loff_t *pos)
> {
> struct ubi_device *ubi = s->private;
>
> - if (v == SEQ_START_TOKEN)
> - return pos;
> (*pos)++;
>
> if (*pos < ubi->peb_count)
> @@ -432,11 +427,8 @@ static int eraseblk_count_seq_show(struct seq_file *s, void *iter)
> int err;
>
> /* If this is the start, print a header */
> - if (iter == SEQ_START_TOKEN) {
> - seq_puts(s,
> - "physical_block_number\terase_count\tblock_status\tread_status\n");
> - return 0;
> - }
> + if (*block_number == 0)
> + seq_puts(s, "physical_block_number\terase_count\n");
>
> err = ubi_io_is_bad(ubi, *block_number);
> if (err)
> --
Applied!
--
Thanks,
//richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-17 21:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-02 12:48 [PATCH] ubi: Fix seq_file usage in detailed_erase_block_info debugfs file Richard Weinberger
2020-05-17 21:39 ` Richard Weinberger
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).