From: Stephen Warren Date: Fri, 3 Jan 2014 03:10:24 +0000 (+1100) Subject: rtc-honor-device-tree-alias-entries-when-assigning-ids-v2 X-Git-Tag: next-20140106~2^2~58 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=d062871ff59b692b78c69b9f8545397957663dc2;p=karo-tx-linux.git rtc-honor-device-tree-alias-entries-when-assigning-ids-v2 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 Signed-off-by: Andrew Morton --- diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 7989b5d030cb..589351ef75d0 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c @@ -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) {