public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Petr Cvek" <petr.cvek@tul.cz>
To: "Grant Likely" <grant.likely@secretlab.ca>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH][TRIVIAL] System ACE fails in look for root devices
Date: Mon, 17 Oct 2011 16:49:24 +0200	[thread overview]
Message-ID: <op.v3h3gmqu4x40tt@localhost> (raw)
In-Reply-To: <20111013172958.GD18574@ponder.secretlab.ca>

Sorry for delay. I had lot of work.

> However, of_property_read_u32() can only accept a u32 value, not an
> int, so this needs to be solved with two variables to be correct:
>
> 	int id;
> 	u32 tmp;
> 	id = dev->id;
> 	if (of_property_read_u32(dev->dev.of_node, "port-number", &tmp)
> 		id = tmp;
> 	if (id < 0)
> 		id = 0;
>

I think of_property_read_u32() returns nonzero, when not found (-ENODATA),  
therefore:

	if (! of_property_read_u32(dev->dev.of_node, "port-number", &tmp))

> It's not as pretty, but it is a limitation of how of_property_read_u32
> has to be implemented.  I hope to find a better way to do it that
> doesn't have the u32 restriction on the return value.

I hope, nobody will use port-number bigger than max(int) :-D. Oh and I  
would improve code to something like this:

	int id;
	u32 tmp;
	if (! of_property_read_u32(dev->dev.of_node, "port-number", &tmp))  
{	/*when return 0, use tmp val*/
	  id = tmp;			/*always >0 */
	} else {			/* when error, use dev->id and test >0 */
	  id = dev->id;
	  if (id < 0)
	    id = 0;
	}

Petr

      reply	other threads:[~2011-10-17 14:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-13 11:02 [RFC][PATCH][TRIVIAL] System ACE fails in look for root devices Petr Cvek
2011-10-13 17:29 ` Grant Likely
2011-10-17 14:49   ` Petr Cvek [this message]

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=op.v3h3gmqu4x40tt@localhost \
    --to=petr.cvek@tul.cz \
    --cc=grant.likely@secretlab.ca \
    --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