Geert Uytterhoeven d717ea73e3 pwm: Fix period and polarity in pwm_get() for non-perfect matches
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: 3796ce1d4d4b ("pwm: add period and polarity to struct pwm_lookup")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: stable@vger.kernel.org
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2014-08-18 10:58:43 +02:00
..
2014-08-08 11:34:32 -07:00
2014-08-08 11:14:29 -07:00
2014-07-23 10:18:07 -07:00
2014-07-23 00:51:30 +02:00
2014-08-06 20:06:14 -07:00
2014-08-05 21:16:46 -07:00
2014-08-15 17:06:40 -04:00
2014-08-04 18:36:12 -07:00
2014-08-08 11:00:26 -07:00
2014-08-08 11:34:32 -07:00
2014-08-08 15:57:28 -07:00
2014-08-08 11:34:32 -07:00
2014-08-08 11:34:32 -07:00
2014-08-08 11:34:32 -07:00
2014-07-30 00:23:09 +02:00
2014-08-08 11:14:29 -07:00
2014-08-15 18:28:58 -06:00
2014-08-08 11:00:26 -07:00
2014-08-06 20:10:32 -07:00
2014-08-04 18:34:04 -07:00