Changeset 68e5406 in mainline


Ignore:
Timestamp:
2017-12-10T21:08:11Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4c6de4f
Parents:
dd8ab1c
Message:

Separate return value from error code in gen_irq_code*() and hcd_send_batch_sync().

Location:
uspace
Files:
10 edited

Legend:

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

    rdd8ab1c r68e5406  
    9696 * @param[in] hw_res Device's resources.
    9797 *
     98 * @param[out] irq
     99 *
    98100 * @return Error code.
    99101 */
    100 int ehci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res)
     102int ehci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res, int *irq)
    101103{
    102104        assert(code);
     
    146148            RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]);
    147149
    148         return hw_res->irqs.irqs[0];
     150        *irq = hw_res->irqs.irqs[0];
     151        return EOK;
    149152}
    150153
  • uspace/drv/bus/usb/ehci/hc.h

    rdd8ab1c r68e5406  
    8888void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep);
    8989
    90 int ehci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res);
     90int ehci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res, int *irq);
    9191
    9292void ehci_hc_interrupt(hcd_t *hcd, uint32_t status);
  • uspace/drv/bus/usb/ohci/hc.c

    rdd8ab1c r68e5406  
    103103 * @return Error code.
    104104 */
    105 int ohci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res)
     105int ohci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res, int *irq)
    106106{
    107107        assert(code);
     
    141141            RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]);
    142142
    143         return hw_res->irqs.irqs[0];
     143        *irq = hw_res->irqs.irqs[0];
     144        return EOK;
    144145}
    145146
  • uspace/drv/bus/usb/ohci/hc.h

    rdd8ab1c r68e5406  
    8686extern void hc_dequeue_endpoint(hc_t *, const endpoint_t *);
    8787
    88 int ohci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res);
     88int ohci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res, int *irq);
    8989
    9090extern void ohci_hc_interrupt(hcd_t *, uint32_t);
  • uspace/drv/bus/usb/uhci/hc.c

    rdd8ab1c r68e5406  
    103103 * @param[out] code IRQ code structure.
    104104 * @param[in] hw_res Device's resources.
     105 * @param[out] irq
    105106 *
    106107 * @return Error code.
    107108 */
    108 int uhci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res)
     109int uhci_hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res, int *irq)
    109110{
    110111        assert(code);
     
    142143            RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]);
    143144
    144         return hw_res->irqs.irqs[0];
     145        *irq = hw_res->irqs.irqs[0];
     146        return EOK;
    145147}
    146148
  • uspace/drv/bus/usb/uhci/hc.h

    rdd8ab1c r68e5406  
    127127extern void hc_fini(hc_t *);
    128128
    129 extern int uhci_hc_gen_irq_code(irq_code_t *, const hw_res_list_parsed_t *);
     129extern int uhci_hc_gen_irq_code(irq_code_t *, const hw_res_list_parsed_t *, int *);
    130130
    131131extern void uhci_hc_interrupt(hcd_t *, uint32_t);
  • uspace/lib/usbhost/include/usb/host/ddf_helpers.h

    rdd8ab1c r68e5406  
    4848typedef void (*driver_fini_t)(hcd_t *);
    4949typedef int (*claim_t)(ddf_dev_t *);
    50 typedef int (*irq_code_gen_t)(irq_code_t *, const hw_res_list_parsed_t *);
     50typedef int (*irq_code_gen_t)(irq_code_t *, const hw_res_list_parsed_t *, int *);
    5151
    5252typedef struct {
     
    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 *, int *),
    7878    cap_handle_t *handle);
    7979void ddf_hcd_gen_irq_handler(ipc_call_t *call, ddf_dev_t *dev);
  • uspace/lib/usbhost/include/usb/host/hcd.h

    rdd8ab1c r68e5406  
    102102}
    103103
    104 extern usb_address_t hcd_request_address(hcd_t *, usb_speed_t);
     104extern int hcd_request_address(hcd_t *, usb_speed_t, usb_address_t *);
    105105
    106106extern int hcd_release_address(hcd_t *, usb_address_t);
     
    123123    usbhc_iface_transfer_out_callback_t, void *, const char *);
    124124
    125 extern ssize_t hcd_send_batch_sync(hcd_t *, usb_target_t, usb_direction_t,
    126     void *, size_t, uint64_t, const char *);
     125extern int hcd_send_batch_sync(hcd_t *, usb_target_t, usb_direction_t,
     126    void *, size_t, uint64_t, const char *, size_t *);
    127127
    128128#endif
  • uspace/lib/usbhost/src/ddf_helpers.c

    rdd8ab1c r68e5406  
    481481        }};
    482482
    483         const usb_address_t address = hcd_request_address(hcd, speed);
    484         if (address < 0) {
     483        usb_address_t address;
     484        ret = hcd_request_address(hcd, speed, &address);
     485        if (ret != EOK) {
    485486                usb_log_error("Failed to reserve new address: %s.",
    486                     str_error(address));
    487                 return address;
     487                    str_error(ret));
     488                return ret;
    488489        }
    489490
     
    518519        usb_log_debug("Device(%d): Requesting first 8B of device descriptor.",
    519520            address);
    520         ssize_t got = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_IN,
     521        size_t got;
     522        ret = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_IN,
    521523            &desc, CTRL_PIPE_MIN_PACKET_SIZE, *(uint64_t *)&get_device_desc_8,
    522             "read first 8 bytes of dev descriptor");
    523 
    524         if (got != CTRL_PIPE_MIN_PACKET_SIZE) {
    525                 ret = got < 0 ? got : EOVERFLOW;
     524            "read first 8 bytes of dev descriptor", &got);
     525
     526        if (ret == EOK && got != CTRL_PIPE_MIN_PACKET_SIZE) {
     527                ret = EOVERFLOW;
     528        }
     529
     530        if (ret != EOK) {
    526531                usb_log_error("Device(%d): Failed to get 8B of dev descr: %s.",
    527532                    address, str_error(ret));
     
    552557
    553558        usb_log_debug("Device(%d): Setting USB address.", address);
    554         got = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_OUT,
    555             NULL, 0, *(uint64_t *)&set_address, "set address");
     559        ret = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_OUT,
     560            NULL, 0, *(uint64_t *)&set_address, "set address", &got);
    556561
    557562        usb_log_debug("Device(%d): Removing default (0:0) EP.", address);
    558563        hcd_remove_ep(hcd, default_target, USB_DIRECTION_BOTH);
    559564
    560         if (got != 0) {
     565        if (ret != EOK) {
    561566                usb_log_error("Device(%d): Failed to set new address: %s.",
    562                     address, str_error(got));
     567                    address, str_error(ret));
    563568                hcd_remove_ep(hcd, target, USB_DIRECTION_BOTH);
    564569                hcd_release_address(hcd, address);
    565                 return got;
     570                return ret;
    566571        }
    567572
     
    572577        usb_log_debug("Device(%d): Requesting full device descriptor.",
    573578            address);
    574         got = hcd_send_batch_sync(hcd, target, USB_DIRECTION_IN,
     579        ret = hcd_send_batch_sync(hcd, target, USB_DIRECTION_IN,
    575580            &desc, sizeof(desc), *(uint64_t *)&get_device_desc,
    576             "read device descriptor");
     581            "read device descriptor", &got);
    577582        if (ret != EOK) {
    578583                usb_log_error("Device(%d): Failed to set get dev descriptor: %s",
     
    749754    const hw_res_list_parsed_t *hw_res,
    750755    interrupt_handler_t handler,
    751     int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *hw_res),
     756    int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *, int *),
    752757    cap_handle_t *handle)
    753758{
     
    759764        irq_code_t irq_code = {0};
    760765
    761         const int irq = gen_irq_code(&irq_code, hw_res);
    762         if (irq < 0) {
     766        int irq;
     767        int ret = gen_irq_code(&irq_code, hw_res, &irq);
     768        if (ret != EOK) {
    763769                usb_log_error("Failed to generate IRQ code: %s.\n",
    764                     str_error(irq));
    765                 return irq;
     770                    str_error(ret));
     771                return ret;
    766772        }
    767773
    768774        /* Register handler to avoid interrupt lockup */
    769         int ret = register_interrupt_handler(device, irq, handler,
     775        ret = register_interrupt_handler(device, irq, handler,
    770776            &irq_code, handle);
    771777        irq_code_clean(&irq_code);
  • uspace/lib/usbhost/src/hcd.c

    rdd8ab1c r68e5406  
    102102}
    103103
    104 usb_address_t hcd_request_address(hcd_t *hcd, usb_speed_t speed)
    105 {
    106         assert(hcd);
    107         usb_address_t address = 0;
    108         const int ret = usb_bus_request_address(
    109             &hcd->bus, &address, false, speed);
    110         if (ret != EOK)
    111                 return ret;
    112         return address;
     104int hcd_request_address(hcd_t *hcd, usb_speed_t speed, usb_address_t *address)
     105{
     106        assert(hcd);
     107        return usb_bus_request_address(&hcd->bus, address, false, speed);
    113108}
    114109
     
    271266
    272267/** this is really ugly version of sync usb communication */
    273 ssize_t hcd_send_batch_sync(
     268int hcd_send_batch_sync(
    274269    hcd_t *hcd, usb_target_t target, usb_direction_t dir,
    275     void *data, size_t size, uint64_t setup_data, const char* name)
     270    void *data, size_t size, uint64_t setup_data, const char* name, size_t *out_size)
    276271{
    277272        assert(hcd);
     
    289284
    290285        if (sd.ret == EOK)
    291                 return sd.size;
     286                *out_size = sd.size;
    292287        return sd.ret;
    293288}
Note: See TracChangeset for help on using the changeset viewer.