Deleted Added
full compact
ofw_bus_subr.c (259516) ofw_bus_subr.c (261403)
1/*-
2 * Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org>.
3 * Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2001 - 2003 by Thomas Moestl <tmm@FreeBSD.org>.
3 * Copyright (c) 2005 Marius Strobl <marius@FreeBSD.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_bus_subr.c 259516 2013-12-17 15:11:24Z nwhitehorn $");
31__FBSDID("$FreeBSD: head/sys/dev/ofw/ofw_bus_subr.c 261403 2014-02-02 16:41:54Z nwhitehorn $");
32
33#include "opt_platform.h"
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/bus.h>
37#include <sys/errno.h>
38#include <sys/libkern.h>
39

--- 10 unchanged lines hidden (view full) ---

50 if (obd == NULL)
51 return (ENOMEM);
52 /* The 'name' property is considered mandatory. */
53 if ((OF_getprop_alloc(node, "name", 1, (void **)&obd->obd_name)) == -1)
54 return (EINVAL);
55 OF_getprop_alloc(node, "compatible", 1, (void **)&obd->obd_compat);
56 OF_getprop_alloc(node, "device_type", 1, (void **)&obd->obd_type);
57 OF_getprop_alloc(node, "model", 1, (void **)&obd->obd_model);
32
33#include "opt_platform.h"
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/bus.h>
37#include <sys/errno.h>
38#include <sys/libkern.h>
39

--- 10 unchanged lines hidden (view full) ---

50 if (obd == NULL)
51 return (ENOMEM);
52 /* The 'name' property is considered mandatory. */
53 if ((OF_getprop_alloc(node, "name", 1, (void **)&obd->obd_name)) == -1)
54 return (EINVAL);
55 OF_getprop_alloc(node, "compatible", 1, (void **)&obd->obd_compat);
56 OF_getprop_alloc(node, "device_type", 1, (void **)&obd->obd_type);
57 OF_getprop_alloc(node, "model", 1, (void **)&obd->obd_model);
58 OF_getprop_alloc(node, "status", 1, (void **)&obd->obd_status);
58 obd->obd_node = node;
59 return (0);
60}
61
62void
63ofw_bus_gen_destroy_devinfo(struct ofw_bus_devinfo *obd)
64{
65
66 if (obd == NULL)
67 return;
68 if (obd->obd_compat != NULL)
69 free(obd->obd_compat, M_OFWPROP);
70 if (obd->obd_model != NULL)
71 free(obd->obd_model, M_OFWPROP);
72 if (obd->obd_name != NULL)
73 free(obd->obd_name, M_OFWPROP);
74 if (obd->obd_type != NULL)
75 free(obd->obd_type, M_OFWPROP);
59 obd->obd_node = node;
60 return (0);
61}
62
63void
64ofw_bus_gen_destroy_devinfo(struct ofw_bus_devinfo *obd)
65{
66
67 if (obd == NULL)
68 return;
69 if (obd->obd_compat != NULL)
70 free(obd->obd_compat, M_OFWPROP);
71 if (obd->obd_model != NULL)
72 free(obd->obd_model, M_OFWPROP);
73 if (obd->obd_name != NULL)
74 free(obd->obd_name, M_OFWPROP);
75 if (obd->obd_type != NULL)
76 free(obd->obd_type, M_OFWPROP);
77 if (obd->obd_status != NULL)
78 free(obd->obd_status, M_OFWPROP);
76}
77
78int
79ofw_bus_gen_child_pnpinfo_str(device_t cbdev, device_t child, char *buf,
80 size_t buflen)
81{
82
83 if (ofw_bus_get_name(child) != NULL) {

--- 58 unchanged lines hidden (view full) ---

142 const struct ofw_bus_devinfo *obd;
143
144 obd = OFW_BUS_GET_DEVINFO(bus, dev);
145 if (obd == NULL)
146 return (NULL);
147 return (obd->obd_type);
148}
149
79}
80
81int
82ofw_bus_gen_child_pnpinfo_str(device_t cbdev, device_t child, char *buf,
83 size_t buflen)
84{
85
86 if (ofw_bus_get_name(child) != NULL) {

--- 58 unchanged lines hidden (view full) ---

145 const struct ofw_bus_devinfo *obd;
146
147 obd = OFW_BUS_GET_DEVINFO(bus, dev);
148 if (obd == NULL)
149 return (NULL);
150 return (obd->obd_type);
151}
152
153const char *
154ofw_bus_get_status(device_t dev)
155{
156 const struct ofw_bus_devinfo *obd;
157
158 obd = OFW_BUS_GET_DEVINFO(device_get_parent(dev), dev);
159 if (obd == NULL)
160 return (NULL);
161
162 return (obd->obd_status);
163}
164
150int
165int
166ofw_bus_status_okay(device_t dev)
167{
168 const char *status;
169
170 status = ofw_bus_get_status(dev);
171 if (status == NULL || strcmp(status, "okay") == 0)
172 return (1);
173
174 return (0);
175}
176
177int
151ofw_bus_is_compatible(device_t dev, const char *onecompat)
152{
153 phandle_t node;
154 const char *compat;
155 int len, onelen, l;
156
157 if ((compat = ofw_bus_get_compat(dev)) == NULL)
158 return (0);

--- 184 unchanged lines hidden ---
178ofw_bus_is_compatible(device_t dev, const char *onecompat)
179{
180 phandle_t node;
181 const char *compat;
182 int len, onelen, l;
183
184 if ((compat = ofw_bus_get_compat(dev)) == NULL)
185 return (0);

--- 184 unchanged lines hidden ---