From: Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <rob.herring@calxeda.com>,
devicetree-discuss@lists.ozlabs.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org,
Bryan Huntsman <bryanh@codeaurora.org>,
Daniel Walker <dwalker@fifo99.com>,
David Brown <davidb@codeaurora.org>,
mbohan@codeaurora.org,
Stepan Moskovchenko <stepanm@codeaurora.org>
Subject: Re: [PATCH] of: Output devicetree alias names in uevent
Date: Wed, 05 Dec 2012 23:03:17 +0000 [thread overview]
Message-ID: <20121205230318.013053E0E22@localhost> (raw)
In-Reply-To: <1354674637-6448-1-git-send-email-stepanm@codeaurora.org>
On Tue, 4 Dec 2012 18:30:37 -0800, Stepan Moskovchenko <stepanm@codeaurora.org> wrote:
> In some situations, userspace may want to resolve a
> device by function and logical number (ie, "serial0")
> rather than by the base address or full device path. Being
> able to resolve a device by alias frees userspace from the
> burden of otherwise having to maintain a mapping between
> device addresses and their logical assignments on each
> platform when multiple instances of the same hardware block
> are present in the system.
>
> Although the uevent device attribute contains devicetree
> compatible information and the full device path, the uevent
> does not list the alises that may have been defined for the
> device.
>
> Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
> ---
> I have followed the OF_COMPATIBLE convention for adding the
> uevent variables for the alias names, but I can follow some
> other convention if people feel something else is more
> appropriate.
No, this seems fine. Comments below.
> drivers/of/base.c | 25 +++++++++++++++++++++++++
> drivers/of/device.c | 1 +
> include/linux/of_device.h | 2 ++
> 3 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 5806449..291f0a0 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -19,6 +19,7 @@
> */
> #include <linux/ctype.h>
> #include <linux/module.h>
> +#include <linux/device.h>
> #include <linux/of.h>
> #include <linux/spinlock.h>
> #include <linux/slab.h>
> @@ -1177,6 +1178,30 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np,
> }
>
> /**
> + * of_device_uevent_aliases - Display OF alises in uevent
> + */
> +void of_device_uevent_aliases(struct device_node *node,
> + struct kobj_uevent_env *env)
> +{
> + struct alias_prop *app;
> + int seen = 0;
> +
> + mutex_lock(&of_aliases_mutex);
> + list_for_each_entry(app, &aliases_lookup, link) {
> + if (node == app->np) {
> + add_uevent_var(env, "OF_ALIAS_%d=%s%d", seen, app->stem,
> + app->id);
add_uevent_var(env, "OF_ALIAS_%d=%s", seen, app->alias);
> + seen++;
> + }
> + }
> +
> + if (seen)
> + add_uevent_var(env, "OF_ALIAS_N=%d", seen);
> +
> + mutex_unlock(&of_aliases_mutex);
> +}
Why is this implemented as a separate function? Do you forsee it being
called by something else? If not, then just roll it into the body of
of_device_uevent_aliases() please.
Oh, wait, alias_prop is only defined in drivers/of/base.c. Rats. Can you
create a header named drivers/of/of_private.h to move it into please? I
don't want the uevent stuff to appear in drivers/of/base.c.
> +
> +/**
> * of_alias_scan - Scan all properties of 'aliases' node
> *
> * The function scans all the properties of 'aliases' node and populate
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index 4c74e4f..06e122d 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -153,6 +153,7 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
> seen++;
> }
> add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen);
> + of_device_uevent_aliases(dev->of_node, env);
> }
>
> int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index 901b743..748056d 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -36,6 +36,8 @@ extern ssize_t of_device_get_modalias(struct device *dev,
> char *str, ssize_t len);
>
> extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
> +extern void of_device_uevent_aliases(struct device_node *node,
> + struct kobj_uevent_env *env);
> extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env);
>
> static inline void of_device_node_put(struct device *dev)
> --
> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
>
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
WARNING: multiple messages have this Message-ID (diff)
From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] of: Output devicetree alias names in uevent
Date: Wed, 05 Dec 2012 23:03:17 +0000 [thread overview]
Message-ID: <20121205230318.013053E0E22@localhost> (raw)
In-Reply-To: <1354674637-6448-1-git-send-email-stepanm@codeaurora.org>
On Tue, 4 Dec 2012 18:30:37 -0800, Stepan Moskovchenko <stepanm@codeaurora.org> wrote:
> In some situations, userspace may want to resolve a
> device by function and logical number (ie, "serial0")
> rather than by the base address or full device path. Being
> able to resolve a device by alias frees userspace from the
> burden of otherwise having to maintain a mapping between
> device addresses and their logical assignments on each
> platform when multiple instances of the same hardware block
> are present in the system.
>
> Although the uevent device attribute contains devicetree
> compatible information and the full device path, the uevent
> does not list the alises that may have been defined for the
> device.
>
> Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
> ---
> I have followed the OF_COMPATIBLE convention for adding the
> uevent variables for the alias names, but I can follow some
> other convention if people feel something else is more
> appropriate.
No, this seems fine. Comments below.
> drivers/of/base.c | 25 +++++++++++++++++++++++++
> drivers/of/device.c | 1 +
> include/linux/of_device.h | 2 ++
> 3 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 5806449..291f0a0 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -19,6 +19,7 @@
> */
> #include <linux/ctype.h>
> #include <linux/module.h>
> +#include <linux/device.h>
> #include <linux/of.h>
> #include <linux/spinlock.h>
> #include <linux/slab.h>
> @@ -1177,6 +1178,30 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np,
> }
>
> /**
> + * of_device_uevent_aliases - Display OF alises in uevent
> + */
> +void of_device_uevent_aliases(struct device_node *node,
> + struct kobj_uevent_env *env)
> +{
> + struct alias_prop *app;
> + int seen = 0;
> +
> + mutex_lock(&of_aliases_mutex);
> + list_for_each_entry(app, &aliases_lookup, link) {
> + if (node == app->np) {
> + add_uevent_var(env, "OF_ALIAS_%d=%s%d", seen, app->stem,
> + app->id);
add_uevent_var(env, "OF_ALIAS_%d=%s", seen, app->alias);
> + seen++;
> + }
> + }
> +
> + if (seen)
> + add_uevent_var(env, "OF_ALIAS_N=%d", seen);
> +
> + mutex_unlock(&of_aliases_mutex);
> +}
Why is this implemented as a separate function? Do you forsee it being
called by something else? If not, then just roll it into the body of
of_device_uevent_aliases() please.
Oh, wait, alias_prop is only defined in drivers/of/base.c. Rats. Can you
create a header named drivers/of/of_private.h to move it into please? I
don't want the uevent stuff to appear in drivers/of/base.c.
> +
> +/**
> * of_alias_scan - Scan all properties of 'aliases' node
> *
> * The function scans all the properties of 'aliases' node and populate
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index 4c74e4f..06e122d 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -153,6 +153,7 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
> seen++;
> }
> add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen);
> + of_device_uevent_aliases(dev->of_node, env);
> }
>
> int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index 901b743..748056d 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -36,6 +36,8 @@ extern ssize_t of_device_get_modalias(struct device *dev,
> char *str, ssize_t len);
>
> extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
> +extern void of_device_uevent_aliases(struct device_node *node,
> + struct kobj_uevent_env *env);
> extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env);
>
> static inline void of_device_node_put(struct device *dev)
> --
> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
>
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
WARNING: multiple messages have this Message-ID (diff)
From: Grant Likely <grant.likely@secretlab.ca>
To: Stepan Moskovchenko <stepanm@codeaurora.org>
Cc: Rob Herring <rob.herring@calxeda.com>,
devicetree-discuss@lists.ozlabs.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-arm-msm@vger.kernel.org,
Bryan Huntsman <bryanh@codeaurora.org>,
Daniel Walker <dwalker@fifo99.com>,
David Brown <davidb@codeaurora.org>,
mbohan@codeaurora.org,
Stepan Moskovchenko <stepanm@codeaurora.org>
Subject: Re: [PATCH] of: Output devicetree alias names in uevent
Date: Wed, 05 Dec 2012 23:03:17 +0000 [thread overview]
Message-ID: <20121205230318.013053E0E22@localhost> (raw)
In-Reply-To: <1354674637-6448-1-git-send-email-stepanm@codeaurora.org>
On Tue, 4 Dec 2012 18:30:37 -0800, Stepan Moskovchenko <stepanm@codeaurora.org> wrote:
> In some situations, userspace may want to resolve a
> device by function and logical number (ie, "serial0")
> rather than by the base address or full device path. Being
> able to resolve a device by alias frees userspace from the
> burden of otherwise having to maintain a mapping between
> device addresses and their logical assignments on each
> platform when multiple instances of the same hardware block
> are present in the system.
>
> Although the uevent device attribute contains devicetree
> compatible information and the full device path, the uevent
> does not list the alises that may have been defined for the
> device.
>
> Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
> ---
> I have followed the OF_COMPATIBLE convention for adding the
> uevent variables for the alias names, but I can follow some
> other convention if people feel something else is more
> appropriate.
No, this seems fine. Comments below.
> drivers/of/base.c | 25 +++++++++++++++++++++++++
> drivers/of/device.c | 1 +
> include/linux/of_device.h | 2 ++
> 3 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 5806449..291f0a0 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -19,6 +19,7 @@
> */
> #include <linux/ctype.h>
> #include <linux/module.h>
> +#include <linux/device.h>
> #include <linux/of.h>
> #include <linux/spinlock.h>
> #include <linux/slab.h>
> @@ -1177,6 +1178,30 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np,
> }
>
> /**
> + * of_device_uevent_aliases - Display OF alises in uevent
> + */
> +void of_device_uevent_aliases(struct device_node *node,
> + struct kobj_uevent_env *env)
> +{
> + struct alias_prop *app;
> + int seen = 0;
> +
> + mutex_lock(&of_aliases_mutex);
> + list_for_each_entry(app, &aliases_lookup, link) {
> + if (node == app->np) {
> + add_uevent_var(env, "OF_ALIAS_%d=%s%d", seen, app->stem,
> + app->id);
add_uevent_var(env, "OF_ALIAS_%d=%s", seen, app->alias);
> + seen++;
> + }
> + }
> +
> + if (seen)
> + add_uevent_var(env, "OF_ALIAS_N=%d", seen);
> +
> + mutex_unlock(&of_aliases_mutex);
> +}
Why is this implemented as a separate function? Do you forsee it being
called by something else? If not, then just roll it into the body of
of_device_uevent_aliases() please.
Oh, wait, alias_prop is only defined in drivers/of/base.c. Rats. Can you
create a header named drivers/of/of_private.h to move it into please? I
don't want the uevent stuff to appear in drivers/of/base.c.
> +
> +/**
> * of_alias_scan - Scan all properties of 'aliases' node
> *
> * The function scans all the properties of 'aliases' node and populate
> diff --git a/drivers/of/device.c b/drivers/of/device.c
> index 4c74e4f..06e122d 100644
> --- a/drivers/of/device.c
> +++ b/drivers/of/device.c
> @@ -153,6 +153,7 @@ void of_device_uevent(struct device *dev, struct kobj_uevent_env *env)
> seen++;
> }
> add_uevent_var(env, "OF_COMPATIBLE_N=%d", seen);
> + of_device_uevent_aliases(dev->of_node, env);
> }
>
> int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env)
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index 901b743..748056d 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -36,6 +36,8 @@ extern ssize_t of_device_get_modalias(struct device *dev,
> char *str, ssize_t len);
>
> extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
> +extern void of_device_uevent_aliases(struct device_node *node,
> + struct kobj_uevent_env *env);
> extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env);
>
> static inline void of_device_node_put(struct device *dev)
> --
> The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
>
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
next prev parent reply other threads:[~2012-12-05 23:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-05 2:30 [PATCH] of: Output devicetree alias names in uevent Stepan Moskovchenko
2012-12-05 2:30 ` Stepan Moskovchenko
2012-12-05 23:03 ` Grant Likely [this message]
2012-12-05 23:03 ` Grant Likely
2012-12-05 23:03 ` Grant Likely
2012-12-06 7:49 ` [PATCH v2] " Stepan Moskovchenko
2012-12-06 7:49 ` Stepan Moskovchenko
2012-12-06 19:24 ` Grant Likely
2012-12-06 19:24 ` Grant Likely
2012-12-06 19:24 ` Grant Likely
2012-12-06 22:55 ` [PATCH v3] " Stepan Moskovchenko
2012-12-06 22:55 ` Stepan Moskovchenko
2012-12-19 11:26 ` Grant Likely
2012-12-19 11:26 ` Grant Likely
2012-12-19 11:26 ` 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=20121205230318.013053E0E22@localhost \
--to=grant.likely@secretlab.ca \
--cc=bryanh@codeaurora.org \
--cc=davidb@codeaurora.org \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=dwalker@fifo99.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbohan@codeaurora.org \
--cc=rob.herring@calxeda.com \
--cc=stepanm@codeaurora.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.