1. 10 6月, 2016 1 次提交
    • B
      pwm: Improve args checking in pwm_apply_state() · ef2bf499
      Brian Norris 提交于
      It seems like in the process of refactoring pwm_config() to utilize the
      newly-introduced pwm_apply_state() API, some args/bounds checking was
      dropped.
      
      In particular, I noted that we are now allowing invalid period
      selections, e.g.:
      
        # echo 1 > /sys/class/pwm/pwmchip0/export
        # cat /sys/class/pwm/pwmchip0/pwm1/period
        100
        # echo 101 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
        [... driver may or may not reject the value, or trigger some logic bug ...]
      
      It's better to see:
      
        # echo 1 > /sys/class/pwm/pwmchip0/export
        # cat /sys/class/pwm/pwmchip0/pwm1/period
        100
        # echo 101 > /sys/class/pwm/pwmchip0/pwm1/duty_cycle
        -bash: echo: write error: Invalid argument
      
      This patch reintroduces some bounds checks in both pwm_config() (for its
      signed parameters; we don't want to convert negative values into large
      unsigned values) and in pwm_apply_state() (which fix the above described
      behavior, as well as other potential API misuses).
      
      Fixes: 5ec803ed ("pwm: Add core infrastructure to allow atomic updates")
      Signed-off-by: NBrian Norris <briannorris@chromium.org>
      Acked-by: NBoris Brezillon <boris.brezillon@free-electrons.com>
      Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
      ef2bf499
  2. 17 5月, 2016 9 次提交
  3. 03 5月, 2016 3 次提交
  4. 21 1月, 2016 1 次提交
    • T
      pwm: Mark all devices as "might sleep" · ff01c944
      Thierry Reding 提交于
      Commit d1cd2142 ("pwm: Set enable state properly on failed call to
      enable") introduced a mutex that is needed to protect internal state of
      PWM devices. Since that mutex is acquired in pwm_set_polarity() and in
      pwm_enable() and might potentially block, all PWM devices effectively
      become "might sleep".
      
      It's rather pointless to keep the .can_sleep field around, but given
      that there are external users let's postpone the removal for the next
      release cycle.
      Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
      ff01c944
  5. 10 11月, 2015 2 次提交
  6. 17 8月, 2015 2 次提交
  7. 20 7月, 2015 1 次提交
  8. 12 6月, 2015 1 次提交
  9. 06 5月, 2015 1 次提交
  10. 23 4月, 2015 1 次提交
  11. 03 2月, 2015 1 次提交
  12. 29 8月, 2014 1 次提交
    • G
      pwm: Fix uninitialized warnings in pwm_get() · 70145f87
      Geert Uytterhoeven 提交于
      With some versions of gcc (e.g. 4.1.2):
      
      drivers/pwm/core.c: In function ‘pwm_get’:
      drivers/pwm/core.c:610: warning: ‘polarity’ may be used uninitialized in this function
      drivers/pwm/core.c:609: warning: ‘period’ may be used uninitialized in this function
      
      While these are false positives, we can get rid of them by refactoring
      the code to store a pointer to the best match, as suggested before by
      Thierry Reding. This does require moving the mutex_unlock() down.
      
      Fixes: d717ea73 ("pwm: Fix period and polarity in pwm_get() for non-perfect matches")
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
      70145f87
  13. 25 8月, 2014 1 次提交
  14. 18 8月, 2014 1 次提交
    • G
      pwm: Fix period and polarity in pwm_get() for non-perfect matches · d717ea73
      Geert Uytterhoeven 提交于
      If pwm_get() finds a look-up entry with a perfect match (both dev_id and
      con_id match), the loop is aborted, and "p" still points to the correct
      struct pwm_lookup.
      
      If only an entry with a matching dev_id or con_id is found, the loop
      terminates after traversing the whole list, and "p" now points to
      arbitrary memory, not part of the pwm_lookup list.
      Then pwm_set_period() and pwm_set_polarity() will set random values for
      period resp. polarity.
      
      To fix this, save period and polarity when finding a new best match,
      just like is done for chip (for the provider) and index.
      
      This fixes the LCD backlight on r8a7740/armadillo-legacy, which was fed
      period 0 and polarity -1068821144 instead of 33333 resp. 1.
      
      Fixes: 3796ce1d ("pwm: add period and polarity to struct pwm_lookup")
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Cc: stable@vger.kernel.org
      Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
      d717ea73
  15. 21 5月, 2014 1 次提交
  16. 20 12月, 2013 1 次提交
  17. 03 9月, 2013 1 次提交
  18. 21 6月, 2013 1 次提交
    • H
      pwm: Add sysfs interface · 76abbdde
      H Hartley Sweeten 提交于
      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
            |-- npwm            (r/o) number of PWM channels in this PWM chip
            |-- pwmX/           for each exported PWM channel
            |   |-- duty_cycle  (r/w) duty cycle (in nanoseconds)
            |   |-- enable      (r/w) enable/disable PWM
            |   |-- period      (r/w) period (in nanoseconds)
            |   `-- polarity    (r/w) polarity of PWM (normal/inversed)
            `-- unexport        (w/o) return a PWM channel to the kernel
      
      Based on work by Lars Poeschel.
      Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: Lars Poeschel <poeschel@lemonage.de>
      Cc: Ryan Mallon <rmallon@gmail.com>
      Cc: Rob Landley <rob@landley.net>
      Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
      76abbdde
  19. 10 6月, 2013 1 次提交
  20. 02 2月, 2013 2 次提交
  21. 30 1月, 2013 2 次提交
  22. 06 12月, 2012 1 次提交
  23. 23 11月, 2012 1 次提交
  24. 06 10月, 2012 1 次提交
    • T
      pwm: Check for negative duty-cycle and period · c2d476a9
      Thierry Reding 提交于
      Make sure the duty-cycle and period passed in are not negative. This
      should eventually be made implicit by making them unsigned. While at
      it, the drivers' .config() implementations can have the equivalent
      checks removed.
      Signed-off-by: NThierry Reding <thierry.reding@avionic-design.de>
      Cc: Shawn Guo <shawn.guo@linaro.org>
      Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Sachin Kamat <sachin.kamat@linaro.org>
      Cc: Axel Lin <axel.lin@gmail.com>
      Cc: Kukjin Kim <kgene.kim@samsung.com>
      Cc: Jingoo Han <jg1.han@samsung.com>
      Cc: Jonghwan Choi <jhbird.choi@samsung.com>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: "Philip, Avinash" <avinashphilip@ti.com>
      Cc: Vaibhav Bedia <vaibhav.bedia@ti.com>
      Acked-by: NJingoo Han <jg1.han@samsung.com>
      c2d476a9
  25. 10 9月, 2012 2 次提交