]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ARM: OMAP2+: clean up some cppcheck warnings
authorPaul Walmsley <paul@pwsan.com>
Fri, 13 Apr 2012 12:34:32 +0000 (06:34 -0600)
committerPaul Walmsley <paul@pwsan.com>
Tue, 17 Apr 2012 21:50:47 +0000 (15:50 -0600)
Resolve some warnings identified by cppcheck in arch/arm/mach-omap2:

    [arch/arm/mach-omap2/usb-tusb6010.c:129]: (style) Checking if unsigned variable 'tmp' is less than zero.
    [arch/arm/mach-omap2/prm_common.c:241]: (error) Possible null pointer dereference: irq_setup - otherwise it is redundant to check if irq_setup is null at line 247
    [arch/arm/mach-omap2/pm34xx.c:790]: (style) Variable 'per_clkdm' is assigned a value that is never used
    [arch/arm/mach-omap2/pm34xx.c:790]: (style) Variable 'core_clkdm' is assigned a value that is never used
    [arch/arm/mach-omap2/pm24xx.c:185]: (style) Variable 'only_idle' is assigned a value that is never used
    [arch/arm/mach-omap2/mux.c:254]: (error) Possible null pointer dereference: mux
    [arch/arm/mach-omap2/mux.c:258]: (error) Possible null pointer dereference: mux
    [arch/arm/mach-omap2/gpmc-onenand.c:178]: (style) Variable 'tick_ns' is assigned a value that is never used
    [arch/arm/mach-omap2/gpio.c:56]: (error) Possible null pointer dereference: pdata - otherwise it is redundant to check if pdata is null at line 57
    [arch/arm/mach-omap2/devices.c:45]: (style) Variable 'l' is assigned a value that is never used
    [arch/arm/mach-omap2/board-omap3evm.c:641] -> [arch/arm/mach-omap2/board-omap3evm.c:639]: (style) Found duplicate branches for if and else.
    [arch/arm/mach-omap2/am35xx-emac.c:95]: (style) Variable 'regval' is assigned a value that is never used
    [arch/arm/mach-omap2/devices.c:74]: (style) Variable 'l' is assigned a value that is never used
    [arch/arm/mach-omap2/pm34xx.c:277]: (style) Variable 'per_prev_state' is assigned a value that is never used
    [arch/arm/plat-omap/dmtimer.c:352]: (error) Possible null pointer dereference: timer - otherwise it is redundant to check if timer is null at line 354
    [arch/arm/plat-omap/omap_device.c:478]: (style) Variable 'c' is assigned a value that is never used
    [arch/arm/plat-omap/usb.c:42]: (style) Variable 'status' is assigned a value that is never used
    [arch/arm/mach-omap1/clock.c:197]: (style) Variable 'dpll1_rate' is assigned a value that is never used
    [arch/arm/mach-omap1/lcd_dma.c:60]: (style) struct or union member 'lcd_dma_info::size' is never used
    [arch/arm/mach-omap1/pm.c:572]: (style) Variable 'entry' is assigned a value that is never used

Some of them are pretty good catches, such as gpio.c:56 and
usb-tusb6010.c:129.

Thanks to Jarkko Nikula for some comments on the sscanf() warnings.
It seems that the kernel sscanf() ignores the field width anyway for the
%d format, so those changes have been dropped from this second version.

Thanks to Daniel Marjamäki <daniel.marjamaki@gmail.com> for pointing
out that a variable was unnecessarily marked static in the
board-omap3evm.c change.

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: Jarkko Nikula <jarkko.nikula@bitmer.com>
Cc: Charulatha Varadarajan <charu@ti.com>
Cc: Daniel Marjamäki <daniel.marjamaki@gmail.com>
Cc: Tarun Kanti DebBarma <tarun.kanti@ti.com>
Reviewed-by: Charulatha Varadarajan <charu@ti.com> # for gpio.c
16 files changed:
arch/arm/mach-omap1/clock.c
arch/arm/mach-omap1/lcd_dma.c
arch/arm/mach-omap1/pm.c
arch/arm/mach-omap2/am35xx-emac.c
arch/arm/mach-omap2/board-omap3evm.c
arch/arm/mach-omap2/devices.c
arch/arm/mach-omap2/gpio.c
arch/arm/mach-omap2/gpmc-onenand.c
arch/arm/mach-omap2/mux.c
arch/arm/mach-omap2/pm24xx.c
arch/arm/mach-omap2/pm34xx.c
arch/arm/mach-omap2/prm_common.c
arch/arm/mach-omap2/usb-tusb6010.c
arch/arm/plat-omap/dmtimer.c
arch/arm/plat-omap/omap_device.c
arch/arm/plat-omap/usb.c

index 67382ddd8c83fe7a4464a2c36d1a2d22979e437a..a9ee06b6cb42a72b262d92434eaf31f87b4abdea 100644 (file)
@@ -194,9 +194,8 @@ int omap1_select_table_rate(struct clk *clk, unsigned long rate)
 {
        /* Find the highest supported frequency <= rate and switch to it */
        struct mpu_rate * ptr;
-       unsigned long dpll1_rate, ref_rate;
+       unsigned long ref_rate;
 
-       dpll1_rate = ck_dpll1_p->rate;
        ref_rate = ck_ref_p->rate;
 
        for (ptr = omap1_rate_table; ptr->rate; ptr++) {
index 9237576270b27377819bdda8c6d95ef7181bd0d9..5769c71815b2e3a6b8324ab17764824791723de5 100644 (file)
@@ -57,7 +57,7 @@ static struct lcd_dma_info {
        void *cb_data;
 
        int active;
-       unsigned long addr, size;
+       unsigned long addr;
        int rotate, data_type, xres, yres;
        int vxres;
        int mirror;
index f66c32912b22d5bef0c4ca7d590ef5e5657c34ac..b2560d32b3a01d455079d43d937124e278c599f8 100644 (file)
@@ -569,11 +569,10 @@ static int omap_pm_read_proc(
 
 static void omap_pm_init_proc(void)
 {
-       struct proc_dir_entry *entry;
-
-       entry = create_proc_read_entry("driver/omap_pm",
-                                      S_IWUSR | S_IRUGO, NULL,
-                                      omap_pm_read_proc, NULL);
+       /* XXX Appears to leak memory */
+       create_proc_read_entry("driver/omap_pm",
+                              S_IWUSR | S_IRUGO, NULL,
+                              omap_pm_read_proc, NULL);
 }
 
 #endif /* DEBUG && CONFIG_PROC_FS */
index 1f97e747520612e80d11c64a6e0d1ebc89cf27ac..447682c4e11cccad255241f2f32240d41c1f1423 100644 (file)
@@ -39,26 +39,23 @@ static struct platform_device am35xx_emac_mdio_device = {
 
 static void am35xx_enable_emac_int(void)
 {
-       u32 regval;
-
-       regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
-       regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
-                 AM35XX_CPGMAC_C0_TX_PULSE_CLR |
-                 AM35XX_CPGMAC_C0_MISC_PULSE_CLR |
-                 AM35XX_CPGMAC_C0_RX_THRESH_CLR);
-       omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
-       regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
+       u32 v;
+
+       v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
+       v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR |
+             AM35XX_CPGMAC_C0_MISC_PULSE_CLR | AM35XX_CPGMAC_C0_RX_THRESH_CLR);
+       omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
+       omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
 }
 
 static void am35xx_disable_emac_int(void)
 {
-       u32 regval;
+       u32 v;
 
-       regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
-       regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
-                 AM35XX_CPGMAC_C0_TX_PULSE_CLR);
-       omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
-       regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
+       v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
+       v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR);
+       omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
+       omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
 }
 
 static struct emac_platform_data am35xx_emac_pdata = {
@@ -92,7 +89,7 @@ static struct platform_device am35xx_emac_device = {
 
 void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en)
 {
-       unsigned int regval;
+       u32 v;
        int err;
 
        am35xx_emac_pdata.rmii_en = rmii_en;
@@ -110,8 +107,8 @@ void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en)
                return;
        }
 
-       regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
-       regval = regval & (~(AM35XX_CPGMACSS_SW_RST));
-       omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
-       regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
+       v = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
+       v &= ~AM35XX_CPGMACSS_SW_RST;
+       omap_ctrl_writel(v, AM35XX_CONTROL_IP_SW_RESET);
+       omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); /* OCP barrier */
 }
index 49df12735b41916db3a9d222880ddb4dcd89015d..fd1b481c762c97576f1c9cb5503e9bd470a4a528 100644 (file)
@@ -630,13 +630,13 @@ static struct regulator_consumer_supply dummy_supplies[] = {
 
 static void __init omap3_evm_init(void)
 {
+       struct omap_board_mux *obm;
+
        omap3_evm_get_revision();
        regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
 
-       if (cpu_is_omap3630())
-               omap3_mux_init(omap36x_board_mux, OMAP_PACKAGE_CBB);
-       else
-               omap3_mux_init(omap35x_board_mux, OMAP_PACKAGE_CBB);
+       obm = (cpu_is_omap3630()) ? omap36x_board_mux : omap35x_board_mux;
+       omap3_mux_init(obm, OMAP_PACKAGE_CBB);
 
        omap_board_config = omap3_evm_config;
        omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
index e4336035c0ea85f94ce4e9d4e6b1cd0752e1f5e4..f3953a4992869966e457dbd91968feed1cb4cf47 100644 (file)
@@ -42,7 +42,6 @@
 
 static int __init omap3_l3_init(void)
 {
-       int l;
        struct omap_hwmod *oh;
        struct platform_device *pdev;
        char oh_name[L3_MODULES_MAX_LEN];
@@ -54,7 +53,7 @@ static int __init omap3_l3_init(void)
        if (!(cpu_is_omap34xx()))
                return -ENODEV;
 
-       l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
+       snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
 
        oh = omap_hwmod_lookup(oh_name);
 
@@ -72,7 +71,7 @@ postcore_initcall(omap3_l3_init);
 
 static int __init omap4_l3_init(void)
 {
-       int l, i;
+       int i;
        struct omap_hwmod *oh[3];
        struct platform_device *pdev;
        char oh_name[L3_MODULES_MAX_LEN];
@@ -89,7 +88,7 @@ static int __init omap4_l3_init(void)
                return -ENODEV;
 
        for (i = 0; i < L3_MODULES; i++) {
-               l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
+               snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
 
                oh[i] = omap_hwmod_lookup(oh_name);
                if (!(oh[i]))
index 2f994e5194e85c932836421f79b90fe7efe0ce4c..064cab03d2bd4f606fe85af3ef0a4753a60bdc73 100644 (file)
@@ -58,7 +58,7 @@ static int __init omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
        pdata->virtual_irq_start = IH_GPIO_BASE + 32 * (id - 1);
        pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count;
        pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL);
-       if (!pdata) {
+       if (!pdata->regs) {
                pr_err("gpio%d: Memory allocation failed\n", id);
                return -ENOMEM;
        }
index 385b3e02c4a696b0a28a218b54027daf98def1b4..a0fa9bb2bda5bed7e952cd7639374c040d858fbc 100644 (file)
@@ -176,7 +176,7 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,
        const int t_wpl  = 40;
        const int t_wph  = 30;
        int min_gpmc_clk_period, t_ces, t_avds, t_avdh, t_ach, t_aavdh, t_rdyo;
-       int tick_ns, div, fclk_offset_ns, fclk_offset, gpmc_clk_ns, latency;
+       int div, fclk_offset_ns, fclk_offset, gpmc_clk_ns, latency;
        int first_time = 0, hf = 0, vhf = 0, sync_read = 0, sync_write = 0;
        int err, ticks_cez;
        int cs = cfg->cs, freq = *freq_ptr;
@@ -240,7 +240,6 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,
                break;
        }
 
-       tick_ns = gpmc_ticks_to_ns(1);
        div = gpmc_cs_calc_divider(cs, min_gpmc_clk_period);
        gpmc_clk_ns = gpmc_ticks_to_ns(div);
        if (gpmc_clk_ns < 15) /* >66Mhz */
index 65c33911341fcf589b1e4372e9f5adbbada62d21..3268ee24eada87ee74d24ce90bc9ea918260bfd2 100644 (file)
@@ -247,7 +247,7 @@ int __init omap_mux_init_signal(const char *muxname, int val)
        int mux_mode;
 
        mux_mode = omap_mux_get_by_name(muxname, &partition, &mux);
-       if (mux_mode < 0)
+       if (mux_mode < 0 || !mux)
                return mux_mode;
 
        old_mode = omap_mux_read(partition, mux->reg_offset);
index 95442b69ae27111fc4bf5dba66eaaa8e01c6547a..facfffca9eacb33471413136e61bea8fd3c9e6cb 100644 (file)
@@ -171,8 +171,6 @@ static int omap2_allow_mpu_retention(void)
 
 static void omap2_enter_mpu_retention(void)
 {
-       int only_idle = 0;
-
        /* Putting MPU into the WFI state while a transfer is active
         * seems to cause the I2C block to timeout. Why? Good question. */
        if (omap2_i2c_active())
@@ -195,7 +193,6 @@ static void omap2_enter_mpu_retention(void)
 
                omap2_prm_write_mod_reg(OMAP_LOGICRETSTATE_MASK, MPU_MOD,
                                                 OMAP2_PM_PWSTCTRL);
-               only_idle = 1;
        }
 
        omap2_sram_idle();
index 703bd10992591ce2a05635052c9cb685dd5c9c83..8b43aefba0eae19b85a574f7324ed672d6670677 100644 (file)
@@ -273,7 +273,7 @@ void omap_sram_idle(void)
        int per_next_state = PWRDM_POWER_ON;
        int core_next_state = PWRDM_POWER_ON;
        int per_going_off;
-       int core_prev_state, per_prev_state;
+       int core_prev_state;
        u32 sdrc_pwr = 0;
 
        mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
@@ -375,10 +375,8 @@ void omap_sram_idle(void)
        pwrdm_post_transition();
 
        /* PER */
-       if (per_next_state < PWRDM_POWER_ON) {
-               per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm);
+       if (per_next_state < PWRDM_POWER_ON)
                omap2_gpio_resume_after_idle();
-       }
 
        /* Disable IO-PAD and IO-CHAIN wakeup */
        if (omap3_has_io_wakeup() &&
@@ -702,7 +700,7 @@ static void __init pm_errata_configure(void)
 static int __init omap3_pm_init(void)
 {
        struct power_state *pwrst, *tmp;
-       struct clockdomain *neon_clkdm, *per_clkdm, *mpu_clkdm, *core_clkdm;
+       struct clockdomain *neon_clkdm, *mpu_clkdm;
        int ret;
 
        if (!cpu_is_omap34xx())
@@ -757,8 +755,6 @@ static int __init omap3_pm_init(void)
 
        neon_clkdm = clkdm_lookup("neon_clkdm");
        mpu_clkdm = clkdm_lookup("mpu_clkdm");
-       per_clkdm = clkdm_lookup("per_clkdm");
-       core_clkdm = clkdm_lookup("core_clkdm");
 
 #ifdef CONFIG_SUSPEND
        omap_pm_suspend = omap3_pm_suspend;
index d28f848897d62083e339d493263032249a2760bd..dfe00ddb5c60f6d3beda1e5955251c459e0e0c7a 100644 (file)
@@ -237,7 +237,7 @@ void omap_prcm_irq_complete(void)
  */
 int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
 {
-       int nr_regs = irq_setup->nr_regs;
+       int nr_regs;
        u32 mask[OMAP_PRCM_MAX_NR_PENDING_REG];
        int offset, i;
        struct irq_chip_generic *gc;
@@ -246,6 +246,8 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
        if (!irq_setup)
                return -EINVAL;
 
+       nr_regs = irq_setup->nr_regs;
+
        if (prcm_irq_setup) {
                pr_err("PRCM: already initialized; won't reinitialize\n");
                return -EINVAL;
index 994d8f591a1d623b5afc3b7e2602e08636cf4a84..db84a46ce7fd6da27ca899d3fcf326cae0a3ee79 100644 (file)
@@ -126,7 +126,7 @@ static int tusb_set_sync_mode(unsigned sysclk_ps, unsigned fclk_ps)
        tmp = (t.sync_clk + fclk_ps - 1) / fclk_ps;
        if (tmp > 4)
                return -ERANGE;
-       if (tmp <= 0)
+       if (tmp == 0)
                tmp = 1;
        t.page_burst_access = (fclk_ps * tmp) / 1000;
 
index 652139c0339e2fe8fae6df508bbc3a548fd06172..c4ed35e89fbde45ee252263b47846d70c11d1f7a 100644 (file)
@@ -349,11 +349,12 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_start);
 int omap_dm_timer_stop(struct omap_dm_timer *timer)
 {
        unsigned long rate = 0;
-       struct dmtimer_platform_data *pdata = timer->pdev->dev.platform_data;
+       struct dmtimer_platform_data *pdata;
 
        if (unlikely(!timer))
                return -EINVAL;
 
+       pdata = timer->pdev->dev.platform_data;
        if (!pdata->needs_manual_reset)
                rate = clk_get_rate(timer->fclk);
 
index d50cbc6385bd48a10fd5d6064b1733b00b563910..c490240bb82c7be0e8b1e11636e7bde2b9face6a 100644 (file)
@@ -475,13 +475,11 @@ static int omap_device_count_resources(struct omap_device *od)
 static int omap_device_fill_resources(struct omap_device *od,
                                      struct resource *res)
 {
-       int c = 0;
        int i, r;
 
        for (i = 0; i < od->hwmods_cnt; i++) {
                r = omap_hwmod_fill_resources(od->hwmods[i], res);
                res += r;
-               c += r;
        }
 
        return 0;
index ab6238815eb2a6cf4b7a207783bded89be81dc17..5db75619f2137d9444e453d90f584c96d6c2b100 100644 (file)
@@ -136,8 +136,6 @@ omap_otg_init(struct omap_usb_config *config)
 #endif
        pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
        omap_writel(syscon, OTG_SYSCON_1);
-
-       status = 0;
 }
 
 #else