Commit 7f68aa2e authored by Fabrice Gasnier's avatar Fabrice Gasnier Committed by Greg Kroah-Hartman

Revert "pwm: Set class for exported channels in sysfs"

commit c289d662 upstream.

This reverts commit 7e5d1fd7 ("pwm: Set
class for exported channels in sysfs") as it causes regression with
multiple pwm chip[1], when exporting a pwm channel (echo X > export):

- ABI (Documentation/ABI/testing/sysfs-class-pwm) states pwmX should be
  created in /sys/class/pwm/pwmchipN/pwmX
- Reverted patch causes new entry to be also created directly in
  /sys/class/pwm/pwmX
- 1st time, exporting pwmX will create an entry in /sys/class/pwm/pwmX
- class attributes are added under pwmX folder, such as export, unexport
  npwm, symlinks. This is wrong as it belongs to pwmchipN. It may cause
  bad behavior and report wrong values.
- when another export happens on another pwmchip, it can't be created
  (e.g. -EEXIST). This is causing the issue with multiple pwmchip.

Example on stm32 (stm32429i-eval) platform:
$ ls /sys/class/pwm
pwmchip0 pwmchip4

$ cd /sys/class/pwm/pwmchip0/
$ echo 0 > export
$ ls /sys/class/pwm
pwm0 pwmchip0 pwmchip4

$ cd /sys/class/pwm/pwmchip4/
$ echo 0 > export
sysfs: cannot create duplicate filename '/class/pwm/pwm0'
...Exception stack follows...

This is also seen on other platform [2]

[1] https://lkml.org/lkml/2018/9/25/713
[2] https://lkml.org/lkml/2018/9/25/447Signed-off-by: default avatarFabrice Gasnier <fabrice.gasnier@st.com>
Tested-by: default avatarGottfried Haider <gottfried.haider@gmail.com>
Tested-by: default avatarMichal Vokáč <michal.vokac@ysoft.com>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
Cc: John Keeping <john@metanate.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 056368fc
...@@ -263,7 +263,6 @@ static int pwm_export_child(struct device *parent, struct pwm_device *pwm) ...@@ -263,7 +263,6 @@ static int pwm_export_child(struct device *parent, struct pwm_device *pwm)
export->pwm = pwm; export->pwm = pwm;
mutex_init(&export->lock); mutex_init(&export->lock);
export->child.class = parent->class;
export->child.release = pwm_export_release; export->child.release = pwm_export_release;
export->child.parent = parent; export->child.parent = parent;
export->child.devt = MKDEV(0, 0); export->child.devt = MKDEV(0, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment