blob: 30f5691314718aae72ee8b42faa85271e9a97e25 [file] [log] [blame]
Greg Kroah-Hartman5fd54ac2017-11-03 11:28:30 +01001// SPDX-License-Identifier: GPL-2.0
Inaky Perez-Gonzalez90ff96f2008-09-17 16:34:23 +01002/*
3 * Wireless USB Host Controller
4 * UWB Protocol Adaptation Layer (PAL) glue.
5 *
6 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
Inaky Perez-Gonzalez90ff96f2008-09-17 16:34:23 +01007 */
8#include "wusbhc.h"
9
David Vrabel6fae35f2008-11-17 15:53:42 +000010static void wusbhc_channel_changed(struct uwb_pal *pal, int channel)
11{
12 struct wusbhc *wusbhc = container_of(pal, struct wusbhc, pal);
13
Thomas Puglieseb4a9dfb2013-12-20 11:45:02 -060014 dev_dbg(wusbhc->dev, "%s: channel = %d\n", __func__, channel);
David Vrabel6fae35f2008-11-17 15:53:42 +000015 if (channel < 0)
16 wusbhc_stop(wusbhc);
17 else
18 wusbhc_start(wusbhc);
19}
20
Inaky Perez-Gonzalez90ff96f2008-09-17 16:34:23 +010021/**
22 * wusbhc_pal_register - register the WUSB HC as a UWB PAL
23 * @wusbhc: the WUSB HC
24 */
25int wusbhc_pal_register(struct wusbhc *wusbhc)
26{
27 uwb_pal_init(&wusbhc->pal);
28
David Vrabelb60066c2008-09-17 16:34:40 +010029 wusbhc->pal.name = "wusbhc";
30 wusbhc->pal.device = wusbhc->usb_hcd.self.controller;
David Vrabel6fae35f2008-11-17 15:53:42 +000031 wusbhc->pal.rc = wusbhc->uwb_rc;
32 wusbhc->pal.channel_changed = wusbhc_channel_changed;
David Vrabelb60066c2008-09-17 16:34:40 +010033
David Vrabel6fae35f2008-11-17 15:53:42 +000034 return uwb_pal_register(&wusbhc->pal);
Inaky Perez-Gonzalez90ff96f2008-09-17 16:34:23 +010035}
36
37/**
Thomas Pugliesea8995752013-06-24 14:26:35 -050038 * wusbhc_pal_unregister - unregister the WUSB HC as a UWB PAL
Inaky Perez-Gonzalez90ff96f2008-09-17 16:34:23 +010039 * @wusbhc: the WUSB HC
40 */
41void wusbhc_pal_unregister(struct wusbhc *wusbhc)
42{
Thomas Pugliesea8995752013-06-24 14:26:35 -050043 if (wusbhc->uwb_rc)
44 uwb_pal_unregister(&wusbhc->pal);
Inaky Perez-Gonzalez90ff96f2008-09-17 16:34:23 +010045}