/* Bind to an existing interdomain event channel in another domain. Returns 0 on success and stores the local port in *port. On error, returns -errno, switches the device to XenbusStateClosing, and saves the error in XenStore.  */
int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port)
/* Bind to an existing interdomain event channel in another domain. Returns 0 on success and stores the local port in *port. On error, returns -errno, switches the device to XenbusStateClosing, and saves the error in XenStore.  */
int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port)
{
	struct evtchn_bind_interdomain bind_interdomain;
	int err;
	bind_interdomain.remote_dom = dev->otherend_id;
	bind_interdomain.remote_port = remote_port;
	err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
					  &bind_interdomain);
	if (err)
		xenbus_dev_fatal(dev, err,
				 "binding to event channel %d from domain %d",
				 remote_port, dev->otherend_id);
	else
		*port = bind_interdomain.local_port;
	return err;
}