Skip to content

Commit edd3bcb

Browse files
Michal WilczynskiUwe Kleine-König
authored andcommitted
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 <[email protected]> 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 <[email protected]>
1 parent 4cd2f41 commit edd3bcb

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

drivers/pwm/core.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ static int __pwm_write_waveform(struct pwm_chip *chip, struct pwm_device *pwm, c
210210
return ret;
211211
}
212212

213-
#define WFHWSIZE 20
214-
215213
/**
216214
* pwm_round_waveform_might_sleep - Query hardware capabilities
217215
* Cannot be used in atomic context.
@@ -248,10 +246,10 @@ int pwm_round_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *
248246
struct pwm_chip *chip = pwm->chip;
249247
const struct pwm_ops *ops = chip->ops;
250248
struct pwm_waveform wf_req = *wf;
251-
char wfhw[WFHWSIZE];
249+
char wfhw[PWM_WFHWSIZE];
252250
int ret_tohw, ret_fromhw;
253251

254-
BUG_ON(WFHWSIZE < ops->sizeof_wfhw);
252+
BUG_ON(PWM_WFHWSIZE < ops->sizeof_wfhw);
255253

256254
if (!pwmchip_supports_waveform(chip))
257255
return -EOPNOTSUPP;
@@ -306,10 +304,10 @@ int pwm_get_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *wf
306304
{
307305
struct pwm_chip *chip = pwm->chip;
308306
const struct pwm_ops *ops = chip->ops;
309-
char wfhw[WFHWSIZE];
307+
char wfhw[PWM_WFHWSIZE];
310308
int err;
311309

312-
BUG_ON(WFHWSIZE < ops->sizeof_wfhw);
310+
BUG_ON(PWM_WFHWSIZE < ops->sizeof_wfhw);
313311

314312
if (!pwmchip_supports_waveform(chip) || !ops->read_waveform)
315313
return -EOPNOTSUPP;
@@ -334,11 +332,11 @@ static int __pwm_set_waveform(struct pwm_device *pwm,
334332
{
335333
struct pwm_chip *chip = pwm->chip;
336334
const struct pwm_ops *ops = chip->ops;
337-
char wfhw[WFHWSIZE];
335+
char wfhw[PWM_WFHWSIZE];
338336
struct pwm_waveform wf_rounded;
339337
int err, ret_tohw;
340338

341-
BUG_ON(WFHWSIZE < ops->sizeof_wfhw);
339+
BUG_ON(PWM_WFHWSIZE < ops->sizeof_wfhw);
342340

343341
if (!pwmchip_supports_waveform(chip))
344342
return -EOPNOTSUPP;
@@ -650,9 +648,9 @@ static int __pwm_apply(struct pwm_device *pwm, const struct pwm_state *state)
650648

651649
if (pwmchip_supports_waveform(chip)) {
652650
struct pwm_waveform wf;
653-
char wfhw[WFHWSIZE];
651+
char wfhw[PWM_WFHWSIZE];
654652

655-
BUG_ON(WFHWSIZE < ops->sizeof_wfhw);
653+
BUG_ON(PWM_WFHWSIZE < ops->sizeof_wfhw);
656654

657655
pwm_state2wf(state, &wf);
658656

@@ -809,10 +807,10 @@ int pwm_get_state_hw(struct pwm_device *pwm, struct pwm_state *state)
809807
return -ENODEV;
810808

811809
if (pwmchip_supports_waveform(chip) && ops->read_waveform) {
812-
char wfhw[WFHWSIZE];
810+
char wfhw[PWM_WFHWSIZE];
813811
struct pwm_waveform wf;
814812

815-
BUG_ON(WFHWSIZE < ops->sizeof_wfhw);
813+
BUG_ON(PWM_WFHWSIZE < ops->sizeof_wfhw);
816814

817815
ret = __pwm_read_waveform(chip, pwm, &wfhw);
818816
if (ret)
@@ -1696,8 +1694,8 @@ static bool pwm_ops_check(const struct pwm_chip *chip)
16961694
!ops->write_waveform)
16971695
return false;
16981696

1699-
if (WFHWSIZE < ops->sizeof_wfhw) {
1700-
dev_warn(pwmchip_parent(chip), "WFHWSIZE < %zu\n", ops->sizeof_wfhw);
1697+
if (PWM_WFHWSIZE < ops->sizeof_wfhw) {
1698+
dev_warn(pwmchip_parent(chip), "PWM_WFHWSIZE < %zu\n", ops->sizeof_wfhw);
17011699
return false;
17021700
}
17031701
} else {

include/linux/pwm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ struct pwm_capture {
274274
unsigned int duty_cycle;
275275
};
276276

277+
#define PWM_WFHWSIZE 20
278+
277279
/**
278280
* struct pwm_ops - PWM controller operations
279281
* @request: optional hook for requesting a PWM

0 commit comments

Comments
 (0)