]> Git Repo - J-linux.git/blobdiff - drivers/pwm/pwm-renesas-tpu.c
Merge tag 'nfsd-6.7-3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
[J-linux.git] / drivers / pwm / pwm-renesas-tpu.c
index d7311614c846dda20dbf7696618d628bff7a3ef0..4239f2c3e8b2a3288bfe43d2a7e7a2cb98a9b2b5 100644 (file)
@@ -85,6 +85,7 @@ struct tpu_device {
 
        void __iomem *base;
        struct clk *clk;
+       struct tpu_pwm_device tpd[TPU_CHANNEL_MAX];
 };
 
 #define to_tpu_device(c)       container_of(c, struct tpu_device, chip)
@@ -215,9 +216,7 @@ static int tpu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
        if (pwm->hwpwm >= TPU_CHANNEL_MAX)
                return -EINVAL;
 
-       tpd = kzalloc(sizeof(*tpd), GFP_KERNEL);
-       if (tpd == NULL)
-               return -ENOMEM;
+       tpd = &tpu->tpd[pwm->hwpwm];
 
        tpd->tpu = tpu;
        tpd->channel = pwm->hwpwm;
@@ -228,24 +227,22 @@ static int tpu_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
 
        tpd->timer_on = false;
 
-       pwm_set_chip_data(pwm, tpd);
-
        return 0;
 }
 
 static void tpu_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-       struct tpu_pwm_device *tpd = pwm_get_chip_data(pwm);
+       struct tpu_device *tpu = to_tpu_device(chip);
+       struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm];
 
        tpu_pwm_timer_stop(tpd);
-       kfree(tpd);
 }
 
 static int tpu_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
                          u64 duty_ns, u64 period_ns, bool enabled)
 {
-       struct tpu_pwm_device *tpd = pwm_get_chip_data(pwm);
        struct tpu_device *tpu = to_tpu_device(chip);
+       struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm];
        unsigned int prescaler;
        bool duty_only = false;
        u32 clk_rate;
@@ -353,7 +350,8 @@ static int tpu_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 static int tpu_pwm_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm,
                                enum pwm_polarity polarity)
 {
-       struct tpu_pwm_device *tpd = pwm_get_chip_data(pwm);
+       struct tpu_device *tpu = to_tpu_device(chip);
+       struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm];
 
        tpd->polarity = polarity;
 
@@ -362,7 +360,8 @@ static int tpu_pwm_set_polarity(struct pwm_chip *chip, struct pwm_device *pwm,
 
 static int tpu_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-       struct tpu_pwm_device *tpd = pwm_get_chip_data(pwm);
+       struct tpu_device *tpu = to_tpu_device(chip);
+       struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm];
        int ret;
 
        ret = tpu_pwm_timer_start(tpd);
@@ -384,7 +383,8 @@ static int tpu_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 
 static void tpu_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-       struct tpu_pwm_device *tpd = pwm_get_chip_data(pwm);
+       struct tpu_device *tpu = to_tpu_device(chip);
+       struct tpu_pwm_device *tpd = &tpu->tpd[pwm->hwpwm];
 
        /* The timer must be running to modify the pin output configuration. */
        tpu_pwm_timer_start(tpd);
@@ -431,7 +431,6 @@ static const struct pwm_ops tpu_pwm_ops = {
        .request = tpu_pwm_request,
        .free = tpu_pwm_free,
        .apply = tpu_pwm_apply,
-       .owner = THIS_MODULE,
 };
 
 /* -----------------------------------------------------------------------------
This page took 0.029554 seconds and 4 git commands to generate.