X-Git-Url: http://git.monstr.eu/?a=blobdiff_plain;f=drivers%2Fpwm%2Fpwm-ab8500.c;h=f000adab85b00e61927e80d14ce0e557c29eee93;hb=705c1da8fa4816fb0159b5602fef1df5946a3ee2;hp=719e4ccf1800d4317b3074c01252468c437e8cb9;hpb=ddabe9093c172445c133dd2a46fb01ac265a8f8d;p=linux-2.6-microblaze.git diff --git a/drivers/pwm/pwm-ab8500.c b/drivers/pwm/pwm-ab8500.c index 719e4ccf1800..f000adab85b0 100644 --- a/drivers/pwm/pwm-ab8500.c +++ b/drivers/pwm/pwm-ab8500.c @@ -24,13 +24,12 @@ #define AB8500_PWM_CLKRATE 9600000 struct ab8500_pwm_chip { - struct pwm_chip chip; unsigned int hwid; }; static struct ab8500_pwm_chip *ab8500_pwm_from_chip(struct pwm_chip *chip) { - return container_of(chip, struct ab8500_pwm_chip, chip); + return pwmchip_get_drvdata(chip); } static int ab8500_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, @@ -185,6 +184,7 @@ static const struct pwm_ops ab8500_pwm_ops = { static int ab8500_pwm_probe(struct platform_device *pdev) { + struct pwm_chip *chip; struct ab8500_pwm_chip *ab8500; int err; @@ -195,16 +195,16 @@ static int ab8500_pwm_probe(struct platform_device *pdev) * Nothing to be done in probe, this is required to get the * device which is required for ab8500 read and write */ - ab8500 = devm_kzalloc(&pdev->dev, sizeof(*ab8500), GFP_KERNEL); - if (ab8500 == NULL) - return -ENOMEM; + chip = devm_pwmchip_alloc(&pdev->dev, 1, sizeof(*ab8500)); + if (IS_ERR(chip)) + return PTR_ERR(chip); - ab8500->chip.dev = &pdev->dev; - ab8500->chip.ops = &ab8500_pwm_ops; - ab8500->chip.npwm = 1; + ab8500 = ab8500_pwm_from_chip(chip); + + chip->ops = &ab8500_pwm_ops; ab8500->hwid = pdev->id - 1; - err = devm_pwmchip_add(&pdev->dev, &ab8500->chip); + err = devm_pwmchip_add(&pdev->dev, chip); if (err < 0) return dev_err_probe(&pdev->dev, err, "Failed to add pwm chip\n");