From: Stefan Mavrodiev Date: Tue, 2 Jul 2019 12:05:50 +0300 Subject: [U-Boot] [PATCH] video: backlight: fix pwm invertation In-Reply-To: References: <1714255.XLXxeDuSEK@ax5200p> <2210d5d9-9fb0-c6a4-e071-2faf35c41c95@olimex.com> Message-ID: <8e7ee040-8f80-6637-1da3-222f37237a1d@olimex.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: u-boot@lists.denx.de Hi, On 7/2/19 11:42 AM, Nicolas Chauvet wrote: > Le mar. 2 juil. 2019 à 09:41, Stefan Mavrodiev a écrit : >> Hi, >> >> On 6/27/19 9:56 PM, marvin24 at posteo.de wrote: >>> Am Freitag, 21. Juni 2019, 22:01:35 CEST schrieb Marc Dietrich: >>>> Fixes: 57e7775413 ("video: backlight: Parse PWM polarity cell") >>>> >>>> set_pwm will always fail if pwm_set_invert is not implemented, leaving the >>>> backlight dark. Fix this by calling pwm_set_invert only if pwm is inverted. >> I'm not sure if this is true. pwm_set_invert() checks for .set_invert. >> Which pwm driver you're using? > This is drivers/pwm/pwm_tegra.c > Here .set_invert is not implemented. > > Thx for the review. > You're right. Some drivers has #pwm-cells = <2> and in this case polarity is 0. However your approach is wrong. You will break other drivers with #pwm-cells = <3>. I think your patch should look something like this: ret = pwm_set_invert(priv->pwm, priv->channel, priv->polarity); if (ret == -ENOSYS)     ret = 0; return log_ret(ret); This will not return error if set_inverted is not implemented. Stefan