linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] Framework for exporting System-on-Chip information via sysfs
Date: Fri, 02 Sep 2011 10:37:47 +0100	[thread overview]
Message-ID: <4E60A3EB.4090804@linaro.org> (raw)
In-Reply-To: <20110902092952.GA28500@pulham.picochip.com>

On 02/09/11 10:29, Jamie Iles wrote:
> On Fri, Sep 02, 2011 at 09:44:52AM +0100, Lee Jones wrote:
>> On 02/09/11 00:34, Greg KH wrote:
>>> On Thu, Sep 01, 2011 at 01:27:19PM +0100, Lee Jones wrote:
>>>> +static ssize_t soc_info_get(struct device *dev,
>>>> +			struct device_attribute *attr,
>>>> +			char *buf)
>>>> +{
>>>> +	struct soc_device *soc_dev = container_of(dev, struct soc_device, dev);
>>>> +
>>>> +	if (!strcmp(attr->attr.name, "machine"))
>>>> +		return sprintf(buf, "%s\n", soc_dev->machine);
>>>> +	if (!strcmp(attr->attr.name, "family"))
>>>> +		return sprintf(buf, "%s\n", soc_dev->family);
>>>> +	if (!strcmp(attr->attr.name, "revision"))
>>>> +		return sprintf(buf, "%s\n", soc_dev->revision);
>>>> +	if (!strcmp(attr->attr.name, "soc_id")) {
>>>> +		if (soc_dev->pfn_soc_id)
>>>> +			return sprintf(buf, "%s\n", soc_dev->pfn_soc_id());
>>>> +		else return sprintf(buf, "N/A \n");
>>>
>>> Move this line
>>>
>>>> +	}
>>>> +
>>>> +	return -EINVAL;
>>>
>>> To here?
>>>
>>
>> I initially had invalid requests return a useful message, but I was told
>> to remove it and return -EINVAL instead:
>>
>> "Just return -EINVAL or similar here to propogate the error to the user."
>>
>> Jamie, what say you?
> 
> Well if there isn't an ID for the SoC, then I think it's better for a 
> read() to return an error rather than have to parse for a special string 
> like "N/A ".  So rather than returning that string, perhaps something 
> like:
> 
> 	if (!strcmp(attr->attr.name, "soc_id")) {
> 		if (!soc_dev->pfn_soc_id)
> 			return -ENOENT;
> 		return sprintf(buf, "%s\n", soc_dev->pfn_soc_id());
> 	}
> 
> or if you don't think this is an error, default to an id of "0" so that 
> it can be parsed by tools?

What about at the very end of the function?

What should we return if an inappropriate attr->attr.name is used?

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
M: +44 77 88 633 515
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2011-09-02  9:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01 12:27 [PATCH 1/5] Framework for exporting System-on-Chip information via sysfs Lee Jones
2011-09-01 12:27 ` [PATCH 2/5] Add documentation for new sysfs devices/soc functionality Lee Jones
2011-09-01 12:27 ` [PATCH 3/5] mach-ux500: export System-on-Chip information ux500 via sysfs Lee Jones
2011-09-02 14:31   ` Arnd Bergmann
2011-09-01 12:27 ` [PATCH 4/5] mach-ux500: move top level platform devices in sysfs to /sys/devices/soc/X Lee Jones
2011-09-01 12:27 ` [PATCH 5/5] mach-ux500: add a SoC ID (serial) callback for the u8500 Lee Jones
2011-09-02 14:22   ` Arnd Bergmann
2011-09-02 15:16     ` Lee Jones
2011-09-02 15:56       ` Arnd Bergmann
2011-09-01 23:34 ` [PATCH 1/5] Framework for exporting System-on-Chip information via sysfs Greg KH
2011-09-02  8:44   ` Lee Jones
2011-09-02  9:29     ` Jamie Iles
2011-09-02  9:37       ` Lee Jones [this message]
2011-09-02  9:56         ` Jamie Iles
2011-09-02 16:31     ` Greg KH
2011-09-02 17:22       ` Arnd Bergmann
2011-09-02 18:14         ` Greg KH
2011-09-06  9:41       ` Lee Jones
2011-09-06 19:33         ` Arnd Bergmann
2011-09-06 19:45         ` Greg KH
2011-09-07  6:14           ` Lee Jones
2011-09-02 14:02   ` Arnd Bergmann
2011-09-02 16:24     ` Greg KH
2011-09-02 17:32       ` 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=4E60A3EB.4090804@linaro.org \
    --to=lee.jones@linaro.org \
    --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).