From: Thierry Reding <thierry.reding@gmail.com>
To: David Hsu <davidhsu@google.com>
Cc: gregkh@linuxfoundation.org, sspatil@google.com,
linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] pwm: Create device class for pwm channels
Date: Mon, 5 Sep 2016 17:20:25 +0200 [thread overview]
Message-ID: <20160905152025.GT31424@ulmo.ba.sec> (raw)
In-Reply-To: <1468880090-46076-1-git-send-email-davidhsu@google.com>
[-- Attachment #1: Type: text/plain, Size: 1879 bytes --]
On Mon, Jul 18, 2016 at 03:14:50PM -0700, David Hsu wrote:
> Pwm channels don't send uevents when exported, this change adds the
> channels to a pwm class and set their device type to pwm_channel so
> uevents are sent.
>
> To do this properly, the device names need to change to uniquely
> identify a channel. This change is from pwmN to pwmchipM:N
>
> Signed-off-by: David Hsu <davidhsu@google.com>
> ---
> v2: Use parent name instead of chip->base for channel naming.
>
> Documentation/pwm.txt | 6 ++++--
> drivers/pwm/sysfs.c | 18 +++++++++++++-----
> 2 files changed, 17 insertions(+), 7 deletions(-)
Forgot to mention one other thing that had come to my mind...
> diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
[...]
> @@ -248,9 +254,11 @@ static int pwm_export_child(struct device *parent, struct pwm_device *pwm)
>
> export->child.release = pwm_export_release;
> export->child.parent = parent;
> + export->child.type = &pwm_channel_type;
> export->child.devt = MKDEV(0, 0);
> + export->child.class = &pwm_class;
> export->child.groups = pwm_groups;
> - dev_set_name(&export->child, "pwm%u", pwm->hwpwm);
> + dev_set_name(&export->child, "%s:%u", dev_name(parent), pwm->hwpwm);
Using the colon as separator could possibly prevent the use of these
files in paths lists. Consider the case where somebody wanted to give a
list of PWM sysfs references:
PWM_DEVICES=/sys/class/pwm/pwmchip0:0:/sys/class/pwm/pwmchip0:1
which might get parsed as four entries:
- /sys/class/pwm/pwmchip0
- 0
- /sys/class/pwm/pwmchip0
- 1
none of which point to a valid PWM. There are a couple of other
separators that might be possible, such as '-' or '.'.
Then again, looking at existing usage in sysfs it seems like the colon
is a fairly popular separator, so maybe I'm just being too paranoid.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
prev parent reply other threads:[~2016-09-05 15:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-18 22:14 [PATCH v2] pwm: Create device class for pwm channels David Hsu
2016-09-05 14:41 ` Thierry Reding
2016-09-05 15:15 ` Thierry Reding
2016-09-05 15:42 ` Thierry Reding
2016-09-05 15:20 ` Thierry Reding [this message]
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=20160905152025.GT31424@ulmo.ba.sec \
--to=thierry.reding@gmail.com \
--cc=davidhsu@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=sspatil@google.com \
/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