blob: 51a4706e0dd36d145db6389b4ad21eaffe8d1a9f [file] [log] [blame]
Thomas Gleixnercaab2772019-06-03 07:44:50 +02001// SPDX-License-Identifier: GPL-2.0-only
Stefano Panellac5995bd2008-11-04 14:06:31 +00002/*
3 * Ultra Wide Band
4 * IE Received notification handling.
5 *
6 * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
Stefano Panellac5995bd2008-11-04 14:06:31 +00007 */
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 */
18int 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;
Stefano Panellac5995bd2008-11-04 14:06:31 +000023
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);
Stefano Panellac5995bd2008-11-04 14:06:31 +000032
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;
40error:
41 return result;
42}