All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: Gregory CLEMENT
	<gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>,
	Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>,
	Ezequiel Garcia
	<ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Sebastian Hesselbarth
	<sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 1/2] ARM: mvebu: Add support to get the ID and the revision of a SoC
Date: Fri, 3 Jan 2014 19:48:00 +0100	[thread overview]
Message-ID: <20140103194800.2d3ca026@skate> (raw)
In-Reply-To: <1388743185-24822-2-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

Dear Gregory CLEMENT,

On Fri,  3 Jan 2014 10:59:44 +0100, Gregory CLEMENT wrote:
> +static int __init mvebu_soc_id_init(void)
> +{
> +	struct device_node *np;
> +	int ret = 0;
> +
> +	np = of_find_matching_node(NULL, mvebu_pcie_of_match_table);
> +	if (np) {

Change this to:

	if (!np)
		return 0;

so that you avoid indenting the entire function code inside the if
{ ... } block.

> +		void __iomem *pci_base;
> +		struct clk *clk;
> +		/*
> +		 * ID and revision are available from any port, so we
> +		 * just pick the first one
> +		 */
> +		struct device_node *child = of_get_next_child(np, NULL);

Maybe check that child is not NULL here?

> +
> +		clk = of_clk_get_by_name(child, NULL);
> +		if (IS_ERR(clk)) {
> +			pr_err("%s: cannot get clock\n", __func__);

I think you should rather do:

#define pr_fmt(fmt) "mvebu-soc-id: " fmt

at the beginning of your C file and get rid of the "%s" for the
__func__.

> +		/* SoC ID */
> +		soc_dev_id = __raw_readl(pci_base + PCIE_DEV_ID_OFF) >> 16;
> +
> +		/* SoC revision */
> +		soc_rev = __raw_readl(pci_base + PCIE_DEV_REV_OFF)
> +			& SOC_REV_MASK;

Use readl() for both of these reads. __raw_readl() will not work
properly when the system is booted big-endian.

> +	return ret;
> +}
> +arch_initcall(mvebu_soc_id_init);

> +#ifdef CONFIG_ARCH_MVEBU
> +int mvebu_get_soc_id(u32 *dev, u32 *rev);
> +#else
> +int mvebu_get_soc_id(u32 *dev, u32 *rev)

Missing "static inline". Without these, if this header file is included
more than once, you will have two times the same symbol defined.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

WARNING: multiple messages have this Message-ID (diff)
From: thomas.petazzoni@free-electrons.com (Thomas Petazzoni)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/2] ARM: mvebu: Add support to get the ID and the revision of a SoC
Date: Fri, 3 Jan 2014 19:48:00 +0100	[thread overview]
Message-ID: <20140103194800.2d3ca026@skate> (raw)
In-Reply-To: <1388743185-24822-2-git-send-email-gregory.clement@free-electrons.com>

Dear Gregory CLEMENT,

On Fri,  3 Jan 2014 10:59:44 +0100, Gregory CLEMENT wrote:
> +static int __init mvebu_soc_id_init(void)
> +{
> +	struct device_node *np;
> +	int ret = 0;
> +
> +	np = of_find_matching_node(NULL, mvebu_pcie_of_match_table);
> +	if (np) {

Change this to:

	if (!np)
		return 0;

so that you avoid indenting the entire function code inside the if
{ ... } block.

> +		void __iomem *pci_base;
> +		struct clk *clk;
> +		/*
> +		 * ID and revision are available from any port, so we
> +		 * just pick the first one
> +		 */
> +		struct device_node *child = of_get_next_child(np, NULL);

Maybe check that child is not NULL here?

> +
> +		clk = of_clk_get_by_name(child, NULL);
> +		if (IS_ERR(clk)) {
> +			pr_err("%s: cannot get clock\n", __func__);

I think you should rather do:

#define pr_fmt(fmt) "mvebu-soc-id: " fmt

at the beginning of your C file and get rid of the "%s" for the
__func__.

> +		/* SoC ID */
> +		soc_dev_id = __raw_readl(pci_base + PCIE_DEV_ID_OFF) >> 16;
> +
> +		/* SoC revision */
> +		soc_rev = __raw_readl(pci_base + PCIE_DEV_REV_OFF)
> +			& SOC_REV_MASK;

Use readl() for both of these reads. __raw_readl() will not work
properly when the system is booted big-endian.

> +	return ret;
> +}
> +arch_initcall(mvebu_soc_id_init);

> +#ifdef CONFIG_ARCH_MVEBU
> +int mvebu_get_soc_id(u32 *dev, u32 *rev);
> +#else
> +int mvebu_get_soc_id(u32 *dev, u32 *rev)

Missing "static inline". Without these, if this header file is included
more than once, you will have two times the same symbol defined.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

  parent reply	other threads:[~2014-01-03 18:48 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-03  9:59 [PATCH v2 0/2] Fix i2c bus hang on A0 version of the Armada XP SoCs Gregory CLEMENT
2014-01-03  9:59 ` Gregory CLEMENT
     [not found] ` <1388743185-24822-1-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-03  9:59   ` [PATCH v2 1/2] ARM: mvebu: Add support to get the ID and the revision of a SoC Gregory CLEMENT
2014-01-03  9:59     ` Gregory CLEMENT
2014-01-03 14:47     ` Andrew Lunn
2014-01-03 14:47       ` Andrew Lunn
2014-01-03 14:51       ` Gregory CLEMENT
2014-01-03 14:51         ` Gregory CLEMENT
     [not found]         ` <52C6CE7E.5010800-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-03 15:13           ` Gregory CLEMENT
2014-01-03 15:13             ` Gregory CLEMENT
2014-01-03 16:41             ` Andrew Lunn
2014-01-03 16:41               ` Andrew Lunn
2014-01-03 19:30               ` Gregory CLEMENT
2014-01-03 19:30                 ` Gregory CLEMENT
     [not found]     ` <1388743185-24822-2-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-03 18:48       ` Thomas Petazzoni [this message]
2014-01-03 18:48         ` Thomas Petazzoni
2014-01-03 19:25         ` Gregory CLEMENT
2014-01-03 19:25           ` Gregory CLEMENT
2014-01-03 18:59     ` Jason Gunthorpe
2014-01-03 18:59       ` Jason Gunthorpe
2014-01-03 19:35       ` Gregory CLEMENT
2014-01-03 19:35         ` Gregory CLEMENT
2014-01-05 14:25     ` Arnd Bergmann
2014-01-05 14:25       ` Arnd Bergmann
2014-01-05 15:40       ` Andrew Lunn
2014-01-05 15:40         ` Andrew Lunn
     [not found]         ` <20140105154023.GA2048-g2DYL2Zd6BY@public.gmane.org>
2014-01-05 17:27           ` Jason Gunthorpe
2014-01-05 17:27             ` Jason Gunthorpe
     [not found]             ` <20140105172756.GA11280-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2014-01-05 17:37               ` Sebastian Hesselbarth
2014-01-05 17:37                 ` Sebastian Hesselbarth
2014-01-05 23:07                 ` Jason Gunthorpe
2014-01-05 23:07                   ` Jason Gunthorpe
2014-01-05 23:12                   ` Sebastian Hesselbarth
2014-01-05 23:12                     ` Sebastian Hesselbarth
     [not found]                     ` <52C9E6D0.3000406-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-05 23:40                       ` Jason Gunthorpe
2014-01-05 23:40                         ` Jason Gunthorpe
2014-01-06  0:05                         ` Sebastian Hesselbarth
2014-01-06  0:05                           ` Sebastian Hesselbarth
2014-01-06  0:17                           ` Andrew Lunn
2014-01-06  0:17                             ` Andrew Lunn
     [not found]                             ` <20140106001709.GD4093-g2DYL2Zd6BY@public.gmane.org>
2014-01-06  9:55                               ` Gregory CLEMENT
2014-01-06  9:55                                 ` Gregory CLEMENT
2014-01-06 10:10                                 ` Gregory CLEMENT
2014-01-06 10:10                                   ` Gregory CLEMENT
2014-01-05 19:17           ` Arnd Bergmann
2014-01-05 19:17             ` Arnd Bergmann
     [not found]             ` <201401052017.10982.arnd-r2nGTMty4D4@public.gmane.org>
2014-01-05 23:51               ` Andrew Lunn
2014-01-05 23:51                 ` Andrew Lunn
2014-01-06 15:37                 ` Arnd Bergmann
2014-01-06 15:37                   ` Arnd Bergmann
     [not found]                   ` <201401061637.28194.arnd-r2nGTMty4D4@public.gmane.org>
2014-01-06 16:24                     ` Andrew Lunn
2014-01-06 16:24                       ` Andrew Lunn
     [not found]                       ` <20140106162442.GB13111-g2DYL2Zd6BY@public.gmane.org>
2014-01-07 14:41                         ` Arnd Bergmann
2014-01-07 14:41                           ` Arnd Bergmann
2014-01-06 10:28       ` Gregory CLEMENT
2014-01-06 10:28         ` Gregory CLEMENT
2014-01-03  9:59 ` [PATCH v2 2/2] i2c: mv64xxx: Fix bus hang on A0 version of the Armada XP SoCs Gregory CLEMENT
2014-01-03  9:59   ` Gregory CLEMENT
     [not found]   ` <1388743185-24822-3-git-send-email-gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-03 12:20     ` Gregory CLEMENT
2014-01-03 12:20       ` Gregory CLEMENT
2014-01-03 18:49   ` Thomas Petazzoni
2014-01-03 18:49     ` Thomas Petazzoni
2014-01-03 19:31     ` Gregory CLEMENT
2014-01-03 19:31       ` Gregory CLEMENT
2014-01-05 14:33   ` Arnd Bergmann
2014-01-05 14:33     ` Arnd Bergmann
     [not found]     ` <201401051533.58931.arnd-r2nGTMty4D4@public.gmane.org>
2014-01-06  9:09       ` Gregory CLEMENT
2014-01-06  9:09         ` Gregory CLEMENT
     [not found]         ` <52CA72BF.10604-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-07  9:03           ` Arnd Bergmann
2014-01-07  9:03             ` Arnd Bergmann
     [not found]             ` <201401071003.31309.arnd-r2nGTMty4D4@public.gmane.org>
2014-01-07 13:17               ` Gregory CLEMENT
2014-01-07 13:17                 ` Gregory CLEMENT
2014-01-07 20:50                 ` Arnd Bergmann
2014-01-07 20:50                   ` 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=20140103194800.2d3ca026@skate \
    --to=thomas.petazzoni-wi1+55scjutkeb57/3fjtnbpr1lh4cv8@public.gmane.org \
    --cc=andrew-g2DYL2Zd6BY@public.gmane.org \
    --cc=ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.