Skip to content

Commit c748a6d

Browse files
seanyoungthierryreding
authored andcommitted
pwm: Rename pwm_apply_state() to pwm_apply_might_sleep()
In order to introduce a pwm api which can be used from atomic context, we will need two functions for applying pwm changes: int pwm_apply_might_sleep(struct pwm *, struct pwm_state *); int pwm_apply_atomic(struct pwm *, struct pwm_state *); This commit just deals with renaming pwm_apply_state(), a following commit will introduce the pwm_apply_atomic() function. Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Mark Brown <broonie@kernel.org> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> # for input Acked-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Jani Nikula <jani.nikula@intel.com> Acked-by: Lee Jones <lee@kernel.org> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
1 parent 80943bb commit c748a6d

22 files changed

Lines changed: 68 additions & 68 deletions

File tree

Documentation/driver-api/pwm.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ the getter, devm_pwm_get() and devm_fwnode_pwm_get(), also exist.
4141

4242
After being requested, a PWM has to be configured using::
4343

44-
int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state);
44+
int pwm_apply_might_sleep(struct pwm_device *pwm, struct pwm_state *state);
4545

4646
This API controls both the PWM period/duty_cycle config and the
4747
enable/disable state.
@@ -57,13 +57,13 @@ If supported by the driver, the signal can be optimized, for example to improve
5757
EMI by phase shifting the individual channels of a chip.
5858

5959
The pwm_config(), pwm_enable() and pwm_disable() functions are just wrappers
60-
around pwm_apply_state() and should not be used if the user wants to change
60+
around pwm_apply_might_sleep() and should not be used if the user wants to change
6161
several parameter at once. For example, if you see pwm_config() and
6262
pwm_{enable,disable}() calls in the same function, this probably means you
63-
should switch to pwm_apply_state().
63+
should switch to pwm_apply_might_sleep().
6464

6565
The PWM user API also allows one to query the PWM state that was passed to the
66-
last invocation of pwm_apply_state() using pwm_get_state(). Note this is
66+
last invocation of pwm_apply_might_sleep() using pwm_get_state(). Note this is
6767
different to what the driver has actually implemented if the request cannot be
6868
satisfied exactly with the hardware in use. There is currently no way for
6969
consumers to get the actually implemented settings.

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17576,7 +17576,7 @@ F: drivers/video/backlight/pwm_bl.c
1757617576
F: include/dt-bindings/pwm/
1757717577
F: include/linux/pwm.h
1757817578
F: include/linux/pwm_backlight.h
17579-
K: pwm_(config|apply_state|ops)
17579+
K: pwm_(config|apply_might_sleep|ops)
1758017580

1758117581
PXA GPIO DRIVER
1758217582
M: Robert Jarzmik <robert.jarzmik@free.fr>

drivers/gpu/drm/i915/display/intel_backlight.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static void ext_pwm_set_backlight(const struct drm_connector_state *conn_state,
274274
struct intel_panel *panel = &to_intel_connector(conn_state->connector)->panel;
275275

276276
pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100);
277-
pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state);
277+
pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state);
278278
}
279279

280280
static void
@@ -427,7 +427,7 @@ static void ext_pwm_disable_backlight(const struct drm_connector_state *old_conn
427427
intel_backlight_set_pwm_level(old_conn_state, level);
428428

429429
panel->backlight.pwm_state.enabled = false;
430-
pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state);
430+
pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state);
431431
}
432432

433433
void intel_backlight_disable(const struct drm_connector_state *old_conn_state)
@@ -749,7 +749,7 @@ static void ext_pwm_enable_backlight(const struct intel_crtc_state *crtc_state,
749749

750750
pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100);
751751
panel->backlight.pwm_state.enabled = true;
752-
pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state);
752+
pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state);
753753
}
754754

755755
static void __intel_backlight_enable(const struct intel_crtc_state *crtc_state,

drivers/gpu/drm/solomon/ssd130x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static int ssd130x_pwm_enable(struct ssd130x_device *ssd130x)
319319

320320
pwm_init_state(ssd130x->pwm, &pwmstate);
321321
pwm_set_relative_duty_cycle(&pwmstate, 50, 100);
322-
pwm_apply_state(ssd130x->pwm, &pwmstate);
322+
pwm_apply_might_sleep(ssd130x->pwm, &pwmstate);
323323

324324
/* Enable the PWM */
325325
pwm_enable(ssd130x->pwm);

drivers/hwmon/pwm-fan.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int pwm_fan_power_on(struct pwm_fan_ctx *ctx)
151151
}
152152

153153
state->enabled = true;
154-
ret = pwm_apply_state(ctx->pwm, state);
154+
ret = pwm_apply_might_sleep(ctx->pwm, state);
155155
if (ret) {
156156
dev_err(ctx->dev, "failed to enable PWM\n");
157157
goto disable_regulator;
@@ -181,7 +181,7 @@ static int pwm_fan_power_off(struct pwm_fan_ctx *ctx)
181181

182182
state->enabled = false;
183183
state->duty_cycle = 0;
184-
ret = pwm_apply_state(ctx->pwm, state);
184+
ret = pwm_apply_might_sleep(ctx->pwm, state);
185185
if (ret) {
186186
dev_err(ctx->dev, "failed to disable PWM\n");
187187
return ret;
@@ -207,7 +207,7 @@ static int __set_pwm(struct pwm_fan_ctx *ctx, unsigned long pwm)
207207

208208
period = state->period;
209209
state->duty_cycle = DIV_ROUND_UP(pwm * (period - 1), MAX_PWM);
210-
ret = pwm_apply_state(ctx->pwm, state);
210+
ret = pwm_apply_might_sleep(ctx->pwm, state);
211211
if (ret)
212212
return ret;
213213
ret = pwm_fan_power_on(ctx);
@@ -278,7 +278,7 @@ static int pwm_fan_update_enable(struct pwm_fan_ctx *ctx, long val)
278278
state,
279279
&enable_regulator);
280280

281-
pwm_apply_state(ctx->pwm, state);
281+
pwm_apply_might_sleep(ctx->pwm, state);
282282
pwm_fan_switch_power(ctx, enable_regulator);
283283
pwm_fan_update_state(ctx, 0);
284284
}

drivers/input/misc/da7280.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static int da7280_haptic_set_pwm(struct da7280_haptic *haptics, bool enabled)
352352
state.duty_cycle = period_mag_multi;
353353
}
354354

355-
error = pwm_apply_state(haptics->pwm_dev, &state);
355+
error = pwm_apply_might_sleep(haptics->pwm_dev, &state);
356356
if (error)
357357
dev_err(haptics->dev, "Failed to apply pwm state: %d\n", error);
358358

@@ -1175,7 +1175,7 @@ static int da7280_probe(struct i2c_client *client)
11751175
/* Sync up PWM state and ensure it is off. */
11761176
pwm_init_state(haptics->pwm_dev, &state);
11771177
state.enabled = false;
1178-
error = pwm_apply_state(haptics->pwm_dev, &state);
1178+
error = pwm_apply_might_sleep(haptics->pwm_dev, &state);
11791179
if (error) {
11801180
dev_err(dev, "Failed to apply PWM state: %d\n", error);
11811181
return error;

drivers/input/misc/pwm-beeper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period)
3939
state.period = period;
4040
pwm_set_relative_duty_cycle(&state, 50, 100);
4141

42-
error = pwm_apply_state(beeper->pwm, &state);
42+
error = pwm_apply_might_sleep(beeper->pwm, &state);
4343
if (error)
4444
return error;
4545

@@ -138,7 +138,7 @@ static int pwm_beeper_probe(struct platform_device *pdev)
138138
/* Sync up PWM state and ensure it is off. */
139139
pwm_init_state(beeper->pwm, &state);
140140
state.enabled = false;
141-
error = pwm_apply_state(beeper->pwm, &state);
141+
error = pwm_apply_might_sleep(beeper->pwm, &state);
142142
if (error) {
143143
dev_err(dev, "failed to apply initial PWM state: %d\n",
144144
error);

drivers/input/misc/pwm-vibra.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator)
5656
pwm_set_relative_duty_cycle(&state, vibrator->level, 0xffff);
5757
state.enabled = true;
5858

59-
err = pwm_apply_state(vibrator->pwm, &state);
59+
err = pwm_apply_might_sleep(vibrator->pwm, &state);
6060
if (err) {
6161
dev_err(pdev, "failed to apply pwm state: %d\n", err);
6262
return err;
@@ -67,7 +67,7 @@ static int pwm_vibrator_start(struct pwm_vibrator *vibrator)
6767
state.duty_cycle = vibrator->direction_duty_cycle;
6868
state.enabled = true;
6969

70-
err = pwm_apply_state(vibrator->pwm_dir, &state);
70+
err = pwm_apply_might_sleep(vibrator->pwm_dir, &state);
7171
if (err) {
7272
dev_err(pdev, "failed to apply dir-pwm state: %d\n", err);
7373
pwm_disable(vibrator->pwm);
@@ -160,7 +160,7 @@ static int pwm_vibrator_probe(struct platform_device *pdev)
160160
/* Sync up PWM state and ensure it is off. */
161161
pwm_init_state(vibrator->pwm, &state);
162162
state.enabled = false;
163-
err = pwm_apply_state(vibrator->pwm, &state);
163+
err = pwm_apply_might_sleep(vibrator->pwm, &state);
164164
if (err) {
165165
dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n",
166166
err);
@@ -174,7 +174,7 @@ static int pwm_vibrator_probe(struct platform_device *pdev)
174174
/* Sync up PWM state and ensure it is off. */
175175
pwm_init_state(vibrator->pwm_dir, &state);
176176
state.enabled = false;
177-
err = pwm_apply_state(vibrator->pwm_dir, &state);
177+
err = pwm_apply_might_sleep(vibrator->pwm_dir, &state);
178178
if (err) {
179179
dev_err(&pdev->dev, "failed to apply initial PWM state: %d\n",
180180
err);

drivers/leds/leds-pwm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static int led_pwm_set(struct led_classdev *led_cdev,
5454

5555
led_dat->pwmstate.duty_cycle = duty;
5656
led_dat->pwmstate.enabled = true;
57-
return pwm_apply_state(led_dat->pwm, &led_dat->pwmstate);
57+
return pwm_apply_might_sleep(led_dat->pwm, &led_dat->pwmstate);
5858
}
5959

6060
__attribute__((nonnull))

drivers/leds/rgb/leds-pwm-multicolor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ static int led_pwm_mc_set(struct led_classdev *cdev,
5151

5252
priv->leds[i].state.duty_cycle = duty;
5353
priv->leds[i].state.enabled = duty > 0;
54-
ret = pwm_apply_state(priv->leds[i].pwm,
55-
&priv->leds[i].state);
54+
ret = pwm_apply_might_sleep(priv->leds[i].pwm,
55+
&priv->leds[i].state);
5656
if (ret)
5757
break;
5858
}

0 commit comments

Comments
 (0)