mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-26 00:30:53 +07:00
Input: pwm-beeper - switch to using "atomic" PWM API
The "atomic" API allows us to configure PWM period and duty cycle and enable it in one call. Reviewed-by: Thierry Reding <thierry.reding@gmail.com> Tested-by: David Lechner <david@lechnology.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
9e54924432
commit
2de8b4110c
@ -37,13 +37,16 @@ struct pwm_beeper {
|
|||||||
|
|
||||||
static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period)
|
static int pwm_beeper_on(struct pwm_beeper *beeper, unsigned long period)
|
||||||
{
|
{
|
||||||
|
struct pwm_state state;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = pwm_config(beeper->pwm, period / 2, period);
|
pwm_get_state(beeper->pwm, &state);
|
||||||
if (error)
|
|
||||||
return error;
|
|
||||||
|
|
||||||
error = pwm_enable(beeper->pwm);
|
state.enabled = true;
|
||||||
|
state.period = period;
|
||||||
|
pwm_set_relative_duty_cycle(&state, 50, 100);
|
||||||
|
|
||||||
|
error = pwm_apply_state(beeper->pwm, &state);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@ -127,6 +130,7 @@ static int pwm_beeper_probe(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct pwm_beeper *beeper;
|
struct pwm_beeper *beeper;
|
||||||
|
struct pwm_state state;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL);
|
beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL);
|
||||||
@ -142,11 +146,15 @@ static int pwm_beeper_probe(struct platform_device *pdev)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Sync up PWM state and ensure it is off. */
|
||||||
* FIXME: pwm_apply_args() should be removed when switching to
|
pwm_init_state(beeper->pwm, &state);
|
||||||
* the atomic PWM API.
|
state.enabled = false;
|
||||||
*/
|
error = pwm_apply_state(beeper->pwm, &state);
|
||||||
pwm_apply_args(beeper->pwm);
|
if (error) {
|
||||||
|
dev_err(dev, "failed to apply initial PWM state: %d\n",
|
||||||
|
error);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
beeper->amplifier = devm_regulator_get(dev, "amp");
|
beeper->amplifier = devm_regulator_get(dev, "amp");
|
||||||
if (IS_ERR(beeper->amplifier)) {
|
if (IS_ERR(beeper->amplifier)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user