pal.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Wireless USB Host Controller
  3. * UWB Protocol Adaptation Layer (PAL) glue.
  4. *
  5. * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License version
  9. * 2 as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "wusbhc.h"
  20. static void wusbhc_channel_changed(struct uwb_pal *pal, int channel)
  21. {
  22. struct wusbhc *wusbhc = container_of(pal, struct wusbhc, pal);
  23. dev_dbg(wusbhc->dev, "%s: channel = %d\n", __func__, channel);
  24. if (channel < 0)
  25. wusbhc_stop(wusbhc);
  26. else
  27. wusbhc_start(wusbhc);
  28. }
  29. /**
  30. * wusbhc_pal_register - register the WUSB HC as a UWB PAL
  31. * @wusbhc: the WUSB HC
  32. */
  33. int wusbhc_pal_register(struct wusbhc *wusbhc)
  34. {
  35. uwb_pal_init(&wusbhc->pal);
  36. wusbhc->pal.name = "wusbhc";
  37. wusbhc->pal.device = wusbhc->usb_hcd.self.controller;
  38. wusbhc->pal.rc = wusbhc->uwb_rc;
  39. wusbhc->pal.channel_changed = wusbhc_channel_changed;
  40. return uwb_pal_register(&wusbhc->pal);
  41. }
  42. /**
  43. * wusbhc_pal_unregister - unregister the WUSB HC as a UWB PAL
  44. * @wusbhc: the WUSB HC
  45. */
  46. void wusbhc_pal_unregister(struct wusbhc *wusbhc)
  47. {
  48. if (wusbhc->uwb_rc)
  49. uwb_pal_unregister(&wusbhc->pal);
  50. }