mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
pwm: keembay: Make use of devm_pwmchip_alloc() function
This prepares the pwm-keembay driver to further changes of the pwm core outlined in the commit introducing devm_pwmchip_alloc(). There is no intended semantical change and the driver should behave as before. Link: https://lore.kernel.org/r/f65c27bf0a1f9ba4e5dbb115ff628860163ff8e0.1707900770.git.u.kleine-koenig@pengutronix.de Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
This commit is contained in:
parent
5d0237a7b0
commit
15527ec252
@ -36,7 +36,6 @@
|
||||
#define KMB_PWM_HIGHLOW_OFFSET(ch) (0x20 + 4 * (ch))
|
||||
|
||||
struct keembay_pwm {
|
||||
struct pwm_chip chip;
|
||||
struct device *dev;
|
||||
struct clk *clk;
|
||||
void __iomem *base;
|
||||
@ -44,7 +43,7 @@ struct keembay_pwm {
|
||||
|
||||
static inline struct keembay_pwm *to_keembay_pwm_dev(struct pwm_chip *chip)
|
||||
{
|
||||
return container_of(chip, struct keembay_pwm, chip);
|
||||
return pwmchip_get_drvdata(chip);
|
||||
}
|
||||
|
||||
static void keembay_clk_unprepare(void *data)
|
||||
@ -185,12 +184,14 @@ static const struct pwm_ops keembay_pwm_ops = {
|
||||
static int keembay_pwm_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct pwm_chip *chip;
|
||||
struct keembay_pwm *priv;
|
||||
int ret;
|
||||
|
||||
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
chip = devm_pwmchip_alloc(dev, KMB_TOTAL_PWM_CHANNELS, sizeof(*priv));
|
||||
if (IS_ERR(chip))
|
||||
return PTR_ERR(chip);
|
||||
priv = to_keembay_pwm_dev(chip);
|
||||
|
||||
priv->clk = devm_clk_get(dev, NULL);
|
||||
if (IS_ERR(priv->clk))
|
||||
@ -204,11 +205,9 @@ static int keembay_pwm_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
priv->chip.dev = dev;
|
||||
priv->chip.ops = &keembay_pwm_ops;
|
||||
priv->chip.npwm = KMB_TOTAL_PWM_CHANNELS;
|
||||
chip->ops = &keembay_pwm_ops;
|
||||
|
||||
ret = devm_pwmchip_add(dev, &priv->chip);
|
||||
ret = devm_pwmchip_add(dev, chip);
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "Failed to add PWM chip\n");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user