Changeset 498ced1 in mainline for uspace/srv/devman


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/srv/devman
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/dev.c

    rb13d80b r498ced1  
    4848                return NULL;
    4949
    50         atomic_set(&dev->refcnt, 0);
     50        refcount_init(&dev->refcnt);
    5151        list_initialize(&dev->functions);
    5252        link_initialize(&dev->driver_devices);
     
    7474void dev_add_ref(dev_node_t *dev)
    7575{
    76         atomic_inc(&dev->refcnt);
     76        refcount_up(&dev->refcnt);
    7777}
    7878
     
    8585void dev_del_ref(dev_node_t *dev)
    8686{
    87         if (atomic_predec(&dev->refcnt) == 0)
     87        if (refcount_down(&dev->refcnt))
    8888                delete_dev_node(dev);
    8989}
  • uspace/srv/devman/devman.h

    rb13d80b r498ced1  
    4141#include <ipc/loc.h>
    4242#include <fibril_synch.h>
    43 #include <atomic.h>
     43#include <refcount.h>
    4444#include <async.h>
    4545
     
    115115struct dev_node {
    116116        /** Reference count */
    117         atomic_t refcnt;
     117        atomic_refcount_t refcnt;
    118118
    119119        /** The global unique identifier of the device. */
     
    155155struct fun_node {
    156156        /** Reference count */
    157         atomic_t refcnt;
     157        atomic_refcount_t refcnt;
    158158        /** State */
    159159        fun_state_t state;
  • uspace/srv/devman/driver.c

    rb13d80b r498ced1  
    406406                }
    407407
    408                 log_msg(LOG_DEFAULT, LVL_DEBUG, "pass_devices_to_driver: dev->refcnt=%d\n",
    409                     (int)atomic_get(&dev->refcnt));
    410408                dev_add_ref(dev);
    411409
  • uspace/srv/devman/fun.c

    rb13d80b r498ced1  
    6060
    6161        fun->state = FUN_INIT;
    62         atomic_set(&fun->refcnt, 0);
     62        refcount_init(&fun->refcnt);
    6363        fibril_mutex_initialize(&fun->busy_lock);
    6464        link_initialize(&fun->dev_functions);
     
    8989void fun_add_ref(fun_node_t *fun)
    9090{
    91         atomic_inc(&fun->refcnt);
     91        refcount_up(&fun->refcnt);
    9292}
    9393
     
    100100void fun_del_ref(fun_node_t *fun)
    101101{
    102         if (atomic_predec(&fun->refcnt) == 0)
     102        if (refcount_down(&fun->refcnt))
    103103                delete_fun_node(fun);
    104104}
Note: See TracChangeset for help on using the changeset viewer.