devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: John Stultz <john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: lkml <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Andy Yan <andy.yan-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
	Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>,
	Heiko St?bner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>,
	Caesar Wang <wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
	Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Guodong Xu <guodong.xu-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Haojian Zhuang
	<haojian.zhuang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	Vishal Bhoj <vishal.bhoj-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Android Kernel Team
	<kernel-team-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
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-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  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
     [not found] ` <1470265523-27557-1-git-send-email-john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
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
     [not found]     ` <1470265523-27557-3-git-send-email-john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-08-04 18:08       ` Rob Herring
2016-08-03 23:05 ` [RFC][PATCH 3/4] power: reset: Add " John Stultz
     [not found]   ` <1470265523-27557-4-git-send-email-john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
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
     [not found]     ` <CAL_JsqLL01G_=b6tV_qsKmPCEJa2Fhp_zk5u9s1-eYdzfHjbxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=andy.yan-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=guodong.xu-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=haojian.zhuang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
    --cc=john.stultz-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=kernel-team-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org \
    --cc=vishal.bhoj-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.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).