blob: 6e47b055ad4748c9d9715ed0b9316b9fd533921e [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.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20#include "wusbhc.h"
21
David Vrabel6fae35f2008-11-17 15:53:42 +000022static void wusbhc_channel_changed(struct uwb_pal *pal, int channel)
23{
24 struct wusbhc *wusbhc = container_of(pal, struct wusbhc, pal);
25
Thomas Puglieseb4a9dfb2013-12-20 11:45:02 -060026 dev_dbg(wusbhc->dev, "%s: channel = %d\n", __func__, channel);
David Vrabel6fae35f2008-11-17 15:53:42 +000027 if (channel < 0)
28 wusbhc_stop(wusbhc);
29 else
30 wusbhc_start(wusbhc);
31}
32
Inaky Perez-Gonzalez90ff96f2008-09-17 16:34:23 +010033/**
34 * wusbhc_pal_register - register the WUSB HC as a UWB PAL
35 * @wusbhc: the WUSB HC
36 */
37int wusbhc_pal_register(struct wusbhc *wusbhc)
38{
39 uwb_pal_init(&wusbhc->pal);
40
David Vrabelb60066c2008-09-17 16:34:40 +010041 wusbhc->pal.name = "wusbhc";
42 wusbhc->pal.device = wusbhc->usb_hcd.self.controller;
David Vrabel6fae35f2008-11-17 15:53:42 +000043 wusbhc->pal.rc = wusbhc->uwb_rc;
44 wusbhc->pal.channel_changed = wusbhc_channel_changed;
David Vrabelb60066c2008-09-17 16:34:40 +010045
David Vrabel6fae35f2008-11-17 15:53:42 +000046 return uwb_pal_register(&wusbhc->pal);
Inaky Perez-Gonzalez90ff96f2008-09-17 16:34:23 +010047}
48
49/**
Thomas Pugliesea8995752013-06-24 14:26:35 -050050 * wusbhc_pal_unregister - unregister the WUSB HC as a UWB PAL
Inaky Perez-Gonzalez90ff96f2008-09-17 16:34:23 +010051 * @wusbhc: the WUSB HC
52 */
53void wusbhc_pal_unregister(struct wusbhc *wusbhc)
54{
Thomas Pugliesea8995752013-06-24 14:26:35 -050055 if (wusbhc->uwb_rc)
56 uwb_pal_unregister(&wusbhc->pal);
Inaky Perez-Gonzalez90ff96f2008-09-17 16:34:23 +010057}