pwm: fsl-ftm: Make use of devm_pwmchip_alloc() function
This prepares the pwm-fsl-ftm 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/b3c75dea5b2944402b14944fdf71a5db0e26cbd7.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
097779f157
commit
2e8d68c02e
@ -40,7 +40,6 @@ struct fsl_pwm_periodcfg {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct fsl_pwm_chip {
|
struct fsl_pwm_chip {
|
||||||
struct pwm_chip chip;
|
|
||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
|
|
||||||
@ -55,7 +54,7 @@ struct fsl_pwm_chip {
|
|||||||
|
|
||||||
static inline struct fsl_pwm_chip *to_fsl_chip(struct pwm_chip *chip)
|
static inline struct fsl_pwm_chip *to_fsl_chip(struct pwm_chip *chip)
|
||||||
{
|
{
|
||||||
return container_of(chip, struct fsl_pwm_chip, chip);
|
return pwmchip_get_drvdata(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ftm_clear_write_protection(struct fsl_pwm_chip *fpc)
|
static void ftm_clear_write_protection(struct fsl_pwm_chip *fpc)
|
||||||
@ -398,15 +397,14 @@ static int fsl_pwm_probe(struct platform_device *pdev)
|
|||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
fpc = devm_kzalloc(&pdev->dev, sizeof(*fpc), GFP_KERNEL);
|
chip = devm_pwmchip_alloc(&pdev->dev, 8, sizeof(*fpc));
|
||||||
if (!fpc)
|
if (IS_ERR(chip))
|
||||||
return -ENOMEM;
|
return PTR_ERR(chip);
|
||||||
chip = &fpc->chip;
|
fpc = to_fsl_chip(chip);
|
||||||
|
|
||||||
mutex_init(&fpc->lock);
|
mutex_init(&fpc->lock);
|
||||||
|
|
||||||
fpc->soc = of_device_get_match_data(&pdev->dev);
|
fpc->soc = of_device_get_match_data(&pdev->dev);
|
||||||
chip->dev = &pdev->dev;
|
|
||||||
|
|
||||||
base = devm_platform_ioremap_resource(pdev, 0);
|
base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
if (IS_ERR(base))
|
if (IS_ERR(base))
|
||||||
@ -446,9 +444,7 @@ static int fsl_pwm_probe(struct platform_device *pdev)
|
|||||||
if (IS_ERR(fpc->ipg_clk))
|
if (IS_ERR(fpc->ipg_clk))
|
||||||
fpc->ipg_clk = fpc->clk[FSL_PWM_CLK_SYS];
|
fpc->ipg_clk = fpc->clk[FSL_PWM_CLK_SYS];
|
||||||
|
|
||||||
|
|
||||||
chip->ops = &fsl_pwm_ops;
|
chip->ops = &fsl_pwm_ops;
|
||||||
chip->npwm = 8;
|
|
||||||
|
|
||||||
ret = devm_pwmchip_add(&pdev->dev, chip);
|
ret = devm_pwmchip_add(&pdev->dev, chip);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user