aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2012-04-13 08:34:32 -0400
committerPaul Walmsley <paul@pwsan.com>2012-04-17 17:50:47 -0400
commiteeb3711b89d68e147e05e7b43a49ecc5009dc157 (patch)
tree1ab372484bc29489a298917d0c709e676d534d69 /arch/arm/mach-omap2
parent31cde0447d779c1b4ae9feb51dc917d6e287de2b (diff)
ARM: OMAP2+: clean up some cppcheck warnings
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
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r--arch/arm/mach-omap2/am35xx-emac.c37
-rw-r--r--arch/arm/mach-omap2/board-omap3evm.c8
-rw-r--r--arch/arm/mach-omap2/devices.c7
-rw-r--r--arch/arm/mach-omap2/gpio.c2
-rw-r--r--arch/arm/mach-omap2/gpmc-onenand.c3
-rw-r--r--arch/arm/mach-omap2/mux.c2
-rw-r--r--arch/arm/mach-omap2/pm24xx.c3
-rw-r--r--arch/arm/mach-omap2/pm34xx.c10
-rw-r--r--arch/arm/mach-omap2/prm_common.c4
-rw-r--r--arch/arm/mach-omap2/usb-tusb6010.c2
10 files changed, 34 insertions, 44 deletions
diff --git a/arch/arm/mach-omap2/am35xx-emac.c b/arch/arm/mach-omap2/am35xx-emac.c
index 1f97e7475206..447682c4e11c 100644
--- a/arch/arm/mach-omap2/am35xx-emac.c
+++ b/arch/arm/mach-omap2/am35xx-emac.c
@@ -39,26 +39,23 @@ static struct platform_device am35xx_emac_mdio_device = {
39 39
40static void am35xx_enable_emac_int(void) 40static void am35xx_enable_emac_int(void)
41{ 41{
42 u32 regval; 42 u32 v;
43 43
44 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); 44 v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
45 regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR | 45 v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR |
46 AM35XX_CPGMAC_C0_TX_PULSE_CLR | 46 AM35XX_CPGMAC_C0_MISC_PULSE_CLR | AM35XX_CPGMAC_C0_RX_THRESH_CLR);
47 AM35XX_CPGMAC_C0_MISC_PULSE_CLR | 47 omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
48 AM35XX_CPGMAC_C0_RX_THRESH_CLR); 48 omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
49 omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
50 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
51} 49}
52 50
53static void am35xx_disable_emac_int(void) 51static void am35xx_disable_emac_int(void)
54{ 52{
55 u32 regval; 53 u32 v;
56 54
57 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); 55 v = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
58 regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR | 56 v |= (AM35XX_CPGMAC_C0_RX_PULSE_CLR | AM35XX_CPGMAC_C0_TX_PULSE_CLR);
59 AM35XX_CPGMAC_C0_TX_PULSE_CLR); 57 omap_ctrl_writel(v, AM35XX_CONTROL_LVL_INTR_CLEAR);
60 omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR); 58 omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR); /* OCP barrier */
61 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
62} 59}
63 60
64static struct emac_platform_data am35xx_emac_pdata = { 61static struct emac_platform_data am35xx_emac_pdata = {
@@ -92,7 +89,7 @@ static struct platform_device am35xx_emac_device = {
92 89
93void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en) 90void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en)
94{ 91{
95 unsigned int regval; 92 u32 v;
96 int err; 93 int err;
97 94
98 am35xx_emac_pdata.rmii_en = rmii_en; 95 am35xx_emac_pdata.rmii_en = rmii_en;
@@ -110,8 +107,8 @@ void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en)
110 return; 107 return;
111 } 108 }
112 109
113 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); 110 v = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
114 regval = regval & (~(AM35XX_CPGMACSS_SW_RST)); 111 v &= ~AM35XX_CPGMACSS_SW_RST;
115 omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET); 112 omap_ctrl_writel(v, AM35XX_CONTROL_IP_SW_RESET);
116 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); 113 omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET); /* OCP barrier */
117} 114}
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 49df12735b41..fd1b481c762c 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -630,13 +630,13 @@ static struct regulator_consumer_supply dummy_supplies[] = {
630 630
631static void __init omap3_evm_init(void) 631static void __init omap3_evm_init(void)
632{ 632{
633 struct omap_board_mux *obm;
634
633 omap3_evm_get_revision(); 635 omap3_evm_get_revision();
634 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); 636 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
635 637
636 if (cpu_is_omap3630()) 638 obm = (cpu_is_omap3630()) ? omap36x_board_mux : omap35x_board_mux;
637 omap3_mux_init(omap36x_board_mux, OMAP_PACKAGE_CBB); 639 omap3_mux_init(obm, OMAP_PACKAGE_CBB);
638 else
639 omap3_mux_init(omap35x_board_mux, OMAP_PACKAGE_CBB);
640 640
641 omap_board_config = omap3_evm_config; 641 omap_board_config = omap3_evm_config;
642 omap_board_config_size = ARRAY_SIZE(omap3_evm_config); 642 omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index e4336035c0ea..f3953a499286 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -42,7 +42,6 @@
42 42
43static int __init omap3_l3_init(void) 43static int __init omap3_l3_init(void)
44{ 44{
45 int l;
46 struct omap_hwmod *oh; 45 struct omap_hwmod *oh;
47 struct platform_device *pdev; 46 struct platform_device *pdev;
48 char oh_name[L3_MODULES_MAX_LEN]; 47 char oh_name[L3_MODULES_MAX_LEN];
@@ -54,7 +53,7 @@ static int __init omap3_l3_init(void)
54 if (!(cpu_is_omap34xx())) 53 if (!(cpu_is_omap34xx()))
55 return -ENODEV; 54 return -ENODEV;
56 55
57 l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main"); 56 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main");
58 57
59 oh = omap_hwmod_lookup(oh_name); 58 oh = omap_hwmod_lookup(oh_name);
60 59
@@ -72,7 +71,7 @@ postcore_initcall(omap3_l3_init);
72 71
73static int __init omap4_l3_init(void) 72static int __init omap4_l3_init(void)
74{ 73{
75 int l, i; 74 int i;
76 struct omap_hwmod *oh[3]; 75 struct omap_hwmod *oh[3];
77 struct platform_device *pdev; 76 struct platform_device *pdev;
78 char oh_name[L3_MODULES_MAX_LEN]; 77 char oh_name[L3_MODULES_MAX_LEN];
@@ -89,7 +88,7 @@ static int __init omap4_l3_init(void)
89 return -ENODEV; 88 return -ENODEV;
90 89
91 for (i = 0; i < L3_MODULES; i++) { 90 for (i = 0; i < L3_MODULES; i++) {
92 l = snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1); 91 snprintf(oh_name, L3_MODULES_MAX_LEN, "l3_main_%d", i+1);
93 92
94 oh[i] = omap_hwmod_lookup(oh_name); 93 oh[i] = omap_hwmod_lookup(oh_name);
95 if (!(oh[i])) 94 if (!(oh[i]))
diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
index 2f994e5194e8..064cab03d2bd 100644
--- a/arch/arm/mach-omap2/gpio.c
+++ b/arch/arm/mach-omap2/gpio.c
@@ -58,7 +58,7 @@ static int __init omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
58 pdata->virtual_irq_start = IH_GPIO_BASE + 32 * (id - 1); 58 pdata->virtual_irq_start = IH_GPIO_BASE + 32 * (id - 1);
59 pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count; 59 pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count;
60 pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL); 60 pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL);
61 if (!pdata) { 61 if (!pdata->regs) {
62 pr_err("gpio%d: Memory allocation failed\n", id); 62 pr_err("gpio%d: Memory allocation failed\n", id);
63 return -ENOMEM; 63 return -ENOMEM;
64 } 64 }
diff --git a/arch/arm/mach-omap2/gpmc-onenand.c b/arch/arm/mach-omap2/gpmc-onenand.c
index 385b3e02c4a6..a0fa9bb2bda5 100644
--- a/arch/arm/mach-omap2/gpmc-onenand.c
+++ b/arch/arm/mach-omap2/gpmc-onenand.c
@@ -176,7 +176,7 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,
176 const int t_wpl = 40; 176 const int t_wpl = 40;
177 const int t_wph = 30; 177 const int t_wph = 30;
178 int min_gpmc_clk_period, t_ces, t_avds, t_avdh, t_ach, t_aavdh, t_rdyo; 178 int min_gpmc_clk_period, t_ces, t_avds, t_avdh, t_ach, t_aavdh, t_rdyo;
179 int tick_ns, div, fclk_offset_ns, fclk_offset, gpmc_clk_ns, latency; 179 int div, fclk_offset_ns, fclk_offset, gpmc_clk_ns, latency;
180 int first_time = 0, hf = 0, vhf = 0, sync_read = 0, sync_write = 0; 180 int first_time = 0, hf = 0, vhf = 0, sync_read = 0, sync_write = 0;
181 int err, ticks_cez; 181 int err, ticks_cez;
182 int cs = cfg->cs, freq = *freq_ptr; 182 int cs = cfg->cs, freq = *freq_ptr;
@@ -240,7 +240,6 @@ static int omap2_onenand_set_sync_mode(struct omap_onenand_platform_data *cfg,
240 break; 240 break;
241 } 241 }
242 242
243 tick_ns = gpmc_ticks_to_ns(1);
244 div = gpmc_cs_calc_divider(cs, min_gpmc_clk_period); 243 div = gpmc_cs_calc_divider(cs, min_gpmc_clk_period);
245 gpmc_clk_ns = gpmc_ticks_to_ns(div); 244 gpmc_clk_ns = gpmc_ticks_to_ns(div);
246 if (gpmc_clk_ns < 15) /* >66Mhz */ 245 if (gpmc_clk_ns < 15) /* >66Mhz */
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 65c33911341f..3268ee24eada 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -247,7 +247,7 @@ int __init omap_mux_init_signal(const char *muxname, int val)
247 int mux_mode; 247 int mux_mode;
248 248
249 mux_mode = omap_mux_get_by_name(muxname, &partition, &mux); 249 mux_mode = omap_mux_get_by_name(muxname, &partition, &mux);
250 if (mux_mode < 0) 250 if (mux_mode < 0 || !mux)
251 return mux_mode; 251 return mux_mode;
252 252
253 old_mode = omap_mux_read(partition, mux->reg_offset); 253 old_mode = omap_mux_read(partition, mux->reg_offset);
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index 95442b69ae27..facfffca9eac 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -171,8 +171,6 @@ static int omap2_allow_mpu_retention(void)
171 171
172static void omap2_enter_mpu_retention(void) 172static void omap2_enter_mpu_retention(void)
173{ 173{
174 int only_idle = 0;
175
176 /* Putting MPU into the WFI state while a transfer is active 174 /* Putting MPU into the WFI state while a transfer is active
177 * seems to cause the I2C block to timeout. Why? Good question. */ 175 * seems to cause the I2C block to timeout. Why? Good question. */
178 if (omap2_i2c_active()) 176 if (omap2_i2c_active())
@@ -195,7 +193,6 @@ static void omap2_enter_mpu_retention(void)
195 193
196 omap2_prm_write_mod_reg(OMAP_LOGICRETSTATE_MASK, MPU_MOD, 194 omap2_prm_write_mod_reg(OMAP_LOGICRETSTATE_MASK, MPU_MOD,
197 OMAP2_PM_PWSTCTRL); 195 OMAP2_PM_PWSTCTRL);
198 only_idle = 1;
199 } 196 }
200 197
201 omap2_sram_idle(); 198 omap2_sram_idle();
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 703bd1099259..8b43aefba0ea 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -273,7 +273,7 @@ void omap_sram_idle(void)
273 int per_next_state = PWRDM_POWER_ON; 273 int per_next_state = PWRDM_POWER_ON;
274 int core_next_state = PWRDM_POWER_ON; 274 int core_next_state = PWRDM_POWER_ON;
275 int per_going_off; 275 int per_going_off;
276 int core_prev_state, per_prev_state; 276 int core_prev_state;
277 u32 sdrc_pwr = 0; 277 u32 sdrc_pwr = 0;
278 278
279 mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm); 279 mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
@@ -375,10 +375,8 @@ void omap_sram_idle(void)
375 pwrdm_post_transition(); 375 pwrdm_post_transition();
376 376
377 /* PER */ 377 /* PER */
378 if (per_next_state < PWRDM_POWER_ON) { 378 if (per_next_state < PWRDM_POWER_ON)
379 per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm);
380 omap2_gpio_resume_after_idle(); 379 omap2_gpio_resume_after_idle();
381 }
382 380
383 /* Disable IO-PAD and IO-CHAIN wakeup */ 381 /* Disable IO-PAD and IO-CHAIN wakeup */
384 if (omap3_has_io_wakeup() && 382 if (omap3_has_io_wakeup() &&
@@ -702,7 +700,7 @@ static void __init pm_errata_configure(void)
702static int __init omap3_pm_init(void) 700static int __init omap3_pm_init(void)
703{ 701{
704 struct power_state *pwrst, *tmp; 702 struct power_state *pwrst, *tmp;
705 struct clockdomain *neon_clkdm, *per_clkdm, *mpu_clkdm, *core_clkdm; 703 struct clockdomain *neon_clkdm, *mpu_clkdm;
706 int ret; 704 int ret;
707 705
708 if (!cpu_is_omap34xx()) 706 if (!cpu_is_omap34xx())
@@ -757,8 +755,6 @@ static int __init omap3_pm_init(void)
757 755
758 neon_clkdm = clkdm_lookup("neon_clkdm"); 756 neon_clkdm = clkdm_lookup("neon_clkdm");
759 mpu_clkdm = clkdm_lookup("mpu_clkdm"); 757 mpu_clkdm = clkdm_lookup("mpu_clkdm");
760 per_clkdm = clkdm_lookup("per_clkdm");
761 core_clkdm = clkdm_lookup("core_clkdm");
762 758
763#ifdef CONFIG_SUSPEND 759#ifdef CONFIG_SUSPEND
764 omap_pm_suspend = omap3_pm_suspend; 760 omap_pm_suspend = omap3_pm_suspend;
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index d28f848897d6..dfe00ddb5c60 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -237,7 +237,7 @@ void omap_prcm_irq_complete(void)
237 */ 237 */
238int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup) 238int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
239{ 239{
240 int nr_regs = irq_setup->nr_regs; 240 int nr_regs;
241 u32 mask[OMAP_PRCM_MAX_NR_PENDING_REG]; 241 u32 mask[OMAP_PRCM_MAX_NR_PENDING_REG];
242 int offset, i; 242 int offset, i;
243 struct irq_chip_generic *gc; 243 struct irq_chip_generic *gc;
@@ -246,6 +246,8 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
246 if (!irq_setup) 246 if (!irq_setup)
247 return -EINVAL; 247 return -EINVAL;
248 248
249 nr_regs = irq_setup->nr_regs;
250
249 if (prcm_irq_setup) { 251 if (prcm_irq_setup) {
250 pr_err("PRCM: already initialized; won't reinitialize\n"); 252 pr_err("PRCM: already initialized; won't reinitialize\n");
251 return -EINVAL; 253 return -EINVAL;
diff --git a/arch/arm/mach-omap2/usb-tusb6010.c b/arch/arm/mach-omap2/usb-tusb6010.c
index 994d8f591a1d..db84a46ce7fd 100644
--- a/arch/arm/mach-omap2/usb-tusb6010.c
+++ b/arch/arm/mach-omap2/usb-tusb6010.c
@@ -126,7 +126,7 @@ static int tusb_set_sync_mode(unsigned sysclk_ps, unsigned fclk_ps)
126 tmp = (t.sync_clk + fclk_ps - 1) / fclk_ps; 126 tmp = (t.sync_clk + fclk_ps - 1) / fclk_ps;
127 if (tmp > 4) 127 if (tmp > 4)
128 return -ERANGE; 128 return -ERANGE;
129 if (tmp <= 0) 129 if (tmp == 0)
130 tmp = 1; 130 tmp = 1;
131 t.page_burst_access = (fclk_ps * tmp) / 1000; 131 t.page_burst_access = (fclk_ps * tmp) / 1000;
132 132