Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/main.c

    r55346870 r920d0fc  
    3333 * Main routines of OHCI driver.
    3434 */
    35 
    36 #include <assert.h>
    3735#include <ddf/driver.h>
    3836#include <errno.h>
    39 #include <io/log.h>
    4037#include <str_error.h>
    4138
    4239#include <usb/debug.h>
    43 #include <usb/host/ddf_helpers.h>
    4440
    45 #include "hc.h"
     41#include "ohci.h"
    4642
    4743#define NAME "ohci"
    48 static int ohci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
    49 static void ohci_driver_fini(hcd_t *);
    50 
    51 static const ddf_hc_driver_t ohci_hc_driver = {
    52         .hc_speed = USB_SPEED_FULL,
    53         .irq_code_gen = ohci_hc_gen_irq_code,
    54         .init = ohci_driver_init,
    55         .fini = ohci_driver_fini,
    56         .name = "OHCI",
    57         .ops = {
    58                 .schedule       = ohci_hc_schedule,
    59                 .ep_add_hook    = ohci_endpoint_init,
    60                 .ep_remove_hook = ohci_endpoint_fini,
    61                 .irq_hook       = ohci_hc_interrupt,
    62                 .status_hook    = ohci_hc_status,
    63         },
    64 };
    65 
    66 
    67 static int ohci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
    68 {
    69         assert(hcd);
    70         assert(hcd_get_driver_data(hcd) == NULL);
    71 
    72         hc_t *instance = malloc(sizeof(hc_t));
    73         if (!instance)
    74                 return ENOMEM;
    75 
    76         const int ret = hc_init(instance, res, irq);
    77         if (ret == EOK) {
    78                 hcd_set_implementation(hcd, instance, &ohci_hc_driver.ops);
    79         } else {
    80                 free(instance);
    81         }
    82         return ret;
    83 }
    84 
    85 static void ohci_driver_fini(hcd_t *hcd)
    86 {
    87         assert(hcd);
    88         hc_t *hc = hcd_get_driver_data(hcd);
    89         if (hc)
    90                 hc_fini(hc);
    91 
    92         hcd_set_implementation(hcd, NULL, NULL);
    93         free(hc);
    94 }
    9544
    9645/** Initializes a new ddf driver instance of OHCI hcd.
     
    10352        usb_log_debug("ohci_dev_add() called\n");
    10453        assert(device);
    105         return hcd_ddf_add_hc(device, &ohci_hc_driver);
     54
     55        int ret = device_setup_ohci(device);
     56        if (ret != EOK) {
     57                usb_log_error("Failed to initialize OHCI driver: %s.\n",
     58                    str_error(ret));
     59                return ret;
     60        }
     61        usb_log_info("Controlling new OHCI device '%s'.\n", ddf_dev_get_name(device));
     62
     63        return EOK;
    10664}
    10765
    108 static const driver_ops_t ohci_driver_ops = {
     66static driver_ops_t ohci_driver_ops = {
    10967        .dev_add = ohci_dev_add,
    11068};
    11169
    112 static const driver_t ohci_driver = {
     70static driver_t ohci_driver = {
    11371        .name = NAME,
    11472        .driver_ops = &ohci_driver_ops
Note: See TracChangeset for help on using the changeset viewer.