/* If the handler pointer is NULL the current listener (if any) is unregistered. Otherwise the new listener is registered provided there is no existing listener registered.  */
int iop_listen(uint iop_num, uint chan, void(*handler)(struct iop_msg *), const char *devname)
/* If the handler pointer is NULL the current listener (if any) is unregistered. Otherwise the new listener is registered provided there is no existing listener registered.  */
int iop_listen(uint iop_num, uint chan, void(*handler)(struct iop_msg *), const char *devname)
{
	if ((iop_num >= NUM_IOPS) || !iop_base[iop_num]) return -EINVAL;
	if (chan >= NUM_IOP_CHAN) return -EINVAL;
	if (iop_listeners[iop_num][chan].handler && handler) return -EINVAL;
	iop_listeners[iop_num][chan].devname = devname;
	iop_listeners[iop_num][chan].handler = handler;
	return 0;
}