• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Ultra Wide Band
4  * IE Received notification handling.
5  *
6  * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
7  */
8 
9 #include <linux/errno.h>
10 #include <linux/module.h>
11 #include <linux/device.h>
12 #include <linux/bitmap.h>
13 #include "uwb-internal.h"
14 
15 /*
16  * Process an incoming IE Received notification.
17  */
uwbd_evt_handle_rc_ie_rcv(struct uwb_event * evt)18 int uwbd_evt_handle_rc_ie_rcv(struct uwb_event *evt)
19 {
20 	int result = -EINVAL;
21 	struct device *dev = &evt->rc->uwb_dev.dev;
22 	struct uwb_rc_evt_ie_rcv *iercv;
23 
24 	/* Is there enough data to decode it? */
25 	if (evt->notif.size < sizeof(*iercv)) {
26 		dev_err(dev, "IE Received notification: Not enough data to "
27 			"decode (%zu vs %zu bytes needed)\n",
28 			evt->notif.size, sizeof(*iercv));
29 		goto error;
30 	}
31 	iercv = container_of(evt->notif.rceb, struct uwb_rc_evt_ie_rcv, rceb);
32 
33 	dev_dbg(dev, "IE received, element ID=%d\n", iercv->IEData[0]);
34 
35 	if (iercv->IEData[0] == UWB_RELINQUISH_REQUEST_IE) {
36 		dev_warn(dev, "unhandled Relinquish Request IE\n");
37 	}
38 
39 	return 0;
40 error:
41 	return result;
42 }
43