linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Is get_property() correct?
@ 2006-10-28  6:41 Grant Likely
  2006-10-28  6:53 ` Michael Ellerman
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Grant Likely @ 2006-10-28  6:41 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, linuxppc-dev@ozlabs.org

Is the implementation of get_property correct?  The comment says it
returns the value of a property; but the return statement just returns
the property pointer (cast as void*) it got from of_find_property();
not the value.

Does the comment or the code need to change?

in prom.c:

/*
 * Find a property with a given name for a given node
 * and return the value.
 */
const void *get_property(const struct device_node *np, const char *name,
                         int *lenp)
{
        struct property *pp = of_find_property(np,name,lenp);
        return pp ? pp->value : NULL;
}
EXPORT_SYMBOL(get_property);

Cheers,
g.

-- 
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is get_property() correct?
  2006-10-28  6:41 Is get_property() correct? Grant Likely
@ 2006-10-28  6:53 ` Michael Ellerman
  2006-10-28  7:17 ` Johannes Berg
  2006-10-28  7:23 ` Benjamin Herrenschmidt
  2 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2006-10-28  6:53 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev@ozlabs.org

[-- Attachment #1: Type: text/plain, Size: 941 bytes --]

On Sat, 2006-10-28 at 00:41 -0600, Grant Likely wrote:
> Is the implementation of get_property correct?  The comment says it
> returns the value of a property; but the return statement just returns
> the property pointer (cast as void*) it got from of_find_property();
> not the value.

Minor correction, it returns the property->value pointer as a void *.

> Does the comment or the code need to change?

I don't think so. get_property() can't return the actual value because
it doesn't know what type it is, so it returns a void pointer to the
value and it's up to the caller to interpret it based on the callers
knowledge of what it's expecting, and/or the lenp.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 191 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is get_property() correct?
  2006-10-28  6:41 Is get_property() correct? Grant Likely
  2006-10-28  6:53 ` Michael Ellerman
@ 2006-10-28  7:17 ` Johannes Berg
  2006-10-28  7:23   ` Grant Likely
  2006-10-28  7:23 ` Benjamin Herrenschmidt
  2 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2006-10-28  7:17 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev@ozlabs.org

[-- Attachment #1: Type: text/plain, Size: 216 bytes --]


> The comment says it
> returns the value of a property

>  * and return the value.

>         return pp ? pp->value : NULL;

...? Looks like the value to me, unless the property doesn't exist.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is get_property() correct?
  2006-10-28  7:17 ` Johannes Berg
@ 2006-10-28  7:23   ` Grant Likely
  0 siblings, 0 replies; 8+ messages in thread
From: Grant Likely @ 2006-10-28  7:23 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linuxppc-dev@ozlabs.org

Bah!  Wack me with the cluestick.  I've got temporary dyslexia tonight.

Sorry.

On 10/28/06, Johannes Berg <johannes@sipsolutions.net> wrote:
>
> > The comment says it
> > returns the value of a property
>
> >  * and return the value.
>
> >         return pp ? pp->value : NULL;
>
> ...? Looks like the value to me, unless the property doesn't exist.
>
> johannes
>
>
>


-- 
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is get_property() correct?
  2006-10-28  6:41 Is get_property() correct? Grant Likely
  2006-10-28  6:53 ` Michael Ellerman
  2006-10-28  7:17 ` Johannes Berg
@ 2006-10-28  7:23 ` Benjamin Herrenschmidt
  2006-10-28  7:38   ` Grant Likely
  2 siblings, 1 reply; 8+ messages in thread
From: Benjamin Herrenschmidt @ 2006-10-28  7:23 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev@ozlabs.org

On Sat, 2006-10-28 at 00:41 -0600, Grant Likely wrote:
> Is the implementation of get_property correct?  The comment says it
> returns the value of a property; but the return statement just returns
> the property pointer (cast as void*) it got from of_find_property();
> not the value.
> 
> Does the comment or the code need to change?

Well considering that we don't know the type of the property value, the
best we can do is return a pointer to it ... 

The comment might want an update, though it never stroke me as confusing
but heh :)

> in prom.c:
> 
> /*
>  * Find a property with a given name for a given node
>  * and return the value.
>  */
> const void *get_property(const struct device_node *np, const char *name,
>                          int *lenp)
> {
>         struct property *pp = of_find_property(np,name,lenp);
>         return pp ? pp->value : NULL;
> }
> EXPORT_SYMBOL(get_property);
> 
> Cheers,
> g.
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is get_property() correct?
  2006-10-28  7:23 ` Benjamin Herrenschmidt
@ 2006-10-28  7:38   ` Grant Likely
  2006-10-28  9:08     ` Michael Ellerman
  0 siblings, 1 reply; 8+ messages in thread
From: Grant Likely @ 2006-10-28  7:38 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev@ozlabs.org

On 10/28/06, Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> On Sat, 2006-10-28 at 00:41 -0600, Grant Likely wrote:
>
> Well considering that we don't know the type of the property value, the
> best we can do is return a pointer to it ...
>
> The comment might want an update, though it never stroke me as confusing
> but heh :)

No, it's not confusing.  Both the comment and the code are correct.  I
just forgot how to read code.  :(

g.

-- 
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Is get_property() correct?
  2006-10-28  7:38   ` Grant Likely
@ 2006-10-28  9:08     ` Michael Ellerman
  2006-10-30  2:05       ` unsubscribe Usha Rani Konudula
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Ellerman @ 2006-10-28  9:08 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev@ozlabs.org

[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

On Sat, 2006-10-28 at 01:38 -0600, Grant Likely wrote:
> On 10/28/06, Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> > On Sat, 2006-10-28 at 00:41 -0600, Grant Likely wrote:
> >
> > Well considering that we don't know the type of the property value, the
> > best we can do is return a pointer to it ...
> >
> > The comment might want an update, though it never stroke me as confusing
> > but heh :)
> 
> No, it's not confusing.  Both the comment and the code are correct.  I
> just forgot how to read code.  :(

But at least now we're all _sure_ they're correct, some good still
done :)

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 191 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* unsubscribe
  2006-10-28  9:08     ` Michael Ellerman
@ 2006-10-30  2:05       ` Usha Rani Konudula
  0 siblings, 0 replies; 8+ messages in thread
From: Usha Rani Konudula @ 2006-10-30  2:05 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: linuxppc-dev

unsubscribe

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-10-30  2:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-28  6:41 Is get_property() correct? Grant Likely
2006-10-28  6:53 ` Michael Ellerman
2006-10-28  7:17 ` Johannes Berg
2006-10-28  7:23   ` Grant Likely
2006-10-28  7:23 ` Benjamin Herrenschmidt
2006-10-28  7:38   ` Grant Likely
2006-10-28  9:08     ` Michael Ellerman
2006-10-30  2:05       ` unsubscribe Usha Rani Konudula

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).