- 10 6月, 2016 1 次提交
-
-
由 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>
-
- 17 5月, 2016 9 次提交
-
-
由 Heiko Stübner 提交于
The PWM states make it possible to also output the polarity, duty cycle and period information in the debugfs summary output. This simplifies gathering information about PWMs without needing to walk through the sysfs attributes of every PWM. Signed-off-by: NHeiko Stuebner <heiko@sntech.de> Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> [thierry.reding@gmail.com: use more spaces in debugfs output] Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Boris Brezillon 提交于
Replace legacy pwm_get/set_xxx() and pwm_config/enable/disable() calls by pwm_get/apply_state(). Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Boris Brezillon 提交于
Add an ->apply() method to the pwm_ops struct to allow PWM drivers to implement atomic updates. This method is preferred over the ->enable(), ->disable() and ->config() methods if available. Add the pwm_apply_state() function to the PWM user API. Note that the pwm_apply_state() does not guarantee the atomicity of the update operation, it all depends on the availability and implementation of the ->apply() method. pwm_enable/disable/set_polarity/config() are now implemented as wrappers around the pwm_apply_state() function. pwm_adjust_config() is allowing smooth handover between the bootloader and the kernel. This function tries to adapt the current PWM state to the PWM arguments coming from a PWM lookup table or a DT definition without changing the duty_cycle/period proportion. Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> [thierry.reding@gmail.com: fix a couple of typos] Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Boris Brezillon 提交于
Add a ->get_state() function to the pwm_ops struct to let PWM drivers initialize the PWM state attached to a PWM device. Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Boris Brezillon 提交于
Prepare the transition to PWM atomic update by moving the enabled and disabled state into the pwm_state struct. This way we can easily update the whole PWM state by copying the new state in the ->state field. Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Boris Brezillon 提交于
The PWM state, represented by its period, duty_cycle and polarity is currently directly stored in the PWM device. Declare a pwm_state structure embedding those field so that we can later use this struct to atomically update all the PWM parameters at once. All pwm_get_xxx() helpers are now implemented as wrappers around pwm_get_state(). Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Boris Brezillon 提交于
Before the introduction of pwm_args, the core was resetting the PWM period and polarity states to the reference values (those provided through the DT, a PWM lookup table or hardcoded in the driver). Now that all PWM users are correctly using pwm_args to configure their PWM device, we can safely remove the pwm_apply_args() call in pwm_get() and of_pwm_get(). We can also get rid of the pwm_set_period() call in pwm_apply_args(), because PWM users are now directly using pargs->period instead of pwm_get_period(). By doing that we avoid messing with the current PWM period. The only remaining bit in pwm_apply_args() is the initial polarity setting, and it should go away when all PWM users have been patched to use the atomic API (with this API the polarity will be set along with other PWM arguments when configuring the PWM). Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Boris BREZILLON 提交于
PWM devices are not protected against concurrent accesses. The lock in struct pwm_device might let PWM users think it is, but it's actually only protecting the enabled state. Removing this lock should be fine as long as all PWM users are aware that accesses to the PWM device have to be serialized, which seems to be the case for all of them except the sysfs interface. Patch the sysfs code by adding a lock to the pwm_export struct and making sure it's taken for all relevant accesses to the exported PWM device. Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Boris Brezillon 提交于
pwm_apply_args() is supposed to initialize a PWM device according to the arguments provided by the DT or the PWM lookup, but this function was called inside pwm_device_request(), which in turn was called before the core had a chance to initialize the pwm->args fields. Fix that by calling pwm_apply_args directly in pwm_get() and of_pwm_get() after initializing pwm->args field. This commit also fixes an invalid pointer dereference introduced by commit e39c0df1 ("pwm: Introduce the pwm_args concept"). Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> Fixes: e39c0df1 ("pwm: Introduce the pwm_args concept") Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 03 5月, 2016 3 次提交
-
-
由 Thierry Reding 提交于
kcalloc() should be preferred for allocations of arrays over kzalloc() with multiplication. Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Thierry Reding 提交于
checkpatch requires that declarations be separated from code by a blank line. Add one for readability and to silence the warning. Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Boris Brezillon 提交于
Currently the PWM core mixes the current PWM state with the per-platform reference config (specified through the PWM lookup table, DT definition or directly hardcoded in PWM drivers). Create a struct pwm_args to store this reference configuration, so that PWM users can differentiate between the current and reference configurations. Patch all places where pwm->args should be initialized. We keep the pwm_set_polarity/period() calls until all PWM users are patched to use pwm_args instead of pwm_get_period/polarity(). Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> [thierry.reding@gmail.com: reword kerneldoc comments] Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 21 1月, 2016 1 次提交
-
-
由 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>
-
- 10 11月, 2015 2 次提交
-
-
由 Thierry Reding 提交于
When looking up a PWM using the lookup table, assume that all entries will have been added already, so failure to find a match means that no corresponding entry has been registered. This fixes an issue where -EPROBE_DEFER would be returned if the PWM lookup table is empty. After this fix, -EPROBE_DEFER is reserved for situations where no provider has yet registered for a matching entry. Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Jonathan Richardson 提交于
The pwm_enable() function didn't clear the enabled bit if a call to the driver's ->enable() callback returned an error. The result was that the state of the PWM core was wrong. Clearing the bit when enable returns an error ensures the state is properly set. Tested-by: NJonathan Richardson <jonathar@broadcom.com> Reviewed-by: NDmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: NJonathan Richardson <jonathar@broadcom.com> [thierry.reding@gmail.com: add missing kerneldoc for the lock] Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 17 8月, 2015 2 次提交
-
-
由 Thierry Reding 提交于
Clean up kerneldoc in preparation for including the PWM documentation in DocBook. Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
由 Thierry Reding 提交于
Remove useless tabs used for padding in structure definitions as well as some blank lines. Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 20 7月, 2015 1 次提交
-
-
由 Boris Brezillon 提交于
Some PWM drivers are testing the PWMF_ENABLED flag. Create a helper function to hide the logic behind enabled test. This will allow us to smoothly move from the current approach to an atomic PWM update approach. Signed-off-by: NBoris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 12 6月, 2015 1 次提交
-
-
由 Tim Kryger 提交于
Add a new function to register a PWM chip with channels that have their initial polarity as specified by an additional parameter. This benefits drivers of controllers that by default operate with inversed polarity by removing the need to modify the polarity during initialization. Signed-off-by: NTim Kryger <tim.kryger@gmail.com> Signed-off-by: NJonathan Richardson <jonathar@broadcom.com> [thierry.reding@gmail.com: export pwmchip_add_with_polarity()] Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 06 5月, 2015 1 次提交
-
-
由 Shobhit Kumar 提交于
In case some drivers are unloading, they can remove lookup tables which they had registered during their load time to avoid redundant entries if loaded again. CC: Samuel Ortiz <sameo@linux.intel.com> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Alexandre Courbot <gnurou@gmail.com> Cc: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: NShobhit Kumar <shobhit.kumar@intel.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 23 4月, 2015 1 次提交
-
-
由 Shobhit Kumar 提交于
For platforms that don't support DT, some early MFD modules can register lookup tables. Remove the __init annotation so that this works. This is similar to gpio_add_lookup_table() which allows late additions. CC: Samuel Ortiz <sameo@linux.intel.com> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Alexandre Courbot <gnurou@gmail.com> Cc: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: NShobhit Kumar <shobhit.kumar@intel.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 03 2月, 2015 1 次提交
-
-
由 Markus Elfring 提交于
The of_node_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: NMarkus Elfring <elfring@users.sourceforge.net> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 29 8月, 2014 1 次提交
-
-
由 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>
-
- 25 8月, 2014 1 次提交
-
-
由 Xiubo Li 提交于
Since we cannot make sure the 'chip->npwm' will always be none zero here, and then if either equal to zero, the kzalloc() will return ZERO_SIZE_PTR, which equals to ((void *)16). So this patch fix this with just doing the zero check before calling kzalloc(). Signed-off-by: NXiubo Li <Li.Xiubo@freescale.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 18 8月, 2014 1 次提交
-
-
由 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>
-
- 21 5月, 2014 1 次提交
-
-
由 Alexandre Belloni 提交于
Add period and polarity members to struct pwm_lookup so that platforms using the lookup table can be treated the same way as those using the device tree. Signed-off-by: NAlexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 20 12月, 2013 1 次提交
-
-
由 Jingoo Han 提交于
For a constant format without additional arguments, use seq_puts() instead of seq_printf(). Also, the following checkpatch warning is fixed. WARNING: Prefer seq_puts to seq_printf Signed-off-by: NJingoo Han <jg1.han@samsung.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 03 9月, 2013 1 次提交
-
-
由 Laurent Pinchart 提交于
Don't redefine a PWM_SPEC_POLARITY macro with a value identical to PWM_POLARITY_INVERTED, use the PWM DT macro directly. Signed-off-by: NLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: NStephen Warren <swarren@nvidia.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 21 6月, 2013 1 次提交
-
-
由 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>
-
- 10 6月, 2013 1 次提交
-
-
由 Wolfram Sang 提交于
The allocated object should be the size of what the pointer is pointing to and not the size of the pointer itself. Signed-off-by: NWolfram Sang <wsa@the-dreams.de> Reviewed-by: NAndy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: NThierry Reding <thierry.reding@gmail.com>
-
- 02 2月, 2013 2 次提交
-
-
由 Peter Ujfalusi 提交于
When booted with DT users can use devm version of of_pwm_get() to benefit from automatic resource release. Signed-off-by: NPeter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: NThierry Reding <thierry.reding@avionic-design.de> Signed-off-by: NBryan Wu <cooloney@gmail.com>
-
由 Peter Ujfalusi 提交于
Allow client driver to use of_pwm_get() to get the PWM they need. This is needed for drivers which handle more than one PWM separately, like leds-pwm driver, which have: pwmleds { compatible = "pwm-leds"; kpad { label = "omap4::keypad"; pwms = <&twl_pwm 0 7812500>; max-brightness = <127>; }; charging { label = "omap4:green:chrg"; pwms = <&twl_pwmled 0 7812500>; max-brightness = <255>; }; }; in the dts files. Signed-off-by: NPeter Ujfalusi <peter.ujfalusi@ti.com> Acked-by: NThierry Reding <thierry.reding@avionic-design.de> Signed-off-by: NBryan Wu <cooloney@gmail.com>
-
- 30 1月, 2013 2 次提交
-
-
由 Thierry Reding 提交于
When building a driver as a module, these functions need to be exported for linking to succeed. Signed-off-by: NThierry Reding <thierry.reding@avionic-design.de>
-
由 Florian Vaussard 提交于
Calls to some external PWM chips can sleep. To help users, add pwm_can_sleep() API. Cc: Thierry Reding <thierry.reding@avionic-design.de> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: NFlorian Vaussard <florian.vaussard@epfl.ch> Reviewed-by: NPeter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: NThierry Reding <thierry.reding@avionic-design.de>
-
- 06 12月, 2012 1 次提交
-
-
由 Thierry Reding 提交于
Drivers may want to use this function if they support any of the flags that can be passed via a third cell in the DT specifier. Since those drivers may be built as modules the symbol needs to be exported to make sure that it can be accessed. Signed-off-by: NThierry Reding <thierry.reding@avionic-design.de>
-
- 23 11月, 2012 1 次提交
-
-
由 Philip, Avinash 提交于
Add support for encoding PWM properties in bit encoded form with of_pwm_xlate_with_flags() function support. Platforms require platform specific PWM properties has to populate in 3rd cell of the pwm-specifier and PWM driver should also set .of_xlate support with this function. Currently PWM property polarity encoded in bit position 0 of the third cell in pwm-specifier. Signed-off-by: NPhilip, Avinash <avinashphilip@ti.com> Acked-by: NGrant Likely <grant.likely@secretlab.ca> Signed-off-by: NThierry Reding <thierry.reding@avionic-design.de>
-
- 06 10月, 2012 1 次提交
-
-
由 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>
-
- 10 9月, 2012 2 次提交
-
-
由 Alexandre Courbot 提交于
Add resource managed variants of pwm_get() and pwm_put() for convenience. Code is largely inspired by the equivalent devm functions of the regulator framework. Signed-off-by: NAlexandre Courbot <acourbot@nvidia.com> Signed-off-by: NThierry Reding <thierry.reding@avionic-design.de>
-
由 Philip, Avinash 提交于
Some hardware supports inverting the polarity of the PWM signal. This commit adds support to the PWM framework to allow users of the PWM API to configure the polarity. Note that in order to reduce complexity, changing the polarity of a PWM signal is only allowed while the PWM is disabled. A practical example where this can prove useful is to simulate inversion of the duty cycle. While inversion of polarity and duty cycle are not exactly the same, the differences for most use-cases are negligible. Signed-off-by: NPhilip, Avinash <avinashphilip@ti.com> Signed-off-by: NThierry Reding <thierry.reding@avionic-design.de>
-