From d062871ff59b692b78c69b9f8545397957663dc2 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Fri, 3 Jan 2014 14:10:24 +1100 Subject: [PATCH] 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 --- drivers/rtc/class.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) 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) { -- 2.39.5