mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-12 01:20:14 +00:00
pwm: rzg2l-gpt: Allow checking period_tick cache value only if sibling channel is enabled
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: 061f087f5d0b ("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>
This commit is contained in:
parent
cda323dbda
commit
fae00ea9f0
@ -96,6 +96,11 @@ static inline unsigned int rzg2l_gpt_subchannel(unsigned int hwpwm)
|
||||
return hwpwm & 0x1;
|
||||
}
|
||||
|
||||
static inline unsigned int rzg2l_gpt_sibling(unsigned int hwpwm)
|
||||
{
|
||||
return hwpwm ^ 0x1;
|
||||
}
|
||||
|
||||
static void rzg2l_gpt_write(struct rzg2l_gpt_chip *rzg2l_gpt, u32 reg, u32 data)
|
||||
{
|
||||
writel(data, rzg2l_gpt->mmio + reg);
|
||||
@ -271,10 +276,14 @@ static int rzg2l_gpt_config(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
* in use with different settings.
|
||||
*/
|
||||
if (rzg2l_gpt->channel_request_count[ch] > 1) {
|
||||
if (period_ticks < rzg2l_gpt->period_ticks[ch])
|
||||
return -EBUSY;
|
||||
else
|
||||
u8 sibling_ch = rzg2l_gpt_sibling(pwm->hwpwm);
|
||||
|
||||
if (rzg2l_gpt_is_ch_enabled(rzg2l_gpt, sibling_ch)) {
|
||||
if (period_ticks < rzg2l_gpt->period_ticks[ch])
|
||||
return -EBUSY;
|
||||
|
||||
period_ticks = rzg2l_gpt->period_ticks[ch];
|
||||
}
|
||||
}
|
||||
|
||||
prescale = rzg2l_gpt_calculate_prescale(rzg2l_gpt, period_ticks);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user