]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - drivers/uwb/rsv.c
uwb: target reservations shouldn't get streams
[linux-2.6.git] / drivers / uwb / rsv.c
1 /*
2  * UWB reservation management.
3  *
4  * Copyright (C) 2008 Cambridge Silicon Radio Ltd.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License version
8  * 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 #include <linux/version.h>
19 #include <linux/kernel.h>
20 #include <linux/uwb.h>
21
22 #include "uwb-internal.h"
23
24 static void uwb_rsv_timer(unsigned long arg);
25
26 static const char *rsv_states[] = {
27         [UWB_RSV_STATE_NONE]          = "none",
28         [UWB_RSV_STATE_O_INITIATED]   = "initiated",
29         [UWB_RSV_STATE_O_PENDING]     = "pending",
30         [UWB_RSV_STATE_O_MODIFIED]    = "modified",
31         [UWB_RSV_STATE_O_ESTABLISHED] = "established",
32         [UWB_RSV_STATE_T_ACCEPTED]    = "accepted",
33         [UWB_RSV_STATE_T_DENIED]      = "denied",
34         [UWB_RSV_STATE_T_PENDING]     = "pending",
35 };
36
37 static const char *rsv_types[] = {
38         [UWB_DRP_TYPE_ALIEN_BP] = "alien-bp",
39         [UWB_DRP_TYPE_HARD]     = "hard",
40         [UWB_DRP_TYPE_SOFT]     = "soft",
41         [UWB_DRP_TYPE_PRIVATE]  = "private",
42         [UWB_DRP_TYPE_PCA]      = "pca",
43 };
44
45 /**
46  * uwb_rsv_state_str - return a string for a reservation state
47  * @state: the reservation state.
48  */
49 const char *uwb_rsv_state_str(enum uwb_rsv_state state)
50 {
51         if (state < UWB_RSV_STATE_NONE || state >= UWB_RSV_STATE_LAST)
52                 return "unknown";
53         return rsv_states[state];
54 }
55 EXPORT_SYMBOL_GPL(uwb_rsv_state_str);
56
57 /**
58  * uwb_rsv_type_str - return a string for a reservation type
59  * @type: the reservation type
60  */
61 const char *uwb_rsv_type_str(enum uwb_drp_type type)
62 {
63         if (type < UWB_DRP_TYPE_ALIEN_BP || type > UWB_DRP_TYPE_PCA)
64                 return "invalid";
65         return rsv_types[type];
66 }
67 EXPORT_SYMBOL_GPL(uwb_rsv_type_str);
68
69 static void uwb_rsv_dump(struct uwb_rsv *rsv)
70 {
71         struct device *dev = &rsv->rc->uwb_dev.dev;
72         struct uwb_dev_addr devaddr;
73         char owner[UWB_ADDR_STRSIZE], target[UWB_ADDR_STRSIZE];
74
75         uwb_dev_addr_print(owner, sizeof(owner), &rsv->owner->dev_addr);
76         if (rsv->target.type == UWB_RSV_TARGET_DEV)
77                 devaddr = rsv->target.dev->dev_addr;
78         else
79                 devaddr = rsv->target.devaddr;
80         uwb_dev_addr_print(target, sizeof(target), &devaddr);
81
82         dev_dbg(dev, "rsv %s -> %s: %s\n", owner, target, uwb_rsv_state_str(rsv->state));
83 }
84
85 /*
86  * Get a free stream index for a reservation.
87  *
88  * If the target is a DevAddr (e.g., a WUSB cluster reservation) then
89  * the stream is allocated from a pool of per-RC stream indexes,
90  * otherwise a unique stream index for the target is selected.
91  */
92 static int uwb_rsv_get_stream(struct uwb_rsv *rsv)
93 {
94         struct uwb_rc *rc = rsv->rc;
95         unsigned long *streams_bm;
96         int stream;
97
98         switch (rsv->target.type) {
99         case UWB_RSV_TARGET_DEV:
100                 streams_bm = rsv->target.dev->streams;
101                 break;
102         case UWB_RSV_TARGET_DEVADDR:
103                 streams_bm = rc->uwb_dev.streams;
104                 break;
105         default:
106                 return -EINVAL;
107         }
108
109         stream = find_first_zero_bit(streams_bm, UWB_NUM_STREAMS);
110         if (stream >= UWB_NUM_STREAMS)
111                 return -EBUSY;
112
113         rsv->stream = stream;
114         set_bit(stream, streams_bm);
115
116         return 0;
117 }
118
119 static void uwb_rsv_put_stream(struct uwb_rsv *rsv)
120 {
121         struct uwb_rc *rc = rsv->rc;
122         unsigned long *streams_bm;
123
124         switch (rsv->target.type) {
125         case UWB_RSV_TARGET_DEV:
126                 streams_bm = rsv->target.dev->streams;
127                 break;
128         case UWB_RSV_TARGET_DEVADDR:
129                 streams_bm = rc->uwb_dev.streams;
130                 break;
131         default:
132                 return;
133         }
134
135         clear_bit(rsv->stream, streams_bm);
136 }
137
138 /*
139  * Generate a MAS allocation with a single row component.
140  */
141 static void uwb_rsv_gen_alloc_row(struct uwb_mas_bm *mas,
142                                   int first_mas, int mas_per_zone,
143                                   int zs, int ze)
144 {
145         struct uwb_mas_bm col;
146         int z;
147
148         bitmap_zero(mas->bm, UWB_NUM_MAS);
149         bitmap_zero(col.bm, UWB_NUM_MAS);
150         bitmap_fill(col.bm, mas_per_zone);
151         bitmap_shift_left(col.bm, col.bm, first_mas + zs * UWB_MAS_PER_ZONE, UWB_NUM_MAS);
152
153         for (z = zs; z <= ze; z++) {
154                 bitmap_or(mas->bm, mas->bm, col.bm, UWB_NUM_MAS);
155                 bitmap_shift_left(col.bm, col.bm, UWB_MAS_PER_ZONE, UWB_NUM_MAS);
156         }
157 }
158
159 /*
160  * Allocate some MAS for this reservation based on current local
161  * availability, the reservation parameters (max_mas, min_mas,
162  * sparsity), and the WiMedia rules for MAS allocations.
163  *
164  * Returns -EBUSY is insufficient free MAS are available.
165  *
166  * FIXME: to simplify this, only safe reservations with a single row
167  * component in zones 1 to 15 are tried (zone 0 is skipped to avoid
168  * problems with the MAS reserved for the BP).
169  *
170  * [ECMA-368] section B.2.
171  */
172 static int uwb_rsv_alloc_mas(struct uwb_rsv *rsv)
173 {
174         static const int safe_mas_in_row[UWB_NUM_ZONES] = {
175                 8, 7, 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1,
176         };
177         int n, r;
178         struct uwb_mas_bm mas;
179         bool found = false;
180
181         /*
182          * Search all valid safe allocations until either: too few MAS
183          * are available; or the smallest allocation with sufficient
184          * MAS is found.
185          *
186          * The top of the zones are preferred, so space for larger
187          * allocations is available in the bottom of the zone (e.g., a
188          * 15 MAS allocation should start in row 14 leaving space for
189          * a 120 MAS allocation at row 0).
190          */
191         for (n = safe_mas_in_row[0]; n >= 1; n--) {
192                 int num_mas;
193
194                 num_mas = n * (UWB_NUM_ZONES - 1);
195                 if (num_mas < rsv->min_mas)
196                         break;
197                 if (found && num_mas < rsv->max_mas)
198                         break;
199
200                 for (r = UWB_MAS_PER_ZONE-1;  r >= 0; r--) {
201                         if (safe_mas_in_row[r] < n)
202                                 continue;
203                         uwb_rsv_gen_alloc_row(&mas, r, n, 1, UWB_NUM_ZONES);
204                         if (uwb_drp_avail_reserve_pending(rsv->rc, &mas) == 0) {
205                                 found = true;
206                                 break;
207                         }
208                 }
209         }
210
211         if (!found)
212                 return -EBUSY;
213
214         bitmap_copy(rsv->mas.bm, mas.bm, UWB_NUM_MAS);
215         return 0;
216 }
217
218 static void uwb_rsv_stroke_timer(struct uwb_rsv *rsv)
219 {
220         int sframes = UWB_MAX_LOST_BEACONS;
221
222         /*
223          * Multicast reservations can become established within 1
224          * super frame and should not be terminated if no response is
225          * received.
226          */
227         if (rsv->is_multicast) {
228                 if (rsv->state == UWB_RSV_STATE_O_INITIATED)
229                         sframes = 1;
230                 if (rsv->state == UWB_RSV_STATE_O_ESTABLISHED)
231                         sframes = 0;
232         }
233
234         rsv->expired = false;
235         if (sframes > 0) {
236                 /*
237                  * Add an additional 2 superframes to account for the
238                  * time to send the SET DRP IE command.
239                  */
240                 unsigned timeout_us = (sframes + 2) * UWB_SUPERFRAME_LENGTH_US;
241                 mod_timer(&rsv->timer, jiffies + usecs_to_jiffies(timeout_us));
242         } else
243                 del_timer(&rsv->timer);
244 }
245
246 /*
247  * Update a reservations state, and schedule an update of the
248  * transmitted DRP IEs.
249  */
250 static void uwb_rsv_state_update(struct uwb_rsv *rsv,
251                                  enum uwb_rsv_state new_state)
252 {
253         rsv->state = new_state;
254         rsv->ie_valid = false;
255
256         uwb_rsv_dump(rsv);
257
258         uwb_rsv_stroke_timer(rsv);
259         uwb_rsv_sched_update(rsv->rc);
260 }
261
262 static void uwb_rsv_callback(struct uwb_rsv *rsv)
263 {
264         if (rsv->callback)
265                 rsv->callback(rsv);
266 }
267
268 void uwb_rsv_set_state(struct uwb_rsv *rsv, enum uwb_rsv_state new_state)
269 {
270         if (rsv->state == new_state) {
271                 switch (rsv->state) {
272                 case UWB_RSV_STATE_O_ESTABLISHED:
273                 case UWB_RSV_STATE_T_ACCEPTED:
274                 case UWB_RSV_STATE_NONE:
275                         uwb_rsv_stroke_timer(rsv);
276                         break;
277                 default:
278                         /* Expecting a state transition so leave timer
279                            as-is. */
280                         break;
281                 }
282                 return;
283         }
284
285         switch (new_state) {
286         case UWB_RSV_STATE_NONE:
287                 uwb_drp_avail_release(rsv->rc, &rsv->mas);
288                 if (uwb_rsv_is_owner(rsv))
289                         uwb_rsv_put_stream(rsv);
290                 uwb_rsv_state_update(rsv, UWB_RSV_STATE_NONE);
291                 uwb_rsv_callback(rsv);
292                 break;
293         case UWB_RSV_STATE_O_INITIATED:
294                 uwb_rsv_state_update(rsv, UWB_RSV_STATE_O_INITIATED);
295                 break;
296         case UWB_RSV_STATE_O_PENDING:
297                 uwb_rsv_state_update(rsv, UWB_RSV_STATE_O_PENDING);
298                 break;
299         case UWB_RSV_STATE_O_ESTABLISHED:
300                 uwb_drp_avail_reserve(rsv->rc, &rsv->mas);
301                 uwb_rsv_state_update(rsv, UWB_RSV_STATE_O_ESTABLISHED);
302                 uwb_rsv_callback(rsv);
303                 break;
304         case UWB_RSV_STATE_T_ACCEPTED:
305                 uwb_drp_avail_reserve(rsv->rc, &rsv->mas);
306                 uwb_rsv_state_update(rsv, UWB_RSV_STATE_T_ACCEPTED);
307                 uwb_rsv_callback(rsv);
308                 break;
309         case UWB_RSV_STATE_T_DENIED:
310                 uwb_rsv_state_update(rsv, UWB_RSV_STATE_T_DENIED);
311                 break;
312         default:
313                 dev_err(&rsv->rc->uwb_dev.dev, "unhandled state: %s (%d)\n",
314                         uwb_rsv_state_str(new_state), new_state);
315         }
316 }
317
318 static struct uwb_rsv *uwb_rsv_alloc(struct uwb_rc *rc)
319 {
320         struct uwb_rsv *rsv;
321
322         rsv = kzalloc(sizeof(struct uwb_rsv), GFP_KERNEL);
323         if (!rsv)
324                 return NULL;
325
326         INIT_LIST_HEAD(&rsv->rc_node);
327         INIT_LIST_HEAD(&rsv->pal_node);
328         init_timer(&rsv->timer);
329         rsv->timer.function = uwb_rsv_timer;
330         rsv->timer.data     = (unsigned long)rsv;
331
332         rsv->rc = rc;
333
334         return rsv;
335 }
336
337 static void uwb_rsv_free(struct uwb_rsv *rsv)
338 {
339         uwb_dev_put(rsv->owner);
340         if (rsv->target.type == UWB_RSV_TARGET_DEV)
341                 uwb_dev_put(rsv->target.dev);
342         kfree(rsv);
343 }
344
345 /**
346  * uwb_rsv_create - allocate and initialize a UWB reservation structure
347  * @rc: the radio controller
348  * @cb: callback to use when the reservation completes or terminates
349  * @pal_priv: data private to the PAL to be passed in the callback
350  *
351  * The callback is called when the state of the reservation changes from:
352  *
353  *   - pending to accepted
354  *   - pending to denined
355  *   - accepted to terminated
356  *   - pending to terminated
357  */
358 struct uwb_rsv *uwb_rsv_create(struct uwb_rc *rc, uwb_rsv_cb_f cb, void *pal_priv)
359 {
360         struct uwb_rsv *rsv;
361
362         rsv = uwb_rsv_alloc(rc);
363         if (!rsv)
364                 return NULL;
365
366         rsv->callback = cb;
367         rsv->pal_priv = pal_priv;
368
369         return rsv;
370 }
371 EXPORT_SYMBOL_GPL(uwb_rsv_create);
372
373 void uwb_rsv_remove(struct uwb_rsv *rsv)
374 {
375         if (rsv->state != UWB_RSV_STATE_NONE)
376                 uwb_rsv_set_state(rsv, UWB_RSV_STATE_NONE);
377         del_timer_sync(&rsv->timer);
378         list_del(&rsv->rc_node);
379         uwb_rsv_free(rsv);
380 }
381
382 /**
383  * uwb_rsv_destroy - free a UWB reservation structure
384  * @rsv: the reservation to free
385  *
386  * The reservation will be terminated if it is pending or established.
387  */
388 void uwb_rsv_destroy(struct uwb_rsv *rsv)
389 {
390         struct uwb_rc *rc = rsv->rc;
391
392         mutex_lock(&rc->rsvs_mutex);
393         uwb_rsv_remove(rsv);
394         mutex_unlock(&rc->rsvs_mutex);
395 }
396 EXPORT_SYMBOL_GPL(uwb_rsv_destroy);
397
398 /**
399  * usb_rsv_establish - start a reservation establishment
400  * @rsv: the reservation
401  *
402  * The PAL should fill in @rsv's owner, target, type, max_mas,
403  * min_mas, sparsity and is_multicast fields.  If the target is a
404  * uwb_dev it must be referenced.
405  *
406  * The reservation's callback will be called when the reservation is
407  * accepted, denied or times out.
408  */
409 int uwb_rsv_establish(struct uwb_rsv *rsv)
410 {
411         struct uwb_rc *rc = rsv->rc;
412         int ret;
413
414         mutex_lock(&rc->rsvs_mutex);
415
416         ret = uwb_rsv_get_stream(rsv);
417         if (ret)
418                 goto out;
419
420         ret = uwb_rsv_alloc_mas(rsv);
421         if (ret) {
422                 uwb_rsv_put_stream(rsv);
423                 goto out;
424         }
425
426         list_add_tail(&rsv->rc_node, &rc->reservations);
427         rsv->owner = &rc->uwb_dev;
428         uwb_dev_get(rsv->owner);
429         uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_INITIATED);
430 out:
431         mutex_unlock(&rc->rsvs_mutex);
432         return ret;
433 }
434 EXPORT_SYMBOL_GPL(uwb_rsv_establish);
435
436 /**
437  * uwb_rsv_modify - modify an already established reservation
438  * @rsv: the reservation to modify
439  * @max_mas: new maximum MAS to reserve
440  * @min_mas: new minimum MAS to reserve
441  * @sparsity: new sparsity to use
442  *
443  * FIXME: implement this once there are PALs that use it.
444  */
445 int uwb_rsv_modify(struct uwb_rsv *rsv, int max_mas, int min_mas, int sparsity)
446 {
447         return -ENOSYS;
448 }
449 EXPORT_SYMBOL_GPL(uwb_rsv_modify);
450
451 /**
452  * uwb_rsv_terminate - terminate an established reservation
453  * @rsv: the reservation to terminate
454  *
455  * A reservation is terminated by removing the DRP IE from the beacon,
456  * the other end will consider the reservation to be terminated when
457  * it does not see the DRP IE for at least mMaxLostBeacons.
458  *
459  * If applicable, the reference to the target uwb_dev will be released.
460  */
461 void uwb_rsv_terminate(struct uwb_rsv *rsv)
462 {
463         struct uwb_rc *rc = rsv->rc;
464
465         mutex_lock(&rc->rsvs_mutex);
466
467         uwb_rsv_set_state(rsv, UWB_RSV_STATE_NONE);
468
469         mutex_unlock(&rc->rsvs_mutex);
470 }
471 EXPORT_SYMBOL_GPL(uwb_rsv_terminate);
472
473 /**
474  * uwb_rsv_accept - accept a new reservation from a peer
475  * @rsv:      the reservation
476  * @cb:       call back for reservation changes
477  * @pal_priv: data to be passed in the above call back
478  *
479  * Reservation requests from peers are denied unless a PAL accepts it
480  * by calling this function.
481  */
482 void uwb_rsv_accept(struct uwb_rsv *rsv, uwb_rsv_cb_f cb, void *pal_priv)
483 {
484         rsv->callback = cb;
485         rsv->pal_priv = pal_priv;
486         rsv->state    = UWB_RSV_STATE_T_ACCEPTED;
487 }
488 EXPORT_SYMBOL_GPL(uwb_rsv_accept);
489
490 /*
491  * Is a received DRP IE for this reservation?
492  */
493 static bool uwb_rsv_match(struct uwb_rsv *rsv, struct uwb_dev *src,
494                           struct uwb_ie_drp *drp_ie)
495 {
496         struct uwb_dev_addr *rsv_src;
497         int stream;
498
499         stream = uwb_ie_drp_stream_index(drp_ie);
500
501         if (rsv->stream != stream)
502                 return false;
503
504         switch (rsv->target.type) {
505         case UWB_RSV_TARGET_DEVADDR:
506                 return rsv->stream == stream;
507         case UWB_RSV_TARGET_DEV:
508                 if (uwb_ie_drp_owner(drp_ie))
509                         rsv_src = &rsv->owner->dev_addr;
510                 else
511                         rsv_src = &rsv->target.dev->dev_addr;
512                 return uwb_dev_addr_cmp(&src->dev_addr, rsv_src) == 0;
513         }
514         return false;
515 }
516
517 static struct uwb_rsv *uwb_rsv_new_target(struct uwb_rc *rc,
518                                           struct uwb_dev *src,
519                                           struct uwb_ie_drp *drp_ie)
520 {
521         struct uwb_rsv *rsv;
522         struct uwb_pal *pal;
523         enum uwb_rsv_state state;
524
525         rsv = uwb_rsv_alloc(rc);
526         if (!rsv)
527                 return NULL;
528
529         rsv->rc          = rc;
530         rsv->owner       = src;
531         uwb_dev_get(rsv->owner);
532         rsv->target.type = UWB_RSV_TARGET_DEV;
533         rsv->target.dev  = &rc->uwb_dev;
534         rsv->type        = uwb_ie_drp_type(drp_ie);
535         rsv->stream      = uwb_ie_drp_stream_index(drp_ie);
536         uwb_drp_ie_to_bm(&rsv->mas, drp_ie);
537
538         /*
539          * See if any PALs are interested in this reservation. If not,
540          * deny the request.
541          */
542         rsv->state = UWB_RSV_STATE_T_DENIED;
543         spin_lock(&rc->pal_lock);
544         list_for_each_entry(pal, &rc->pals, node) {
545                 if (pal->new_rsv)
546                         pal->new_rsv(rsv);
547                 if (rsv->state == UWB_RSV_STATE_T_ACCEPTED)
548                         break;
549         }
550         spin_unlock(&rc->pal_lock);
551
552         list_add_tail(&rsv->rc_node, &rc->reservations);
553         state = rsv->state;
554         rsv->state = UWB_RSV_STATE_NONE;
555         uwb_rsv_set_state(rsv, state);
556
557         return rsv;
558 }
559
560 /**
561  * uwb_rsv_find - find a reservation for a received DRP IE.
562  * @rc: the radio controller
563  * @src: source of the DRP IE
564  * @drp_ie: the DRP IE
565  *
566  * If the reservation cannot be found and the DRP IE is from a peer
567  * attempting to establish a new reservation, create a new reservation
568  * and add it to the list.
569  */
570 struct uwb_rsv *uwb_rsv_find(struct uwb_rc *rc, struct uwb_dev *src,
571                              struct uwb_ie_drp *drp_ie)
572 {
573         struct uwb_rsv *rsv;
574
575         list_for_each_entry(rsv, &rc->reservations, rc_node) {
576                 if (uwb_rsv_match(rsv, src, drp_ie))
577                         return rsv;
578         }
579
580         if (uwb_ie_drp_owner(drp_ie))
581                 return uwb_rsv_new_target(rc, src, drp_ie);
582
583         return NULL;
584 }
585
586 /*
587  * Go through all the reservations and check for timeouts and (if
588  * necessary) update their DRP IEs.
589  *
590  * FIXME: look at building the SET_DRP_IE command here rather than
591  * having to rescan the list in uwb_rc_send_all_drp_ie().
592  */
593 static bool uwb_rsv_update_all(struct uwb_rc *rc)
594 {
595         struct uwb_rsv *rsv, *t;
596         bool ie_updated = false;
597
598         list_for_each_entry_safe(rsv, t, &rc->reservations, rc_node) {
599                 if (rsv->expired)
600                         uwb_drp_handle_timeout(rsv);
601                 if (!rsv->ie_valid) {
602                         uwb_drp_ie_update(rsv);
603                         ie_updated = true;
604                 }
605         }
606
607         return ie_updated;
608 }
609
610 void uwb_rsv_sched_update(struct uwb_rc *rc)
611 {
612         queue_work(rc->rsv_workq, &rc->rsv_update_work);
613 }
614
615 /*
616  * Update DRP IEs and, if necessary, the DRP Availability IE and send
617  * the updated IEs to the radio controller.
618  */
619 static void uwb_rsv_update_work(struct work_struct *work)
620 {
621         struct uwb_rc *rc = container_of(work, struct uwb_rc, rsv_update_work);
622         bool ie_updated;
623
624         mutex_lock(&rc->rsvs_mutex);
625
626         ie_updated = uwb_rsv_update_all(rc);
627
628         if (!rc->drp_avail.ie_valid) {
629                 uwb_drp_avail_ie_update(rc);
630                 ie_updated = true;
631         }
632
633         if (ie_updated)
634                 uwb_rc_send_all_drp_ie(rc);
635
636         mutex_unlock(&rc->rsvs_mutex);
637 }
638
639 static void uwb_rsv_timer(unsigned long arg)
640 {
641         struct uwb_rsv *rsv = (struct uwb_rsv *)arg;
642
643         rsv->expired = true;
644         uwb_rsv_sched_update(rsv->rc);
645 }
646
647 void uwb_rsv_init(struct uwb_rc *rc)
648 {
649         INIT_LIST_HEAD(&rc->reservations);
650         mutex_init(&rc->rsvs_mutex);
651         INIT_WORK(&rc->rsv_update_work, uwb_rsv_update_work);
652
653         bitmap_complement(rc->uwb_dev.streams, rc->uwb_dev.streams, UWB_NUM_STREAMS);
654 }
655
656 int uwb_rsv_setup(struct uwb_rc *rc)
657 {
658         char name[16];
659
660         snprintf(name, sizeof(name), "%s_rsvd", dev_name(&rc->uwb_dev.dev));
661         rc->rsv_workq = create_singlethread_workqueue(name);
662         if (rc->rsv_workq == NULL)
663                 return -ENOMEM;
664
665         return 0;
666 }
667
668 void uwb_rsv_cleanup(struct uwb_rc *rc)
669 {
670         struct uwb_rsv *rsv, *t;
671
672         mutex_lock(&rc->rsvs_mutex);
673         list_for_each_entry_safe(rsv, t, &rc->reservations, rc_node) {
674                 uwb_rsv_remove(rsv);
675         }
676         mutex_unlock(&rc->rsvs_mutex);
677
678         cancel_work_sync(&rc->rsv_update_work);
679         destroy_workqueue(rc->rsv_workq);
680 }