aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm/pwm-meson.c
diff options
context:
space:
mode:
authorMartin Blumenstingl <martin.blumenstingl@googlemail.com>2019-06-12 15:59:06 -0400
committerThierry Reding <thierry.reding@gmail.com>2019-06-26 05:39:09 -0400
commit1064c6bacedd70edfcea6b1b6af529f621e681ae (patch)
tree6b3d3e692acec2ae5b8f7f51be2f9c04ac64bb47 /drivers/pwm/pwm-meson.c
parent8bbf316453818a47468702f26804e4ced3065c0f (diff)
pwm: meson: Move pwm_set_chip_data() to meson_pwm_request()
All existing PWM drivers (except pwm-meson and two other ones) call pwm_set_chip_data() from their pwm_ops.request() callback. Now that we can access the struct meson_pwm_channel from struct meson_pwm we can do the same. Move the call to pwm_set_chip_data() to meson_pwm_request() and drop the custom meson_pwm_add_channels(). This makes the implementation consistent with other drivers and makes it slightly more obvious thatpwm_get_chip_data() cannot be used from pwm_ops.get_state() (because that's called by the PWM core before pwm_ops.request()). No functional changes intended. Reviewed-by: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-meson.c')
-rw-r--r--drivers/pwm/pwm-meson.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
index 56f603e8023a..8a5658f2b947 100644
--- a/drivers/pwm/pwm-meson.c
+++ b/drivers/pwm/pwm-meson.c
@@ -98,12 +98,16 @@ static inline struct meson_pwm *to_meson_pwm(struct pwm_chip *chip)
98 98
99static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) 99static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
100{ 100{
101 struct meson_pwm_channel *channel = pwm_get_chip_data(pwm); 101 struct meson_pwm *meson = to_meson_pwm(chip);
102 struct meson_pwm_channel *channel;
102 struct device *dev = chip->dev; 103 struct device *dev = chip->dev;
103 int err; 104 int err;
104 105
105 if (!channel) 106 channel = pwm_get_chip_data(pwm);
106 return -ENODEV; 107 if (channel)
108 return 0;
109
110 channel = &meson->channels[pwm->hwpwm];
107 111
108 if (channel->clk_parent) { 112 if (channel->clk_parent) {
109 err = clk_set_parent(channel->clk, channel->clk_parent); 113 err = clk_set_parent(channel->clk, channel->clk_parent);
@@ -124,7 +128,7 @@ static int meson_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
124 128
125 chip->ops->get_state(chip, pwm, &channel->state); 129 chip->ops->get_state(chip, pwm, &channel->state);
126 130
127 return 0; 131 return pwm_set_chip_data(pwm, channel);
128} 132}
129 133
130static void meson_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) 134static void meson_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
@@ -469,14 +473,6 @@ static int meson_pwm_init_channels(struct meson_pwm *meson)
469 return 0; 473 return 0;
470} 474}
471 475
472static void meson_pwm_add_channels(struct meson_pwm *meson)
473{
474 unsigned int i;
475
476 for (i = 0; i < meson->chip.npwm; i++)
477 pwm_set_chip_data(&meson->chip.pwms[i], &meson->channels[i]);
478}
479
480static int meson_pwm_probe(struct platform_device *pdev) 476static int meson_pwm_probe(struct platform_device *pdev)
481{ 477{
482 struct meson_pwm *meson; 478 struct meson_pwm *meson;
@@ -512,8 +508,6 @@ static int meson_pwm_probe(struct platform_device *pdev)
512 return err; 508 return err;
513 } 509 }
514 510
515 meson_pwm_add_channels(meson);
516
517 platform_set_drvdata(pdev, meson); 511 platform_set_drvdata(pdev, meson);
518 512
519 return 0; 513 return 0;