Changeset 498ced1 in mainline for uspace/lib/usbhost


Ignore:
Timestamp:
2018-08-11T02:43:32Z (7 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
05882233
Parents:
b13d80b
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-11 02:29:02)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-11 02:43:32)
Message:

Unify reference counting and remove some unnecessary instances of <atomic.h>

Location:
uspace/lib/usbhost
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/endpoint.h

    rb13d80b r498ced1  
    4242
    4343#include <adt/list.h>
    44 #include <atomic.h>
    4544#include <fibril_synch.h>
     45#include <refcount.h>
    4646#include <stdbool.h>
    4747#include <sys/time.h>
     
    7878        device_t *device;
    7979        /** Reference count. */
    80         atomic_t refcnt;
     80        atomic_refcount_t refcnt;
    8181
    8282        /** An inherited guard */
  • uspace/lib/usbhost/include/usb/host/usb_transfer_batch.h

    rb13d80b r498ced1  
    3838#define LIBUSBHOST_HOST_USB_TRANSFER_BATCH_H
    3939
    40 #include <atomic.h>
    4140#include <errno.h>
     41#include <refcount.h>
    4242#include <stddef.h>
    4343#include <stdint.h>
  • uspace/lib/usbhost/src/endpoint.c

    rb13d80b r498ced1  
    3636
    3737#include <assert.h>
    38 #include <atomic.h>
    3938#include <mem.h>
    4039#include <stdlib.h>
     
    6059        ep->device = dev;
    6160
    62         atomic_set(&ep->refcnt, 0);
     61        refcount_init(&ep->refcnt);
    6362        fibril_condvar_initialize(&ep->avail);
    6463
     
    9190void endpoint_add_ref(endpoint_t *ep)
    9291{
    93         atomic_inc(&ep->refcnt);
     92        refcount_up(&ep->refcnt);
    9493}
    9594
     
    115114void endpoint_del_ref(endpoint_t *ep)
    116115{
    117         if (atomic_predec(&ep->refcnt) == 0) {
     116        if (refcount_down(&ep->refcnt))
    118117                endpoint_destroy(ep);
    119         }
    120118}
    121119
Note: See TracChangeset for help on using the changeset viewer.