From: Grant Likely <grant.likely@secretlab.ca>
To: Andres Salomon <dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
Cc: sparclinux-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
Daniel Drake <dsd-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] of/pdt: allow DT device matching by fixing 'name'
Date: Wed, 23 Feb 2011 23:28:15 +0000 [thread overview]
Message-ID: <20110223232815.GC5404@angua.secretlab.ca> (raw)
In-Reply-To: <20110223150357.5a40793d-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
On Wed, Feb 23, 2011 at 03:03:57PM -0800, Andres Salomon wrote:
>
> Commit e2f2a93b changed dp->name from using the 'name' property to
> using package-to-path. This fixed /proc/device-tree creation by
> eliminating conflicts between names (the 'name' property provides
> names like 'battery', whereas package-to-path provides names like
> '/foo/bar/battery@0', which we stripped to 'battery@0'). However,
> it also breaks of_device_id table matching.
>
> The fix that we _really_ wanted was to keep dp->name based upon
> the name property ('battery'), but based dp->full_name upon
> package-to-path ('battery@0'). This patch does just that.
>
> This also changes OLPC behavior to use the full result from
> package-to-path for full_name, rather than stripping the directory
> out. In practice, the strings end up being exactly the same; this
> change saves time, code, and memory.
>
> Note that this affects sparc by reverting dp->name back to what
> sparc was originally doing (looking at the name property).
>
> v2: combine two patches and revert of_pdt_node_name to original version.
>
> Signed-off-by: Andres Salomon <dilinger@queued.net>
Hi Andres, comments below.
g.
> ---
> drivers/of/pdt.c | 42 +++++++++++++++---------------------------
> 1 files changed, 15 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c
> index 28295d0..a7aa85e 100644
> --- a/drivers/of/pdt.c
> +++ b/drivers/of/pdt.c
> @@ -134,7 +134,7 @@ static char * __init of_pdt_get_one_property(phandle node, const char *name)
>
> static char * __init of_pdt_try_pkg2path(phandle node)
> {
> - char *res, *buf = NULL;
> + char *buf = NULL;
> int len;
>
> if (!of_pdt_prom_ops->pkg2path)
> @@ -147,29 +147,6 @@ static char * __init of_pdt_try_pkg2path(phandle node)
> pr_err("%s: package-to-path failed\n", __func__);
> return NULL;
> }
> -
> - res = strrchr(buf, '/');
> - if (!res) {
> - pr_err("%s: couldn't find / in %s\n", __func__, buf);
> - return NULL;
> - }
> - return res+1;
> -}
> -
> -/*
> - * When fetching the node's name, first try using package-to-path; if
> - * that fails (either because the arch hasn't supplied a PROM callback,
> - * or some other random failure), fall back to just looking at the node's
> - * 'name' property.
> - */
> -static char * __init of_pdt_build_name(phandle node)
> -{
> - char *buf;
> -
> - buf = of_pdt_try_pkg2path(node);
> - if (!buf)
> - buf = of_pdt_get_one_property(node, "name");
> -
> return buf;
> }
>
It seems to me that of_pdt_build_full_name will still be missing the
'@<addr>' component on non-sparc non-olpc builds because it uses the
broken of_pdt_node_name(). That needs to be fixed too, even if there
are no current users (or removed).
> @@ -187,7 +164,7 @@ static struct device_node * __init of_pdt_create_node(phandle node,
>
> kref_init(&dp->kref);
>
> - dp->name = of_pdt_build_name(node);
> + dp->name = of_pdt_get_one_property(node, "name");
> dp->type = of_pdt_get_one_property(node, "device_type");
> dp->phandle = node;
>
> @@ -198,11 +175,22 @@ static struct device_node * __init of_pdt_create_node(phandle node,
> return dp;
> }
>
> -static char * __init of_pdt_build_full_name(struct device_node *dp)
> +static char * __init of_pdt_build_full_name(struct device_node *dp,
> + phandle node)
Is dp->phandle not suitable here?
> {
> int len, ourlen, plen;
> char *n;
>
> + /*
> + * When fetching the full name we want the name we see with
> + * package-to-path (ie, '/foo/bar/battery@0') rather than what
> + * we see with the name property (ie, 'battery').
> + */
> + n = of_pdt_try_pkg2path(node);
> + if (n)
> + return n;
> +
> + /* Older method for determining full name */
> plen = strlen(dp->parent->full_name);
> ourlen = strlen(of_pdt_node_name(dp));
> len = ourlen + plen + 2;
> @@ -243,7 +231,7 @@ static struct device_node * __init of_pdt_build_tree(struct device_node *parent,
> #if defined(CONFIG_SPARC)
> dp->path_component_name = build_path_component(dp);
> #endif
I still think it would be useful to remove the #if
defined(CONFIG_SPARC) from path_component_name, and it might be the
best way to solve my comment about broken of_pdt_node_name above.
> - dp->full_name = of_pdt_build_full_name(dp);
> + dp->full_name = of_pdt_build_full_name(dp, node);
>
> dp->child = of_pdt_build_tree(dp,
> of_pdt_prom_ops->getchild(node), nextp);
> --
> 1.7.2.3
>
WARNING: multiple messages have this Message-ID (diff)
From: Grant Likely <grant.likely@secretlab.ca>
To: Andres Salomon <dilinger@queued.net>
Cc: Daniel Drake <dsd@laptop.org>,
linux-kernel@vger.kernel.org,
devicetree-discuss@lists.ozlabs.org,
"David S. Miller" <davem@davemloft.net>,
sparclinux@vger.kernel.org
Subject: Re: [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v2)
Date: Wed, 23 Feb 2011 16:28:15 -0700 [thread overview]
Message-ID: <20110223232815.GC5404@angua.secretlab.ca> (raw)
In-Reply-To: <20110223150357.5a40793d@queued.net>
On Wed, Feb 23, 2011 at 03:03:57PM -0800, Andres Salomon wrote:
>
> Commit e2f2a93b changed dp->name from using the 'name' property to
> using package-to-path. This fixed /proc/device-tree creation by
> eliminating conflicts between names (the 'name' property provides
> names like 'battery', whereas package-to-path provides names like
> '/foo/bar/battery@0', which we stripped to 'battery@0'). However,
> it also breaks of_device_id table matching.
>
> The fix that we _really_ wanted was to keep dp->name based upon
> the name property ('battery'), but based dp->full_name upon
> package-to-path ('battery@0'). This patch does just that.
>
> This also changes OLPC behavior to use the full result from
> package-to-path for full_name, rather than stripping the directory
> out. In practice, the strings end up being exactly the same; this
> change saves time, code, and memory.
>
> Note that this affects sparc by reverting dp->name back to what
> sparc was originally doing (looking at the name property).
>
> v2: combine two patches and revert of_pdt_node_name to original version.
>
> Signed-off-by: Andres Salomon <dilinger@queued.net>
Hi Andres, comments below.
g.
> ---
> drivers/of/pdt.c | 42 +++++++++++++++---------------------------
> 1 files changed, 15 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c
> index 28295d0..a7aa85e 100644
> --- a/drivers/of/pdt.c
> +++ b/drivers/of/pdt.c
> @@ -134,7 +134,7 @@ static char * __init of_pdt_get_one_property(phandle node, const char *name)
>
> static char * __init of_pdt_try_pkg2path(phandle node)
> {
> - char *res, *buf = NULL;
> + char *buf = NULL;
> int len;
>
> if (!of_pdt_prom_ops->pkg2path)
> @@ -147,29 +147,6 @@ static char * __init of_pdt_try_pkg2path(phandle node)
> pr_err("%s: package-to-path failed\n", __func__);
> return NULL;
> }
> -
> - res = strrchr(buf, '/');
> - if (!res) {
> - pr_err("%s: couldn't find / in %s\n", __func__, buf);
> - return NULL;
> - }
> - return res+1;
> -}
> -
> -/*
> - * When fetching the node's name, first try using package-to-path; if
> - * that fails (either because the arch hasn't supplied a PROM callback,
> - * or some other random failure), fall back to just looking at the node's
> - * 'name' property.
> - */
> -static char * __init of_pdt_build_name(phandle node)
> -{
> - char *buf;
> -
> - buf = of_pdt_try_pkg2path(node);
> - if (!buf)
> - buf = of_pdt_get_one_property(node, "name");
> -
> return buf;
> }
>
It seems to me that of_pdt_build_full_name will still be missing the
'@<addr>' component on non-sparc non-olpc builds because it uses the
broken of_pdt_node_name(). That needs to be fixed too, even if there
are no current users (or removed).
> @@ -187,7 +164,7 @@ static struct device_node * __init of_pdt_create_node(phandle node,
>
> kref_init(&dp->kref);
>
> - dp->name = of_pdt_build_name(node);
> + dp->name = of_pdt_get_one_property(node, "name");
> dp->type = of_pdt_get_one_property(node, "device_type");
> dp->phandle = node;
>
> @@ -198,11 +175,22 @@ static struct device_node * __init of_pdt_create_node(phandle node,
> return dp;
> }
>
> -static char * __init of_pdt_build_full_name(struct device_node *dp)
> +static char * __init of_pdt_build_full_name(struct device_node *dp,
> + phandle node)
Is dp->phandle not suitable here?
> {
> int len, ourlen, plen;
> char *n;
>
> + /*
> + * When fetching the full name we want the name we see with
> + * package-to-path (ie, '/foo/bar/battery@0') rather than what
> + * we see with the name property (ie, 'battery').
> + */
> + n = of_pdt_try_pkg2path(node);
> + if (n)
> + return n;
> +
> + /* Older method for determining full name */
> plen = strlen(dp->parent->full_name);
> ourlen = strlen(of_pdt_node_name(dp));
> len = ourlen + plen + 2;
> @@ -243,7 +231,7 @@ static struct device_node * __init of_pdt_build_tree(struct device_node *parent,
> #if defined(CONFIG_SPARC)
> dp->path_component_name = build_path_component(dp);
> #endif
I still think it would be useful to remove the #if
defined(CONFIG_SPARC) from path_component_name, and it might be the
best way to solve my comment about broken of_pdt_node_name above.
> - dp->full_name = of_pdt_build_full_name(dp);
> + dp->full_name = of_pdt_build_full_name(dp, node);
>
> dp->child = of_pdt_build_tree(dp,
> of_pdt_prom_ops->getchild(node), nextp);
> --
> 1.7.2.3
>
WARNING: multiple messages have this Message-ID (diff)
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Andres Salomon <dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
Cc: sparclinux-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
Daniel Drake <dsd-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v2)
Date: Wed, 23 Feb 2011 16:28:15 -0700 [thread overview]
Message-ID: <20110223232815.GC5404@angua.secretlab.ca> (raw)
In-Reply-To: <20110223150357.5a40793d-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
On Wed, Feb 23, 2011 at 03:03:57PM -0800, Andres Salomon wrote:
>
> Commit e2f2a93b changed dp->name from using the 'name' property to
> using package-to-path. This fixed /proc/device-tree creation by
> eliminating conflicts between names (the 'name' property provides
> names like 'battery', whereas package-to-path provides names like
> '/foo/bar/battery@0', which we stripped to 'battery@0'). However,
> it also breaks of_device_id table matching.
>
> The fix that we _really_ wanted was to keep dp->name based upon
> the name property ('battery'), but based dp->full_name upon
> package-to-path ('battery@0'). This patch does just that.
>
> This also changes OLPC behavior to use the full result from
> package-to-path for full_name, rather than stripping the directory
> out. In practice, the strings end up being exactly the same; this
> change saves time, code, and memory.
>
> Note that this affects sparc by reverting dp->name back to what
> sparc was originally doing (looking at the name property).
>
> v2: combine two patches and revert of_pdt_node_name to original version.
>
> Signed-off-by: Andres Salomon <dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
Hi Andres, comments below.
g.
> ---
> drivers/of/pdt.c | 42 +++++++++++++++---------------------------
> 1 files changed, 15 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/of/pdt.c b/drivers/of/pdt.c
> index 28295d0..a7aa85e 100644
> --- a/drivers/of/pdt.c
> +++ b/drivers/of/pdt.c
> @@ -134,7 +134,7 @@ static char * __init of_pdt_get_one_property(phandle node, const char *name)
>
> static char * __init of_pdt_try_pkg2path(phandle node)
> {
> - char *res, *buf = NULL;
> + char *buf = NULL;
> int len;
>
> if (!of_pdt_prom_ops->pkg2path)
> @@ -147,29 +147,6 @@ static char * __init of_pdt_try_pkg2path(phandle node)
> pr_err("%s: package-to-path failed\n", __func__);
> return NULL;
> }
> -
> - res = strrchr(buf, '/');
> - if (!res) {
> - pr_err("%s: couldn't find / in %s\n", __func__, buf);
> - return NULL;
> - }
> - return res+1;
> -}
> -
> -/*
> - * When fetching the node's name, first try using package-to-path; if
> - * that fails (either because the arch hasn't supplied a PROM callback,
> - * or some other random failure), fall back to just looking at the node's
> - * 'name' property.
> - */
> -static char * __init of_pdt_build_name(phandle node)
> -{
> - char *buf;
> -
> - buf = of_pdt_try_pkg2path(node);
> - if (!buf)
> - buf = of_pdt_get_one_property(node, "name");
> -
> return buf;
> }
>
It seems to me that of_pdt_build_full_name will still be missing the
'@<addr>' component on non-sparc non-olpc builds because it uses the
broken of_pdt_node_name(). That needs to be fixed too, even if there
are no current users (or removed).
> @@ -187,7 +164,7 @@ static struct device_node * __init of_pdt_create_node(phandle node,
>
> kref_init(&dp->kref);
>
> - dp->name = of_pdt_build_name(node);
> + dp->name = of_pdt_get_one_property(node, "name");
> dp->type = of_pdt_get_one_property(node, "device_type");
> dp->phandle = node;
>
> @@ -198,11 +175,22 @@ static struct device_node * __init of_pdt_create_node(phandle node,
> return dp;
> }
>
> -static char * __init of_pdt_build_full_name(struct device_node *dp)
> +static char * __init of_pdt_build_full_name(struct device_node *dp,
> + phandle node)
Is dp->phandle not suitable here?
> {
> int len, ourlen, plen;
> char *n;
>
> + /*
> + * When fetching the full name we want the name we see with
> + * package-to-path (ie, '/foo/bar/battery@0') rather than what
> + * we see with the name property (ie, 'battery').
> + */
> + n = of_pdt_try_pkg2path(node);
> + if (n)
> + return n;
> +
> + /* Older method for determining full name */
> plen = strlen(dp->parent->full_name);
> ourlen = strlen(of_pdt_node_name(dp));
> len = ourlen + plen + 2;
> @@ -243,7 +231,7 @@ static struct device_node * __init of_pdt_build_tree(struct device_node *parent,
> #if defined(CONFIG_SPARC)
> dp->path_component_name = build_path_component(dp);
> #endif
I still think it would be useful to remove the #if
defined(CONFIG_SPARC) from path_component_name, and it might be the
best way to solve my comment about broken of_pdt_node_name above.
> - dp->full_name = of_pdt_build_full_name(dp);
> + dp->full_name = of_pdt_build_full_name(dp, node);
>
> dp->child = of_pdt_build_tree(dp,
> of_pdt_prom_ops->getchild(node), nextp);
> --
> 1.7.2.3
>
next prev parent reply other threads:[~2011-02-23 23:28 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-16 22:28 [PATCH v3] olpc_battery: convert to platform device Daniel Drake
2011-02-16 22:34 ` Dmitry Torokhov
2011-02-16 22:44 ` David Woodhouse
2011-02-16 23:39 ` H. Peter Anvin
2011-02-18 23:42 ` Daniel Drake
2011-02-19 3:06 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Andres Salomon
2011-02-19 3:06 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness Andres Salomon
2011-02-19 3:06 ` Andres Salomon
2011-02-19 3:12 ` [PATCH] of/pdt: don't bother parsing pkg2path results, return as-is Andres Salomon
2011-02-19 3:12 ` Andres Salomon
2011-02-19 3:12 ` Andres Salomon
2011-02-23 19:45 ` [PATCH] of/pdt: don't bother parsing pkg2path results, return Grant Likely
2011-02-23 19:45 ` [PATCH] of/pdt: don't bother parsing pkg2path results, return as-is Grant Likely
2011-02-23 19:45 ` Grant Likely
2011-02-23 19:43 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Grant Likely
2011-02-23 19:43 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness Grant Likely
2011-02-23 19:43 ` Grant Likely
2011-02-23 19:54 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Andres Salomon
2011-02-23 19:54 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness Andres Salomon
2011-02-23 19:54 ` Andres Salomon
2011-02-23 20:06 ` Daniel Drake
2011-02-23 20:06 ` Daniel Drake
[not found] ` <AANLkTi=D1eWGsN4JVWEGeHp3AXfpbOOKr9Fq7juGAXtT-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-23 20:37 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Grant Likely
2011-02-23 20:37 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness Grant Likely
2011-02-23 20:37 ` Grant Likely
2011-02-23 20:35 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Grant Likely
2011-02-23 20:35 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness Grant Likely
2011-02-23 23:03 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Andres Salomon
2011-02-23 23:03 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v2) Andres Salomon
[not found] ` <20110223150357.5a40793d-pFFUokh25LWsTnJN9+BGXg@public.gmane.org>
2011-02-23 23:28 ` Grant Likely [this message]
2011-02-23 23:28 ` Grant Likely
2011-02-23 23:28 ` Grant Likely
2011-02-24 0:16 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Andres Salomon
2011-02-24 0:16 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v2) Andres Salomon
2011-02-24 4:06 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Grant Likely
2011-02-24 4:06 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v2) Grant Likely
[not found] ` <20110224040638.GB22111-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-02-24 4:36 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Andres Salomon
2011-02-24 4:36 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v2) Andres Salomon
2011-02-24 4:36 ` Andres Salomon
2011-02-24 5:38 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Grant Likely
2011-02-24 5:38 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v2) Grant Likely
2011-02-24 6:38 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Andres Salomon
2011-02-24 6:38 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v4) Andres Salomon
2011-02-24 0:34 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Andres Salomon
2011-02-24 0:34 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v3) Andres Salomon
2011-02-24 2:47 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Grant Likely
2011-02-24 2:47 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v3) Grant Likely
2011-02-24 2:51 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Andres Salomon
2011-02-24 2:51 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v3) Andres Salomon
2011-02-24 3:25 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' Grant Likely
2011-02-24 3:25 ` [PATCH] of/pdt: allow DT device matching by fixing 'name' brokenness (v3) Grant Likely
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=20110223232815.GC5404@angua.secretlab.ca \
--to=grant.likely@secretlab.ca \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=dilinger-pFFUokh25LWsTnJN9+BGXg@public.gmane.org \
--cc=dsd-2X9k7bc8m7Mdnm+yROfE0A@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sparclinux-u79uwXL29TY76Z2rM5mHXA@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.