mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
pwm: apple: Make use of devm_pwmchip_alloc() function
This prepares the pwm-apple 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/34cf20a82ca07bb4ec0578b193daa5caed37825e.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
6357c2cd05
commit
5dd820cbfc
1 changed files with 9 additions and 9 deletions
|
@ -32,14 +32,13 @@
|
||||||
#define APPLE_PWM_CTRL_OUTPUT_ENABLE BIT(14)
|
#define APPLE_PWM_CTRL_OUTPUT_ENABLE BIT(14)
|
||||||
|
|
||||||
struct apple_pwm {
|
struct apple_pwm {
|
||||||
struct pwm_chip chip;
|
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
u64 clkrate;
|
u64 clkrate;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct apple_pwm *to_apple_pwm(struct pwm_chip *chip)
|
static inline struct apple_pwm *to_apple_pwm(struct pwm_chip *chip)
|
||||||
{
|
{
|
||||||
return container_of(chip, struct apple_pwm, chip);
|
return pwmchip_get_drvdata(chip);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int apple_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
static int apple_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||||
|
@ -103,13 +102,16 @@ static const struct pwm_ops apple_pwm_ops = {
|
||||||
|
|
||||||
static int apple_pwm_probe(struct platform_device *pdev)
|
static int apple_pwm_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
|
struct pwm_chip *chip;
|
||||||
struct apple_pwm *fpwm;
|
struct apple_pwm *fpwm;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
fpwm = devm_kzalloc(&pdev->dev, sizeof(*fpwm), GFP_KERNEL);
|
chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*fpwm));
|
||||||
if (!fpwm)
|
if (IS_ERR(chip))
|
||||||
return -ENOMEM;
|
return PTR_ERR(chip);
|
||||||
|
|
||||||
|
fpwm = to_apple_pwm(chip);
|
||||||
|
|
||||||
fpwm->base = devm_platform_ioremap_resource(pdev, 0);
|
fpwm->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
if (IS_ERR(fpwm->base))
|
if (IS_ERR(fpwm->base))
|
||||||
|
@ -129,11 +131,9 @@ static int apple_pwm_probe(struct platform_device *pdev)
|
||||||
if (fpwm->clkrate > NSEC_PER_SEC)
|
if (fpwm->clkrate > NSEC_PER_SEC)
|
||||||
return dev_err_probe(&pdev->dev, -EINVAL, "pwm clock out of range");
|
return dev_err_probe(&pdev->dev, -EINVAL, "pwm clock out of range");
|
||||||
|
|
||||||
fpwm->chip.dev = &pdev->dev;
|
chip->ops = &apple_pwm_ops;
|
||||||
fpwm->chip.npwm = 1;
|
|
||||||
fpwm->chip.ops = &apple_pwm_ops;
|
|
||||||
|
|
||||||
ret = devm_pwmchip_add(&pdev->dev, &fpwm->chip);
|
ret = devm_pwmchip_add(&pdev->dev, chip);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return dev_err_probe(&pdev->dev, ret, "unable to add pwm chip");
|
return dev_err_probe(&pdev->dev, ret, "unable to add pwm chip");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue