Changeset b4b534ac in mainline for uspace/drv/bus/usb/ohci/main.c


Ignore:
Timestamp:
2016-07-22T08:24:47Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f76d2c2
Parents:
5b18137 (diff), 8351f9a4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~jan.vesely/helenos/usb

File:
1 edited

Legend:

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

    r5b18137 rb4b534ac  
    3333 * Main routines of OHCI driver.
    3434 */
     35
     36#include <assert.h>
    3537#include <ddf/driver.h>
    3638#include <errno.h>
     39#include <io/log.h>
    3740#include <str_error.h>
    3841
    3942#include <usb/debug.h>
     43#include <usb/host/ddf_helpers.h>
    4044
    41 #include "ohci.h"
     45#include "hc.h"
    4246
    4347#define NAME "ohci"
     48static int ohci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
     49static void ohci_driver_fini(hcd_t *);
     50
     51static 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
     67static 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
     85static 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}
    4495
    4596/** Initializes a new ddf driver instance of OHCI hcd.
     
    52103        usb_log_debug("ohci_dev_add() called\n");
    53104        assert(device);
    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;
     105        return hcd_ddf_add_hc(device, &ohci_hc_driver);
    64106}
    65107
    66 static driver_ops_t ohci_driver_ops = {
     108static const driver_ops_t ohci_driver_ops = {
    67109        .dev_add = ohci_dev_add,
    68110};
    69111
    70 static driver_t ohci_driver = {
     112static const driver_t ohci_driver = {
    71113        .name = NAME,
    72114        .driver_ops = &ohci_driver_ops
Note: See TracChangeset for help on using the changeset viewer.