Commit c48cd659 authored by Russell King's avatar Russell King

ARM: OMAP: use consistent error checking

Consistently check errors using the usual method used in the kernel
for much of its history.  For instance:

int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t)
{
	int div;
	div = gpmc_calc_divider(t->sync_clk);
	if (div < 0)
		return div;
static int gpmc_set_async_mode(int cs, struct gpmc_timings *t)
{
...
	return gpmc_cs_set_timings(cs, t);

.....
	ret = gpmc_set_async_mode(gpmc_onenand_data->cs, &t);
	if (IS_ERR_VALUE(ret))
		return ret;

So, gpmc_cs_set_timings() thinks any negative return value is an error,
but where we check that in higher levels, only a limited range are
errors...

There is only _one_ use of IS_ERR_VALUE() in arch/arm which is really
appropriate, and that is in arch/arm/include/asm/syscall.h:

static inline long syscall_get_error(struct task_struct *task,
				     struct pt_regs *regs)
{
	unsigned long error = regs->ARM_r0;
	return IS_ERR_VALUE(error) ? error : 0;
}

because this function really does have to differentiate between error
return values and addresses which look like negative numbers (eg, from
mmap()).

So, here's a patch to remove them from OMAP, except for the above.
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 857835c6
...@@ -457,7 +457,7 @@ static int __init beagle_opp_init(void) ...@@ -457,7 +457,7 @@ static int __init beagle_opp_init(void)
/* Initialize the omap3 opp table if not already created. */ /* Initialize the omap3 opp table if not already created. */
r = omap3_opp_init(); r = omap3_opp_init();
if (IS_ERR_VALUE(r) && (r != -EEXIST)) { if (r < 0 && (r != -EEXIST)) {
pr_err("%s: opp default init failed\n", __func__); pr_err("%s: opp default init failed\n", __func__);
return r; return r;
} }
......
...@@ -596,7 +596,7 @@ int __init omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name) ...@@ -596,7 +596,7 @@ int __init omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name)
return -ENOENT; return -ENOENT;
r = clk_set_rate(mpurate_ck, mpurate); r = clk_set_rate(mpurate_ck, mpurate);
if (IS_ERR_VALUE(r)) { if (r < 0) {
WARN(1, "clock: %s: unable to set MPU rate to %d: %d\n", WARN(1, "clock: %s: unable to set MPU rate to %d: %d\n",
mpurate_ck_name, mpurate, r); mpurate_ck_name, mpurate, r);
clk_put(mpurate_ck); clk_put(mpurate_ck);
......
...@@ -303,7 +303,7 @@ static int omap2_onenand_setup_async(void __iomem *onenand_base) ...@@ -303,7 +303,7 @@ static int omap2_onenand_setup_async(void __iomem *onenand_base)
t = omap2_onenand_calc_async_timings(); t = omap2_onenand_calc_async_timings();
ret = gpmc_set_async_mode(gpmc_onenand_data->cs, &t); ret = gpmc_set_async_mode(gpmc_onenand_data->cs, &t);
if (IS_ERR_VALUE(ret)) if (ret < 0)
return ret; return ret;
omap2_onenand_set_async_mode(onenand_base); omap2_onenand_set_async_mode(onenand_base);
...@@ -325,7 +325,7 @@ static int omap2_onenand_setup_sync(void __iomem *onenand_base, int *freq_ptr) ...@@ -325,7 +325,7 @@ static int omap2_onenand_setup_sync(void __iomem *onenand_base, int *freq_ptr)
t = omap2_onenand_calc_sync_timings(gpmc_onenand_data, freq); t = omap2_onenand_calc_sync_timings(gpmc_onenand_data, freq);
ret = gpmc_set_sync_mode(gpmc_onenand_data->cs, &t); ret = gpmc_set_sync_mode(gpmc_onenand_data->cs, &t);
if (IS_ERR_VALUE(ret)) if (ret < 0)
return ret; return ret;
set_onenand_cfg(onenand_base); set_onenand_cfg(onenand_base);
......
...@@ -709,7 +709,7 @@ static int gpmc_setup_irq(void) ...@@ -709,7 +709,7 @@ static int gpmc_setup_irq(void)
return -EINVAL; return -EINVAL;
gpmc_irq_start = irq_alloc_descs(-1, 0, GPMC_NR_IRQ, 0); gpmc_irq_start = irq_alloc_descs(-1, 0, GPMC_NR_IRQ, 0);
if (IS_ERR_VALUE(gpmc_irq_start)) { if (gpmc_irq_start < 0) {
pr_err("irq_alloc_descs failed\n"); pr_err("irq_alloc_descs failed\n");
return gpmc_irq_start; return gpmc_irq_start;
} }
...@@ -797,7 +797,7 @@ static int gpmc_mem_init(void) ...@@ -797,7 +797,7 @@ static int gpmc_mem_init(void)
continue; continue;
gpmc_cs_get_memconf(cs, &base, &size); gpmc_cs_get_memconf(cs, &base, &size);
rc = gpmc_cs_insert_mem(cs, base, size); rc = gpmc_cs_insert_mem(cs, base, size);
if (IS_ERR_VALUE(rc)) { if (rc < 0) {
while (--cs >= 0) while (--cs >= 0)
if (gpmc_cs_mem_enabled(cs)) if (gpmc_cs_mem_enabled(cs))
gpmc_cs_delete_mem(cs); gpmc_cs_delete_mem(cs);
...@@ -1164,14 +1164,14 @@ static int gpmc_probe(struct platform_device *pdev) ...@@ -1164,14 +1164,14 @@ static int gpmc_probe(struct platform_device *pdev)
GPMC_REVISION_MINOR(l)); GPMC_REVISION_MINOR(l));
rc = gpmc_mem_init(); rc = gpmc_mem_init();
if (IS_ERR_VALUE(rc)) { if (rc < 0) {
clk_disable_unprepare(gpmc_l3_clk); clk_disable_unprepare(gpmc_l3_clk);
clk_put(gpmc_l3_clk); clk_put(gpmc_l3_clk);
dev_err(gpmc_dev, "failed to reserve memory\n"); dev_err(gpmc_dev, "failed to reserve memory\n");
return rc; return rc;
} }
if (IS_ERR_VALUE(gpmc_setup_irq())) if (gpmc_setup_irq() < 0)
dev_warn(gpmc_dev, "gpmc_setup_irq failed\n"); dev_warn(gpmc_dev, "gpmc_setup_irq failed\n");
return 0; return 0;
......
...@@ -333,7 +333,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev) ...@@ -333,7 +333,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
int oh_cnt, i, ret = 0; int oh_cnt, i, ret = 0;
oh_cnt = of_property_count_strings(node, "ti,hwmods"); oh_cnt = of_property_count_strings(node, "ti,hwmods");
if (!oh_cnt || IS_ERR_VALUE(oh_cnt)) { if (oh_cnt <= 0) {
dev_dbg(&pdev->dev, "No 'hwmods' to build omap_device\n"); dev_dbg(&pdev->dev, "No 'hwmods' to build omap_device\n");
return -ENODEV; return -ENODEV;
} }
......
...@@ -1661,7 +1661,7 @@ static int _deassert_hardreset(struct omap_hwmod *oh, const char *name) ...@@ -1661,7 +1661,7 @@ static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
return -ENOSYS; return -ENOSYS;
ret = _lookup_hardreset(oh, name, &ohri); ret = _lookup_hardreset(oh, name, &ohri);
if (IS_ERR_VALUE(ret)) if (ret < 0)
return ret; return ret;
if (oh->clkdm) { if (oh->clkdm) {
...@@ -2387,7 +2387,7 @@ static int __init _init(struct omap_hwmod *oh, void *data) ...@@ -2387,7 +2387,7 @@ static int __init _init(struct omap_hwmod *oh, void *data)
_init_mpu_rt_base(oh, NULL); _init_mpu_rt_base(oh, NULL);
r = _init_clocks(oh, NULL); r = _init_clocks(oh, NULL);
if (IS_ERR_VALUE(r)) { if (r < 0) {
WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name); WARN(1, "omap_hwmod: %s: couldn't init clocks\n", oh->name);
return -EINVAL; return -EINVAL;
} }
......
...@@ -288,7 +288,7 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer, ...@@ -288,7 +288,7 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
r = -EINVAL; r = -EINVAL;
} else { } else {
r = clk_set_parent(timer->fclk, src); r = clk_set_parent(timer->fclk, src);
if (IS_ERR_VALUE(r)) if (r < 0)
pr_warn("%s: %s cannot set source\n", pr_warn("%s: %s cannot set source\n",
__func__, oh->name); __func__, oh->name);
clk_put(src); clk_put(src);
......
...@@ -505,7 +505,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source) ...@@ -505,7 +505,7 @@ int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
} }
ret = clk_set_parent(timer->fclk, parent); ret = clk_set_parent(timer->fclk, parent);
if (IS_ERR_VALUE(ret)) if (ret < 0)
pr_err("%s: failed to set %s as parent\n", __func__, pr_err("%s: failed to set %s as parent\n", __func__,
parent_name); parent_name);
......
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