Changeset 57c8fc9 in mainline


Ignore:
Timestamp:
2013-09-21T02:17:14Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c898236
Parents:
ce33c10
Message:

libusbhost: Move interrupt enabling to library.

Reduce code duplication.

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/res.c

    rce33c10 r57c8fc9  
    105105        hw_res_list_parsed_clean(&hw_res);
    106106        return EOK;
    107 }
    108 
    109 /** Calls the PCI driver with a request to enable interrupts
    110  *
    111  * @param[in] device Device asking for interrupts
    112  * @return Error code.
    113  */
    114 int enable_interrupts(ddf_dev_t *device)
    115 {
    116         async_sess_t *parent_sess = devman_parent_device_connect(
    117             EXCHANGE_SERIALIZE, ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    118         if (!parent_sess)
    119                 return ENOMEM;
    120        
    121         const bool enabled = hw_res_enable_interrupt(parent_sess);
    122         async_hangup(parent_sess);
    123        
    124         return enabled ? EOK : EIO;
    125107}
    126108
  • uspace/drv/bus/usb/ohci/ohci.c

    rce33c10 r57c8fc9  
    114114        /* Try to enable interrupts */
    115115        bool interrupts = false;
    116         ret = enable_interrupts(device);
     116        ret = hcd_ddf_enable_interrupts(device);
    117117        if (ret != EOK) {
    118118                usb_log_warning("Failed to enable interrupts: %s."
  • uspace/drv/bus/usb/ohci/res.c

    rce33c10 r57c8fc9  
    8585}
    8686
    87 /** Call the PCI driver with a request to enable interrupts
    88  *
    89  * @param[in] device Device asking for interrupts
    90  * @return Error code.
    91  */
    92 int enable_interrupts(ddf_dev_t *device)
    93 {
    94         async_sess_t *parent_sess =
    95             devman_parent_device_connect(EXCHANGE_SERIALIZE,
    96             ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    97         if (!parent_sess)
    98                 return ENOMEM;
    99        
    100         const bool enabled = hw_res_enable_interrupt(parent_sess);
    101         async_hangup(parent_sess);
    102        
    103         return enabled ? EOK : EIO;
    104 }
    10587
    10688/**
  • uspace/drv/bus/usb/uhci/res.c

    rce33c10 r57c8fc9  
    8383}
    8484
    85 /** Call the PCI driver with a request to enable interrupts
    86  *
    87  * @param[in] device Device asking for interrupts
    88  * @return Error code.
    89  */
    90 int enable_interrupts(ddf_dev_t *device)
    91 {
    92         async_sess_t *parent_sess =
    93             devman_parent_device_connect(EXCHANGE_SERIALIZE,
    94             ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
    95         if (!parent_sess)
    96                 return ENOMEM;
    97 
    98         const bool enabled = hw_res_enable_interrupt(parent_sess);
    99         async_hangup(parent_sess);
    100 
    101         return enabled ? EOK : EIO;
    102 }
    103 
    10485/** Call the PCI driver with a request to clear legacy support register
    10586 *
  • uspace/drv/bus/usb/uhci/uhci.c

    rce33c10 r57c8fc9  
    115115
    116116        bool interrupts = false;
    117         ret = enable_interrupts(device);
     117        ret = hcd_ddf_enable_interrupts(device);
    118118        if (ret != EOK) {
    119119                usb_log_warning("Failed to enable interrupts: %s."
  • uspace/lib/usbhost/include/usb/host/ddf_helpers.h

    rce33c10 r57c8fc9  
    3737#define LIBUSBHOST_HOST_DDF_HELPERS_H
    3838
     39#include <device/hw_res_parsed.h>
    3940#include <usb/host/hcd.h>
    4041#include <usbhc_iface.h>
     
    4748hcd_t *dev_to_hcd(ddf_dev_t *dev);
    4849
     50int hcd_ddf_enable_interrupts(ddf_dev_t *device);
     51int hcd_ddf_get_registers(ddf_dev_t *device, hw_res_list_parsed_t *hw_res);
     52
    4953#endif
    5054
  • uspace/lib/usbhost/src/ddf_helpers.c

    rce33c10 r57c8fc9  
    3939#include <usb/descriptor.h>
    4040#include <usb/request.h>
     41#include <devman.h>
    4142#include <errno.h>
    4243#include <str_error.h>
     
    640641                ddf_fun_destroy(hc->ctl_fun);
    641642}
     643
     644
     645//TODO: Move this to generic ddf?
     646/** Call the parent driver with a request to enable interrupts
     647 *
     648 * @param[in] device Device asking for interrupts
     649 * @return Error code.
     650 */
     651int hcd_ddf_enable_interrupts(ddf_dev_t *device)
     652{
     653        assert(device);
     654        async_sess_t *parent_sess =
     655            devman_parent_device_connect(EXCHANGE_SERIALIZE,
     656            ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
     657        const bool enabled = hw_res_enable_interrupt(parent_sess);
     658        async_hangup(parent_sess);
     659
     660        return enabled ? EOK : EIO;
     661}
     662
     663int hcd_ddf_get_registers(ddf_dev_t *device, hw_res_list_parsed_t *hw_res)
     664{
     665        assert(device);
     666        assert(hw_res);
     667
     668        async_sess_t *parent_sess =
     669            devman_parent_device_connect(EXCHANGE_SERIALIZE,
     670            ddf_dev_get_handle(device), IPC_FLAG_BLOCKING);
     671        hw_res_list_parsed_init(hw_res);
     672        const int ret = hw_res_get_list_parsed(parent_sess, hw_res, 0);
     673        async_hangup(parent_sess);
     674        return ret;
     675}
    642676/**
    643677 * @}
Note: See TracChangeset for help on using the changeset viewer.