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

Function ether_poll_register

freebsd/kern/kern_poll.c:478–520  ·  view source on GitHub ↗

* Try to register routine for polling. Returns 0 if successful * (and polling should be enabled), error code otherwise. * A device is not supposed to register itself multiple times. * * This is called from within the *_ioctl() functions. */

Source from the content-addressed store, hash-verified

476 * This is called from within the *_ioctl() functions.
477 */
478int
479ether_poll_register(poll_handler_t *h, if_t ifp)
480{
481 int i;
482
483 KASSERT(h != NULL, ("%s: handler is NULL", __func__));
484 KASSERT(ifp != NULL, ("%s: ifp is NULL", __func__));
485
486 mtx_lock(&poll_mtx);
487 if (poll_handlers >= POLL_LIST_LEN) {
488 /*
489 * List full, cannot register more entries.
490 * This should never happen; if it does, it is probably a
491 * broken driver trying to register multiple times. Checking
492 * this at runtime is expensive, and won't solve the problem
493 * anyways, so just report a few times and then give up.
494 */
495 static int verbose = 10 ;
496 if (verbose >0) {
497 log(LOG_ERR, "poll handlers list full, "
498 "maybe a broken driver ?\n");
499 verbose--;
500 }
501 mtx_unlock(&poll_mtx);
502 return (ENOMEM); /* no polling for you */
503 }
504
505 for (i = 0 ; i < poll_handlers ; i++)
506 if (pr[i].ifp == ifp && pr[i].handler != NULL) {
507 mtx_unlock(&poll_mtx);
508 log(LOG_DEBUG, "ether_poll_register: %s: handler"
509 " already registered\n", ifp->if_xname);
510 return (EEXIST);
511 }
512
513 pr[poll_handlers].handler = h;
514 pr[poll_handlers].ifp = ifp;
515 poll_handlers++;
516 mtx_unlock(&poll_mtx);
517 if (idlepoll_sleeping)
518 wakeup(&idlepoll_sleeping);
519 return (0);
520}
521
522/*
523 * Remove interface from the polling list. Called from *_ioctl(), too.

Callers 2

arge_ioctlFunction · 0.85
awg_ioctlFunction · 0.85

Calls 4

mtx_lockFunction · 0.70
logFunction · 0.70
mtx_unlockFunction · 0.70
wakeupFunction · 0.70

Tested by

no test coverage detected