linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Ravi Chandra Sadineni <ravisadineni@chromium.org>
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	hpa@zytor.com, x86@kernel.org, rjw@rjwysocki.net, pavel@ucw.cz,
	len.brown@intel.com, gregkh@linuxfoundation.org, bhe@redhat.com,
	dyoung@redhat.com, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, tbroch@chromium.org, trong@google.com
Subject: Re: [PATCH 1/2] power: sysfs: Add link to wakeup class device.
Date: Fri, 6 Sep 2019 16:40:25 -0700	[thread overview]
Message-ID: <20190906234025.GD133864@google.com> (raw)
In-Reply-To: <20190724174355.255314-2-ravisadineni@chromium.org>

Hi Ravi,

On Wed, Jul 24, 2019 at 10:43:54AM -0700, Ravi Chandra Sadineni wrote:
> https://patchwork.kernel.org/patch/11045069/ creates a virtual
> device

To refer to unsubmitted patches in the commit message it is
probably better to use the subject ("PM / wakeup: show wakeup
sources stats in sysfs") and add a link after '---', or say
"${subject}" [1] and put the link at the bottom of the commit message

You might want to try again now that the patch has landed :)

> under wakeup class for each wake capable device exposing all related
> sysfs attributes. But there isn't a symlink from the actual device
> node to these virtual devices. This patch creates a symlink from the
> actual device to the corresponding wakeup_source device under wakeup
> class.

> Signed-off-by: Ravi Chandra Sadineni <ravisadineni@chromium.org>
> ---
>  drivers/base/power/power.h  |  2 ++
>  drivers/base/power/sysfs.c  | 25 +++++++++++++++++++++++++
>  drivers/base/power/wakeup.c |  2 ++
>  3 files changed, 29 insertions(+)
> 
> diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
> index c511def48b48..32b0f5c080a9 100644
> --- a/drivers/base/power/power.h
> +++ b/drivers/base/power/power.h
> @@ -67,6 +67,8 @@ extern void dpm_sysfs_remove(struct device *dev);
>  extern void rpm_sysfs_remove(struct device *dev);
>  extern int wakeup_sysfs_add(struct device *dev);
>  extern void wakeup_sysfs_remove(struct device *dev);
> +extern void wakeup_source_sysfs_link_add(struct device *dev);
> +extern void wakeup_source_sysfs_link_remove(struct device *dev);

the names seem a bit clunky, how about wakeup_sysfs_add/remove_link()?

>  extern int pm_qos_sysfs_add_resume_latency(struct device *dev);
>  extern void pm_qos_sysfs_remove_resume_latency(struct device *dev);
>  extern int pm_qos_sysfs_add_flags(struct device *dev);
> diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
> index d713738ce796..fbbdb7b16ac5 100644
> --- a/drivers/base/power/sysfs.c
> +++ b/drivers/base/power/sysfs.c
> @@ -95,6 +95,7 @@
>  const char power_group_name[] = "power";
>  EXPORT_SYMBOL_GPL(power_group_name);
>  
> +static const char wakeup_source_symlink_name[] = "wakeup_source";
>  static const char ctrl_auto[] = "auto";
>  static const char ctrl_on[] = "on";
>  
> @@ -679,6 +680,30 @@ int dpm_sysfs_add(struct device *dev)
>  	return rc;
>  }
>  
> +void wakeup_source_sysfs_link_add(struct device *dev)
> +{
> +	struct wakeup_source *ws;
> +	int err;
> +
> +	ws = dev->power.wakeup;
> +	if (ws && ws->dev) {
> +		err = sysfs_add_link_to_group(&dev->kobj, power_group_name,
> +			&ws->dev->kobj, wakeup_source_symlink_name);
> +		if (err) {
> +			dev_err(dev,
> +				"could not add %s symlink err %d\n",

I'd suggest

				"could not add '%s' symlink: %d\n",

or

				"could not add 'wakeup_source' symlink: %d\n",

the latter is easier to grep.

> +				wakeup_source_symlink_name,
> +				err);
> +		}
> +	}
> +}
> +
> +void wakeup_source_sysfs_link_remove(struct device *dev)
> +{
> +	sysfs_remove_link_from_group(&dev->kobj, power_group_name,
> +		wakeup_source_symlink_name);
> +}
> +
>  int wakeup_sysfs_add(struct device *dev)
>  {
>  	return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
> index fe779fe13a7f..87dfe401b035 100644
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -270,6 +270,7 @@ static int device_wakeup_attach(struct device *dev, struct wakeup_source *ws)
>  	if (dev->power.wakeirq)
>  		device_wakeup_attach_irq(dev, dev->power.wakeirq);
>  	spin_unlock_irq(&dev->power.lock);
> +	wakeup_source_sysfs_link_add(dev);
>  	return 0;
>  }
>  
> @@ -391,6 +392,7 @@ static struct wakeup_source *device_wakeup_detach(struct device *dev)
>  	ws = dev->power.wakeup;
>  	dev->power.wakeup = NULL;
>  	spin_unlock_irq(&dev->power.lock);
> +	wakeup_source_sysfs_link_remove(dev);

you want to do this before the wakeup source is detached.

  reply	other threads:[~2019-09-06 23:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-24 17:43 [PATCH 0/2] Add wakeup_source symlink and update documentation Ravi Chandra Sadineni
2019-07-24 17:43 ` [PATCH 1/2] power: sysfs: Add link to wakeup class device Ravi Chandra Sadineni
2019-09-06 23:40   ` Matthias Kaehlcke [this message]
2019-07-24 17:43 ` [PATCH 2/2] power: sysfs: move wakeup related nodes in power dir to obselete Ravi Chandra Sadineni

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=20190906234025.GD133864@google.com \
    --to=mka@chromium.org \
    --cc=bhe@redhat.com \
    --cc=bp@alien8.de \
    --cc=dyoung@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=ravisadineni@chromium.org \
    --cc=rjw@rjwysocki.net \
    --cc=tbroch@chromium.org \
    --cc=tglx@linutronix.de \
    --cc=trong@google.com \
    --cc=x86@kernel.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;
as well as URLs for NNTP newsgroup(s).