neh.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. /*
  2. * WUSB Wire Adapter: Radio Control Interface (WUSB[8])
  3. * Notification and Event Handling
  4. *
  5. * Copyright (C) 2005-2006 Intel Corporation
  6. * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
  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, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  20. * 02110-1301, USA.
  21. *
  22. *
  23. * The RC interface of the Host Wire Adapter (USB dongle) or WHCI PCI
  24. * card delivers a stream of notifications and events to the
  25. * notification end event endpoint or area. This code takes care of
  26. * getting a buffer with that data, breaking it up in separate
  27. * notifications and events and then deliver those.
  28. *
  29. * Events are answers to commands and they carry a context ID that
  30. * associates them to the command. Notifications are that,
  31. * notifications, they come out of the blue and have a context ID of
  32. * zero. Think of the context ID kind of like a handler. The
  33. * uwb_rc_neh_* code deals with managing context IDs.
  34. *
  35. * This is why you require a handle to operate on a UWB host. When you
  36. * open a handle a context ID is assigned to you.
  37. *
  38. * So, as it is done is:
  39. *
  40. * 1. Add an event handler [uwb_rc_neh_add()] (assigns a ctx id)
  41. * 2. Issue command [rc->cmd(rc, ...)]
  42. * 3. Arm the timeout timer [uwb_rc_neh_arm()]
  43. * 4, Release the reference to the neh [uwb_rc_neh_put()]
  44. * 5. Wait for the callback
  45. * 6. Command result (RCEB) is passed to the callback
  46. *
  47. * If (2) fails, you should remove the handle [uwb_rc_neh_rm()]
  48. * instead of arming the timer.
  49. *
  50. * Handles are for using in *serialized* code, single thread.
  51. *
  52. * When the notification/event comes, the IRQ handler/endpoint
  53. * callback passes the data read to uwb_rc_neh_grok() which will break
  54. * it up in a discrete series of events, look up who is listening for
  55. * them and execute the pertinent callbacks.
  56. *
  57. * If the reader detects an error while reading the data stream, call
  58. * uwb_rc_neh_error().
  59. *
  60. * CONSTRAINTS/ASSUMPTIONS:
  61. *
  62. * - Most notifications/events are small (less thank .5k), copying
  63. * around is ok.
  64. *
  65. * - Notifications/events are ALWAYS smaller than PAGE_SIZE
  66. *
  67. * - Notifications/events always come in a single piece (ie: a buffer
  68. * will always contain entire notifications/events).
  69. *
  70. * - we cannot know in advance how long each event is (because they
  71. * lack a length field in their header--smart move by the standards
  72. * body, btw). So we need a facility to get the event size given the
  73. * header. This is what the EST code does (notif/Event Size
  74. * Tables), check nest.c--as well, you can associate the size to
  75. * the handle [w/ neh->extra_size()].
  76. *
  77. * - Most notifications/events are fixed size; only a few are variable
  78. * size (NEST takes care of that).
  79. *
  80. * - Listeners of events expect them, so they usually provide a
  81. * buffer, as they know the size. Listeners to notifications don't,
  82. * so we allocate their buffers dynamically.
  83. */
  84. #include <linux/kernel.h>
  85. #include <linux/timer.h>
  86. #include <linux/err.h>
  87. #include "uwb-internal.h"
  88. #define D_LOCAL 0
  89. #include <linux/uwb/debug.h>
  90. /*
  91. * UWB Radio Controller Notification/Event Handle
  92. *
  93. * Represents an entity waiting for an event coming from the UWB Radio
  94. * Controller with a given context id (context) and type (evt_type and
  95. * evt). On reception of the notification/event, the callback (cb) is
  96. * called with the event.
  97. *
  98. * If the timer expires before the event is received, the callback is
  99. * called with -ETIMEDOUT as the event size.
  100. */
  101. struct uwb_rc_neh {
  102. struct kref kref;
  103. struct uwb_rc *rc;
  104. u8 evt_type;
  105. __le16 evt;
  106. u8 context;
  107. uwb_rc_cmd_cb_f cb;
  108. void *arg;
  109. struct timer_list timer;
  110. struct list_head list_node;
  111. };
  112. static void uwb_rc_neh_timer(unsigned long arg);
  113. static void uwb_rc_neh_release(struct kref *kref)
  114. {
  115. struct uwb_rc_neh *neh = container_of(kref, struct uwb_rc_neh, kref);
  116. kfree(neh);
  117. }
  118. static void uwb_rc_neh_get(struct uwb_rc_neh *neh)
  119. {
  120. kref_get(&neh->kref);
  121. }
  122. /**
  123. * uwb_rc_neh_put - release reference to a neh
  124. * @neh: the neh
  125. */
  126. void uwb_rc_neh_put(struct uwb_rc_neh *neh)
  127. {
  128. kref_put(&neh->kref, uwb_rc_neh_release);
  129. }
  130. /**
  131. * Assigns @neh a context id from @rc's pool
  132. *
  133. * @rc: UWB Radio Controller descriptor; @rc->neh_lock taken
  134. * @neh: Notification/Event Handle
  135. * @returns 0 if context id was assigned ok; < 0 errno on error (if
  136. * all the context IDs are taken).
  137. *
  138. * (assumes @wa is locked).
  139. *
  140. * NOTE: WUSB spec reserves context ids 0x00 for notifications and
  141. * 0xff is invalid, so they must not be used. Initialization
  142. * fills up those two in the bitmap so they are not allocated.
  143. *
  144. * We spread the allocation around to reduce the posiblity of two
  145. * consecutive opened @neh's getting the same context ID assigned (to
  146. * avoid surprises with late events that timed out long time ago). So
  147. * first we search from where @rc->ctx_roll is, if not found, we
  148. * search from zero.
  149. */
  150. static
  151. int __uwb_rc_ctx_get(struct uwb_rc *rc, struct uwb_rc_neh *neh)
  152. {
  153. int result;
  154. result = find_next_zero_bit(rc->ctx_bm, UWB_RC_CTX_MAX,
  155. rc->ctx_roll++);
  156. if (result < UWB_RC_CTX_MAX)
  157. goto found;
  158. result = find_first_zero_bit(rc->ctx_bm, UWB_RC_CTX_MAX);
  159. if (result < UWB_RC_CTX_MAX)
  160. goto found;
  161. return -ENFILE;
  162. found:
  163. set_bit(result, rc->ctx_bm);
  164. neh->context = result;
  165. return 0;
  166. }
  167. /** Releases @neh's context ID back to @rc (@rc->neh_lock is locked). */
  168. static
  169. void __uwb_rc_ctx_put(struct uwb_rc *rc, struct uwb_rc_neh *neh)
  170. {
  171. struct device *dev = &rc->uwb_dev.dev;
  172. if (neh->context == 0)
  173. return;
  174. if (test_bit(neh->context, rc->ctx_bm) == 0) {
  175. dev_err(dev, "context %u not set in bitmap\n",
  176. neh->context);
  177. WARN_ON(1);
  178. }
  179. clear_bit(neh->context, rc->ctx_bm);
  180. neh->context = 0;
  181. }
  182. /**
  183. * uwb_rc_neh_add - add a neh for a radio controller command
  184. * @rc: the radio controller
  185. * @cmd: the radio controller command
  186. * @expected_type: the type of the expected response event
  187. * @expected_event: the expected event ID
  188. * @cb: callback for when the event is received
  189. * @arg: argument for the callback
  190. *
  191. * Creates a neh and adds it to the list of those waiting for an
  192. * event. A context ID will be assigned to the command.
  193. */
  194. struct uwb_rc_neh *uwb_rc_neh_add(struct uwb_rc *rc, struct uwb_rccb *cmd,
  195. u8 expected_type, u16 expected_event,
  196. uwb_rc_cmd_cb_f cb, void *arg)
  197. {
  198. int result;
  199. unsigned long flags;
  200. struct device *dev = &rc->uwb_dev.dev;
  201. struct uwb_rc_neh *neh;
  202. neh = kzalloc(sizeof(*neh), GFP_KERNEL);
  203. if (neh == NULL) {
  204. result = -ENOMEM;
  205. goto error_kzalloc;
  206. }
  207. kref_init(&neh->kref);
  208. INIT_LIST_HEAD(&neh->list_node);
  209. init_timer(&neh->timer);
  210. neh->timer.function = uwb_rc_neh_timer;
  211. neh->timer.data = (unsigned long)neh;
  212. neh->rc = rc;
  213. neh->evt_type = expected_type;
  214. neh->evt = cpu_to_le16(expected_event);
  215. neh->cb = cb;
  216. neh->arg = arg;
  217. spin_lock_irqsave(&rc->neh_lock, flags);
  218. result = __uwb_rc_ctx_get(rc, neh);
  219. if (result >= 0) {
  220. cmd->bCommandContext = neh->context;
  221. list_add_tail(&neh->list_node, &rc->neh_list);
  222. uwb_rc_neh_get(neh);
  223. }
  224. spin_unlock_irqrestore(&rc->neh_lock, flags);
  225. if (result < 0)
  226. goto error_ctx_get;
  227. return neh;
  228. error_ctx_get:
  229. kfree(neh);
  230. error_kzalloc:
  231. dev_err(dev, "cannot open handle to radio controller: %d\n", result);
  232. return ERR_PTR(result);
  233. }
  234. static void __uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh)
  235. {
  236. del_timer(&neh->timer);
  237. __uwb_rc_ctx_put(rc, neh);
  238. list_del(&neh->list_node);
  239. }
  240. /**
  241. * uwb_rc_neh_rm - remove a neh.
  242. * @rc: the radio controller
  243. * @neh: the neh to remove
  244. *
  245. * Remove an active neh immediately instead of waiting for the event
  246. * (or a time out).
  247. */
  248. void uwb_rc_neh_rm(struct uwb_rc *rc, struct uwb_rc_neh *neh)
  249. {
  250. unsigned long flags;
  251. spin_lock_irqsave(&rc->neh_lock, flags);
  252. __uwb_rc_neh_rm(rc, neh);
  253. spin_unlock_irqrestore(&rc->neh_lock, flags);
  254. uwb_rc_neh_put(neh);
  255. }
  256. /**
  257. * uwb_rc_neh_arm - arm an event handler timeout timer
  258. *
  259. * @rc: UWB Radio Controller
  260. * @neh: Notification/event handler for @rc
  261. *
  262. * The timer is only armed if the neh is active.
  263. */
  264. void uwb_rc_neh_arm(struct uwb_rc *rc, struct uwb_rc_neh *neh)
  265. {
  266. unsigned long flags;
  267. spin_lock_irqsave(&rc->neh_lock, flags);
  268. if (neh->context)
  269. mod_timer(&neh->timer,
  270. jiffies + msecs_to_jiffies(UWB_RC_CMD_TIMEOUT_MS));
  271. spin_unlock_irqrestore(&rc->neh_lock, flags);
  272. }
  273. static void uwb_rc_neh_cb(struct uwb_rc_neh *neh, struct uwb_rceb *rceb, size_t size)
  274. {
  275. (*neh->cb)(neh->rc, neh->arg, rceb, size);
  276. uwb_rc_neh_put(neh);
  277. }
  278. static bool uwb_rc_neh_match(struct uwb_rc_neh *neh, const struct uwb_rceb *rceb)
  279. {
  280. return neh->evt_type == rceb->bEventType
  281. && neh->evt == rceb->wEvent
  282. && neh->context == rceb->bEventContext;
  283. }
  284. /**
  285. * Find the handle waiting for a RC Radio Control Event
  286. *
  287. * @rc: UWB Radio Controller
  288. * @rceb: Pointer to the RCEB buffer
  289. * @event_size: Pointer to the size of the RCEB buffer. Might be
  290. * adjusted to take into account the @neh->extra_size
  291. * settings.
  292. *
  293. * If the listener has no buffer (NULL buffer), one is allocated for
  294. * the right size (the amount of data received). @neh->ptr will point
  295. * to the event payload, which always starts with a 'struct
  296. * uwb_rceb'. kfree() it when done.
  297. */
  298. static
  299. struct uwb_rc_neh *uwb_rc_neh_lookup(struct uwb_rc *rc,
  300. const struct uwb_rceb *rceb)
  301. {
  302. struct uwb_rc_neh *neh = NULL, *h;
  303. unsigned long flags;
  304. spin_lock_irqsave(&rc->neh_lock, flags);
  305. list_for_each_entry(h, &rc->neh_list, list_node) {
  306. if (uwb_rc_neh_match(h, rceb)) {
  307. neh = h;
  308. break;
  309. }
  310. }
  311. if (neh)
  312. __uwb_rc_neh_rm(rc, neh);
  313. spin_unlock_irqrestore(&rc->neh_lock, flags);
  314. return neh;
  315. }
  316. /**
  317. * Process notifications coming from the radio control interface
  318. *
  319. * @rc: UWB Radio Control Interface descriptor
  320. * @neh: Notification/Event Handler @neh->ptr points to
  321. * @uwb_evt->buffer.
  322. *
  323. * This function is called by the event/notif handling subsystem when
  324. * notifications arrive (hwarc_probe() arms a notification/event handle
  325. * that calls back this function for every received notification; this
  326. * function then will rearm itself).
  327. *
  328. * Notification data buffers are dynamically allocated by the NEH
  329. * handling code in neh.c [uwb_rc_neh_lookup()]. What is actually
  330. * allocated is space to contain the notification data.
  331. *
  332. * Buffers are prefixed with a Radio Control Event Block (RCEB) as
  333. * defined by the WUSB Wired-Adapter Radio Control interface. We
  334. * just use it for the notification code.
  335. *
  336. * On each case statement we just transcode endianess of the different
  337. * fields. We declare a pointer to a RCI definition of an event, and
  338. * then to a UWB definition of the same event (which are the same,
  339. * remember). Event if we use different pointers
  340. */
  341. static
  342. void uwb_rc_notif(struct uwb_rc *rc, struct uwb_rceb *rceb, ssize_t size)
  343. {
  344. struct device *dev = &rc->uwb_dev.dev;
  345. struct uwb_event *uwb_evt;
  346. if (size == -ESHUTDOWN)
  347. return;
  348. if (size < 0) {
  349. dev_err(dev, "ignoring event with error code %zu\n",
  350. size);
  351. return;
  352. }
  353. uwb_evt = kzalloc(sizeof(*uwb_evt), GFP_ATOMIC);
  354. if (unlikely(uwb_evt == NULL)) {
  355. dev_err(dev, "no memory to queue event 0x%02x/%04x/%02x\n",
  356. rceb->bEventType, le16_to_cpu(rceb->wEvent),
  357. rceb->bEventContext);
  358. return;
  359. }
  360. uwb_evt->rc = __uwb_rc_get(rc); /* will be put by uwbd's uwbd_event_handle() */
  361. uwb_evt->ts_jiffies = jiffies;
  362. uwb_evt->type = UWB_EVT_TYPE_NOTIF;
  363. uwb_evt->notif.size = size;
  364. uwb_evt->notif.rceb = rceb;
  365. switch (le16_to_cpu(rceb->wEvent)) {
  366. /* Trap some vendor specific events
  367. *
  368. * FIXME: move this to handling in ptc-est, where we
  369. * register a NULL event handler for these two guys
  370. * using the Intel IDs.
  371. */
  372. case 0x0103:
  373. dev_info(dev, "FIXME: DEVICE ADD\n");
  374. return;
  375. case 0x0104:
  376. dev_info(dev, "FIXME: DEVICE RM\n");
  377. return;
  378. default:
  379. break;
  380. }
  381. uwbd_event_queue(uwb_evt);
  382. }
  383. static void uwb_rc_neh_grok_event(struct uwb_rc *rc, struct uwb_rceb *rceb, size_t size)
  384. {
  385. struct device *dev = &rc->uwb_dev.dev;
  386. struct uwb_rc_neh *neh;
  387. struct uwb_rceb *notif;
  388. if (rceb->bEventContext == 0) {
  389. notif = kmalloc(size, GFP_ATOMIC);
  390. if (notif) {
  391. memcpy(notif, rceb, size);
  392. uwb_rc_notif(rc, notif, size);
  393. } else
  394. dev_err(dev, "event 0x%02x/%04x/%02x (%zu bytes): no memory\n",
  395. rceb->bEventType, le16_to_cpu(rceb->wEvent),
  396. rceb->bEventContext, size);
  397. } else {
  398. neh = uwb_rc_neh_lookup(rc, rceb);
  399. if (neh)
  400. uwb_rc_neh_cb(neh, rceb, size);
  401. else
  402. dev_warn(dev, "event 0x%02x/%04x/%02x (%zu bytes): nobody cared\n",
  403. rceb->bEventType, le16_to_cpu(rceb->wEvent),
  404. rceb->bEventContext, size);
  405. }
  406. }
  407. /**
  408. * Given a buffer with one or more UWB RC events/notifications, break
  409. * them up and dispatch them.
  410. *
  411. * @rc: UWB Radio Controller
  412. * @buf: Buffer with the stream of notifications/events
  413. * @buf_size: Amount of data in the buffer
  414. *
  415. * Note each notification/event starts always with a 'struct
  416. * uwb_rceb', so the minimum size if 4 bytes.
  417. *
  418. * The device may pass us events formatted differently than expected.
  419. * These are first filtered, potentially creating a new event in a new
  420. * memory location. If a new event is created by the filter it is also
  421. * freed here.
  422. *
  423. * For each notif/event, tries to guess the size looking at the EST
  424. * tables, then looks for a neh that is waiting for that event and if
  425. * found, copies the payload to the neh's buffer and calls it back. If
  426. * not, the data is ignored.
  427. *
  428. * Note that if we can't find a size description in the EST tables, we
  429. * still might find a size in the 'neh' handle in uwb_rc_neh_lookup().
  430. *
  431. * Assumptions:
  432. *
  433. * @rc->neh_lock is NOT taken
  434. *
  435. * We keep track of various sizes here:
  436. * size: contains the size of the buffer that is processed for the
  437. * incoming event. this buffer may contain events that are not
  438. * formatted as WHCI.
  439. * real_size: the actual space taken by this event in the buffer.
  440. * We need to keep track of the real size of an event to be able to
  441. * advance the buffer correctly.
  442. * event_size: the size of the event as expected by the core layer
  443. * [OR] the size of the event after filtering. if the filtering
  444. * created a new event in a new memory location then this is
  445. * effectively the size of a new event buffer
  446. */
  447. void uwb_rc_neh_grok(struct uwb_rc *rc, void *buf, size_t buf_size)
  448. {
  449. struct device *dev = &rc->uwb_dev.dev;
  450. void *itr;
  451. struct uwb_rceb *rceb;
  452. size_t size, real_size, event_size;
  453. int needtofree;
  454. d_fnstart(3, dev, "(rc %p buf %p %zu buf_size)\n", rc, buf, buf_size);
  455. d_printf(2, dev, "groking event block: %zu bytes\n", buf_size);
  456. itr = buf;
  457. size = buf_size;
  458. while (size > 0) {
  459. if (size < sizeof(*rceb)) {
  460. dev_err(dev, "not enough data in event buffer to "
  461. "process incoming events (%zu left, minimum is "
  462. "%zu)\n", size, sizeof(*rceb));
  463. break;
  464. }
  465. rceb = itr;
  466. if (rc->filter_event) {
  467. needtofree = rc->filter_event(rc, &rceb, size,
  468. &real_size, &event_size);
  469. if (needtofree < 0 && needtofree != -ENOANO) {
  470. dev_err(dev, "BUG: Unable to filter event "
  471. "(0x%02x/%04x/%02x) from "
  472. "device. \n", rceb->bEventType,
  473. le16_to_cpu(rceb->wEvent),
  474. rceb->bEventContext);
  475. break;
  476. }
  477. } else
  478. needtofree = -ENOANO;
  479. /* do real processing if there was no filtering or the
  480. * filtering didn't act */
  481. if (needtofree == -ENOANO) {
  482. ssize_t ret = uwb_est_find_size(rc, rceb, size);
  483. if (ret < 0)
  484. break;
  485. if (ret > size) {
  486. dev_err(dev, "BUG: hw sent incomplete event "
  487. "0x%02x/%04x/%02x (%zd bytes), only got "
  488. "%zu bytes. We don't handle that.\n",
  489. rceb->bEventType, le16_to_cpu(rceb->wEvent),
  490. rceb->bEventContext, ret, size);
  491. break;
  492. }
  493. real_size = event_size = ret;
  494. }
  495. uwb_rc_neh_grok_event(rc, rceb, event_size);
  496. if (needtofree == 1)
  497. kfree(rceb);
  498. itr += real_size;
  499. size -= real_size;
  500. d_printf(2, dev, "consumed %zd bytes, %zu left\n",
  501. event_size, size);
  502. }
  503. d_fnend(3, dev, "(rc %p buf %p %zu buf_size) = void\n", rc, buf, buf_size);
  504. }
  505. EXPORT_SYMBOL_GPL(uwb_rc_neh_grok);
  506. /**
  507. * The entity that reads from the device notification/event channel has
  508. * detected an error.
  509. *
  510. * @rc: UWB Radio Controller
  511. * @error: Errno error code
  512. *
  513. */
  514. void uwb_rc_neh_error(struct uwb_rc *rc, int error)
  515. {
  516. struct uwb_rc_neh *neh, *next;
  517. unsigned long flags;
  518. BUG_ON(error >= 0);
  519. spin_lock_irqsave(&rc->neh_lock, flags);
  520. list_for_each_entry_safe(neh, next, &rc->neh_list, list_node) {
  521. __uwb_rc_neh_rm(rc, neh);
  522. uwb_rc_neh_cb(neh, NULL, error);
  523. }
  524. spin_unlock_irqrestore(&rc->neh_lock, flags);
  525. }
  526. EXPORT_SYMBOL_GPL(uwb_rc_neh_error);
  527. static void uwb_rc_neh_timer(unsigned long arg)
  528. {
  529. struct uwb_rc_neh *neh = (struct uwb_rc_neh *)arg;
  530. struct uwb_rc *rc = neh->rc;
  531. unsigned long flags;
  532. spin_lock_irqsave(&rc->neh_lock, flags);
  533. __uwb_rc_neh_rm(rc, neh);
  534. spin_unlock_irqrestore(&rc->neh_lock, flags);
  535. uwb_rc_neh_cb(neh, NULL, -ETIMEDOUT);
  536. }
  537. /** Initializes the @rc's neh subsystem
  538. */
  539. void uwb_rc_neh_create(struct uwb_rc *rc)
  540. {
  541. spin_lock_init(&rc->neh_lock);
  542. INIT_LIST_HEAD(&rc->neh_list);
  543. set_bit(0, rc->ctx_bm); /* 0 is reserved (see [WUSB] table 8-65) */
  544. set_bit(0xff, rc->ctx_bm); /* and 0xff is invalid */
  545. rc->ctx_roll = 1;
  546. }
  547. /** Release's the @rc's neh subsystem */
  548. void uwb_rc_neh_destroy(struct uwb_rc *rc)
  549. {
  550. unsigned long flags;
  551. struct uwb_rc_neh *neh, *next;
  552. spin_lock_irqsave(&rc->neh_lock, flags);
  553. list_for_each_entry_safe(neh, next, &rc->neh_list, list_node) {
  554. __uwb_rc_neh_rm(rc, neh);
  555. uwb_rc_neh_put(neh);
  556. }
  557. spin_unlock_irqrestore(&rc->neh_lock, flags);
  558. }