Re: [PATCH 1/5] pwm: rz-mtu3: fix prescale check when enabling 2nd channel
From: Geert Uytterhoeven
Date: Tue Mar 17 2026 - 04:26:21 EST
Hi Cosmin,
On Mon, 16 Mar 2026 at 20:13, Cosmin-Gabriel Tanislav
<cosmin-gabriel.tanislav.xa@xxxxxxxxxxx> wrote:
> > From: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> > Sent: Monday, March 16, 2026 8:26 PM
> >
> > Hi Cosmin,
> >
> > On Mon, 16 Mar 2026 at 16:52, Cosmin-Gabriel Tanislav
> > <cosmin-gabriel.tanislav.xa@xxxxxxxxxxx> wrote:
> > > static int rz_mtu3_sibling_hwpwm(u32 hwpwm, u32 *sibling_hwpwm)
> >
> > Unused sibling_hwpwm?
> >
> > > {
> > > if (!rz_mtu3_hwpwm_is_primary(hwpwm))
> > > return hwpwm - 1;
> > >
> > > if (rz_mtu3_hwpwm_is_primary(hwpwm + 1))
> > > return -EINVAL;
> > >
> > > return hwpwm + 1;
> > > }
> It's funny how even after triple-checking the message I was about to
> send, I didn't notice it.
>
> This should have been what I sent.
>
> static int rz_mtu3_sibling_hwpwm(u32 hwpwm, u32 *sibling_hwpwm)
> {
> if (!rz_mtu3_hwpwm_is_primary(hwpwm)) {
> *sibling_hwpwm = hwpwm - 1;
> return 0;
> }
>
> if (rz_mtu3_hwpwm_is_primary(hwpwm + 1))
> return -EINVAL;
>
> *sibling_hwpwm = hwpwm + 1;
>
> return 0;
> }
Thanks, now I can see what you intended ;-)
As the output parameter value is unsigned, and never very large,
returning that value or a negative error code as the return value may
be simpler (i.e. use the original "bad" version, and drop the unused
output parameter)?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds