Changeset 60744cb in mainline for uspace/drv/char


Ignore:
Timestamp:
2024-05-17T17:51:56Z (22 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
1801005
Parents:
646849b3
Message:

Let driver specify any argument to IRQ handler

This allows the driver to register a single handler for multiple
interrupts and still distinguish between them. It also removes
the extra step of having to get softstate from ddf_dev_t.

Location:
uspace/drv/char
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/i8042/i8042.c

    r646849b3 r60744cb  
    123123 * Write new data to the corresponding buffer.
    124124 *
    125  * @param call pointerr to call data.
    126  * @param dev  Device that caued the interrupt.
    127  *
    128  */
    129 static void i8042_irq_handler(ipc_call_t *call, ddf_dev_t *dev)
    130 {
    131         i8042_t *controller = ddf_dev_data_get(dev);
     125 * @param call Pointer to call data.
     126 * @param arg  Argument (i8042_t *)
     127 */
     128static void i8042_irq_handler(ipc_call_t *call, void *arg)
     129{
     130        i8042_t *controller = (i8042_t *)arg;
    132131        errno_t rc;
    133132
     
    147146        fibril_condvar_broadcast(&port->buf_cv);
    148147
    149         async_sess_t *parent_sess = ddf_dev_parent_sess_get(dev);
     148        async_sess_t *parent_sess = ddf_dev_parent_sess_get(controller->dev);
    150149        hw_res_clear_interrupt(parent_sess, port->irq);
    151150}
     
    178177        bool aux_bound = false;
    179178
     179        dev->dev = ddf_dev;
     180
    180181        if (regs->size < sizeof(i8042_regs_t)) {
    181182                rc = EINVAL;
     
    288289        cap_irq_handle_t kbd_ihandle;
    289290        rc = register_interrupt_handler(ddf_dev, irq_kbd,
    290             i8042_irq_handler, &irq_code, &kbd_ihandle);
     291            i8042_irq_handler, (void *)dev, &irq_code, &kbd_ihandle);
    291292        if (rc != EOK) {
    292293                ddf_msg(LVL_ERROR, "Failed set handler for kbd: %s.",
     
    297298        cap_irq_handle_t mouse_ihandle;
    298299        rc = register_interrupt_handler(ddf_dev, irq_mouse,
    299             i8042_irq_handler, &irq_code, &mouse_ihandle);
     300            i8042_irq_handler, (void *)dev, &irq_code, &mouse_ihandle);
    300301        if (rc != EOK) {
    301302                ddf_msg(LVL_ERROR, "Failed set handler for mouse: %s.",
  • uspace/drv/char/i8042/i8042.h

    r646849b3 r60744cb  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * Copyright (c) 2006 Josef Cejka
    44 * Copyright (c) 2011 Jan Vesely
     
    8282/** i8042 Controller. */
    8383typedef struct i8042 {
     84        /** DDF device */
     85        ddf_dev_t *dev;
    8486        /** I/O registers. */
    8587        i8042_regs_t *regs;
  • uspace/drv/char/ns8250/ns8250.c

    r646849b3 r60744cb  
    783783 * data and reading the line status register.
    784784 *
    785  * @param dev The serial port device.
    786  *
    787  */
    788 static inline void ns8250_interrupt_handler(ipc_call_t *icall, ddf_dev_t *dev)
    789 {
    790         ns8250_t *ns = dev_ns8250(dev);
     785 * @pram icall IRQ event notificatoin
     786 * @param arg Argument (ns8250_t *)
     787 */
     788static inline void ns8250_interrupt_handler(ipc_call_t *icall, void *arg)
     789{
     790        ns8250_t *ns = (ns8250_t *)arg;
    791791        uint8_t iir = pio_read_8(&ns->regs->iid);
    792792        if ((iir & NS8250_IID_CAUSE_MASK) == NS8250_IID_CAUSE_RXSTATUS) {
     
    809809{
    810810        return register_interrupt_handler(ns->dev, ns->irq,
    811             ns8250_interrupt_handler, NULL, ihandle);
     811            ns8250_interrupt_handler, (void *)ns, NULL, ihandle);
    812812}
    813813
  • uspace/drv/char/pl050/pl050.c

    r646849b3 r60744cb  
    143143}
    144144
    145 static void pl050_interrupt(ipc_call_t *call, ddf_dev_t *dev)
    146 {
    147         pl050_t *pl050 = (pl050_t *)ddf_dev_data_get(dev);
     145/** PL050 interrupt handler
     146 *
     147 * @param call IRQ event notification
     148 * @param arg Argument (pl050_t *)
     149 */
     150static void pl050_interrupt(ipc_call_t *call, void *arg)
     151{
     152        pl050_t *pl050 = (pl050_t *)arg;
    148153        size_t nidx;
    149154
     
    220225        cap_irq_handle_t ihandle;
    221226        rc = register_interrupt_handler(pl050->dev,
    222             res.irqs.irqs[0], pl050_interrupt, &pl050_irq_code, &ihandle);
     227            res.irqs.irqs[0], pl050_interrupt, (void *)pl050, &pl050_irq_code,
     228            &ihandle);
    223229        if (rc != EOK) {
    224230                ddf_msg(LVL_ERROR, "Failed registering interrupt handler. (%s)",
Note: See TracChangeset for help on using the changeset viewer.