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: Expose PWM_WFHWSIZE in public header

The WFHWSIZE constant defines the maximum size for the hardware-specific
waveform representation buffer. It is currently local to
drivers/pwm/core.c, which makes it inaccessible to external tools like
bindgen.

Move the constant to include/linux/pwm.h to make it part of the public
API. As part of this change, rename it to PWM_WFHWSIZE to follow
standard kernel conventions for namespacing macros in public headers.

This allows bindgen to automatically generate a corresponding constant
for the Rust PWM abstractions, ensuring the value remains synchronized
between the C core and Rust code and preventing future maintenance
issues.

Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
Link: https://lore.kernel.org/r/20250702-rust-next-pwm-working-fan-for-sending-v7-1-67ef39ff1d29@samsung.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>

authored by

Michal Wilczynski and committed by
Uwe Kleine-König
edd3bcb1 4cd2f417

+14 -14
+12 -14
drivers/pwm/core.c
··· 210 210 return ret; 211 211 } 212 212 213 - #define WFHWSIZE 20 214 - 215 213 /** 216 214 * pwm_round_waveform_might_sleep - Query hardware capabilities 217 215 * Cannot be used in atomic context. ··· 246 248 struct pwm_chip *chip = pwm->chip; 247 249 const struct pwm_ops *ops = chip->ops; 248 250 struct pwm_waveform wf_req = *wf; 249 - char wfhw[WFHWSIZE]; 251 + char wfhw[PWM_WFHWSIZE]; 250 252 int ret_tohw, ret_fromhw; 251 253 252 - BUG_ON(WFHWSIZE < ops->sizeof_wfhw); 254 + BUG_ON(PWM_WFHWSIZE < ops->sizeof_wfhw); 253 255 254 256 if (!pwmchip_supports_waveform(chip)) 255 257 return -EOPNOTSUPP; ··· 304 306 { 305 307 struct pwm_chip *chip = pwm->chip; 306 308 const struct pwm_ops *ops = chip->ops; 307 - char wfhw[WFHWSIZE]; 309 + char wfhw[PWM_WFHWSIZE]; 308 310 int err; 309 311 310 - BUG_ON(WFHWSIZE < ops->sizeof_wfhw); 312 + BUG_ON(PWM_WFHWSIZE < ops->sizeof_wfhw); 311 313 312 314 if (!pwmchip_supports_waveform(chip) || !ops->read_waveform) 313 315 return -EOPNOTSUPP; ··· 332 334 { 333 335 struct pwm_chip *chip = pwm->chip; 334 336 const struct pwm_ops *ops = chip->ops; 335 - char wfhw[WFHWSIZE]; 337 + char wfhw[PWM_WFHWSIZE]; 336 338 struct pwm_waveform wf_rounded; 337 339 int err, ret_tohw; 338 340 339 - BUG_ON(WFHWSIZE < ops->sizeof_wfhw); 341 + BUG_ON(PWM_WFHWSIZE < ops->sizeof_wfhw); 340 342 341 343 if (!pwmchip_supports_waveform(chip)) 342 344 return -EOPNOTSUPP; ··· 648 650 649 651 if (pwmchip_supports_waveform(chip)) { 650 652 struct pwm_waveform wf; 651 - char wfhw[WFHWSIZE]; 653 + char wfhw[PWM_WFHWSIZE]; 652 654 653 - BUG_ON(WFHWSIZE < ops->sizeof_wfhw); 655 + BUG_ON(PWM_WFHWSIZE < ops->sizeof_wfhw); 654 656 655 657 pwm_state2wf(state, &wf); 656 658 ··· 807 809 return -ENODEV; 808 810 809 811 if (pwmchip_supports_waveform(chip) && ops->read_waveform) { 810 - char wfhw[WFHWSIZE]; 812 + char wfhw[PWM_WFHWSIZE]; 811 813 struct pwm_waveform wf; 812 814 813 - BUG_ON(WFHWSIZE < ops->sizeof_wfhw); 815 + BUG_ON(PWM_WFHWSIZE < ops->sizeof_wfhw); 814 816 815 817 ret = __pwm_read_waveform(chip, pwm, &wfhw); 816 818 if (ret) ··· 1694 1696 !ops->write_waveform) 1695 1697 return false; 1696 1698 1697 - if (WFHWSIZE < ops->sizeof_wfhw) { 1698 - dev_warn(pwmchip_parent(chip), "WFHWSIZE < %zu\n", ops->sizeof_wfhw); 1699 + if (PWM_WFHWSIZE < ops->sizeof_wfhw) { 1700 + dev_warn(pwmchip_parent(chip), "PWM_WFHWSIZE < %zu\n", ops->sizeof_wfhw); 1699 1701 return false; 1700 1702 } 1701 1703 } else {
+2
include/linux/pwm.h
··· 274 274 unsigned int duty_cycle; 275 275 }; 276 276 277 + #define PWM_WFHWSIZE 20 278 + 277 279 /** 278 280 * struct pwm_ops - PWM controller operations 279 281 * @request: optional hook for requesting a PWM