Changeset 95c675b in mainline for uspace/lib/drv/generic


Ignore:
Timestamp:
2017-10-17T13:11:35Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
60af4cdb
Parents:
dbf32b1 (diff), a416d070 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline

Location:
uspace/lib/drv/generic
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/driver.c

    rdbf32b1 r95c675b  
    599599}
    600600
    601 /** Create session with the parent function.
    602  *
    603  * The session will be automatically closed when @a dev is destroyed.
    604  *
    605  * @param dev Device
    606  *
    607  * @return New session or NULL if session could not be created
    608  *
    609  */
    610 async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev)
    611 {
    612         assert(dev->parent_sess == NULL);
    613         dev->parent_sess = devman_parent_device_connect(dev->handle,
    614             IPC_FLAG_BLOCKING);
    615 
    616         return dev->parent_sess;
    617 }
    618 
    619601/** Return existing session with the parent function.
    620602 *
    621603 * @param dev   Device
    622  * @return      Existing session or NULL if there is no session
     604 * @return      Session with parent function or NULL upon failure
    623605 */
    624606async_sess_t *ddf_dev_parent_sess_get(ddf_dev_t *dev)
    625607{
     608        if (dev->parent_sess == NULL) {
     609                dev->parent_sess = devman_parent_device_connect(dev->handle,
     610                    IPC_FLAG_BLOCKING);
     611        }
     612
    626613        return dev->parent_sess;
    627614}
     
    943930        int rc = async_create_port(INTERFACE_DDF_DRIVER, driver_connection_driver,
    944931            NULL, &port);
    945         if (rc != EOK)
     932        if (rc != EOK) {
     933                printf("Error: Failed to create driver port.\n");
    946934                return rc;
     935        }
    947936       
    948937        rc = async_create_port(INTERFACE_DDF_DEVMAN, driver_connection_devman,
    949938            NULL, &port);
    950         if (rc != EOK)
     939        if (rc != EOK) {
     940                printf("Error: Failed to create devman port.\n");
    951941                return rc;
     942        }
    952943       
    953944        async_set_fallback_port_handler(driver_connection_client, NULL);
     
    964955        /* Return success from the task since server has started. */
    965956        rc = task_retval(0);
    966         if (rc != EOK)
     957        if (rc != EOK) {
     958                printf("Error: Failed returning task value.\n");
    967959                return rc;
     960        }
    968961       
    969962        async_manager();
  • uspace/lib/drv/generic/interrupt.c

    rdbf32b1 r95c675b  
    4444
    4545int register_interrupt_handler(ddf_dev_t *dev, int irq,
    46     interrupt_handler_t *handler, const irq_code_t *pseudocode)
     46    interrupt_handler_t *handler, const irq_code_t *irq_code)
    4747{
    48         return async_irq_subscribe(irq, dev->handle,
    49             (async_notification_handler_t) handler, dev, pseudocode);
     48        return async_irq_subscribe(irq, (async_notification_handler_t) handler,
     49            dev, irq_code);
    5050}
    5151
    52 int unregister_interrupt_handler(ddf_dev_t *dev, int irq)
     52int unregister_interrupt_handler(ddf_dev_t *dev, int cap)
    5353{
    54         return async_irq_unsubscribe(irq, dev->handle);
     54        return async_irq_unsubscribe(cap);
    5555}
    5656
  • uspace/lib/drv/generic/remote_hw_res.c

    rdbf32b1 r95c675b  
    4545static void remote_hw_res_enable_interrupt(ddf_fun_t *, void *, ipc_callid_t,
    4646    ipc_call_t *);
     47static void remote_hw_res_disable_interrupt(ddf_fun_t *, void *, ipc_callid_t,
     48    ipc_call_t *);
     49static void remote_hw_res_clear_interrupt(ddf_fun_t *, void *, ipc_callid_t,
     50    ipc_call_t *);
    4751static void remote_hw_res_dma_channel_setup(ddf_fun_t *, void *, ipc_callid_t,
    4852    ipc_call_t *);
     
    5357        [HW_RES_GET_RESOURCE_LIST] = &remote_hw_res_get_resource_list,
    5458        [HW_RES_ENABLE_INTERRUPT] = &remote_hw_res_enable_interrupt,
     59        [HW_RES_DISABLE_INTERRUPT] = &remote_hw_res_disable_interrupt,
     60        [HW_RES_CLEAR_INTERRUPT] = &remote_hw_res_clear_interrupt,
    5561        [HW_RES_DMA_CHANNEL_SETUP] = &remote_hw_res_dma_channel_setup,
    5662        [HW_RES_DMA_CHANNEL_REMAIN] = &remote_hw_res_dma_channel_remain,
     
    6773        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
    6874       
    69         if (hw_res_ops->enable_interrupt == NULL)
     75        if (hw_res_ops->enable_interrupt == NULL) {
    7076                async_answer_0(callid, ENOTSUP);
    71         else if (hw_res_ops->enable_interrupt(fun))
    72                 async_answer_0(callid, EOK);
    73         else
    74                 async_answer_0(callid, EREFUSED);
     77                return;
     78        }
     79       
     80        const int irq = DEV_IPC_GET_ARG1(*call);
     81        const int ret = hw_res_ops->enable_interrupt(fun, irq);
     82        async_answer_0(callid, ret);
     83}
     84
     85static void remote_hw_res_disable_interrupt(ddf_fun_t *fun, void *ops,
     86    ipc_callid_t callid, ipc_call_t *call)
     87{
     88        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
     89       
     90        if (hw_res_ops->disable_interrupt == NULL) {
     91                async_answer_0(callid, ENOTSUP);
     92                return;
     93        }
     94       
     95        const int irq = DEV_IPC_GET_ARG1(*call);
     96        const int ret = hw_res_ops->disable_interrupt(fun, irq);
     97        async_answer_0(callid, ret);
     98}
     99
     100static void remote_hw_res_clear_interrupt(ddf_fun_t *fun, void *ops,
     101    ipc_callid_t callid, ipc_call_t *call)
     102{
     103        hw_res_ops_t *hw_res_ops = (hw_res_ops_t *) ops;
     104       
     105        if (hw_res_ops->clear_interrupt == NULL) {
     106                async_answer_0(callid, ENOTSUP);
     107                return;
     108        }
     109       
     110        const int irq = DEV_IPC_GET_ARG1(*call);
     111        const int ret = hw_res_ops->enable_interrupt(fun, irq);
     112        async_answer_0(callid, ret);
    75113}
    76114
Note: See TracChangeset for help on using the changeset viewer.