svn commit: r312745 - head/sys/dev/ofw

Wojciech Macek wma at FreeBSD.org
Wed Jan 25 10:28:22 UTC 2017


Author: wma
Date: Wed Jan 25 10:28:21 2017
New Revision: 312745
URL: https://svnweb.freebsd.org/changeset/base/312745

Log:
  Expand OpenFirmware API with ofw_bus_node_status_okay
   method
  
  Method could be used before we can access device_t structure.
  As per simple phandle_t handle we can access FDT to check
  if specified node has been enabled.
  It will be used in Marvell's common configuration code.
  
  Submitted by:          Konrad Adamczyk <ka at semihalf.com>
  Obtained from:         Semihalf
  Sponsored by:          Stormshield
  Reviewed by:           zbb, meloun-miracle-cz
  Differential revision: https://reviews.freebsd.org/D9218

Modified:
  head/sys/dev/ofw/ofw_bus_subr.c
  head/sys/dev/ofw/ofw_bus_subr.h

Modified: head/sys/dev/ofw/ofw_bus_subr.c
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.c	Wed Jan 25 10:25:59 2017	(r312744)
+++ head/sys/dev/ofw/ofw_bus_subr.c	Wed Jan 25 10:28:21 2017	(r312745)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 #include "ofw_bus_if.h"
 
 #define	OFW_COMPAT_LEN	255
+#define	OFW_STATUS_LEN	16
 
 int
 ofw_bus_gen_setup_devinfo(struct ofw_bus_devinfo *obd, phandle_t node)
@@ -179,6 +180,24 @@ ofw_bus_status_okay(device_t dev)
 	return (0);
 }
 
+int
+ofw_bus_node_status_okay(phandle_t node)
+{
+	char status[OFW_STATUS_LEN];
+	int len;
+
+	len = OF_getproplen(node, "status");
+	if (len <= 0)
+		return (1);
+
+	OF_getprop(node, "status", status, OFW_STATUS_LEN);
+	if ((len == 5 && (bcmp(status, "okay", len) == 0)) ||
+	    (len == 3 && (bcmp(status, "ok", len))))
+		return (1);
+
+	return (0);
+}
+
 static int
 ofw_bus_node_is_compatible_int(const char *compat, int len,
     const char *onecompat)

Modified: head/sys/dev/ofw/ofw_bus_subr.h
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.h	Wed Jan 25 10:25:59 2017	(r312744)
+++ head/sys/dev/ofw/ofw_bus_subr.h	Wed Jan 25 10:28:21 2017	(r312745)
@@ -100,6 +100,7 @@ int ofw_bus_intr_by_rid(device_t, phandl
 /* Helper to get device status property */
 const char *ofw_bus_get_status(device_t dev);
 int ofw_bus_status_okay(device_t dev);
+int ofw_bus_node_status_okay(phandle_t node);
 
 /* Helper to get node's interrupt parent */
 phandle_t ofw_bus_find_iparent(phandle_t);


More information about the svn-src-all mailing list