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 <redacted>
---
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.
drivers/of/base.c | 25 +++++++++++++++++++++++++
drivers/of/device.c | 1 +
include/linux/of_device.h | 2 ++
3 files changed, 28 insertions(+), 0 deletions(-)
From: Grant Likely <hidden> Date: 2012-12-05 23:03:24
On Tue, 4 Dec 2012 18:30:37 -0800, Stepan Moskovchenko [off-list ref] 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 <redacted>
---
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.
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.
quoted hunk
+
+/**
* of_alias_scan - Scan all properties of 'aliases' node
*
* The function scans all the properties of 'aliases' node and populate
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 <redacted>
---
v2: Create of_private.h and move struct alias_prop there
Add alias uevent variables from of_device_uevent
Use app->alias instead of app->stem / app->id directly
Expose alias_lookup and of_alias_mutex
drivers/of/base.c | 23 +++--------------------
drivers/of/device.c | 17 +++++++++++++++++
drivers/of/of_private.h | 33 +++++++++++++++++++++++++++++++++
3 files changed, 53 insertions(+), 20 deletions(-)
create mode 100644 drivers/of/of_private.h
@@ -24,32 +24,15 @@#include<linux/slab.h>#include<linux/proc_fs.h>-/**-*structalias_prop-Aliaspropertyin'aliases'node-*@link:Listnodetolinkthestructureinaliases_lookuplist-*@alias:Aliaspropertyname-*@np:Pointertodevice_nodethatthealiasstandsfor-*@id:Indexvaluefromendofaliasname-*@stem:Aliasstringwithouttheindex-*-*Thestructurerepresentsonealiaspropertyof'aliases'nodeas-*anentryinaliases_lookuplist.-*/-structalias_prop{-structlist_headlink;-constchar*alias;-structdevice_node*np;-intid;-charstem[0];-};+#include"of_private.h"-staticLIST_HEAD(aliases_lookup);+LIST_HEAD(aliases_lookup);structdevice_node*allnodes;structdevice_node*of_chosen;structdevice_node*of_aliases;-staticDEFINE_MUTEX(of_aliases_mutex);+DEFINE_MUTEX(of_aliases_mutex);/* use when traversing tree through the allnext, child, sibling,*orparentmembersofstructdevice_node.
@@ -0,0 +1,33 @@+/* Copyright (c) 2012, The Linux Foundation. All rights reserved.+*+*Thisprogramisfreesoftware;youcanredistributeitand/ormodify+*itunderthetermsoftheGNUGeneralPublicLicenseversion2and+*onlyversion2aspublishedbytheFreeSoftwareFoundation.+*+*Thisprogramisdistributedinthehopethatitwillbeuseful,+*butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof+*MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe+*GNUGeneralPublicLicenseformoredetails.+*/++/**+*structalias_prop-Aliaspropertyin'aliases'node+*@link:Listnodetolinkthestructureinaliases_lookuplist+*@alias:Aliaspropertyname+*@np:Pointertodevice_nodethatthealiasstandsfor+*@id:Indexvaluefromendofaliasname+*@stem:Aliasstringwithouttheindex+*+*Thestructurerepresentsonealiaspropertyof'aliases'nodeas+*anentryinaliases_lookuplist.+*/+structalias_prop{+structlist_headlink;+constchar*alias;+structdevice_node*np;+intid;+charstem[0];+};++externstructmutexof_aliases_mutex;+externstructlist_headaliases_lookup;--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
From: Grant Likely <hidden> Date: 2012-12-06 19:25:07
On Wed, 5 Dec 2012 23:49:25 -0800, Stepan Moskovchenko [off-list ref] wrote:
quoted hunk
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 <redacted>
---
v2: Create of_private.h and move struct alias_prop there
Add alias uevent variables from of_device_uevent
Use app->alias instead of app->stem / app->id directly
Expose alias_lookup and of_alias_mutex
drivers/of/base.c | 23 +++--------------------
drivers/of/device.c | 17 +++++++++++++++++
drivers/of/of_private.h | 33 +++++++++++++++++++++++++++++++++
3 files changed, 53 insertions(+), 20 deletions(-)
create mode 100644 drivers/of/of_private.h
@@ -24,32 +24,15 @@#include<linux/slab.h>#include<linux/proc_fs.h>-/**-*structalias_prop-Aliaspropertyin'aliases'node-*@link:Listnodetolinkthestructureinaliases_lookuplist-*@alias:Aliaspropertyname-*@np:Pointertodevice_nodethatthealiasstandsfor-*@id:Indexvaluefromendofaliasname-*@stem:Aliasstringwithouttheindex-*-*Thestructurerepresentsonealiaspropertyof'aliases'nodeas-*anentryinaliases_lookuplist.-*/-structalias_prop{-structlist_headlink;-constchar*alias;-structdevice_node*np;-intid;-charstem[0];-};+#include"of_private.h"-staticLIST_HEAD(aliases_lookup);+LIST_HEAD(aliases_lookup);structdevice_node*allnodes;structdevice_node*of_chosen;structdevice_node*of_aliases;-staticDEFINE_MUTEX(of_aliases_mutex);+DEFINE_MUTEX(of_aliases_mutex);/* use when traversing tree through the allnext, child, sibling,*orparentmembersofstructdevice_node.
@@ -0,0 +1,33 @@+/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
Oops, that doesn't look right. You need to preserve the copyright
messages from the file this came from. You didn't write this code, you
only moved it about.
Otherwise the patch looks good. Can you please respin with that change?
g.
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 <redacted>
---
v3: Fix copyright/license message on of_platform.h to match
the messages in the file the code came from.
I also noticed that some of the comments in the original
header might no longer apply, but I copied the header in
its entirety. I can try to trim these down if you like.
drivers/of/base.c | 23 +++--------------------
drivers/of/device.c | 17 +++++++++++++++++
drivers/of/of_private.h | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 20 deletions(-)
create mode 100644 drivers/of/of_private.h
@@ -24,32 +24,15 @@#include<linux/slab.h>#include<linux/proc_fs.h>-/**-*structalias_prop-Aliaspropertyin'aliases'node-*@link:Listnodetolinkthestructureinaliases_lookuplist-*@alias:Aliaspropertyname-*@np:Pointertodevice_nodethatthealiasstandsfor-*@id:Indexvaluefromendofaliasname-*@stem:Aliasstringwithouttheindex-*-*Thestructurerepresentsonealiaspropertyof'aliases'nodeas-*anentryinaliases_lookuplist.-*/-structalias_prop{-structlist_headlink;-constchar*alias;-structdevice_node*np;-intid;-charstem[0];-};+#include"of_private.h"-staticLIST_HEAD(aliases_lookup);+LIST_HEAD(aliases_lookup);structdevice_node*allnodes;structdevice_node*of_chosen;structdevice_node*of_aliases;-staticDEFINE_MUTEX(of_aliases_mutex);+DEFINE_MUTEX(of_aliases_mutex);/* use when traversing tree through the allnext, child, sibling,*orparentmembersofstructdevice_node.
From: Grant Likely <hidden> Date: 2012-12-19 11:27:15
On Thu, 6 Dec 2012 14:55:41 -0800, Stepan Moskovchenko [off-list ref] 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 <redacted>
I've picked this up into my devicetree/next branch. It will get pushed out to linux-next after the merge window closes.
Thanks,
g.