bus: ts-nbus: Convert to atomic pwm API

With this change the PWM hardware is only configured once (instead of
three times).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Uwe Kleine-König 2024-01-24 09:12:04 +01:00 committed by Arnd Bergmann
parent f0379bd1c7
commit 8129d25e32
No known key found for this signature in database
GPG key ID: 60AB47FFC9095227

View file

@ -273,7 +273,7 @@ EXPORT_SYMBOL_GPL(ts_nbus_write);
static int ts_nbus_probe(struct platform_device *pdev)
{
struct pwm_device *pwm;
struct pwm_args pargs;
struct pwm_state state;
struct device *dev = &pdev->dev;
struct ts_nbus *ts_nbus;
int ret;
@ -296,25 +296,22 @@ static int ts_nbus_probe(struct platform_device *pdev)
return ret;
}
pwm_get_args(pwm, &pargs);
if (!pargs.period) {
pwm_init_state(pwm, &state);
if (!state.period) {
dev_err(&pdev->dev, "invalid PWM period\n");
return -EINVAL;
}
/*
* FIXME: pwm_apply_args() should be removed when switching to
* the atomic PWM API.
*/
pwm_apply_args(pwm);
ret = pwm_config(pwm, pargs.period, pargs.period);
state.duty_cycle = state.period;
state.enabled = true;
ret = pwm_apply_state(pwm, &state);
if (ret < 0)
return ret;
/*
* we can now start the FPGA and populate the peripherals.
*/
pwm_enable(pwm);
ts_nbus->pwm = pwm;
/*