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

Nathan Whitehorn nwhitehorn at FreeBSD.org
Sun Feb 2 16:41:56 UTC 2014


Author: nwhitehorn
Date: Sun Feb  2 16:41:54 2014
New Revision: 261403
URL: http://svnweb.freebsd.org/changeset/base/261403

Log:
  Add a set of helpers (ofw_bus_get_status() and ofw_bus_status_okay()) to
  process "status" properties of OF nodes.
  
  I've avoided adding new KOBJ methods here so that we don't have to modify
  every ofw_bus in the tree. Since 100% of implementations of ofw_bus use
  only ofw_bus_gen_*(), it might be worth garbage-collecting the other
  methods as well.

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

Modified: head/sys/dev/ofw/ofw_bus_if.m
==============================================================================
--- head/sys/dev/ofw/ofw_bus_if.m	Sun Feb  2 14:13:51 2014	(r261402)
+++ head/sys/dev/ofw/ofw_bus_if.m	Sun Feb  2 16:41:54 2014	(r261403)
@@ -46,6 +46,7 @@ HEADER {
 		char		*obd_model;
 		char		*obd_name;
 		char		*obd_type;
+		char		*obd_status;
 	};
 };
 

Modified: head/sys/dev/ofw/ofw_bus_subr.c
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.c	Sun Feb  2 14:13:51 2014	(r261402)
+++ head/sys/dev/ofw/ofw_bus_subr.c	Sun Feb  2 16:41:54 2014	(r261403)
@@ -55,6 +55,7 @@ ofw_bus_gen_setup_devinfo(struct ofw_bus
 	OF_getprop_alloc(node, "compatible", 1, (void **)&obd->obd_compat);
 	OF_getprop_alloc(node, "device_type", 1, (void **)&obd->obd_type);
 	OF_getprop_alloc(node, "model", 1, (void **)&obd->obd_model);
+	OF_getprop_alloc(node, "status", 1, (void **)&obd->obd_status);
 	obd->obd_node = node;
 	return (0);
 }
@@ -73,6 +74,8 @@ ofw_bus_gen_destroy_devinfo(struct ofw_b
 		free(obd->obd_name, M_OFWPROP);
 	if (obd->obd_type != NULL)
 		free(obd->obd_type, M_OFWPROP);
+	if (obd->obd_status != NULL)
+		free(obd->obd_status, M_OFWPROP);
 }
 
 int
@@ -147,6 +150,30 @@ ofw_bus_gen_get_type(device_t bus, devic
 	return (obd->obd_type);
 }
 
+const char *
+ofw_bus_get_status(device_t dev)
+{
+	const struct ofw_bus_devinfo *obd;
+
+	obd = OFW_BUS_GET_DEVINFO(device_get_parent(dev), dev);
+	if (obd == NULL)
+		return (NULL);
+
+	return (obd->obd_status);
+}
+
+int
+ofw_bus_status_okay(device_t dev)
+{
+	const char *status;
+
+	status = ofw_bus_get_status(dev);
+	if (status == NULL || strcmp(status, "okay") == 0)
+		return (1);
+	
+	return (0);
+}
+
 int
 ofw_bus_is_compatible(device_t dev, const char *onecompat)
 {

Modified: head/sys/dev/ofw/ofw_bus_subr.h
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.h	Sun Feb  2 14:13:51 2014	(r261402)
+++ head/sys/dev/ofw/ofw_bus_subr.h	Sun Feb  2 16:41:54 2014	(r261403)
@@ -72,6 +72,10 @@ int	ofw_bus_lookup_imap(phandle_t, struc
 int	ofw_bus_search_intrmap(void *, int, void *, int, void *, int, void *,
 	    void *, void *, int, phandle_t *);
 
+/* Helper to get device status property */
+const char *ofw_bus_get_status(device_t dev);
+int ofw_bus_status_okay(device_t dev);
+
 /* Helper to get node's interrupt parent */
 void	ofw_bus_find_iparent(phandle_t);
 


More information about the svn-src-all mailing list