linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 1/1] ARM:vt8500: Convert to use .restart and remove arch_reset()
Date: Wed, 18 Jul 2012 12:59:21 +0000	[thread overview]
Message-ID: <201207181259.21669.arnd@arndb.de> (raw)
In-Reply-To: <1342615030.5079.YahooMailNeo@web140804.mail.bf1.yahoo.com>

On Wednesday 18 July 2012, Tony Prisk wrote:
> Changed the existing board files to use .restart in there machine
> descriptions.
> Removed system.h as it only contained an inline for arch_reset()
> 
> Added device tree support for the restart controller.
> Device tree support for vt8500 is still a work-in-progress.
> 
> Signed-off-by: Tony Prisk <linux@prisktech.co.nz>

Looks ok from the point of view that it's technically correct.
Let me make some comments about the style though:

> +/* PM Software Reset request register */
> +#define LEGACY_PMSR_REG        0xD8130060
> +#define WMT_PRIZM_PMSR_REG    0x60
> +
> +static void __iomem *wmt_restart_reg;

I think it's better to point this to the pmc_base virtual address,
which is what we commonly do for similar scenarios. This also means
changing the phys address constant here to 0xD8130000, i.e. the
same as the one in the device tree.

> +    /*
> +     * Check if Power Mgmt Controller node is present in device tree. If no
> +     * device tree node, use the legacy PMSR value (valid for all current
> +     * SoCs).
> +     */
> +    np = of_find_compatible_node(NULL, NULL, "wmt,prizm-pmc");
> +    if (np) {
> +        pmc_base = of_iomap(np, 0);
> +
> +        if (!pmc_base)
> +            pr_err("%s:of_iomap(pmc) failed\n", __func__);
> +
> +        of_node_put(np);
> +
> +        wmt_restart_reg = (void *)((u32)(pmc_base) + WMT_PRIZM_PMSR_REG);

The type cast is ugly, wrong and uncessary ;-)

It's ugly because you are casting the same address twice, which you should
never need to do.
It's wrong because you use the wrong target type (should be void __iomem *)
and the intermediate type (u32) relies on the code being compiled for 32
bit. This is probably a safe assumption, but if you have to cast between
a pointer and an integer in the kernel, the idiom is to use 'unsigned long'
as the integer type.

It's also unnecessary because 

	wmt_restart_reg = pmc_base + WMT_PRIZM_PMSR_REG;

has the exact same effect without any of the above disadvantages.

As mentioned, I would not do the calculation here at all but instead
do it below in wmt_restart(), as 

	if (pmc_base)
		writel(1, pmc_base + WMT_PRIZM_PMSR_REG);

	Arnd

  parent reply	other threads:[~2012-07-18 12:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 12:37 [PATCHv2 1/1] ARM:vt8500: Convert to use .restart and remove arch_reset() Tony Prisk
2012-07-18 12:52 ` Alexey Charkov
2012-07-18 12:59 ` Arnd Bergmann [this message]
2012-07-18 13:43   ` [PATCHv3 " Tony Prisk
2012-07-18 15:13     ` Arnd Bergmann
2012-07-18 16:52     ` Arnd Bergmann

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=201207181259.21669.arnd@arndb.de \
    --to=arnd@arndb.de \
    --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).