linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Keerthy <j-keerthy@ti.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Dave Gerlach <d-gerlach@ti.com>
Cc: linux-arm-kernel@lists.infradead.org
Subject: Re: [bug report] soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support
Date: Thu, 13 Jun 2019 17:15:23 +0530	[thread overview]
Message-ID: <627167de-1d28-7d7e-dbf2-9f9c02641b22@ti.com> (raw)
In-Reply-To: <20190612113623.GA24020@mwanda>



On 12/06/19 5:06 PM, Dan Carpenter wrote:
> 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:

Thanks Dan. I will post a patch to fix these.

> 
> 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
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      reply	other threads:[~2019-06-13 11:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 11:36 [bug report] soc: ti: pm33xx: AM437X: Add rtc_only with ddr in self-refresh support Dan Carpenter
2019-06-13 11:45 ` Keerthy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=627167de-1d28-7d7e-dbf2-9f9c02641b22@ti.com \
    --to=j-keerthy@ti.com \
    --cc=d-gerlach@ti.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).