Changeset da06e92 in mainline


Ignore:
Timestamp:
2014-01-02T20:32:46Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
972e8a9
Parents:
1a0fa29c
Message:

ohci: Use the newly provided helpers.

Location:
uspace/drv/bus/usb/ohci
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/Makefile

    r1a0fa29c rda06e92  
    4848        hc.c \
    4949        main.c \
    50         ohci.c \
    5150        ohci_batch.c \
    5251        ohci_endpoint.c \
  • uspace/drv/bus/usb/ohci/main.c

    r1a0fa29c rda06e92  
    4141
    4242#include <usb/debug.h>
     43#include <usb/host/ddf_helpers.h>
    4344
    44 #include "ohci.h"
     45#include "hc.h"
    4546
    4647#define NAME "ohci"
     48// TODO: This should be merged to hc_interrupt
     49static void ohci_interrupt(hcd_t *hcd, uint32_t status)
     50{
     51        assert(hcd);
     52        if (hcd->driver.data)
     53                hc_interrupt(hcd->driver.data, status);
     54}
     55
     56static int ohci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
     57{
     58        assert(hcd);
     59        assert(hcd->driver.data == NULL);
     60
     61        hc_t *instance = malloc(sizeof(hc_t));
     62        if (!instance)
     63                return ENOMEM;
     64
     65        const int ret =  hc_init(instance, res, irq);
     66        if (ret == EOK)
     67                hcd_set_implementation(hcd, instance, hc_schedule,
     68                    ohci_endpoint_init, ohci_endpoint_fini, ohci_interrupt);
     69        return ret;
     70}
     71
     72static void ohci_driver_fini(hcd_t *hcd)
     73{
     74        assert(hcd);
     75        if (hcd->driver.data)
     76                hc_fini(hcd->driver.data);
     77
     78        free(hcd->driver.data);
     79        hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL);
     80}
    4781
    4882/** Initializes a new ddf driver instance of OHCI hcd.
     
    5690        assert(device);
    5791
    58         int ret = device_setup_ohci(device);
     92        const int ret = ddf_hcd_device_setup_all(device, USB_SPEED_FULL,
     93            BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11,
     94            ddf_hcd_gen_irq_handler, hc_gen_irq_code,
     95            ohci_driver_init, ohci_driver_fini);
    5996        if (ret != EOK) {
    6097                usb_log_error("Failed to initialize OHCI driver: %s.\n",
    6198                    str_error(ret));
    62                 return ret;
    6399        }
    64         usb_log_info("Controlling new OHCI device '%s'.\n", ddf_dev_get_name(device));
     100        usb_log_info("Controlling new OHCI device '%s'.\n",
     101            ddf_dev_get_name(device));
    65102
    66         return EOK;
     103        return ret;
    67104}
    68105
Note: See TracChangeset for help on using the changeset viewer.