/* Depending on the previous state of the MMCs, start, stop or change the sent MMC. This effectively switches the host controller on and off (radio wise).  */
int wusbhc_chid_set(struct wusbhc *wusbhc, const struct wusb_ckhdid *chid)
/* Depending on the previous state of the MMCs, start, stop or change the sent MMC. This effectively switches the host controller on and off (radio wise).  */
int wusbhc_chid_set(struct wusbhc *wusbhc, const struct wusb_ckhdid *chid)
{
	int result = 0;
	if (memcmp(chid, &wusb_ckhdid_zero, sizeof(chid)) == 0)
		chid = NULL;
	mutex_lock(&wusbhc->mutex);
	if (chid) {
		if (wusbhc->active) {
			mutex_unlock(&wusbhc->mutex);
			return -EBUSY;
		}
		wusbhc->chid = *chid;
	}
	mutex_unlock(&wusbhc->mutex);
	if (chid)
		result = uwb_radio_start(&wusbhc->pal);
	else
		uwb_radio_stop(&wusbhc->pal);
	return result;
}