Patchwork [1/2] pwm: new field name added to pwm_device

login
register
mail settings
Submitter Aurelio Colosimo
Date Aug. 5, 2014, 3:12 p.m.
Message ID <1407251538-17566-2-git-send-email-aurelio@aureliocolosimo.it>
Download mbox | patch
Permalink /patch/376732/
State New
Headers show

Comments

Aurelio Colosimo - Aug. 5, 2014, 3:12 p.m.
Since label is used dinamically, I added one more optional field,
which statically defines the name of a pwm output, in a similar way
as gpio framework does.

Signed-off-by: Aurelio Colosimo <aurelio@aureliocolosimo.it>
---
 drivers/pwm/sysfs.c | 7 ++++++-
 include/linux/pwm.h | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
index 4bd0c63..c1d6064 100644
--- a/drivers/pwm/sysfs.c
+++ b/drivers/pwm/sysfs.c
@@ -198,7 +198,12 @@  static int pwm_export_child(struct device *parent, struct pwm_device *pwm)
 	export->child.parent = parent;
 	export->child.devt = MKDEV(0, 0);
 	export->child.groups = pwm_groups;
-	dev_set_name(&export->child, "pwm%u", pwm->hwpwm);
+
+	if (pwm->name)
+		dev_set_name(&export->child, pwm->name, pwm->hwpwm);
+	else
+		dev_set_name(&export->child, "pwm%u", pwm->hwpwm);
+
 
 	ret = device_register(&export->child);
 	if (ret) {
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index e90628c..9bacf35 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -86,6 +86,7 @@  struct pwm_device {
 	unsigned int		pwm;
 	struct pwm_chip		*chip;
 	void			*chip_data;
+	const char		*name; /* optional static name for pwm device */
 
 	unsigned int		period; 	/* in nanoseconds */
 	unsigned int		duty_cycle;	/* in nanoseconds */