Merge tag 'folio-5.18d' of git://git.infradead.org/users/willy/pagecache
[linux-2.6-microblaze.git] / drivers / pwm / pwm-meson.c
index 3cf3bcf..57112f4 100644 (file)
@@ -120,16 +120,10 @@ static inline struct meson_pwm *to_meson_pwm(struct pwm_chip *chip)
 static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
 {
        struct meson_pwm *meson = to_meson_pwm(chip);
-       struct meson_pwm_channel *channel;
+       struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm];
        struct device *dev = chip->dev;
        int err;
 
-       channel = pwm_get_chip_data(pwm);
-       if (channel)
-               return 0;
-
-       channel = &meson->channels[pwm->hwpwm];
-
        if (channel->clk_parent) {
                err = clk_set_parent(channel->clk, channel->clk_parent);
                if (err < 0) {
@@ -147,21 +141,21 @@ static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
                return err;
        }
 
-       return pwm_set_chip_data(pwm, channel);
+       return 0;
 }
 
 static void meson_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-       struct meson_pwm_channel *channel = pwm_get_chip_data(pwm);
+       struct meson_pwm *meson = to_meson_pwm(chip);
+       struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm];
 
-       if (channel)
-               clk_disable_unprepare(channel->clk);
+       clk_disable_unprepare(channel->clk);
 }
 
 static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
                          const struct pwm_state *state)
 {
-       struct meson_pwm_channel *channel = pwm_get_chip_data(pwm);
+       struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm];
        unsigned int duty, period, pre_div, cnt, duty_cnt;
        unsigned long fin_freq;
 
@@ -224,7 +218,7 @@ static int meson_pwm_calc(struct meson_pwm *meson, struct pwm_device *pwm,
 
 static void meson_pwm_enable(struct meson_pwm *meson, struct pwm_device *pwm)
 {
-       struct meson_pwm_channel *channel = pwm_get_chip_data(pwm);
+       struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm];
        struct meson_pwm_channel_data *channel_data;
        unsigned long flags;
        u32 value;
@@ -267,13 +261,10 @@ static void meson_pwm_disable(struct meson_pwm *meson, struct pwm_device *pwm)
 static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
                           const struct pwm_state *state)
 {
-       struct meson_pwm_channel *channel = pwm_get_chip_data(pwm);
        struct meson_pwm *meson = to_meson_pwm(chip);
+       struct meson_pwm_channel *channel = &meson->channels[pwm->hwpwm];
        int err = 0;
 
-       if (!state)
-               return -EINVAL;
-
        if (!state->enabled) {
                if (state->polarity == PWM_POLARITY_INVERSED) {
                        /*