Changeset 92232331 in mainline


Ignore:
Timestamp:
2017-11-16T10:19:02Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9280dd0
Parents:
19d2ce01
git-author:
Jiri Svoboda <jiri@…> (2017-11-15 22:17:43)
git-committer:
Jiri Svoboda <jiri@…> (2017-11-16 10:19:02)
Message:

MSIM console driver should avoid storing per-instance data in global variables.

Location:
uspace/drv/char/msim-con
Files:
2 edited

Legend:

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

    r19d2ce01 r92232331  
    4343static void msim_con_connection(ipc_callid_t, ipc_call_t *, void *);
    4444
    45 static irq_pio_range_t msim_ranges[] = {
    46         {
    47                 .base = 0,
    48                 .size = 1
    49         }
    50 };
    51 
    52 static irq_cmd_t msim_cmds[] = {
     45static irq_cmd_t msim_cmds_proto[] = {
    5346        {
    5447                .cmd = CMD_PIO_READ_8,
     
    5952                .cmd = CMD_ACCEPT
    6053        }
    61 };
    62 
    63 static irq_code_t msim_kbd = {
    64         sizeof(msim_ranges) / sizeof(irq_pio_range_t),
    65         msim_ranges,
    66         sizeof(msim_cmds) / sizeof(irq_cmd_t),
    67         msim_cmds
    6854};
    6955
     
    8773        ddf_fun_t *fun = NULL;
    8874        bool subscribed = false;
     75        irq_cmd_t *msim_cmds = NULL;
    8976        int rc;
     77
     78        msim_cmds = malloc(sizeof(msim_cmds_proto));
     79        if (msim_cmds == NULL) {
     80                rc = ENOMEM;
     81                goto error;
     82        }
    9083
    9184        con->res = *res;
     
    10093        ddf_fun_set_conn_handler(fun, msim_con_connection);
    10194
    102         msim_ranges[0].base = res->base;
     95        con->irq_range[0].base = res->base;
     96        con->irq_range[0].size = 1;
     97
     98        memcpy(msim_cmds, msim_cmds_proto, sizeof(msim_cmds_proto));
    10399        msim_cmds[0].addr = (void *) res->base;
    104         async_irq_subscribe(res->irq, msim_irq_handler, con, &msim_kbd);
     100
     101        con->irq_code.rangecount = 1;
     102        con->irq_code.ranges = con->irq_range;
     103        con->irq_code.cmdcount = sizeof(msim_cmds_proto) / sizeof(irq_cmd_t);
     104        con->irq_code.cmds = msim_cmds;
     105
     106        async_irq_subscribe(res->irq, msim_irq_handler, con, &con->irq_code);
    105107        subscribed = true;
    106108
     
    117119        if (fun != NULL)
    118120                ddf_fun_destroy(fun);
     121        free(msim_cmds);
    119122
    120123        return rc;
  • uspace/drv/char/msim-con/msim-con.h

    r19d2ce01 r92232331  
    5252        ddf_dev_t *dev;
    5353        msim_con_res_t res;
     54        irq_pio_range_t irq_range[1];
     55        irq_code_t irq_code;
    5456} msim_con_t;
    5557
Note: See TracChangeset for help on using the changeset viewer.