00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00036 #include <usb/dev/driver.h>
00037 #include <usb/debug.h>
00038 #include <errno.h>
00039 #include <str_error.h>
00040
00041 #define NAME "usbflbk"
00042
00048 static int usbfallback_add_device(usb_device_t *dev)
00049 {
00050 int rc;
00051 const char *fun_name = "ctl";
00052
00053 ddf_fun_t *ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed,
00054 fun_name);
00055 if (ctl_fun == NULL) {
00056 usb_log_error("Failed to create control function.\n");
00057 return ENOMEM;
00058 }
00059 rc = ddf_fun_bind(ctl_fun);
00060 if (rc != EOK) {
00061 usb_log_error("Failed to bind control function: %s.\n",
00062 str_error(rc));
00063 return rc;
00064 }
00065
00066 usb_log_info("Pretending to control %s `%s'" \
00067 " (node `%s', handle %" PRIun ").\n",
00068 dev->interface_no < 0 ? "device" : "interface",
00069 dev->ddf_dev->name, fun_name, dev->ddf_dev->handle);
00070
00071 return EOK;
00072 }
00073
00075 static usb_driver_ops_t usbfallback_driver_ops = {
00076 .add_device = usbfallback_add_device,
00077 };
00078
00080 static usb_driver_t usbfallback_driver = {
00081 .name = NAME,
00082 .ops = &usbfallback_driver_ops,
00083 .endpoints = NULL
00084 };
00085
00086 int main(int argc, char *argv[])
00087 {
00088 usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
00089
00090 return usb_driver_main(&usbfallback_driver);
00091 }
00092