pwm: tiehrpwm: Change prototype of helpers to prepare further changes
[sfrench/cifs-2.6.git] / drivers / pwm / pwm-tiehrpwm.c
index 9848493dee97e5d38a7d3610ced9c85af5fcdf67..6d7babf6fdb04c391b3699499d8ae874dd4456f3 100644 (file)
@@ -450,6 +450,7 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct ehrpwm_pwm_chip *pc;
+       struct pwm_chip *chip;
        struct clk *clk;
        int ret;
 
@@ -474,9 +475,10 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       pc->chip.dev = &pdev->dev;
-       pc->chip.ops = &ehrpwm_pwm_ops;
-       pc->chip.npwm = NUM_PWM_CHANNEL;
+       chip = &pc->chip;
+       chip->dev = &pdev->dev;
+       chip->ops = &ehrpwm_pwm_ops;
+       chip->npwm = NUM_PWM_CHANNEL;
 
        pc->mmio_base = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(pc->mmio_base))
@@ -493,13 +495,13 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
                return ret;
        }
 
-       ret = pwmchip_add(&pc->chip);
+       ret = pwmchip_add(chip);
        if (ret < 0) {
                dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret);
                goto err_clk_unprepare;
        }
 
-       platform_set_drvdata(pdev, pc);
+       platform_set_drvdata(pdev, chip);
        pm_runtime_enable(&pdev->dev);
 
        return 0;
@@ -512,18 +514,21 @@ err_clk_unprepare:
 
 static void ehrpwm_pwm_remove(struct platform_device *pdev)
 {
-       struct ehrpwm_pwm_chip *pc = platform_get_drvdata(pdev);
+       struct pwm_chip *chip = platform_get_drvdata(pdev);
+       struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
 
-       pwmchip_remove(&pc->chip);
+       pwmchip_remove(chip);
 
        clk_unprepare(pc->tbclk);
 
        pm_runtime_disable(&pdev->dev);
 }
 
-static void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc)
+static void ehrpwm_pwm_save_context(struct pwm_chip *chip)
 {
-       pm_runtime_get_sync(pc->chip.dev);
+       struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
+
+       pm_runtime_get_sync(chip->dev);
 
        pc->ctx.tbctl = ehrpwm_read(pc->mmio_base, TBCTL);
        pc->ctx.tbprd = ehrpwm_read(pc->mmio_base, TBPRD);
@@ -534,11 +539,13 @@ static void ehrpwm_pwm_save_context(struct ehrpwm_pwm_chip *pc)
        pc->ctx.aqsfrc = ehrpwm_read(pc->mmio_base, AQSFRC);
        pc->ctx.aqcsfrc = ehrpwm_read(pc->mmio_base, AQCSFRC);
 
-       pm_runtime_put_sync(pc->chip.dev);
+       pm_runtime_put_sync(chip->dev);
 }
 
-static void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc)
+static void ehrpwm_pwm_restore_context(struct pwm_chip *chip)
 {
+       struct ehrpwm_pwm_chip *pc = to_ehrpwm_pwm_chip(chip);
+
        ehrpwm_write(pc->mmio_base, TBPRD, pc->ctx.tbprd);
        ehrpwm_write(pc->mmio_base, CMPA, pc->ctx.cmpa);
        ehrpwm_write(pc->mmio_base, CMPB, pc->ctx.cmpb);
@@ -551,13 +558,13 @@ static void ehrpwm_pwm_restore_context(struct ehrpwm_pwm_chip *pc)
 
 static int ehrpwm_pwm_suspend(struct device *dev)
 {
-       struct ehrpwm_pwm_chip *pc = dev_get_drvdata(dev);
+       struct pwm_chip *chip = dev_get_drvdata(dev);
        unsigned int i;
 
-       ehrpwm_pwm_save_context(pc);
+       ehrpwm_pwm_save_context(chip);
 
-       for (i = 0; i < pc->chip.npwm; i++) {
-               struct pwm_device *pwm = &pc->chip.pwms[i];
+       for (i = 0; i < chip->npwm; i++) {
+               struct pwm_device *pwm = &chip->pwms[i];
 
                if (!pwm_is_enabled(pwm))
                        continue;
@@ -571,11 +578,11 @@ static int ehrpwm_pwm_suspend(struct device *dev)
 
 static int ehrpwm_pwm_resume(struct device *dev)
 {
-       struct ehrpwm_pwm_chip *pc = dev_get_drvdata(dev);
+       struct pwm_chip *chip = dev_get_drvdata(dev);
        unsigned int i;
 
-       for (i = 0; i < pc->chip.npwm; i++) {
-               struct pwm_device *pwm = &pc->chip.pwms[i];
+       for (i = 0; i < chip->npwm; i++) {
+               struct pwm_device *pwm = &chip->pwms[i];
 
                if (!pwm_is_enabled(pwm))
                        continue;
@@ -584,7 +591,7 @@ static int ehrpwm_pwm_resume(struct device *dev)
                pm_runtime_get_sync(dev);
        }
 
-       ehrpwm_pwm_restore_context(pc);
+       ehrpwm_pwm_restore_context(chip);
 
        return 0;
 }