Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pwm: Export `pwmchip_release` for external use

The upcoming Rust abstraction layer for the PWM subsystem uses a custom
`dev->release` handler to safely manage the lifetime of its driver
data.

To prevent leaking the memory of the `struct pwm_chip` (allocated by
`pwmchip_alloc`), this custom handler must also call the original
`pwmchip_release` function to complete the cleanup.

Make `pwmchip_release` a global, exported function so that it can be
called from the Rust FFI bridge. This involves removing the `static`
keyword, adding a prototype to the public header, and exporting the
symbol.

Reviewed-by: Elle Rhumsaa <elle@weathered-steel.dev>
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
Link: https://patch.msgid.link/20251016-rust-next-pwm-working-fan-for-sending-v16-1-a5df2405d2bd@samsung.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>

authored by

Michal Wilczynski and committed by
Uwe Kleine-König
ce284f88 739ad9be

+8 -1
+2 -1
drivers/pwm/core.c
··· 1608 1608 } 1609 1609 EXPORT_SYMBOL_GPL(pwmchip_put); 1610 1610 1611 - static void pwmchip_release(struct device *pwmchip_dev) 1611 + void pwmchip_release(struct device *pwmchip_dev) 1612 1612 { 1613 1613 struct pwm_chip *chip = pwmchip_from_dev(pwmchip_dev); 1614 1614 1615 1615 kfree(chip); 1616 1616 } 1617 + EXPORT_SYMBOL_GPL(pwmchip_release); 1617 1618 1618 1619 struct pwm_chip *pwmchip_alloc(struct device *parent, unsigned int npwm, size_t sizeof_priv) 1619 1620 {
+6
include/linux/pwm.h
··· 488 488 #define pwmchip_add(chip) __pwmchip_add(chip, THIS_MODULE) 489 489 void pwmchip_remove(struct pwm_chip *chip); 490 490 491 + /* 492 + * For FFI wrapper use only: 493 + * The Rust PWM abstraction needs this to properly free the pwm_chip. 494 + */ 495 + void pwmchip_release(struct device *dev); 496 + 491 497 int __devm_pwmchip_add(struct device *dev, struct pwm_chip *chip, struct module *owner); 492 498 #define devm_pwmchip_add(dev, chip) __devm_pwmchip_add(dev, chip, THIS_MODULE) 493 499