pwm: atmel: Make use of devm_pwmchip_alloc() function
This prepares the pwm-atmel 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/f2a83af5660de461b4dcaf76929e9813bddfeff1.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
f9e4d438e1
commit
8de8ccaca9
@ -77,7 +77,6 @@ struct atmel_pwm_data {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct atmel_pwm_chip {
|
struct atmel_pwm_chip {
|
||||||
struct pwm_chip chip;
|
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
const struct atmel_pwm_data *data;
|
const struct atmel_pwm_data *data;
|
||||||
@ -99,7 +98,7 @@ struct atmel_pwm_chip {
|
|||||||
|
|
||||||
static inline struct atmel_pwm_chip *to_atmel_pwm_chip(struct pwm_chip *chip)
|
static inline struct atmel_pwm_chip *to_atmel_pwm_chip(struct pwm_chip *chip)
|
||||||
{
|
{
|
||||||
return container_of(chip, struct atmel_pwm_chip, chip);
|
return pwmchip_get_drvdata(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline u32 atmel_pwm_readl(struct atmel_pwm_chip *chip,
|
static inline u32 atmel_pwm_readl(struct atmel_pwm_chip *chip,
|
||||||
@ -502,10 +501,11 @@ static int atmel_pwm_probe(struct platform_device *pdev)
|
|||||||
struct pwm_chip *chip;
|
struct pwm_chip *chip;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
atmel_pwm = devm_kzalloc(&pdev->dev, sizeof(*atmel_pwm), GFP_KERNEL);
|
chip = devm_pwmchip_alloc(&pdev->dev, 4, sizeof(*atmel_pwm));
|
||||||
if (!atmel_pwm)
|
if (IS_ERR(chip))
|
||||||
return -ENOMEM;
|
return PTR_ERR(chip);
|
||||||
|
|
||||||
|
atmel_pwm = to_atmel_pwm_chip(chip);
|
||||||
atmel_pwm->data = of_device_get_match_data(&pdev->dev);
|
atmel_pwm->data = of_device_get_match_data(&pdev->dev);
|
||||||
|
|
||||||
atmel_pwm->update_pending = 0;
|
atmel_pwm->update_pending = 0;
|
||||||
@ -520,10 +520,7 @@ static int atmel_pwm_probe(struct platform_device *pdev)
|
|||||||
return dev_err_probe(&pdev->dev, PTR_ERR(atmel_pwm->clk),
|
return dev_err_probe(&pdev->dev, PTR_ERR(atmel_pwm->clk),
|
||||||
"failed to get prepared PWM clock\n");
|
"failed to get prepared PWM clock\n");
|
||||||
|
|
||||||
chip = &atmel_pwm->chip;
|
|
||||||
chip->dev = &pdev->dev;
|
|
||||||
chip->ops = &atmel_pwm_ops;
|
chip->ops = &atmel_pwm_ops;
|
||||||
chip->npwm = 4;
|
|
||||||
|
|
||||||
ret = atmel_pwm_enable_clk_if_on(chip, true);
|
ret = atmel_pwm_enable_clk_if_on(chip, true);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user