Skip to content

Commit 17be376

Browse files
bijudasgregkh
authored andcommitted
pwm: rzg2l-gpt: Allow checking period_tick cache value only if sibling channel is enabled
commit fae00ea upstream. The rzg2l_gpt_config() tests the rzg2l_gpt->period_tick variable when both channels of a hardware channel are in use. This check is not valid if rzg2l_gpt_config() is called after disabling all the channels, as it tests against the cached value. Hence, allow checking and setting the cached value only if the sibling channel is enabled. While at it, drop else after return statement to fix the check patch warning. Cc: stable@kernel.org Fixes: 061f087 ("pwm: Add support for RZ/G2L GPT") Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com> Link: https://patch.msgid.link/20251126104308.142302-1-biju.das.jz@bp.renesas.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f80e4e9 commit 17be376

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/pwm/pwm-rzg2l-gpt.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ static inline unsigned int rzg2l_gpt_subchannel(unsigned int hwpwm)
9696
return hwpwm & 0x1;
9797
}
9898

99+
static inline unsigned int rzg2l_gpt_sibling(unsigned int hwpwm)
100+
{
101+
return hwpwm ^ 0x1;
102+
}
103+
99104
static void rzg2l_gpt_write(struct rzg2l_gpt_chip *rzg2l_gpt, u32 reg, u32 data)
100105
{
101106
writel(data, rzg2l_gpt->mmio + reg);
@@ -271,10 +276,14 @@ static int rzg2l_gpt_config(struct pwm_chip *chip, struct pwm_device *pwm,
271276
* in use with different settings.
272277
*/
273278
if (rzg2l_gpt->channel_request_count[ch] > 1) {
274-
if (period_ticks < rzg2l_gpt->period_ticks[ch])
275-
return -EBUSY;
276-
else
279+
u8 sibling_ch = rzg2l_gpt_sibling(pwm->hwpwm);
280+
281+
if (rzg2l_gpt_is_ch_enabled(rzg2l_gpt, sibling_ch)) {
282+
if (period_ticks < rzg2l_gpt->period_ticks[ch])
283+
return -EBUSY;
284+
277285
period_ticks = rzg2l_gpt->period_ticks[ch];
286+
}
278287
}
279288

280289
prescale = rzg2l_gpt_calculate_prescale(rzg2l_gpt, period_ticks);

0 commit comments

Comments
 (0)