dm: core: Use dev_has_ofnode() instead of dev_of_valid()

We have two functions which do the same thing. Standardise on
dev_has_ofnode() since there is no such thing as an 'invalid' ofnode in
normal operation: it is either null or missing.

Also move the functions into one place.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
diff --git a/include/dm/device.h b/include/dm/device.h
index b15a14e..4a1224b 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -192,6 +192,17 @@
 	dev->flags_ &= ~bic;
 }
 
+/**
+ * dev_ofnode() - get the DT node reference associated with a udevice
+ *
+ * @dev:	device to check
+ * @return reference of the the device's DT node
+ */
+static inline ofnode dev_ofnode(const struct udevice *dev)
+{
+	return dev->node;
+}
+
 /* Returns non-zero if the device is active (probed and not removed) */
 #define device_active(dev)	(dev_get_flags(dev) & DM_FLAG_ACTIVATED)
 
@@ -200,7 +211,7 @@
 	return ofnode_to_offset(dev->node);
 }
 
-static inline bool dev_has_ofnode(struct udevice *dev)
+static inline bool dev_has_ofnode(const struct udevice *dev)
 {
 	return ofnode_valid(dev->node);
 }