FreeBSD/sys/kern/kern_poll.c
/*
 * 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.
 */
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.
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 .
int
ether_poll_register(poll_handler_t *h, if_t ifp)
{
	int i;
	KASSERT(h != NULL, ("%s: handler is NULL", __func__));
	KASSERT(ifp != NULL, ("%s: ifp is NULL", __func__));
	mtx_lock(&poll_mtx);
	if (poll_handlers >= POLL_LIST_LEN) {
		static int verbose = 10 ;
		if (verbose >0) {
			log(LOG_ERR, "poll handlers list full, "
			    "maybe a broken driver ?\n");
			verbose--;
		}
		mtx_unlock(&poll_mtx);
		return (ENOMEM); 
	}
	for (i = 0 ; i < poll_handlers ; i++)
		if (pr[i].ifp == ifp && pr[i].handler != NULL) {
			mtx_unlock(&poll_mtx);
			log(LOG_DEBUG, "ether_poll_register: %s: handler"
			    " already registered\n", ifp->if_xname);
			return (EEXIST);
		}
	pr[poll_handlers].handler = h;
	pr[poll_handlers].ifp = ifp;
	poll_handlers++;
	mtx_unlock(&poll_mtx);
	if (idlepoll_sleeping)
		wakeup(&idlepoll_sleeping);
	return (0);
}
int ether_poll_register ( poll_handler_t * h , if_t ifp ) { int i ; KASSERT ( h != NULL , ( " " , __func__ ) ) ; KASSERT ( ifp != NULL , ( " " , __func__ ) ) ; mtx_lock ( & poll_mtx ) ; if ( poll_handlers >= POLL_LIST_LEN ) { static int verbose = 10 ; if ( verbose > 0 ) { log ( LOG_ERR , " " " \n " ) ; verbose -- ; } mtx_unlock ( & poll_mtx ) ; return ( ENOMEM ) ; } for ( i = 0 ; i < poll_handlers ; i ++ ) if ( pr [ i ] . ifp == ifp && pr [ i ] . handler != NULL ) { mtx_unlock ( & poll_mtx ) ; log ( LOG_DEBUG , " " " \n " , ifp -> if_xname ) ; return ( EEXIST ) ; } pr [ poll_handlers ] . handler = h ; pr [ poll_handlers ] . ifp = ifp ; poll_handlers ++ ; mtx_unlock ( & poll_mtx ) ; if ( idlepoll_sleeping ) wakeup ( & idlepoll_sleeping ) ; return ( 0 ) ; }
Try to register routine for polling.
Try to register routine for polling .
/*
		 * List full, cannot register more entries.
		 * This should never happen; if it does, it is probably a
		 * broken driver trying to register multiple times. Checking
		 * this at runtime is expensive, and won't solve the problem
		 * anyways, so just report a few times and then give up.
		 */ /* no polling for you */