soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support
Hello Keerthy,
The patch 5a99ae0092fe: "soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support" from Apr 3, 2019, leads to the following static checker warnings:
drivers/soc/ti/pm33xx.c:254 am33xx_pm_begin() warn: 'nvmem' is an error pointer or valid drivers/soc/ti/pm33xx.c:293 am33xx_pm_end() warn: curly braces intended? drivers/soc/ti/pm33xx.c:417 am33xx_pm_rtc_setup() warn: 'nvmem' is an error pointer or valid
drivers/soc/ti/pm33xx.c
247 static int am33xx_pm_begin(suspend_state_t state) 248 {
249 int ret = -EINVAL;
250 struct nvmem_device *nvmem;
251
252 if (state == PM_SUSPEND_MEM && pm_ops->check_off_mode_enable()) {
253 nvmem = devm_nvmem_device_get(&omap_rtc->dev,
254 "omap_rtc_scratch0");
255 if (nvmem)
^^^^^
This should be if (!IS_ERR(nvmem)).
256 nvmem_device_write(nvmem, RTC_SCRATCH_MAGIC_REG * 4, 4,
257 (void *)&rtc_magic_val);
258 rtc_only_idle = 1;
259 } else {
260 rtc_only_idle = 0;
261 }
262
263 switch (state) {
264 case PM_SUSPEND_MEM:
265 ret = m3_ipc->ops->prepare_low_power(m3_ipc, WKUP_M3_DEEPSLEEP);
266 break;
267 case PM_SUSPEND_STANDBY:
268 ret = m3_ipc->ops->prepare_low_power(m3_ipc, WKUP_M3_STANDBY);
269 break;
270 }
271
272 return ret;
273 }
274
275 static void am33xx_pm_end(void)
276 {
277 u32 val = 0;
278 struct nvmem_device *nvmem;
279
280 nvmem = devm_nvmem_device_get(&omap_rtc->dev, "omap_rtc_scratch0");Does this need error handling?
281 m3_ipc->ops->finish_low_power(m3_ipc);
282 if (rtc_only_idle) {
283 if (retrigger_irq)We need curly braces for this if statement.
284 /*
285 * 32 bits of Interrupt Set-Pending correspond to 32 286 * 32 interrupts. Compute the bit offset of the 287 * Interrupt and set that particular bit 288 * Compute the register offset by dividing interrupt 289 * number by 32 and mutiplying by 4 290 */
291 writel_relaxed(1 << (retrigger_irq & 31),
292 gic_dist_base + GIC_INT_SET_PENDING_BASE
293 + retrigger_irq / 32 * 4);
294 nvmem_device_write(nvmem, RTC_SCRATCH_MAGIC_REG * 4, 4,
295 (void *)&val);
296 }
297
298 rtc_only_idle = 0;
299 }
[ snip ]
401 static int am33xx_pm_rtc_setup(void)
402 {
403 struct device_node *np;
404 unsigned long val = 0;
405 struct nvmem_device *nvmem;
406
407 np = of_find_node_by_name(NULL, "rtc");
408
409 if (of_device_is_available(np)) {
410 omap_rtc = rtc_class_open("rtc0");
411 if (!omap_rtc) {
412 pr_warn("PM: rtc0 not available");
413 return -EPROBE_DEFER;
414 }
415
416 nvmem = devm_nvmem_device_get(&omap_rtc->dev,
417 "omap_rtc_scratch0");
418 if (nvmem) {if (!IS_ERR(nvmem)) {
419 nvmem_device_read(nvmem, RTC_SCRATCH_MAGIC_REG * 4,
420 4, (void *)&rtc_magic_val);
421 if ((rtc_magic_val & 0xffff) != RTC_REG_BOOT_MAGIC)
422 pr_warn("PM: bootloader does not support rtc-only!\n");
423
424 nvmem_device_write(nvmem, RTC_SCRATCH_MAGIC_REG * 4,
425 4, (void *)&val);
426 val = pm_sram->resume_address;
427 nvmem_device_write(nvmem, RTC_SCRATCH_RESUME_REG * 4,
428 4, (void *)&val);
429 }
430 } else {
431 pr_warn("PM: no-rtc available, rtc-only mode disabled.\n");
432 }
433
434 return 0;
435 }regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 5 lines · Dan Carpenter
Hello Keerthy,
The patch
5a99ae0092fe: "soc: ti: pm33xx: AM437X: Addrtc_onlywith ddr in self-refresh support" from Apr 3, 2019, leads to the following static checker warnings:
Thanks Dan. I will post a patch to fix these.
Quoted 110 lines
drivers/soc/ti/pm33xx.c:254am33xx_pm_begin()warn: 'nvmem' is an error pointer or validdrivers/soc/ti/pm33xx.c:293am33xx_pm_end()warn: curly braces intended?drivers/soc/ti/pm33xx.c:417am33xx_pm_rtc_setup()warn: 'nvmem' is an error pointer or valid
drivers/soc/ti/pm33xx.c247 static int am33xx_pm_begin(suspend_state_t state) 248 { 249 int ret = -EINVAL; 250 struct nvmem_device *nvmem; 251 252 if (state == PM_SUSPEND_MEM && pm_ops->check_off_mode_enable()) { 253 nvmem = devm_nvmem_device_get(&omap_rtc->dev, 254 "omap_rtc_scratch0"); 255 if (nvmem) ^^^^^This should be if (!IS_ERR(nvmem)).
256 nvmem_device_write(nvmem, RTC_SCRATCH_MAGIC_REG * 4, 4, 257 (void *)&rtc_magic_val); 258 rtc_only_idle = 1; 259 } else { 260 rtc_only_idle = 0; 261 } 262 263 switch (state) { 264 case PM_SUSPEND_MEM: 265 ret = m3_ipc->ops->prepare_low_power(m3_ipc, WKUP_M3_DEEPSLEEP); 266 break; 267 case PM_SUSPEND_STANDBY: 268 ret = m3_ipc->ops->prepare_low_power(m3_ipc, WKUP_M3_STANDBY); 269 break; 270 } 271 272 return ret; 273 } 274 275 static void am33xx_pm_end(void) 276 { 277 u32 val = 0; 278 struct nvmem_device *nvmem; 279 280 nvmem = devm_nvmem_device_get(&omap_rtc->dev, "omap_rtc_scratch0");Does this need error handling?
281 m3_ipc->ops->finish_low_power(m3_ipc); 282 if (rtc_only_idle) { 283 if (retrigger_irq)We need curly braces for this if statement.
284 /*
285 * 32 bits of Interrupt Set-Pending correspond to 32
286 * 32 interrupts. Compute the bit offset of the
287 * Interrupt and set that particular bit
288 * Compute the register offset by dividing interrupt
289 * number by 32 and mutiplying by 4
290 */
291 writel_relaxed(1 << (retrigger_irq& 31),
292gic_dist_base+GIC_INT_SET_PENDING_BASE
293 +retrigger_irq/ 32 * 4);
294 nvmem_device_write(nvmem,RTC_SCRATCH_MAGIC_REG* 4, 4,
295 (void *)&val);
296 }
297
298rtc_only_idle= 0;
299 }[ snip ]
401 static int am33xx_pm_rtc_setup(void) 402 { 403 struct device_node *np; 404 unsigned long val = 0; 405 struct nvmem_device *nvmem; 406 407 np = of_find_node_by_name(NULL, "rtc"); 408 409 if (of_device_is_available(np)) { 410 omap_rtc = rtc_class_open("rtc0"); 411 if (!omap_rtc) { 412 pr_warn("PM: rtc0 not available"); 413 return -EPROBE_DEFER; 414 } 415 416 nvmem = devm_nvmem_device_get(&omap_rtc->dev, 417 "omap_rtc_scratch0"); 418 if (nvmem) {if (!IS_ERR(nvmem)) {
419 nvmem_device_read(nvmem, RTC_SCRATCH_MAGIC_REG * 4, 420 4, (void *)&rtc_magic_val); 421 if ((rtc_magic_val & 0xffff) != RTC_REG_BOOT_MAGIC) 422 pr_warn("PM: bootloader does not support rtc-only!\n"); 423 424 nvmem_device_write(nvmem, RTC_SCRATCH_MAGIC_REG * 4, 425 4, (void *)&val); 426 val = pm_sram->resume_address; 427 nvmem_device_write(nvmem, RTC_SCRATCH_RESUME_REG * 4, 428 4, (void *)&val); 429 } 430 } else { 431 pr_warn("PM: no-rtc available, rtc-only mode disabled.\n"); 432 } 433 434 return 0; 435 }
Quoted 3 lines
regards,
dan carpenter
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel