]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
rtc-honor-device-tree-alias-entries-when-assigning-ids-v2
authorStephen Warren <swarren@nvidia.com>
Fri, 3 Jan 2014 03:10:24 +0000 (14:10 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 3 Jan 2014 03:10:24 +0000 (14:10 +1100)
v2: Explicitly check for both dev->of_node and dev->parent->of_node.
    This covers the MFD case, without the MFD core having to set
    child MFD devices' of_node pointer to the same node as the top-
    level MFD device, which causes problems such as:
    http://www.spinics.net/lists/arm-kernel/msg295854.html

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/rtc/class.c

index 7989b5d030cb9aa23b0fe9215d1771897aae484f..589351ef75d03cd3c226389912e27316216df677 100644 (file)
@@ -158,17 +158,19 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev,
 {
        struct rtc_device *rtc;
        struct rtc_wkalrm alrm;
-       int of_id, id = -1, err;
+       int of_id = -1, id = -1, err;
 
-       if (dev->of_node) {
+       if (dev->of_node)
                of_id = of_alias_get_id(dev->of_node, "rtc");
-               if (of_id >= 0) {
-                       id = ida_simple_get(&rtc_ida, of_id, of_id + 1,
-                                           GFP_KERNEL);
-                       if (id < 0)
-                               dev_warn(dev, "/aliases ID %d not available\n",
-                                        of_id);
-               }
+       else if (dev->parent && dev->parent->of_node)
+               of_id = of_alias_get_id(dev->parent->of_node, "rtc");
+
+       if (of_id >= 0) {
+               id = ida_simple_get(&rtc_ida, of_id, of_id + 1,
+                                   GFP_KERNEL);
+               if (id < 0)
+                       dev_warn(dev, "/aliases ID %d not available\n",
+                                   of_id);
        }
 
        if (id < 0) {