Skip to content

Commit

Permalink
ARM: OMAP: clean up some smatch warnings, fix some printk(KERN_ERR ...
Browse files Browse the repository at this point in the history
Resolve the following warnings from smatch:

arch/arm/mach-omap2/gpmc.c:282 gpmc_cs_set_timings() info: why not propagate 'div' from gpmc_cs_calc_divider() instead of -1?
arch/arm/mach-omap2/serial.c:328 omap_serial_init_port() error: 'pdev' dereferencing possible ERR_PTR()
arch/arm/mach-omap2/timer.c:213 omap2_gp_clockevent_init() Error invalid range 4096 to -1
arch/arm/mach-omap2/gpio.c:63 omap2_gpio_dev_init() warn: possible memory leak of 'pdata'
arch/arm/mach-omap2/omap_hwmod.c:1478 _assert_hardreset() warn: assigning -22 to unsigned variable 'ret'
arch/arm/mach-omap2/omap_hwmod.c:1487 _assert_hardreset() warn: 4294963201 is more than 255 (max '(ret)' can be) so this is always the same.
arch/arm/mach-omap2/omap_hwmod.c:1545 _read_hardreset() warn: assigning -22 to unsigned variable 'ret'
arch/arm/mach-omap2/omap_hwmod.c:1554 _read_hardreset() warn: 4294963201 is more than 255 (max '(ret)' can be) so this is always the same.
arch/arm/mach-omap2/dpll3xxx.c:629 omap3_clkoutx2_recalc() error: we previously assumed 'pclk' could be null (see line 627)
arch/arm/mach-omap2/board-n8x0.c:422 n8x0_mmc_late_init() Error invalid range 14 to 13
arch/arm/mach-omap1/leds-h2p2-debug.c:71 h2p2_dbg_leds_event() error: potentially derefencing uninitialized 'fpga'.
arch/arm/plat-omap/mux.c:79 omap_cfg_reg() Error invalid range 4096 to -1

Thanks to Tony Lindgren <tony@atomide.com> for pointing out that BUG()
can be disabled.  The changes in the first version that removed the
subsequent return() after BUG() states have been dropped.

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Tony Lindgren <tony@atomide.com>
  • Loading branch information
Paul Walmsley committed Sep 12, 2012
1 parent 55d512e commit a032d33
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
12 changes: 7 additions & 5 deletions arch/arm/mach-omap1/leds-h2p2-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ void h2p2_dbg_leds_event(led_event_t evt)
gpio_set_value(GPIO_IDLE, 0);
}

__raw_writew(~0, &fpga->leds);
led_state &= ~LED_STATE_ENABLED;
if (evt == led_halted) {
iounmap(fpga);
fpga = NULL;
if (fpga) {
__raw_writew(~0, &fpga->leds);
if (evt == led_halted) {
iounmap(fpga);
fpga = NULL;
}
}

goto done;
Expand Down Expand Up @@ -158,7 +160,7 @@ void h2p2_dbg_leds_event(led_event_t evt)
/*
* Actually burn the LEDs
*/
if (led_state & LED_STATE_ENABLED)
if (led_state & LED_STATE_ENABLED && fpga)
__raw_writew(~hw_led_state, &fpga->leds);

done:
Expand Down
7 changes: 5 additions & 2 deletions arch/arm/mach-omap2/dpll3xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,11 @@ unsigned long omap3_clkoutx2_recalc(struct clk *clk)
while (pclk && !pclk->dpll_data)
pclk = pclk->parent;

/* clk does not have a DPLL as a parent? */
WARN_ON(!pclk);
/* clk does not have a DPLL as a parent? error in the clock data */
if (!pclk) {
WARN_ON(1);
return 0;
}

dd = pclk->dpll_data;

Expand Down
1 change: 1 addition & 0 deletions arch/arm/mach-omap2/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static int __init omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL);
if (!pdata->regs) {
pr_err("gpio%d: Memory allocation failed\n", id);
kfree(pdata);
return -ENOMEM;
}

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-omap2/gpmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ int gpmc_cs_set_timings(int cs, const struct gpmc_timings *t)

div = gpmc_cs_calc_divider(cs, t->sync_clk);
if (div < 0)
return -1;
return div;

GPMC_SET_ONE(GPMC_CS_CONFIG2, 0, 3, cs_on);
GPMC_SET_ONE(GPMC_CS_CONFIG2, 8, 12, cs_rd_off);
Expand Down
12 changes: 6 additions & 6 deletions arch/arm/mach-omap2/omap_hwmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,8 +1438,8 @@ static int _init_clocks(struct omap_hwmod *oh, void *data)
* Return the bit position of the reset line that match the
* input name. Return -ENOENT if not found.
*/
static u8 _lookup_hardreset(struct omap_hwmod *oh, const char *name,
struct omap_hwmod_rst_info *ohri)
static int _lookup_hardreset(struct omap_hwmod *oh, const char *name,
struct omap_hwmod_rst_info *ohri)
{
int i;

Expand Down Expand Up @@ -1475,7 +1475,7 @@ static u8 _lookup_hardreset(struct omap_hwmod *oh, const char *name,
static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
{
struct omap_hwmod_rst_info ohri;
u8 ret = -EINVAL;
int ret = -EINVAL;

if (!oh)
return -EINVAL;
Expand All @@ -1484,7 +1484,7 @@ static int _assert_hardreset(struct omap_hwmod *oh, const char *name)
return -ENOSYS;

ret = _lookup_hardreset(oh, name, &ohri);
if (IS_ERR_VALUE(ret))
if (ret < 0)
return ret;

ret = soc_ops.assert_hardreset(oh, &ohri);
Expand Down Expand Up @@ -1542,7 +1542,7 @@ static int _deassert_hardreset(struct omap_hwmod *oh, const char *name)
static int _read_hardreset(struct omap_hwmod *oh, const char *name)
{
struct omap_hwmod_rst_info ohri;
u8 ret = -EINVAL;
int ret = -EINVAL;

if (!oh)
return -EINVAL;
Expand All @@ -1551,7 +1551,7 @@ static int _read_hardreset(struct omap_hwmod *oh, const char *name)
return -ENOSYS;

ret = _lookup_hardreset(oh, name, &ohri);
if (IS_ERR_VALUE(ret))
if (ret < 0)
return ret;

return soc_ops.is_hardreset_asserted(oh, &ohri);
Expand Down
7 changes: 5 additions & 2 deletions arch/arm/mach-omap2/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,11 @@ void __init omap_serial_init_port(struct omap_board_data *bdata,

pdev = omap_device_build(name, uart->num, oh, pdata, pdata_size,
NULL, 0, false);
WARN(IS_ERR(pdev), "Could not build omap_device for %s: %s.\n",
name, oh->name);
if (IS_ERR(pdev)) {
WARN(1, "Could not build omap_device for %s: %s.\n", name,
oh->name);
return;
}

if ((console_uart_id == bdata->id) && no_console_suspend)
omap_device_disable_idle_on_suspend(pdev);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-omap2/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static void __init omap2_gp_clockevent_init(int gptimer_id,
res = omap_dm_timer_init_one(&clkev, gptimer_id, fck_source);
BUG_ON(res);

omap2_gp_timer_irq.dev_id = (void *)&clkev;
omap2_gp_timer_irq.dev_id = &clkev;
setup_irq(clkev.irq, &omap2_gp_timer_irq);

__omap_dm_timer_int_enable(&clkev, OMAP_TIMER_INT_OVERFLOW);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/plat-omap/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int __init_or_module omap_cfg_reg(const unsigned long index)
return -ENODEV;
}

reg = (struct pin_config *)&mux_cfg->pins[index];
reg = &mux_cfg->pins[index];

if (!mux_cfg->cfg_reg)
return -ENODEV;
Expand Down

0 comments on commit a032d33

Please sign in to comment.