[Bug 298301] arm/broadcom: Fix copy-paste typo in bcm2835_pwm.c affecting channel 2 ratio

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 07 Sep 2026 22:47:34 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=298301

            Bug ID: 298301
           Summary: arm/broadcom: Fix copy-paste typo in bcm2835_pwm.c
                    affecting channel 2 ratio
           Product: Base System
           Version: 14.4-RELEASE
          Hardware: arm
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: arm
          Assignee: freebsd-arm@FreeBSD.org
          Reporter: attila.kover@guardian.co.uk

There is a copy-paste typo in `sys/arm/broadcom/bcm2835/bcm2835_pwm.c` inside
the sysctl handler for the second PWM channel's ratio (`bcm_pwm_ratio2_proc`). 

Instead of writing to the channel 2 data register (`W_DAT2`), the function uses
the macro for the channel 1 data register (`W_DAT`). As a result, attempts to
modify the ratio for channel 2 (`dev.pwm.0.ratio2`) incorrectly overwrite the
channel 1 register, leaving channel 2 non-functional or misconfigured.

The issue was verified on a Raspberry Pi Zero running FreeBSD 14.4-RELEASE.

How to reproduce:
Set a value for `dev.pwm.0.ratio2`. Observe that the configuration applies to
channel 1 instead of channel 2.

Fix:
Change `W_DAT` to `W_DAT2` in `bcm_pwm_ratio2_proc`.

Patch / Unified Diff:

--- sys/arm/broadcom/bcm2835/bcm2835_pwm.c.orig 2026-09-08 00:00:00.000000000
+0200
+++ sys/arm/broadcom/bcm2835/bcm2835_pwm.c      2026-09-08 00:00:00.000000000
+0200
@@ -382,7 +382,7 @@
                if (sc->mode2 == 1)
                        bcm_pwm_write(sc, PWM_RNG2, sc->period2);

-               W_DAT(sc, sc->ratio2);
+               W_DAT2(sc, sc->ratio2);
        }

        return (error);

-- 
You are receiving this mail because:
You are the assignee for the bug.