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/test/dm/pci.c b/test/dm/pci.c
index 76490be..fa2e4a8 100644
--- a/test/dm/pci.c
+++ b/test/dm/pci.c
@@ -120,13 +120,13 @@
 
 	ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x08, 0), &swap));
 	ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
-	ut_assertok(dev_of_valid(swap));
+	ut_assertok(dev_has_ofnode(swap));
 	ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x0c, 0), &swap));
 	ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
-	ut_assertok(dev_of_valid(swap));
+	ut_assertok(dev_has_ofnode(swap));
 	ut_assertok(dm_pci_bus_find_bdf(PCI_BDF(1, 0x10, 0), &swap));
 	ut_asserteq(SWAP_CASE_DRV_DATA, swap->driver_data);
-	ut_assertok(!dev_of_valid(swap));
+	ut_assertok(!dev_has_ofnode(swap));
 
 	return 0;
 }