diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2016-07-04 11:36:27 -0400 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2016-07-11 06:49:24 -0400 |
commit | d9cd4a73693bc7153766d22079e0fc90c0fc1107 (patch) | |
tree | 23d7470561f3df9e6727fb99678fcf7fefcf5509 | |
parent | b89b4b7a3d0adab8de1062579e4305d05a028c31 (diff) |
pwm: lpss: Move clk_rate check to ->probe()
There is no need to check each time if the clk_rate defined or not when we call
pwm_lpss_config(). Move the check to ->probe() instead.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
-rw-r--r-- | drivers/pwm/pwm-lpss.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c index be4658b42882..72c0bce5a75c 100644 --- a/drivers/pwm/pwm-lpss.c +++ b/drivers/pwm/pwm-lpss.c | |||
@@ -92,7 +92,7 @@ static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm, | |||
92 | { | 92 | { |
93 | struct pwm_lpss_chip *lpwm = to_lpwm(chip); | 93 | struct pwm_lpss_chip *lpwm = to_lpwm(chip); |
94 | unsigned long long on_time_div; | 94 | unsigned long long on_time_div; |
95 | unsigned long c, base_unit_range; | 95 | unsigned long c = lpwm->info->clk_rate, base_unit_range; |
96 | unsigned long long base_unit, freq = NSEC_PER_SEC; | 96 | unsigned long long base_unit, freq = NSEC_PER_SEC; |
97 | u32 ctrl; | 97 | u32 ctrl; |
98 | 98 | ||
@@ -105,10 +105,6 @@ static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm, | |||
105 | base_unit_range = BIT(lpwm->info->base_unit_bits); | 105 | base_unit_range = BIT(lpwm->info->base_unit_bits); |
106 | freq *= base_unit_range; | 106 | freq *= base_unit_range; |
107 | 107 | ||
108 | c = lpwm->info->clk_rate; | ||
109 | if (!c) | ||
110 | return -EINVAL; | ||
111 | |||
112 | base_unit = DIV_ROUND_CLOSEST_ULL(freq, c); | 108 | base_unit = DIV_ROUND_CLOSEST_ULL(freq, c); |
113 | 109 | ||
114 | if (duty_ns <= 0) | 110 | if (duty_ns <= 0) |
@@ -169,6 +165,7 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, | |||
169 | const struct pwm_lpss_boardinfo *info) | 165 | const struct pwm_lpss_boardinfo *info) |
170 | { | 166 | { |
171 | struct pwm_lpss_chip *lpwm; | 167 | struct pwm_lpss_chip *lpwm; |
168 | unsigned long c; | ||
172 | int ret; | 169 | int ret; |
173 | 170 | ||
174 | lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL); | 171 | lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL); |
@@ -180,6 +177,11 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, | |||
180 | return ERR_CAST(lpwm->regs); | 177 | return ERR_CAST(lpwm->regs); |
181 | 178 | ||
182 | lpwm->info = info; | 179 | lpwm->info = info; |
180 | |||
181 | c = lpwm->info->clk_rate; | ||
182 | if (!c) | ||
183 | return ERR_PTR(-EINVAL); | ||
184 | |||
183 | lpwm->chip.dev = dev; | 185 | lpwm->chip.dev = dev; |
184 | lpwm->chip.ops = &pwm_lpss_ops; | 186 | lpwm->chip.ops = &pwm_lpss_ops; |
185 | lpwm->chip.base = -1; | 187 | lpwm->chip.base = -1; |