From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: John Stultz <john.stultz@linaro.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
Andy Yan <andy.yan@rock-chips.com>, Rob Herring <robh@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Thierry Reding <treding@nvidia.com>,
Heiko St?bner <heiko@sntech.de>, Caesar Wang <wxt@rock-chips.com>,
Kees Cook <keescook@chromium.org>,
Guodong Xu <guodong.xu@linaro.org>,
Haojian Zhuang <haojian.zhuang@linaro.org>,
Vishal Bhoj <vishal.bhoj@linaro.org>,
devicetree@vger.kernel.org,
Android Kernel Team <kernel-team@android.com>
Subject: Re: [RFC][PATCH 3/4] power: reset: Add sram-reboot-mode driver
Date: Wed, 3 Aug 2016 18:03:41 -0700 [thread overview]
Message-ID: <20160804010341.GH13516@tuxbot> (raw)
In-Reply-To: <1470265523-27557-4-git-send-email-john.stultz@linaro.org>
On Wed 03 Aug 16:05 PDT 2016, John Stultz wrote:
[..]
> diff --git a/drivers/power/reset/sram-reboot-mode.c b/drivers/power/reset/sram-reboot-mode.c
[..]
> +
> +struct sram_reboot_mode {
> + struct reboot_mode_driver reboot;
> + void __iomem *reboot_reason_val_addr;
23 characters is...a lot of characters...
> +};
> +
> +static int sram_reboot_mode_write(struct reboot_mode_driver *reboot,
> + unsigned int magic)
> +{
> + struct sram_reboot_mode *sram_rbm;
> +
> + sram_rbm = container_of(reboot, struct sram_reboot_mode, reboot);
> +
> + writel(magic, sram_rbm->reboot_reason_val_addr);
> + return 0;
> +}
> +
> +static int sram_reboot_mode_probe(struct platform_device *pdev)
> +{
> + struct sram_reboot_mode *sram_rbm;
> + struct resource *res;
> + int ret;
> +
> + sram_rbm = devm_kzalloc(&pdev->dev, sizeof(*sram_rbm), GFP_KERNEL);
> + if (!sram_rbm)
> + return -ENOMEM;
> +
> + sram_rbm->reboot.dev = &pdev->dev;
> + sram_rbm->reboot.write = sram_reboot_mode_write;
> +
> + dev_set_drvdata(&pdev->dev, sram_rbm);
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res)
> + return PTR_ERR(res);
> +
> + sram_rbm->reboot_reason_val_addr = devm_ioremap(&pdev->dev, res->start,
> + resource_size(res));
Use devm_ioremap_resource() instead, it saves you the return value check
on platform_get_resource() and is cleaner.
> + if (IS_ERR(sram_rbm->reboot_reason_val_addr))
> + return PTR_ERR(sram_rbm->reboot_reason_val_addr);
> +
> + ret = reboot_mode_register(&sram_rbm->reboot);
I think you should take the time to throw in a
devm_reboot_mode_register(), it would save you from the
dev_set_drvdata() and you can drop the remove function.
> + if (ret)
> + dev_err(&pdev->dev, "can't register reboot mode\n");
> +
> + return ret;
> +}
> +
Regards,
Bjorn
next prev parent reply other threads:[~2016-08-04 1:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-03 23:05 [RFC][PATCH 0/4] SRAM based reboot reason driver for HiKey John Stultz
2016-08-03 23:05 ` [RFC][PATCH 1/4] drivers: sram: Have sram driver probe children nodes John Stultz
2016-08-03 23:05 ` [RFC][PATCH 2/4] dt-bindings: power: reset: Add document for sram-reboot-mode driver John Stultz
2016-08-04 18:08 ` Rob Herring
2016-08-03 23:05 ` [RFC][PATCH 3/4] power: reset: Add " John Stultz
2016-08-04 1:03 ` Bjorn Andersson [this message]
2016-08-04 3:08 ` John Stultz
2016-08-04 5:29 ` Bjorn Andersson
2016-08-05 23:23 ` Paul Gortmaker
2016-08-03 23:05 ` [RFC][PATCH 4/4] dts: hikey: Add hikey support for sram-reboot-mode John Stultz
2016-08-05 12:46 ` [RFC][PATCH 0/4] SRAM based reboot reason driver for HiKey Vladimir Zapolskiy
2016-08-05 22:37 ` Rob Herring
2016-08-05 22:51 ` John Stultz
2016-08-08 13:48 ` Vladimir Zapolskiy
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=20160804010341.GH13516@tuxbot \
--to=bjorn.andersson@linaro.org \
--cc=andy.yan@rock-chips.com \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=guodong.xu@linaro.org \
--cc=haojian.zhuang@linaro.org \
--cc=heiko@sntech.de \
--cc=john.stultz@linaro.org \
--cc=keescook@chromium.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=treding@nvidia.com \
--cc=vishal.bhoj@linaro.org \
--cc=wxt@rock-chips.com \
/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