Patch "pwm: meson: Explicitly set .polarity in .get_state()" has been added to the 6.2-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    pwm: meson: Explicitly set .polarity in .get_state()

to the 6.2-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     pwm-meson-explicitly-set-.polarity-in-.get_state.patch
and it can be found in the queue-6.2 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit cebf24573ba0f95785309b6874bd2535912256e5
Author: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
Date:   Wed Mar 22 22:45:44 2023 +0100

    pwm: meson: Explicitly set .polarity in .get_state()
    
    [ Upstream commit 8caa81eb950cb2e9d2d6959b37d853162d197f57 ]
    
    The driver only supports normal polarity. Complete the implementation of
    .get_state() by setting .polarity accordingly.
    
    This fixes a regression that was possible since commit c73a3107624d
    ("pwm: Handle .get_state() failures") which stopped to zero-initialize
    the state passed to the .get_state() callback. This was reported at
    https://forum.odroid.com/viewtopic.php?f=177&t=46360 . While this was an
    unintended side effect, the real issue is the driver's callback not
    setting the polarity.
    
    There is a complicating fact, that the .apply() callback fakes support
    for inversed polarity. This is not (and cannot) be matched by
    .get_state(). As fixing this isn't easy, only point it out in a comment
    to prevent authors of other drivers from copying that approach.
    
    Fixes: c375bcbaabdb ("pwm: meson: Read the full hardware state in meson_pwm_get_state()")
    Reported-by: Munehisa Kamata <kamatam@xxxxxxxxxx>
    Acked-by: Martin Blumenstingl <martin.blumenstingl@xxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230310191405.2606296-1-u.kleine-koenig@xxxxxxxxxxxxxx
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
    Signed-off-by: Thierry Reding <thierry.reding@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 16d79ca5d8f53..5cd7b90872c62 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -162,6 +162,12 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
 	duty = state->duty_cycle;
 	period = state->period;
 
+	/*
+	 * Note this is wrong. The result is an output wave that isn't really
+	 * inverted and so is wrongly identified by .get_state as normal.
+	 * Fixing this needs some care however as some machines might rely on
+	 * this.
+	 */
 	if (state->polarity == PWM_POLARITY_INVERSED)
 		duty = period - duty;
 
@@ -358,6 +364,8 @@ static int meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 		state->duty_cycle = 0;
 	}
 
+	state->polarity = PWM_POLARITY_NORMAL;
+
 	return 0;
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux