pwm: lpc18xx-sct: Initialize driver data and hardware before pwmchip_add()
BugLink: https://bugs.launchpad.net/bugs/1969110
[ Upstream commit
0401f24cd238ae200a23a13925f98de3d2c883b8 ]
When a driver calls pwmchip_add() it has to be prepared to immediately
get its callbacks called. So move allocation of driver data and hardware
initialization before the call to pwmchip_add().
This fixes a potential NULL pointer exception and a race condition on
register writes.
Fixes: 841e6f90bb78 ("pwm: NXP LPC18xx PWM/SCT driver")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit
6f4f778f2747c23a14bda72df6bf5a445b68fee2)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>