public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Justin Chen <justinpopo6@gmail.com>, linux-kernel@vger.kernel.org
Cc: bcm-kernel-feedback-list@broadcom.com, f.fainelli@gmail.com,
	linux-arm-kernel@lists.infradead.org, arnd@arndb.de,
	Justin Chen <justin.chen@broadcom.com>
Subject: Re: [PATCH v2] bsp: add SoC driver to brcmstb
Date: Fri, 11 Mar 2016 10:55:05 -0800	[thread overview]
Message-ID: <1457722505.4654.8.camel@perches.com> (raw)
In-Reply-To: <1457721579-9646-1-git-send-email-justinpopo6@gmail.com>

On Fri, 2016-03-11 at 10:39 -0800, Justin Chen wrote:
> From: Justin Chen <justin.chen@broadcom.com>
> 
> Value of soc_dev_attributes:
> family = chip family id
> soc_id = product id
> revision = product revision
[]
> diff --git a/drivers/soc/brcmstb/common.c b/drivers/soc/brcmstb/common.c
[]
> +static int __init brcmstb_soc_device_init(void)
> +{
> +	struct soc_device_attribute *soc_dev_attr;
> +	struct soc_device *soc_dev;
> +	struct device_node *sun_top_ctrl;
> +	void __iomem *sun_top_ctrl_base;
> +
> +	sun_top_ctrl = of_find_matching_node(NULL, sun_top_ctrl_match);
> +	if (!sun_top_ctrl)
> +		return -ENODEV;
> +
> +	sun_top_ctrl_base = of_iomap(sun_top_ctrl, 0);
> +	if (!sun_top_ctrl_base)
> +		return -ENODEV;
> +
> +	family_id = readl(sun_top_ctrl_base);
> +	product_id = readl(sun_top_ctrl_base + 0x4);
> +
> +	soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
> +	if (!soc_dev_attr)
> +		return -ENOMEM;
> +
> +	soc_dev_attr->family = kasprintf(GFP_KERNEL, "%x",
> +					family_id >> 28 ?
> +					family_id >> 16 : family_id >> 8);
> +	soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%x",
> +					product_id >> 28 ?
> +					product_id >> 16 : product_id >> 8);
> +	soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c%d",
> +				    (char)(((product_id & 0xff) >> 4) + 65),
> +				     product_id & 0xf);

This might be easier to read as:

	soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c%d"
					   ((product_id & 0xf0) >> 4) + 'A',
					   product_id & 0xf);
> +
> +	soc_dev = soc_device_register(soc_dev_attr);
> +	if (IS_ERR(soc_dev)) {
> +		kfree(soc_dev_attr->family);
> +		kfree(soc_dev_attr->soc_id);
> +		kfree(soc_dev_attr->revision);
> +		kfree(soc_dev_attr);
> +		return -1;

Mixing GENERIC_ERRNO types and fixed values seems odd.
Is -EPERM the correct return here?  Maybe -ENODEV?

> +	}
> +
> +	return 0;
> +}
> +arch_initcall(brcmstb_soc_device_init);

  reply	other threads:[~2016-03-11 18:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-11 18:39 [PATCH v2] bsp: add SoC driver to brcmstb Justin Chen
2016-03-11 18:55 ` Joe Perches [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-03-04 23:00 Justin Chen

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=1457722505.4654.8.camel@perches.com \
    --to=joe@perches.com \
    --cc=arnd@arndb.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=f.fainelli@gmail.com \
    --cc=justin.chen@broadcom.com \
    --cc=justinpopo6@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.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