On Thursday, May 30, 2013 12:30 PM, H Hartley Sweeten wrote: > Add a simple sysfs interface to the generic PWM framework. > > /sys/class/pwm/ > `-- pwmchipN/ for each PWM chip > |-- export (w/o) ask the kernel to export a PWM channel > |-- npwn (r/o) number of PWM channels in this PWM chip > |-- pwmX/ for each exported PWM channel (per PWM chip) > | |-- duty_ns (r/w) duty cycle (in nanoseconds) > | |-- enable (r/w) enable/disable PWM > | |-- period_ns (r/w) period (in nanoseconds) > | `-- polarity (r/w) polarity of PWM > `-- unexport (w/o) return a PWM channel to the kernel > > Signed-off-by: H Hartley Sweeten <hswee...@visionengravers.com> > Cc: Thierry Reding <thierry.red...@gmail.com> > Cc: Lars Poeschel <poesc...@lemonage.de> > Cc: Ryan Mallon <rmal...@gmai.com> > Cc: Rob Landley <r...@landley.net> > --- > v2: * add API documentation and update Documentation/pwm.txt > * fix some issues pointed out by Ryan Mallon > * add the pwm attributes to dev.groups so they are created > when the device is registered for the exported PWM. > > Documentation/ABI/testing/sysfs-class-pwm | 80 +++++++ > Documentation/pwm.txt | 39 ++++ > drivers/pwm/Kconfig | 12 + > drivers/pwm/Makefile | 1 + > drivers/pwm/core.c | 25 ++- > drivers/pwm/pwm-sysfs.c | 350 > ++++++++++++++++++++++++++++++ > include/linux/pwm.h | 28 +++ > 7 files changed, 533 insertions(+), 2 deletions(-) > create mode 100644 Documentation/ABI/testing/sysfs-class-pwm > create mode 100644 drivers/pwm/pwm-sysfs.c
<snip> > diff --git a/drivers/pwm/pwm-sysfs.c b/drivers/pwm/pwm-sysfs.c <snip> > +void pwmchip_sysfs_export(struct pwm_chip *chip) > +{ > + /* > + * If device_create() fails the pwm_chip is still usable by > + * the kernel its just not exported. > + */ > + chip->dev = device_create(&pwm_class, chip->dev, MKDEV(0, 0), chip, > + "pwmchip%d", chip->base); > +} I just realized this will not work. chip->dev is initialized by the PWM driver before calling pwmchip_add(). I'll post a v3 shortly. Regards, Hartley N�����r��y����b�X��ǧv�^�){.n�+����{����zX����ܨ}���Ơz�&j:+v�������zZ+��+zf���h���~����i���z��w���?�����&�)ߢf��^jǫy�m��@A�a��� 0��h���i