Changeset eadaeae8 in mainline for uspace/drv/char/msim-con/msim-con.c


Ignore:
Timestamp:
2018-03-21T20:58:49Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3be9d10
Parents:
874381a
Message:

Make capability handles type-safe

Define distinct pointer types for the handles of the supported
capability types and use them instead of integer handles. This makes it
virtually impossible to pass a non-handle or a handle of different type
instead of the proper handle. Also turn cap_handle_t into an "untyped"
capability handle that can be assigned to and from the "typed" handles.

This commit also fixes a bug in msim-con driver, which wrongly used the
IRQ number instead of the IRQ capability handle to unregister the IRQ.

This commit also fixes the wrong use of the capability handle instead
of error code in libusbhost.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/msim-con/msim-con.c

    r874381a readaeae8  
    8383{
    8484        ddf_fun_t *fun = NULL;
    85         bool subscribed = false;
    8685        irq_cmd_t *msim_cmds = NULL;
    8786        errno_t rc;
     
    9089        fibril_mutex_initialize(&con->buf_lock);
    9190        fibril_condvar_initialize(&con->buf_cv);
     91
     92        con->irq_handle = CAP_NIL;
    9293
    9394        msim_cmds = malloc(sizeof(msim_cmds_proto));
     
    125126        con->irq_code.cmds = msim_cmds;
    126127
    127         async_irq_subscribe(res->irq, msim_irq_handler, con, &con->irq_code, NULL);
    128         subscribed = true;
     128        rc = async_irq_subscribe(res->irq, msim_irq_handler, con,
     129            &con->irq_code, &con->irq_handle);
     130        if (rc != EOK) {
     131                ddf_msg(LVL_ERROR, "Error registering IRQ code.");
     132                goto error;
     133        }
    129134
    130135        chardev_srvs_init(&con->cds);
     
    142147        return EOK;
    143148error:
    144         if (subscribed)
    145                 async_irq_unsubscribe(res->irq);
     149        if (CAP_HANDLE_VALID(con->irq_handle))
     150                async_irq_unsubscribe(con->irq_handle);
    146151        if (fun != NULL)
    147152                ddf_fun_destroy(fun);
Note: See TracChangeset for help on using the changeset viewer.