Commit d9cd4a73 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Thierry Reding

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent b89b4b7a
...@@ -92,7 +92,7 @@ static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -92,7 +92,7 @@ static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm,
{ {
struct pwm_lpss_chip *lpwm = to_lpwm(chip); struct pwm_lpss_chip *lpwm = to_lpwm(chip);
unsigned long long on_time_div; unsigned long long on_time_div;
unsigned long c, base_unit_range; unsigned long c = lpwm->info->clk_rate, base_unit_range;
unsigned long long base_unit, freq = NSEC_PER_SEC; unsigned long long base_unit, freq = NSEC_PER_SEC;
u32 ctrl; u32 ctrl;
...@@ -105,10 +105,6 @@ static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -105,10 +105,6 @@ static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm,
base_unit_range = BIT(lpwm->info->base_unit_bits); base_unit_range = BIT(lpwm->info->base_unit_bits);
freq *= base_unit_range; freq *= base_unit_range;
c = lpwm->info->clk_rate;
if (!c)
return -EINVAL;
base_unit = DIV_ROUND_CLOSEST_ULL(freq, c); base_unit = DIV_ROUND_CLOSEST_ULL(freq, c);
if (duty_ns <= 0) if (duty_ns <= 0)
...@@ -169,6 +165,7 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, ...@@ -169,6 +165,7 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
const struct pwm_lpss_boardinfo *info) const struct pwm_lpss_boardinfo *info)
{ {
struct pwm_lpss_chip *lpwm; struct pwm_lpss_chip *lpwm;
unsigned long c;
int ret; int ret;
lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL); 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,6 +177,11 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
return ERR_CAST(lpwm->regs); return ERR_CAST(lpwm->regs);
lpwm->info = info; lpwm->info = info;
c = lpwm->info->clk_rate;
if (!c)
return ERR_PTR(-EINVAL);
lpwm->chip.dev = dev; lpwm->chip.dev = dev;
lpwm->chip.ops = &pwm_lpss_ops; lpwm->chip.ops = &pwm_lpss_ops;
lpwm->chip.base = -1; lpwm->chip.base = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment