Changeset a35b458 in mainline for kernel/generic/src/ipc/irq.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/irq.c

    r3061bc1 ra35b458  
    8585        for (size_t i = 0; i < rangecount; i++)
    8686                pbase[i] = ranges[i].base;
    87        
     87
    8888        /* Map the PIO ranges into the kernel virtual address space. */
    8989        for (size_t i = 0; i < rangecount; i++) {
     
    100100                }
    101101        }
    102        
     102
    103103        /* Rewrite the IRQ code addresses from physical to kernel virtual. */
    104104        for (size_t i = 0; i < cmdcount; i++) {
    105105                uintptr_t addr;
    106106                size_t size;
    107                
     107
    108108                /* Process only commands that use an address. */
    109109                switch (cmds[i].cmd) {
     
    127127                        continue;
    128128                }
    129                
     129
    130130                addr = (uintptr_t) cmds[i].addr;
    131                
     131
    132132                size_t j;
    133133                for (j = 0; j < rangecount; j++) {
     
    135135                        if (!iswithin(pbase[j], ranges[j].size, addr, size))
    136136                                continue;
    137                        
     137
    138138                        /* Switch the command to a kernel virtual address. */
    139139                        addr -= pbase[j];
    140140                        addr += ranges[j].base;
    141                        
     141
    142142                        cmds[i].addr = (void *) addr;
    143143                        break;
    144144                }
    145                
     145
    146146                if (j == rangecount) {
    147147                        /*
     
    154154                }
    155155        }
    156        
     156
    157157        free(pbase);
    158158        return EOK;
     
    172172                if (cmds[i].cmd >= CMD_LAST)
    173173                        return EINVAL;
    174                
     174
    175175                if (cmds[i].srcarg >= IPC_CALL_LEN)
    176176                        return EINVAL;
    177                
     177
    178178                if (cmds[i].dstarg >= IPC_CALL_LEN)
    179179                        return EINVAL;
    180                
     180
    181181                switch (cmds[i].cmd) {
    182182                case CMD_PREDICATE:
     
    188188                        if (i + cmds[i].value > cmdcount)
    189189                                return EINVAL;
    190                        
     190
    191191                        break;
    192192                default:
     
    194194                }
    195195        }
    196        
     196
    197197        return EOK;
    198198}
     
    224224        irq_pio_range_t *ranges = NULL;
    225225        irq_cmd_t *cmds = NULL;
    226        
     226
    227227        irq_code_t *code = malloc(sizeof(*code), 0);
    228228        errno_t rc = copy_from_uspace(code, ucode, sizeof(*code));
    229229        if (rc != EOK)
    230230                goto error;
    231        
     231
    232232        if ((code->rangecount > IRQ_MAX_RANGE_COUNT) ||
    233233            (code->cmdcount > IRQ_MAX_PROG_SIZE))
    234234                goto error;
    235        
     235
    236236        ranges = malloc(sizeof(code->ranges[0]) * code->rangecount, 0);
    237237        rc = copy_from_uspace(ranges, code->ranges,
     
    239239        if (rc != EOK)
    240240                goto error;
    241        
     241
    242242        cmds = malloc(sizeof(code->cmds[0]) * code->cmdcount, 0);
    243243        rc = copy_from_uspace(cmds, code->cmds,
     
    245245        if (rc != EOK)
    246246                goto error;
    247        
     247
    248248        rc = code_check(cmds, code->cmdcount);
    249249        if (rc != EOK)
    250250                goto error;
    251        
     251
    252252        rc = ranges_map_and_apply(ranges, code->rangecount, cmds,
    253253            code->cmdcount);
    254254        if (rc != EOK)
    255255                goto error;
    256        
     256
    257257        code->ranges = ranges;
    258258        code->cmds = cmds;
    259        
     259
    260260        return code;
    261        
     261
    262262error:
    263263        if (cmds)
    264264                free(cmds);
    265        
     265
    266266        if (ranges)
    267267                free(ranges);
    268        
     268
    269269        free(code);
    270270        return NULL;
     
    275275        irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
    276276        irq_spinlock_lock(&irq->lock, false);
    277        
     277
    278278        if (irq->notif_cfg.hashed_in) {
    279279                /* Remove the IRQ from the uspace IRQ hash table. */
     
    318318        if ((inr < 0) || (inr > last_inr))
    319319                return ELIMIT;
    320        
     320
    321321        irq_code_t *code;
    322322        if (ucode) {
     
    326326        } else
    327327                code = NULL;
    328        
     328
    329329        /*
    330330         * Allocate and populate the IRQ kernel object.
     
    334334        if (rc != EOK)
    335335                return rc;
    336        
     336
    337337        rc = copy_to_uspace(uspace_handle, &handle, sizeof(cap_handle_t));
    338338        if (rc != EOK) {
     
    353353                return ENOMEM;
    354354        }
    355        
     355
    356356        irq_initialize(irq);
    357357        irq->inr = inr;
     
    363363        irq->notif_cfg.code = code;
    364364        irq->notif_cfg.counter = 0;
    365        
     365
    366366        /*
    367367         * Insert the IRQ structure into the uspace IRQ hash table.
     
    369369        irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
    370370        irq_spinlock_lock(&irq->lock, false);
    371        
     371
    372372        irq->notif_cfg.hashed_in = true;
    373373        hash_table_insert(&irq_uspace_hash_table, &irq->link);
    374        
     374
    375375        irq_spinlock_unlock(&irq->lock, false);
    376376        irq_spinlock_unlock(&irq_uspace_hash_table_lock, true);
     
    378378        kobject_initialize(kobject, KOBJECT_TYPE_IRQ, irq, &irq_kobject_ops);
    379379        cap_publish(TASK, handle, kobject);
    380        
     380
    381381        return EOK;
    382382}
     
    395395        if (!kobj)
    396396                return ENOENT;
    397        
     397
    398398        assert(kobj->irq->notif_cfg.answerbox == box);
    399399
     
    402402        kobject_put(kobj);
    403403        cap_free(TASK, handle);
    404        
     404
    405405        return EOK;
    406406}
     
    419419        list_append(&call->ab_link, &irq->notif_cfg.answerbox->irq_notifs);
    420420        irq_spinlock_unlock(&irq->notif_cfg.answerbox->irq_lock, false);
    421        
     421
    422422        waitq_wakeup(&irq->notif_cfg.answerbox->wq, WAKEUP_FIRST);
    423423}
     
    435435        irq_code_t *code = irq->notif_cfg.code;
    436436        uint32_t *scratch = irq->notif_cfg.scratch;
    437        
     437
    438438        if (!irq->notif_cfg.notify)
    439439                return IRQ_DECLINE;
    440        
     440
    441441        if (!code)
    442442                return IRQ_DECLINE;
    443        
     443
    444444        for (size_t i = 0; i < code->cmdcount; i++) {
    445445                uintptr_t srcarg = code->cmds[i].srcarg;
    446446                uintptr_t dstarg = code->cmds[i].dstarg;
    447                
     447
    448448                switch (code->cmds[i].cmd) {
    449449                case CMD_PIO_READ_8:
     
    493493                        if (scratch[srcarg] == 0)
    494494                                i += code->cmds[i].value;
    495                        
     495
    496496                        break;
    497497                case CMD_ACCEPT:
     
    502502                }
    503503        }
    504        
     504
    505505        return IRQ_DECLINE;
    506506}
     
    516516{
    517517        assert(irq);
    518        
     518
    519519        assert(interrupts_disabled());
    520520        assert(irq_spinlock_locked(&irq->lock));
    521        
     521
    522522        if (irq->notif_cfg.answerbox) {
    523523                call_t *call = ipc_call_alloc(FRAME_ATOMIC);
    524524                if (!call)
    525525                        return;
    526                
     526
    527527                call->flags |= IPC_CALL_NOTIF;
    528528                /* Put a counter to the message */
    529529                call->priv = ++irq->notif_cfg.counter;
    530                
     530
    531531                /* Set up args */
    532532                IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod);
     
    536536                IPC_SET_ARG4(call->data, irq->notif_cfg.scratch[4]);
    537537                IPC_SET_ARG5(call->data, irq->notif_cfg.scratch[5]);
    538                
     538
    539539                send_call(irq, call);
    540540        }
     
    555555{
    556556        irq_spinlock_lock(&irq->lock, true);
    557        
     557
    558558        if (irq->notif_cfg.answerbox) {
    559559                call_t *call = ipc_call_alloc(FRAME_ATOMIC);
     
    562562                        return;
    563563                }
    564                
     564
    565565                call->flags |= IPC_CALL_NOTIF;
    566566                /* Put a counter to the message */
    567567                call->priv = ++irq->notif_cfg.counter;
    568                
     568
    569569                IPC_SET_IMETHOD(call->data, irq->notif_cfg.imethod);
    570570                IPC_SET_ARG1(call->data, a1);
     
    573573                IPC_SET_ARG4(call->data, a4);
    574574                IPC_SET_ARG5(call->data, a5);
    575                
     575
    576576                send_call(irq, call);
    577577        }
    578        
     578
    579579        irq_spinlock_unlock(&irq->lock, true);
    580580}
Note: See TracChangeset for help on using the changeset viewer.