MCPcopy Create free account
hub / github.com/F-Stack/f-stack / devstat_add_entry

Function devstat_add_entry

freebsd/kern/subr_devstat.c:115–191  ·  view source on GitHub ↗

* Take a malloced and zeroed devstat structure given to us, fill it in * and add it to the queue of devices. */

Source from the content-addressed store, hash-verified

113 * and add it to the queue of devices.
114 */
115static void
116devstat_add_entry(struct devstat *ds, const void *dev_name,
117 int unit_number, uint32_t block_size,
118 devstat_support_flags flags,
119 devstat_type_flags device_type,
120 devstat_priority priority)
121{
122 struct devstatlist *devstat_head;
123 struct devstat *ds_tmp;
124
125 mtx_assert(&devstat_mutex, MA_OWNED);
126 devstat_num_devs++;
127
128 devstat_head = &device_statq;
129
130 /*
131 * Priority sort. Each driver passes in its priority when it adds
132 * its devstat entry. Drivers are sorted first by priority, and
133 * then by probe order.
134 *
135 * For the first device, we just insert it, since the priority
136 * doesn't really matter yet. Subsequent devices are inserted into
137 * the list using the order outlined above.
138 */
139 if (devstat_num_devs == 1)
140 STAILQ_INSERT_TAIL(devstat_head, ds, dev_links);
141 else {
142 STAILQ_FOREACH(ds_tmp, devstat_head, dev_links) {
143 struct devstat *ds_next;
144
145 ds_next = STAILQ_NEXT(ds_tmp, dev_links);
146
147 /*
148 * If we find a break between higher and lower
149 * priority items, and if this item fits in the
150 * break, insert it. This also applies if the
151 * "lower priority item" is the end of the list.
152 */
153 if ((priority <= ds_tmp->priority)
154 && ((ds_next == NULL)
155 || (priority > ds_next->priority))) {
156 STAILQ_INSERT_AFTER(devstat_head, ds_tmp, ds,
157 dev_links);
158 break;
159 } else if (priority > ds_tmp->priority) {
160 /*
161 * If this is the case, we should be able
162 * to insert ourselves at the head of the
163 * list. If we can't, something is wrong.
164 */
165 if (ds_tmp == STAILQ_FIRST(devstat_head)) {
166 STAILQ_INSERT_HEAD(devstat_head,
167 ds, dev_links);
168 break;
169 } else {
170 STAILQ_INSERT_TAIL(devstat_head,
171 ds, dev_links);
172 printf("devstat_add_entry: HELP! "

Callers 1

devstat_new_entryFunction · 0.85

Calls 4

mtx_assertFunction · 0.85
binuptimeFunction · 0.85
printfFunction · 0.70
strlcpyFunction · 0.50

Tested by

no test coverage detected