Re: [PATCH] PM/wakeup: Add print_wakeup_sour_stats(m, &deleted_ws)

From: Rafael J. Wysocki
Date: Fri Nov 08 2019 - 06:34:27 EST


On Monday, October 21, 2019 10:51:40 AM CET zhuguangqing83@xxxxxxxxx wrote:
> From: zhuguangqing <zhuguangqing@xxxxxxxxxx>
>
> After commit 00ee22c28915 (PM / wakeup: Use seq_open()
> to show wakeup stats), print_wakeup_source_stats(m, &deleted_ws)
> is deleted in function wakeup_sources_stats_seq_show().
>
> Because deleted_ws is one of wakeup sources, so it should
> also be showed. This patch add it to the end of all other
> wakeup sources.
>
> Signed-off-by: zhuguangqing <zhuguangqing@xxxxxxxxxx>
> ---
> drivers/base/power/wakeup.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
> index 5817b51d2b15..29e9434ccaaa 100644
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -1071,6 +1071,9 @@ static void *wakeup_sources_stats_seq_next(struct seq_file *m,
> break;
> }
>
> + if (&ws->entry == &wakeup_sources)
> + print_wakeup_source_stats(m, &deleted_ws);
> +

That would be when NULL is about to be returned, right?

Why not to check for !next_ws instead, then?

Moreover, why to call print_wakeup_source_stats() directly instead of returning
&deleted_ws?

Also it looks like you need a similar change in wakeup_sources_stats_seq_start(),
in case n is greater than the number of list entries, don't you?

> return next_ws;
> }
>
>