Changeset 6c8a221c in mainline for uspace/drv/bus/usb/usbdbg/main.c


Ignore:
Timestamp:
2017-11-26T12:14:38Z (6 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1814b4ae
Parents:
d23fab9
Message:

usbdbg: basic device driver bookkeeping

File:
1 edited

Legend:

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

    rd23fab9 r6c8a221c  
    3838#include <usb/dev/driver.h>
    3939
     40#include "usbdbg.h"
     41#include "device.h"
     42
    4043#define NAME "usbdbg"
    4144
    42 static int usbdbg_device_add(usb_device_t *dev)
     45static int device_add(usb_device_t *dev)
    4346{
    44         usb_log_info("usbdbg_device_add");
     47        usb_log_info("Adding device '%s'", usb_device_get_name(dev));
     48
     49        int err;
     50
     51        usb_dbg_dev_t *dbg_dev;
     52        if ((err = usb_dbg_dev_create(dev, &dbg_dev)))
     53                return err;
     54
     55        /* TODO: Register device in some list. */
     56        /* TODO: Register device DDF function. */
     57
    4558        return EOK;
    4659}
    4760
    48 static int usbdbg_device_remove(usb_device_t *dev)
     61static int device_remove(usb_device_t *dev)
    4962{
    50         usb_log_info("usbdbg_device_remove");
     63        usb_log_info("Removing device '%s'", usb_device_get_name(dev));
     64
     65        usb_dbg_dev_t *dbg_dev = usb_dbg_dev_get(dev);
     66
     67        /* TODO: Make sure nothing is going on with the device. */
     68        /* TODO: Unregister device DDF function. */
     69        /* TODO: Remove device from list */
     70
     71        usb_dbg_dev_destroy(dbg_dev);
     72
    5173        return EOK;
    5274}
    5375
    54 static int usbdbg_device_gone(usb_device_t *dev)
     76static int device_gone(usb_device_t *dev)
    5577{
    56         usb_log_info("usbdbg_device_gone");
     78        usb_log_info("Device '%s' gone.", usb_device_get_name(dev));
     79
     80        usb_dbg_dev_t *dbg_dev = usb_dbg_dev_get(dev);
     81
     82        /* TODO: Make sure nothing is going on with the device. */
     83        /* TODO: Unregister device DDF function. */
     84        /* TODO: Remove device from list */
     85
     86        usb_dbg_dev_destroy(dbg_dev);
     87
    5788        return EOK;
    5889}
    5990
    60 static int usbdbg_function_online(ddf_fun_t *fun)
     91static int function_online(ddf_fun_t *fun)
    6192{
    62         /* TODO: What if this is the control function? */
    6393        return ddf_fun_online(fun);
    6494}
    6595
    66 static int usbdbg_function_offline(ddf_fun_t *fun)
     96static int function_offline(ddf_fun_t *fun)
    6797{
    68         /* TODO: What if this is the control function? */
    6998        return ddf_fun_offline(fun);
    7099}
     
    72101/** USB debug driver ops. */
    73102static const usb_driver_ops_t dbg_driver_ops = {
    74         .device_add = usbdbg_device_add,
    75         .device_rem = usbdbg_device_remove,
    76         .device_gone = usbdbg_device_gone,
    77         .function_online = usbdbg_function_online,
    78         .function_offline = usbdbg_function_offline
     103        .device_add = device_add,
     104        .device_rem = device_remove,
     105        .device_gone = device_gone,
     106        .function_online = function_online,
     107        .function_offline = function_offline
    79108};
    80109
Note: See TracChangeset for help on using the changeset viewer.