Commit 86287958 authored by Russell King's avatar Russell King

ARM: cleanup: clk_get() error handling

Use the correct IS_ERR() to determine if clk_get() returned an error.
Set timer->fclk to be an error value initially, and check everywhere
using IS_ERR().  This keeps the range of valid values for 'struct clk'
consistent.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent b269b170
...@@ -140,8 +140,7 @@ static int omap_dm_timer_prepare(struct omap_dm_timer *timer) ...@@ -140,8 +140,7 @@ static int omap_dm_timer_prepare(struct omap_dm_timer *timer)
*/ */
if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) { if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) {
timer->fclk = clk_get(&timer->pdev->dev, "fck"); timer->fclk = clk_get(&timer->pdev->dev, "fck");
if (WARN_ON_ONCE(IS_ERR_OR_NULL(timer->fclk))) { if (WARN_ON_ONCE(IS_ERR(timer->fclk))) {
timer->fclk = NULL;
dev_err(&timer->pdev->dev, ": No fclk handle.\n"); dev_err(&timer->pdev->dev, ": No fclk handle.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -373,7 +372,7 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask); ...@@ -373,7 +372,7 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_modify_idlect_mask);
struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *timer) struct clk *omap_dm_timer_get_fclk(struct omap_dm_timer *timer)
{ {
if (timer) if (timer && !IS_ERR(timer->fclk))
return timer->fclk; return timer->fclk;
return NULL; return NULL;
} }
...@@ -482,7 +481,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source) ...@@ -482,7 +481,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
if (pdata && pdata->set_timer_src) if (pdata && pdata->set_timer_src)
return pdata->set_timer_src(timer->pdev, source); return pdata->set_timer_src(timer->pdev, source);
if (!timer->fclk) if (IS_ERR(timer->fclk))
return -EINVAL; return -EINVAL;
switch (source) { switch (source) {
...@@ -500,7 +499,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source) ...@@ -500,7 +499,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
} }
parent = clk_get(&timer->pdev->dev, parent_name); parent = clk_get(&timer->pdev->dev, parent_name);
if (IS_ERR_OR_NULL(parent)) { if (IS_ERR(parent)) {
pr_err("%s: %s not found\n", __func__, parent_name); pr_err("%s: %s not found\n", __func__, parent_name);
return -EINVAL; return -EINVAL;
} }
...@@ -808,6 +807,7 @@ static int omap_dm_timer_probe(struct platform_device *pdev) ...@@ -808,6 +807,7 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
timer->fclk = ERR_PTR(-ENODEV);
timer->io_base = devm_request_and_ioremap(dev, mem); timer->io_base = devm_request_and_ioremap(dev, mem);
if (!timer->io_base) { if (!timer->io_base) {
dev_err(dev, "%s: region already claimed.\n", __func__); dev_err(dev, "%s: region already claimed.\n", __func__);
......
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