Changes in uspace/drv/ohci/pci.c [79ae36dd:dc5f2fb] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/pci.c

    r79ae36dd rdc5f2fb  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    28 
    2928/**
    3029 * @addtogroup drvusbohci
     
    3534 * PCI related functions needed by the OHCI driver.
    3635 */
    37 
    3836#include <errno.h>
    3937#include <assert.h>
     
    6563        assert(irq_no);
    6664
    67         async_sess_t *parent_sess =
    68             devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
     65        int parent_phone = devman_parent_device_connect(dev->handle,
    6966            IPC_FLAG_BLOCKING);
    70         if (!parent_sess)
    71                 return ENOMEM;
    72        
     67        if (parent_phone < 0) {
     68                return parent_phone;
     69        }
     70
     71        int rc;
     72
    7373        hw_resource_list_t hw_resources;
    74         int rc = hw_res_get_resource_list(parent_sess, &hw_resources);
     74        rc = hw_res_get_resource_list(parent_phone, &hw_resources);
    7575        if (rc != EOK) {
    76                 async_hangup(parent_sess);
     76                async_hangup(parent_phone);
    7777                return rc;
    7878        }
    79        
     79
    8080        uintptr_t mem_address = 0;
    8181        size_t mem_size = 0;
    8282        bool mem_found = false;
    83        
     83
    8484        int irq = 0;
    8585        bool irq_found = false;
    86        
     86
    8787        size_t i;
    8888        for (i = 0; i < hw_resources.count; i++) {
    8989                hw_resource_t *res = &hw_resources.resources[i];
    90                 switch (res->type) {
     90                switch (res->type)
     91                {
    9192                case INTERRUPT:
    9293                        irq = res->res.interrupt.irq;
     
    9495                        usb_log_debug2("Found interrupt: %d.\n", irq);
    9596                        break;
     97
    9698                case MEM_RANGE:
    9799                        if (res->res.mem_range.address != 0
     
    102104                                    (void *) mem_address, mem_size);
    103105                                mem_found = true;
    104                         }
     106                                }
    105107                default:
    106108                        break;
    107109                }
    108110        }
    109        
     111
    110112        if (mem_found && irq_found) {
    111113                *mem_reg_address = mem_address;
     
    113115                *irq_no = irq;
    114116                rc = EOK;
    115         } else
     117        } else {
    116118                rc = ENOENT;
    117        
    118         async_hangup(parent_sess);
     119        }
     120
     121        async_hangup(parent_phone);
    119122        return rc;
    120123}
    121 
    122 /** Call the PCI driver with a request to enable interrupts
     124/*----------------------------------------------------------------------------*/
     125/** Calls the PCI driver with a request to enable interrupts
    123126 *
    124127 * @param[in] device Device asking for interrupts
     
    127130int pci_enable_interrupts(ddf_dev_t *device)
    128131{
    129         async_sess_t *parent_sess =
    130             devman_parent_device_connect(EXCHANGE_SERIALIZE, device->handle,
    131             IPC_FLAG_BLOCKING);
    132         if (!parent_sess)
    133                 return ENOMEM;
    134        
    135         bool enabled = hw_res_enable_interrupt(parent_sess);
    136         async_hangup(parent_sess);
    137        
     132        int parent_phone =
     133            devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING);
     134        if (parent_phone < 0) {
     135                return parent_phone;
     136        }
     137        bool enabled = hw_res_enable_interrupt(parent_phone);
     138        async_hangup(parent_phone);
    138139        return enabled ? EOK : EIO;
    139140}
     141/**
     142 * @}
     143 */
    140144
    141145/**
Note: See TracChangeset for help on using the changeset viewer.