Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 071a1ddb in mainline


Ignore:
Timestamp:
2017-12-08T21:17:27Z (4 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
0722869, 569a51a
Parents:
9233e9d
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 00:30:18)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 21:17:27)
Message:

Return IRQ handles via a separate out parameter in all uspace code.

Location:
uspace
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/hdaudio/hdaudio.c

    r9233e9d r071a1ddb  
    263263        }
    264264
    265         int irq_cap = register_interrupt_handler(dev, res.irqs.irqs[0],
    266             hdaudio_interrupt, &irq_code);
    267         if (irq_cap < 0) {
    268                 rc = irq_cap;
     265        int irq_cap;
     266        rc = register_interrupt_handler(dev, res.irqs.irqs[0],
     267            hdaudio_interrupt, &irq_code, &irq_cap);
     268        if (rc != EOK) {
    269269                ddf_msg(LVL_ERROR, "Failed registering interrupt handler. (%d)",
    270270                    rc);
  • uspace/drv/audio/sb16/main.c

    r9233e9d r071a1ddb  
    123123        };
    124124
    125         irq_cap = register_interrupt_handler(device, irq, irq_handler,
    126             &irq_code);
    127         if (irq_cap < 0) {
    128                 rc = irq_cap;
     125        rc = register_interrupt_handler(device, irq, irq_handler,
     126            &irq_code, &irq_cap);
     127        if (rc != EOK) {
    129128                ddf_log_error("Failed to register irq handler: %s.",
    130129                    str_error(rc));
  • uspace/drv/block/ahci/ahci.c

    r9233e9d r071a1ddb  
    11841184        ct.ranges = ahci_ranges;
    11851185       
    1186         int irq_cap = register_interrupt_handler(dev,
    1187             hw_res_parsed.irqs.irqs[0], ahci_interrupt, &ct);
    1188         if (irq_cap < 0) {
     1186        int irq_cap;
     1187        int rc = register_interrupt_handler(dev,
     1188            hw_res_parsed.irqs.irqs[0], ahci_interrupt, &ct, &irq_cap);
     1189        if (rc != EOK) {
    11891190                ddf_msg(LVL_ERROR, "Failed registering interrupt handler.");
    11901191                goto error_register_interrupt_handler;
    11911192        }
    11921193       
    1193         int rc = hw_res_enable_interrupt(ahci->parent_sess,
     1194        rc = hw_res_enable_interrupt(ahci->parent_sess,
    11941195            hw_res_parsed.irqs.irqs[0]);
    11951196        if (rc != EOK) {
  • uspace/drv/block/ddisk/ddisk.c

    r9233e9d r071a1ddb  
    503503        ddisk_irq_commands[0].addr = (void *) &res_phys->status;
    504504        ddisk_irq_commands[3].addr = (void *) &res_phys->command;
    505         ddisk->irq_cap = register_interrupt_handler(dev, ddisk->ddisk_res.irq,
    506             ddisk_irq_handler, &ddisk_irq_code);
    507         if (ddisk->irq_cap < 0) {
    508                 rc = ddisk->irq_cap;
     505        rc = register_interrupt_handler(dev, ddisk->ddisk_res.irq,
     506            ddisk_irq_handler, &ddisk_irq_code, &ddisk->irq_cap);
     507        if (rc != EOK) {
    509508                ddf_msg(LVL_ERROR, "Failed to register interrupt handler.");
    510509                goto error;
  • uspace/drv/bus/adb/cuda_adb/cuda_adb.c

    r9233e9d r071a1ddb  
    252252        cuda_irq_code.cmds[0].addr = (void *) &((cuda_regs_t *)
    253253            cuda->phys_base)->ifr;
    254         async_irq_subscribe(10, cuda_irq_handler, cuda, &cuda_irq_code);
     254        async_irq_subscribe(10, cuda_irq_handler, cuda, &cuda_irq_code, NULL);
    255255
    256256        /* Enable SR interrupt. */
  • uspace/drv/char/i8042/i8042.c

    r9233e9d r071a1ddb  
    281281        };
    282282       
    283         const int irq_kbd_cap = register_interrupt_handler(ddf_dev, irq_kbd,
    284             i8042_irq_handler, &irq_code);
    285         if (irq_kbd_cap < 0) {
    286                 rc = irq_kbd_cap;
     283        int irq_kbd_cap;
     284        rc = register_interrupt_handler(ddf_dev, irq_kbd,
     285            i8042_irq_handler, &irq_code, &irq_kbd_cap);
     286        if (rc != EOK) {
    287287                ddf_msg(LVL_ERROR, "Failed set handler for kbd: %s.",
    288288                    ddf_dev_get_name(ddf_dev));
     
    290290        }
    291291       
    292         const int irq_mouse_cap = register_interrupt_handler(ddf_dev, irq_mouse,
    293             i8042_irq_handler, &irq_code);
    294         if (irq_mouse_cap < 0) {
    295                 rc = irq_mouse_cap;
     292        int irq_mouse_cap;
     293        rc = register_interrupt_handler(ddf_dev, irq_mouse,
     294            i8042_irq_handler, &irq_code, &irq_mouse_cap);
     295        if (rc != EOK) {
    296296                ddf_msg(LVL_ERROR, "Failed set handler for mouse: %s.",
    297297                    ddf_dev_get_name(ddf_dev));
  • uspace/drv/char/msim-con/msim-con.c

    r9233e9d r071a1ddb  
    125125        con->irq_code.cmds = msim_cmds;
    126126
    127         async_irq_subscribe(res->irq, msim_irq_handler, con, &con->irq_code);
     127        async_irq_subscribe(res->irq, msim_irq_handler, con, &con->irq_code, NULL);
    128128        subscribed = true;
    129129
  • uspace/drv/char/ns8250/ns8250.c

    r9233e9d r071a1ddb  
    802802 * @param ns            Serial port device
    803803 */
    804 static inline int ns8250_register_interrupt_handler(ns8250_t *ns)
     804static inline int ns8250_register_interrupt_handler(ns8250_t *ns,
     805    cap_handle_t *handle)
    805806{
    806807        return register_interrupt_handler(ns->dev, ns->irq,
    807             ns8250_interrupt_handler, NULL);
     808            ns8250_interrupt_handler, NULL, handle);
    808809}
    809810
     
    874875       
    875876        /* Register interrupt handler. */
    876         ns->irq_cap = ns8250_register_interrupt_handler(ns);
    877         if (ns->irq_cap < 0) {
     877        rc = ns8250_register_interrupt_handler(ns, &ns->irq_cap);
     878        if (rc != EOK) {
    878879                ddf_msg(LVL_ERROR, "Failed to register interrupt handler.");
    879880                rc = EADDRNOTAVAIL;
  • uspace/drv/char/pl050/pl050.c

    r9233e9d r071a1ddb  
    213213        pl050->regs = regs;
    214214
    215         const int irq_cap = register_interrupt_handler(pl050->dev,
    216             res.irqs.irqs[0], pl050_interrupt, &pl050_irq_code);
    217         if (irq_cap < 0) {
    218                 rc = irq_cap;
     215        int irq_cap;
     216        rc = register_interrupt_handler(pl050->dev,
     217            res.irqs.irqs[0], pl050_interrupt, &pl050_irq_code, &irq_cap);
     218        if (rc != EOK) {
    219219                ddf_msg(LVL_ERROR, "Failed registering interrupt handler. (%d)",
    220220                    rc);
  • uspace/drv/nic/e1k/e1k.c

    r9233e9d r071a1ddb  
    12591259 * @param nic Driver data
    12601260 *
    1261  * @return IRQ capability handle if the handler was registered
     1261 * @param[out] handle  IRQ capability handle if the handler was registered
     1262 *
    12621263 * @return Negative error code otherwise
    12631264 *
    12641265 */
    1265 inline static int e1000_register_int_handler(nic_t *nic)
     1266inline static int e1000_register_int_handler(nic_t *nic, cap_handle_t *handle)
    12661267{
    12671268        e1000_t *e1000 = DRIVER_DATA_NIC(nic);
     
    12741275        e1000_irq_code.cmds[2].addr = e1000->reg_base_phys + E1000_IMC;
    12751276       
    1276         int cap = register_interrupt_handler(nic_get_ddf_dev(nic), e1000->irq,
    1277             e1000_interrupt_handler, &e1000_irq_code);
     1277        int rc = register_interrupt_handler(nic_get_ddf_dev(nic), e1000->irq,
     1278            e1000_interrupt_handler, &e1000_irq_code, handle);
    12781279       
    12791280        fibril_mutex_unlock(&irq_reg_mutex);
    1280         return cap;
     1281        return rc;
    12811282}
    12821283
     
    21642165        ddf_fun_set_ops(fun, &e1000_dev_ops);
    21652166       
    2166         int irq_cap = e1000_register_int_handler(nic);
    2167         if (irq_cap < 0) {
    2168                 rc = irq_cap;
     2167        int irq_cap;
     2168        rc = e1000_register_int_handler(nic, &irq_cap);
     2169        if (rc != EOK) {
    21692170                goto err_fun_create;
    21702171        }
  • uspace/drv/nic/ne2k/ne2k.c

    r9233e9d r071a1ddb  
    124124static void ne2k_interrupt_handler(ipc_call_t *, ddf_dev_t *);
    125125
    126 static int ne2k_register_interrupt(nic_t *nic_data)
     126static int ne2k_register_interrupt(nic_t *nic_data, cap_handle_t *handle)
    127127{
    128128        ne2k_t *ne2k = (ne2k_t *) nic_get_specific(nic_data);
     
    160160        }
    161161
    162         int irq_cap = register_interrupt_handler(nic_get_ddf_dev(nic_data),
    163                 ne2k->irq, ne2k_interrupt_handler, &ne2k->code);
    164         return irq_cap;
     162        return register_interrupt_handler(nic_get_ddf_dev(nic_data),
     163                ne2k->irq, ne2k_interrupt_handler, &ne2k->code, handle);
    165164}
    166165
     
    228227        ne2k->probed = true;
    229228       
    230         int irq_cap = ne2k_register_interrupt(nic_data);
    231         if (irq_cap < 0)
     229        if (ne2k_register_interrupt(nic_data, NULL) != EOK)
    232230                return EINVAL;
    233231       
  • uspace/drv/nic/rtl8139/driver.c

    r9233e9d r071a1ddb  
    842842 *  @param nic_data  The driver data
    843843 *
    844  *  @return IRQ capability handle if the handler was registered.
     844 *  @param[out] handle  IRQ capability handle if the handler was registered.
     845 *
    845846 *  @return Negative error code otherwise.
    846847 */
    847 inline static int rtl8139_register_int_handler(nic_t *nic_data)
     848inline static int rtl8139_register_int_handler(nic_t *nic_data, cap_handle_t *handle)
    848849{
    849850        rtl8139_t *rtl8139 = nic_get_specific(nic_data);
     
    856857        rtl8139_irq_code.cmds[2].addr = rtl8139->io_addr + ISR;
    857858        rtl8139_irq_code.cmds[3].addr = rtl8139->io_addr + IMR;
    858         int cap = register_interrupt_handler(nic_get_ddf_dev(nic_data),
    859             rtl8139->irq, rtl8139_interrupt_handler, &rtl8139_irq_code);
     859        int rc = register_interrupt_handler(nic_get_ddf_dev(nic_data),
     860            rtl8139->irq, rtl8139_interrupt_handler, &rtl8139_irq_code, handle);
    860861
    861862        RTL8139_IRQ_STRUCT_UNLOCK();
    862863
    863         return cap;
     864        return rc;
    864865}
    865866
     
    12871288
    12881289        /* Register interrupt handler */
    1289         int irq_cap = rtl8139_register_int_handler(nic_data);
    1290         if (irq_cap < 0) {
    1291                 rc = irq_cap;
     1290        int irq_cap;
     1291        rc = rtl8139_register_int_handler(nic_data, &irq_cap);
     1292        if (rc != EOK) {
    12921293                goto err_pio;
    12931294        }
  • uspace/drv/nic/rtl8169/driver.c

    r9233e9d r071a1ddb  
    7373static void rtl8169_send_frame(nic_t *nic_data, void *data, size_t size);
    7474static void rtl8169_irq_handler(ipc_call_t *icall, ddf_dev_t *dev);
    75 static inline int rtl8169_register_int_handler(nic_t *nic_data);
     75static inline int rtl8169_register_int_handler(nic_t *nic_data, cap_handle_t *handle);
    7676static inline void rtl8169_get_hwaddr(rtl8169_t *rtl8169, nic_address_t *addr);
    7777static inline void rtl8169_set_hwaddr(rtl8169_t *rtl8169, const nic_address_t *addr);
     
    359359}
    360360
    361 inline static int rtl8169_register_int_handler(nic_t *nic_data)
     361inline static int rtl8169_register_int_handler(nic_t *nic_data, cap_handle_t *handle)
    362362{
    363363        rtl8169_t *rtl8169 = nic_get_specific(nic_data);
     
    367367        rtl8169_irq_code.cmds[2].addr = rtl8169->regs + ISR;
    368368        rtl8169_irq_code.cmds[3].addr = rtl8169->regs + IMR;
    369         int irq_cap = register_interrupt_handler(nic_get_ddf_dev(nic_data),
    370             rtl8169->irq, rtl8169_irq_handler, &rtl8169_irq_code);
    371 
    372         return irq_cap;
     369        int rc = register_interrupt_handler(nic_get_ddf_dev(nic_data),
     370            rtl8169->irq, rtl8169_irq_handler, &rtl8169_irq_code, handle);
     371
     372        return rc;
    373373}
    374374
     
    427427                goto err_pio;
    428428
    429         int irq_cap = rtl8169_register_int_handler(nic_data);
    430         if (irq_cap < 0) {
    431                 rc = irq_cap;
     429        int irq_cap;
     430        rc = rtl8169_register_int_handler(nic_data, &irq_cap);
     431        if (rc != EOK) {
    432432                ddf_msg(LVL_ERROR, "Failed to register IRQ handler (%d)", rc);
    433433                goto err_irq;
  • uspace/lib/c/generic/async.c

    r9233e9d r071a1ddb  
    10511051 * @param ucode   Top-half pseudocode handler.
    10521052 *
    1053  * @return IRQ capability handle on success.
     1053 * @param[out] handle  IRQ capability handle on success.
     1054 *
    10541055 * @return Negative error code.
    10551056 *
    10561057 */
    10571058int async_irq_subscribe(int inr, async_notification_handler_t handler,
    1058     void *data, const irq_code_t *ucode)
     1059    void *data, const irq_code_t *ucode, cap_handle_t *handle)
    10591060{
    10601061        notification_t *notification =
     
    10781079        cap_handle_t cap;
    10791080        int rc = ipc_irq_subscribe(inr, imethod, ucode, &cap);
    1080         if (rc != EOK) {
    1081                 return rc;
    1082         }
    1083         return cap;
     1081        if (rc == EOK && handle != NULL) {
     1082                *handle = cap;
     1083        }
     1084        return rc;
    10841085}
    10851086
  • uspace/lib/c/include/async.h

    r9233e9d r071a1ddb  
    169169
    170170extern int async_irq_subscribe(int, async_notification_handler_t, void *,
    171     const irq_code_t *);
     171    const irq_code_t *, cap_handle_t *);
    172172extern int async_irq_unsubscribe(int);
    173173
  • uspace/lib/drv/generic/interrupt.c

    r9233e9d r071a1ddb  
    4444
    4545int register_interrupt_handler(ddf_dev_t *dev, int irq,
    46     interrupt_handler_t *handler, const irq_code_t *irq_code)
     46    interrupt_handler_t *handler, const irq_code_t *irq_code,
     47    cap_handle_t *handle)
    4748{
    4849        return async_irq_subscribe(irq, (async_notification_handler_t) handler,
    49             dev, irq_code);
     50            dev, irq_code, handle);
    5051}
    5152
  • uspace/lib/drv/include/ddf/interrupt.h

    r9233e9d r071a1ddb  
    5151
    5252extern int register_interrupt_handler(ddf_dev_t *, int, interrupt_handler_t *,
    53     const irq_code_t *);
     53    const irq_code_t *, cap_handle_t *);
    5454extern int unregister_interrupt_handler(ddf_dev_t *, int);
    5555
  • uspace/lib/usbhost/include/usb/host/ddf_helpers.h

    r9233e9d r071a1ddb  
    7575    const hw_res_list_parsed_t *hw_res,
    7676    interrupt_handler_t handler,
    77     int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *));
     77    int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *),
     78    cap_handle_t *handle);
    7879void ddf_hcd_gen_irq_handler(ipc_call_t *call, ddf_dev_t *dev);
    7980
  • uspace/lib/usbhost/src/ddf_helpers.c

    r9233e9d r071a1ddb  
    742742 * @param[in] gen_irq_code IRQ code generator.
    743743 *
    744  * @return IRQ capability handle on success.
    745  * @return Negative error code.
     744 * @param[out] handle  IRQ capability handle on success.
     745 *
     746 * @return Error code.
    746747 */
    747748int hcd_ddf_setup_interrupts(ddf_dev_t *device,
    748749    const hw_res_list_parsed_t *hw_res,
    749750    interrupt_handler_t handler,
    750     int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *hw_res))
     751    int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *hw_res),
     752    cap_handle_t *handle)
    751753{
    752754
     
    765767
    766768        /* Register handler to avoid interrupt lockup */
    767         const int irq_cap = register_interrupt_handler(device, irq, handler,
    768             &irq_code);
     769        int ret = register_interrupt_handler(device, irq, handler,
     770            &irq_code, handle);
    769771        irq_code_clean(&irq_code);
    770         if (irq_cap < 0) {
    771                 usb_log_error("Failed to register interrupt handler: %s.\n",
    772                     str_error(irq_cap));
    773                 return irq_cap;
    774         }
    775 
    776         /* Enable interrupts */
    777         int ret = hcd_ddf_enable_interrupt(device, irq);
    778772        if (ret != EOK) {
    779773                usb_log_error("Failed to register interrupt handler: %s.\n",
    780774                    str_error(ret));
    781                 unregister_interrupt_handler(device, irq_cap);
    782                 return ret;
    783         }
    784         return irq_cap;
     775                return ret;
     776        }
     777
     778        /* Enable interrupts */
     779        ret = hcd_ddf_enable_interrupt(device, irq);
     780        if (ret != EOK) {
     781                usb_log_error("Failed to register interrupt handler: %s.\n",
     782                    str_error(ret));
     783                unregister_interrupt_handler(device, *handle);
     784        }
     785        return ret;
    785786}
    786787
     
    876877        interrupt_handler_t *irq_handler =
    877878            driver->irq_handler ? driver->irq_handler : ddf_hcd_gen_irq_handler;
    878         const int irq_cap = hcd_ddf_setup_interrupts(device, &hw_res,
    879             irq_handler, driver->irq_code_gen);
    880         bool irqs_enabled = !(irq_cap < 0);
     879        int irq_cap;
     880        ret = hcd_ddf_setup_interrupts(device, &hw_res,
     881            irq_handler, driver->irq_code_gen, &irq_cap);
     882        bool irqs_enabled = (ret == EOK);
    881883        if (irqs_enabled) {
    882884                usb_log_debug("Hw interrupts enabled.\n");
    883885        }
    884886
    885         if (driver->claim)
     887        if (driver->claim) {
    886888                ret = driver->claim(device);
    887         if (ret != EOK) {
    888                 usb_log_error("Failed to claim `%s' for driver `%s'",
    889                     ddf_dev_get_name(device), driver->name);
    890                 return ret;
     889                if (ret != EOK) {
     890                        usb_log_error("Failed to claim `%s' for driver `%s'",
     891                            ddf_dev_get_name(device), driver->name);
     892                        return ret;
     893                }
    891894        }
    892895
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c

    r9233e9d r071a1ddb  
    137137            (void *) ts->paddr, inr);
    138138
    139         async_irq_subscribe(inr, s3c24xx_ts_irq_handler, NULL, &ts_irq_code);
     139        async_irq_subscribe(inr, s3c24xx_ts_irq_handler, NULL, &ts_irq_code, NULL);
    140140
    141141        s3c24xx_ts_wait_for_int_mode(ts, updn_down);
  • uspace/srv/hw/char/s3c24xx_uart/s3c24xx_uart.c

    r9233e9d r071a1ddb  
    173173            (void *) uart->paddr, inr);
    174174
    175         async_irq_subscribe(inr, s3c24xx_uart_irq_handler, NULL, &uart_irq_code);
     175        async_irq_subscribe(inr, s3c24xx_uart_irq_handler, NULL, &uart_irq_code, NULL);
    176176
    177177        /* Enable FIFO, Tx trigger level: empty, Rx trigger level: 1 byte. */
Note: See TracChangeset for help on using the changeset viewer.