All of lore.kernel.org
 help / color / mirror / Atom feed
From: poeschel@lemonage.de
To: "Thierry Reding" <thierry.reding@gmail.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Lee Jones" <lee.jones@linaro.org>,
	linux-pwm@vger.kernel.org (open list:PWM SUBSYSTEM),
	linux-kernel@vger.kernel.org (open list)
Cc: Lars Poeschel <poeschel@lemonage.de>
Subject: [PATCH] pwm: sysfs: Set class on pwm devices
Date: Tue, 29 Sep 2020 14:19:53 +0200	[thread overview]
Message-ID: <20200929121953.2817843-1-poeschel@lemonage.de> (raw)

From: Lars Poeschel <poeschel@lemonage.de>

This adds a class to exported pwm devices.
Exporting a pwm through sysfs did not yield udev events. The
dev_uevent_filter function does filter-out devices without a bus or
class.
This was already addressed in commit
commit 7e5d1fd75c3d ("pwm: Set class for exported channels in sysfs")
but this did cause problems and the commit got reverted with
commit c289d6625237 ("Revert "pwm: Set class for exported channels in
sysfs"")

pwm's have to be local to its pwmchip, so we create an individual class
for each pwmchip and assign this class to the pwm belonging to the
pwmchip. This does better map to structure that is also visible in
sysfs.

Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
---
 drivers/pwm/sysfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
index 449dbc0f49ed..e2dfbc335366 100644
--- a/drivers/pwm/sysfs.c
+++ b/drivers/pwm/sysfs.c
@@ -259,7 +259,7 @@ static int pwm_export_child(struct device *parent, struct pwm_device *pwm)
 	export->child.release = pwm_export_release;
 	export->child.parent = parent;
 	export->child.devt = MKDEV(0, 0);
-	export->child.groups = pwm_groups;
+	export->child.class = parent->class;
 	dev_set_name(&export->child, "pwm%u", pwm->hwpwm);
 
 	ret = device_register(&export->child);
@@ -499,6 +499,9 @@ void pwmchip_sysfs_export(struct pwm_chip *chip)
 		dev_warn(chip->dev,
 			 "device_create failed for pwm_chip sysfs export\n");
 	}
+
+	parent->class = class_create(THIS_MODULE, parent->kobj.name);
+	parent->class->dev_groups = pwm_groups;
 }
 
 void pwmchip_sysfs_unexport(struct pwm_chip *chip)
@@ -518,6 +521,7 @@ void pwmchip_sysfs_unexport(struct pwm_chip *chip)
 			pwm_unexport_child(parent, pwm);
 	}
 
+	class_destroy(parent->class);
 	put_device(parent);
 	device_unregister(parent);
 }
-- 
2.28.0


             reply	other threads:[~2020-09-29 12:21 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 12:19 poeschel [this message]
2020-09-30  6:57 ` [PATCH] pwm: sysfs: Set class on pwm devices Uwe Kleine-König
2020-09-30  9:20   ` Lars Poeschel
2020-09-30  9:41     ` Uwe Kleine-König
2020-09-30  9:52       ` Greg Kroah-Hartman
2020-09-30 10:01         ` Uwe Kleine-König
2020-09-30 10:52           ` Greg Kroah-Hartman
2020-09-30 11:27             ` Lars Poeschel
2020-09-30 11:51               ` Greg Kroah-Hartman
2020-09-30 14:13                 ` Lars Poeschel
2020-09-30 15:03                   ` Uwe Kleine-König
2020-09-30 16:30                     ` Greg Kroah-Hartman
2020-10-01  9:05       ` Lars Poeschel
2020-10-01 11:24         ` Greg Kroah-Hartman
2020-10-01 13:50           ` Lars Poeschel
2020-10-02  7:58             ` Greg Kroah-Hartman
2020-10-05  9:30           ` Thierry Reding
2020-10-05  9:45             ` Greg Kroah-Hartman
2020-10-05 10:17               ` Thierry Reding
2020-10-05 10:40                 ` Greg Kroah-Hartman
2020-10-05 11:08                   ` Thierry Reding
2020-10-05 11:17                     ` Greg Kroah-Hartman
2020-10-05 11:58                       ` Thierry Reding
2020-10-05 12:12                         ` Greg Kroah-Hartman
2020-10-05 10:49             ` Lars Poeschel

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=20200929121953.2817843-1-poeschel@lemonage.de \
    --to=poeschel@lemonage.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.