PERFORCE change 171817 for review
Rafal Jaworowski
raj at FreeBSD.org
Tue Dec 15 14:29:38 PST 2009
http://p4web.freebsd.org/chv.cgi?CH=171817
Change 171817 by raj at raj_fdt on 2009/12/15 22:29:35
Provide helper routine for checking node compatibility.
It will be useful for FDT-enabled devices, when matching for
'compatible' property, as they can often have multi-string form e.g.:
compatible = "fsl,mpc8572-elbc", "fsl,elbc", "simple-bus";
compatible = "fsl,mpc8572-dma", "fsl,eloplus-dma";
compatible = "fsl,mpc8572-msi", "fsl,mpic-msi";
Affected files ...
.. //depot/projects/fdt/sys/dev/ofw/ofw_bus_subr.c#2 edit
.. //depot/projects/fdt/sys/dev/ofw/ofw_bus_subr.h#2 edit
Differences ...
==== //depot/projects/fdt/sys/dev/ofw/ofw_bus_subr.c#2 (text+ko) ====
@@ -146,6 +146,38 @@
return (obd->obd_type);
}
+int
+ofw_bus_is_compatible(device_t dev, const char *onecompat)
+{
+ phandle_t node;
+ const char *compat;
+ int len, onelen, l;
+
+ if ((compat = ofw_bus_get_compat(dev)) == NULL)
+ return (0);
+
+ if ((node = ofw_bus_get_node(dev)) == 0)
+ return (0);
+
+ /* Get total 'compatible' prop len */
+ if ((len = OF_getproplen(node, "compatible")) <= 0)
+ return (0);
+
+ onelen = strlen(onecompat);
+
+ while (len > 0) {
+ if (strncasecmp(compat, onecompat, onelen) == 0)
+ /* Found it. */
+ return (1);
+
+ /* Slide to the next sub-string. */
+ l = strlen(compat) + 1;
+ compat += l;
+ len -= l;
+ }
+ return (0);
+}
+
void
ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iinfo *ii, int intrsz)
{
==== //depot/projects/fdt/sys/dev/ofw/ofw_bus_subr.h#2 (text+ko) ====
@@ -67,4 +67,7 @@
int ofw_bus_search_intrmap(void *, int, void *, int, void *, int, void *,
void *, void *, int);
+/* Helper routine for checking compat prop */
+int ofw_bus_is_compatible(device_t, const char *);
+
#endif /* !_DEV_OFW_OFW_BUS_SUBR_H_ */
More information about the p4-projects
mailing list