aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/watchdog/watchdog_core.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 1a8059455413..873f13972cf4 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -139,7 +139,7 @@ EXPORT_SYMBOL_GPL(watchdog_init_timeout);
139 139
140static int __watchdog_register_device(struct watchdog_device *wdd) 140static int __watchdog_register_device(struct watchdog_device *wdd)
141{ 141{
142 int ret, id, devno; 142 int ret, id = -1, devno;
143 143
144 if (wdd == NULL || wdd->info == NULL || wdd->ops == NULL) 144 if (wdd == NULL || wdd->info == NULL || wdd->ops == NULL)
145 return -EINVAL; 145 return -EINVAL;
@@ -157,7 +157,18 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
157 */ 157 */
158 158
159 mutex_init(&wdd->lock); 159 mutex_init(&wdd->lock);
160 id = ida_simple_get(&watchdog_ida, 0, MAX_DOGS, GFP_KERNEL); 160
161 /* Use alias for watchdog id if possible */
162 if (wdd->parent) {
163 ret = of_alias_get_id(wdd->parent->of_node, "watchdog");
164 if (ret >= 0)
165 id = ida_simple_get(&watchdog_ida, ret,
166 ret + 1, GFP_KERNEL);
167 }
168
169 if (id < 0)
170 id = ida_simple_get(&watchdog_ida, 0, MAX_DOGS, GFP_KERNEL);
171
161 if (id < 0) 172 if (id < 0)
162 return id; 173 return id;
163 wdd->id = id; 174 wdd->id = id;