]> Git Repo - J-linux.git/blobdiff - drivers/pwm/pwm-stmpe.c
Merge tag 'amd-drm-next-6.5-2023-06-09' of https://gitlab.freedesktop.org/agd5f/linux...
[J-linux.git] / drivers / pwm / pwm-stmpe.c
index 9dc983a3cbf1b1f427396378e80e8de8940ad3ea..5d4a4762ce0cdb1475bc345b19151d89e5a98756 100644 (file)
@@ -259,29 +259,52 @@ static int stmpe_24xx_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
        return 0;
 }
 
+static int stmpe_24xx_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+                               const struct pwm_state *state)
+{
+       int err;
+
+       if (state->polarity != PWM_POLARITY_NORMAL)
+               return -EINVAL;
+
+       if (!state->enabled) {
+               if (pwm->state.enabled)
+                       stmpe_24xx_pwm_disable(chip, pwm);
+
+               return 0;
+       }
+
+       err = stmpe_24xx_pwm_config(pwm->chip, pwm, state->duty_cycle, state->period);
+       if (err)
+               return err;
+
+       if (!pwm->state.enabled)
+               err = stmpe_24xx_pwm_enable(chip, pwm);
+
+       return err;
+}
+
 static const struct pwm_ops stmpe_24xx_pwm_ops = {
-       .config = stmpe_24xx_pwm_config,
-       .enable = stmpe_24xx_pwm_enable,
-       .disable = stmpe_24xx_pwm_disable,
+       .apply = stmpe_24xx_pwm_apply,
        .owner = THIS_MODULE,
 };
 
 static int __init stmpe_pwm_probe(struct platform_device *pdev)
 {
        struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
-       struct stmpe_pwm *pwm;
+       struct stmpe_pwm *stmpe_pwm;
        int ret;
 
-       pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL);
-       if (!pwm)
+       stmpe_pwm = devm_kzalloc(&pdev->dev, sizeof(*stmpe_pwm), GFP_KERNEL);
+       if (!stmpe_pwm)
                return -ENOMEM;
 
-       pwm->stmpe = stmpe;
-       pwm->chip.dev = &pdev->dev;
+       stmpe_pwm->stmpe = stmpe;
+       stmpe_pwm->chip.dev = &pdev->dev;
 
        if (stmpe->partnum == STMPE2401 || stmpe->partnum == STMPE2403) {
-               pwm->chip.ops = &stmpe_24xx_pwm_ops;
-               pwm->chip.npwm = 3;
+               stmpe_pwm->chip.ops = &stmpe_24xx_pwm_ops;
+               stmpe_pwm->chip.npwm = 3;
        } else {
                if (stmpe->partnum == STMPE1601)
                        dev_err(&pdev->dev, "STMPE1601 not yet supported\n");
@@ -295,14 +318,12 @@ static int __init stmpe_pwm_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       ret = pwmchip_add(&pwm->chip);
+       ret = pwmchip_add(&stmpe_pwm->chip);
        if (ret) {
                stmpe_disable(stmpe, STMPE_BLOCK_PWM);
                return ret;
        }
 
-       platform_set_drvdata(pdev, pwm);
-
        return 0;
 }
 
This page took 0.032549 seconds and 4 git commands to generate.