Commit c748a6d7 authored by Sean Young's avatar Sean Young Committed by Thierry Reding
Browse files

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: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: default avatarGuenter Roeck <linux@roeck-us.net>
Acked-by: default avatarMark Brown <broonie@kernel.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> # for input
Acked-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
Acked-by: default avatarLee Jones <lee@kernel.org>
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 80943bbd
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ the getter, devm_pwm_get() and devm_fwnode_pwm_get(), also exist.

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

	int pwm_apply_state(struct pwm_device *pwm, struct pwm_state *state);
	int pwm_apply_might_sleep(struct pwm_device *pwm, struct pwm_state *state);

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

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

The PWM user API also allows one to query the PWM state that was passed to the
last invocation of pwm_apply_state() using pwm_get_state(). Note this is
last invocation of pwm_apply_might_sleep() using pwm_get_state(). Note this is
different to what the driver has actually implemented if the request cannot be
satisfied exactly with the hardware in use. There is currently no way for
consumers to get the actually implemented settings.
+1 −1
Original line number Diff line number Diff line
@@ -17576,7 +17576,7 @@ F: drivers/video/backlight/pwm_bl.c
F:	include/dt-bindings/pwm/
F:	include/linux/pwm.h
F:	include/linux/pwm_backlight.h
K:	pwm_(config|apply_state|ops)
K:	pwm_(config|apply_might_sleep|ops)
PXA GPIO DRIVER
M:	Robert Jarzmik <robert.jarzmik@free.fr>
+3 −3
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ static void ext_pwm_set_backlight(const struct drm_connector_state *conn_state,
	struct intel_panel *panel = &to_intel_connector(conn_state->connector)->panel;

	pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100);
	pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state);
	pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state);
}

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

	panel->backlight.pwm_state.enabled = false;
	pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state);
	pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state);
}

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,

	pwm_set_relative_duty_cycle(&panel->backlight.pwm_state, level, 100);
	panel->backlight.pwm_state.enabled = true;
	pwm_apply_state(panel->backlight.pwm, &panel->backlight.pwm_state);
	pwm_apply_might_sleep(panel->backlight.pwm, &panel->backlight.pwm_state);
}

static void __intel_backlight_enable(const struct intel_crtc_state *crtc_state,
+1 −1
Original line number Diff line number Diff line
@@ -319,7 +319,7 @@ static int ssd130x_pwm_enable(struct ssd130x_device *ssd130x)

	pwm_init_state(ssd130x->pwm, &pwmstate);
	pwm_set_relative_duty_cycle(&pwmstate, 50, 100);
	pwm_apply_state(ssd130x->pwm, &pwmstate);
	pwm_apply_might_sleep(ssd130x->pwm, &pwmstate);

	/* Enable the PWM */
	pwm_enable(ssd130x->pwm);
+4 −4
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ static int pwm_fan_power_on(struct pwm_fan_ctx *ctx)
	}

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

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

		period = state->period;
		state->duty_cycle = DIV_ROUND_UP(pwm * (period - 1), MAX_PWM);
		ret = pwm_apply_state(ctx->pwm, state);
		ret = pwm_apply_might_sleep(ctx->pwm, state);
		if (ret)
			return ret;
		ret = pwm_fan_power_on(ctx);
@@ -278,7 +278,7 @@ static int pwm_fan_update_enable(struct pwm_fan_ctx *ctx, long val)
						    state,
						    &enable_regulator);

			pwm_apply_state(ctx->pwm, state);
			pwm_apply_might_sleep(ctx->pwm, state);
			pwm_fan_switch_power(ctx, enable_regulator);
			pwm_fan_update_state(ctx, 0);
		}
Loading