From: Stephen Boyd <swboyd@chromium.org>
To: Tri Vo <trong@android.com>,
gregkh@linuxfoundation.org, rjw@rjwysocki.net,
viresh.kumar@linaro.org
Cc: rafael@kernel.org, hridya@google.com, sspatil@google.com,
kaleshsingh@google.com, ravisadineni@chromium.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
kernel-team@android.com, Tri Vo <trong@android.com>
Subject: Re: [PATCH v7 1/3] PM / wakeup: Drop wakeup_source_init(), wakeup_source_prepare()
Date: Mon, 05 Aug 2019 13:54:05 -0700 [thread overview]
Message-ID: <5d48976e.1c69fb81.a6781.3565@mx.google.com> (raw)
In-Reply-To: <20190805175848.163558-2-trong@android.com>
Quoting Tri Vo (2019-08-05 10:58:46)
> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
> index ee31d4f8d856..3938892c8903 100644
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -72,23 +72,6 @@ static struct wakeup_source deleted_ws = {
> .lock = __SPIN_LOCK_UNLOCKED(deleted_ws.lock),
> };
>
> -/**
> - * wakeup_source_prepare - Prepare a new wakeup source for initialization.
> - * @ws: Wakeup source to prepare.
> - * @name: Pointer to the name of the new wakeup source.
> - *
> - * Callers must ensure that the @name string won't be freed when @ws is still in
> - * use.
> - */
> -void wakeup_source_prepare(struct wakeup_source *ws, const char *name)
> -{
> - if (ws) {
> - memset(ws, 0, sizeof(*ws));
> - ws->name = name;
> - }
> -}
> -EXPORT_SYMBOL_GPL(wakeup_source_prepare);
> -
> /**
> * wakeup_source_create - Create a struct wakeup_source object.
> * @name: Name of the new wakeup source.
> @@ -96,13 +79,23 @@ EXPORT_SYMBOL_GPL(wakeup_source_prepare);
> struct wakeup_source *wakeup_source_create(const char *name)
> {
> struct wakeup_source *ws;
> + const char *ws_name;
>
> - ws = kmalloc(sizeof(*ws), GFP_KERNEL);
> + ws = kzalloc(sizeof(*ws), GFP_KERNEL);
> if (!ws)
> - return NULL;
> + goto err_ws;
> +
> + ws_name = kstrdup_const(name, GFP_KERNEL);
> + if (!ws_name)
Does this intentionally change this function to return an error if
'name' is NULL? Before, wakeup_source_prepare() would just assign
ws->name to NULL, but now it errors out. I don't see how it's good or
useful to allow NULL for the wakeup source name, but it is what it is.
> + goto err_name;
> + ws->name = ws_name;
>
> - wakeup_source_prepare(ws, name ? kstrdup_const(name, GFP_KERNEL) : NULL);
> return ws;
> +
> +err_name:
> + kfree(ws);
> +err_ws:
> + return NULL;
> }
> EXPORT_SYMBOL_GPL(wakeup_source_create);
>
next prev parent reply other threads:[~2019-08-05 20:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-05 17:58 [PATCH v7 0/3] PM / wakeup: show wakeup sources stats in sysfs Tri Vo
2019-08-05 17:58 ` [PATCH v7 1/3] PM / wakeup: Drop wakeup_source_init(), wakeup_source_prepare() Tri Vo
2019-08-05 20:54 ` Stephen Boyd [this message]
2019-08-05 21:11 ` Tri Vo
2019-08-05 21:15 ` Stephen Boyd
2019-08-05 17:58 ` [PATCH v7 2/3] PM / wakeup: Use wakeup_source_register() in wakelock.c Tri Vo
2019-08-05 20:57 ` Stephen Boyd
2019-08-05 17:58 ` [PATCH v7 3/3] PM / wakeup: Show wakeup sources stats in sysfs Tri Vo
2019-08-05 21:02 ` Stephen Boyd
2019-08-05 23:29 ` Stephen Boyd
2019-08-06 18:51 ` Tri Vo
2019-08-06 21:32 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5d48976e.1c69fb81.a6781.3565@mx.google.com \
--to=swboyd@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=hridya@google.com \
--cc=kaleshsingh@google.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=ravisadineni@chromium.org \
--cc=rjw@rjwysocki.net \
--cc=sspatil@google.com \
--cc=trong@android.com \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox