Skip to content

Commit aabec9a

Browse files
nbuchwitzpelwell
authored andcommitted
pwm: rp1: use pwmchip_get_drvdata() instead of container_of()
The PWM framework may not embed struct pwm_chip within the driver’s private data. Using container_of() can result in accessing invalid memory or NULL pointers, especially after recent kernel changes. Switch to pwmchip_get_drvdata() to reliably access the driver data. This resolves kernel warnings and probe failures seen after updating from kernel 6.12.28 to 6.12.34 [1] While at it remove the now obsolete `struct pwm_chip chip` member from `struct pwm_pio_rp1`. [1] #6971 Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
1 parent 4507911 commit aabec9a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/pwm/pwm-pio-rp1.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <linux/pwm.h>
2323

2424
struct pwm_pio_rp1 {
25-
struct pwm_chip chip;
2625
struct device *dev;
2726
struct gpio_desc *gpiod;
2827
struct mutex mutex;
@@ -98,7 +97,7 @@ static void pio_pwm_set_level(PIO pio, uint sm, uint32_t level)
9897
static int pwm_pio_rp1_apply(struct pwm_chip *chip, struct pwm_device *pwm,
9998
const struct pwm_state *state)
10099
{
101-
struct pwm_pio_rp1 *ppwm = container_of(chip, struct pwm_pio_rp1, chip);
100+
struct pwm_pio_rp1 *ppwm = pwmchip_get_drvdata(chip);
102101
uint32_t new_duty_cycle;
103102
uint32_t new_period;
104103

0 commit comments

Comments
 (0)