diff options
Diffstat (limited to 'drivers/rtc')
| -rw-r--r-- | drivers/rtc/class.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 02426812bebc..589351ef75d0 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 15 | 15 | ||
| 16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
| 17 | #include <linux/of.h> | ||
| 17 | #include <linux/rtc.h> | 18 | #include <linux/rtc.h> |
| 18 | #include <linux/kdev_t.h> | 19 | #include <linux/kdev_t.h> |
| 19 | #include <linux/idr.h> | 20 | #include <linux/idr.h> |
| @@ -157,12 +158,27 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, | |||
| 157 | { | 158 | { |
| 158 | struct rtc_device *rtc; | 159 | struct rtc_device *rtc; |
| 159 | struct rtc_wkalrm alrm; | 160 | struct rtc_wkalrm alrm; |
| 160 | int id, err; | 161 | int of_id = -1, id = -1, err; |
| 162 | |||
| 163 | if (dev->of_node) | ||
| 164 | of_id = of_alias_get_id(dev->of_node, "rtc"); | ||
| 165 | else if (dev->parent && dev->parent->of_node) | ||
| 166 | of_id = of_alias_get_id(dev->parent->of_node, "rtc"); | ||
| 167 | |||
| 168 | if (of_id >= 0) { | ||
| 169 | id = ida_simple_get(&rtc_ida, of_id, of_id + 1, | ||
| 170 | GFP_KERNEL); | ||
| 171 | if (id < 0) | ||
| 172 | dev_warn(dev, "/aliases ID %d not available\n", | ||
| 173 | of_id); | ||
| 174 | } | ||
| 161 | 175 | ||
| 162 | id = ida_simple_get(&rtc_ida, 0, 0, GFP_KERNEL); | ||
| 163 | if (id < 0) { | 176 | if (id < 0) { |
| 164 | err = id; | 177 | id = ida_simple_get(&rtc_ida, 0, 0, GFP_KERNEL); |
| 165 | goto exit; | 178 | if (id < 0) { |
| 179 | err = id; | ||
| 180 | goto exit; | ||
| 181 | } | ||
| 166 | } | 182 | } |
| 167 | 183 | ||
| 168 | rtc = kzalloc(sizeof(struct rtc_device), GFP_KERNEL); | 184 | rtc = kzalloc(sizeof(struct rtc_device), GFP_KERNEL); |
