aboutsummaryrefslogtreecommitdiffstats
path: root/io_libusb.c
diff options
context:
space:
mode:
Diffstat (limited to 'io_libusb.c')
-rw-r--r--io_libusb.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/io_libusb.c b/io_libusb.c
index 0c30494..4890747 100644
--- a/io_libusb.c
+++ b/io_libusb.c
@@ -1,3 +1,14 @@
+/*
+ * io_libusb.c
+ *
+ * Copyright (C) 200X ???
+ * Copyright (C) 2011 Holger Hans Peter Freyther
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2.
+ *
+ */
#include "config.h"
#include <usb.h>
@@ -8,7 +19,7 @@
static usb_dev_handle *io_handle;
-int io_init( char *dev )
+static int lusb_io_init( char *dev )
{
struct usb_bus *bus;
struct usb_device *usbdev;
@@ -43,7 +54,7 @@ int io_init( char *dev )
return -1;
}
-int io_cleanup( void )
+static int lusb_io_cleanup( void )
{
usb_release_interface(io_handle, 1);
usb_close(io_handle);
@@ -51,7 +62,7 @@ int io_cleanup( void )
}
-int io_write( void *buff, int len )
+static int lusb_io_write( void *buff, int len )
{
int ret = usb_bulk_write(io_handle, 0x1, buff, len, 5000);
if( ret < 0 ) {
@@ -60,7 +71,7 @@ int io_write( void *buff, int len )
return ret;
}
-int io_read( void *buff, int len )
+static int lusb_io_read( void *buff, int len )
{
int ret = usb_bulk_read(io_handle, 0x82, buff, len, 5000);
if( ret < 0 ) {
@@ -68,3 +79,16 @@ int io_read( void *buff, int len )
}
return ret;
}
+
+static struct io_driver lusb_driver = {
+ .name = "libusb",
+ .io_init = lusb_io_init,
+ .io_cleanup = lusb_io_cleanup,
+ .io_write = lusb_io_write,
+ .io_read = lusb_io_read,
+};
+
+static void __attribute__((constructor)) lusb_on_load(void)
+{
+ io_driver_register(&lusb_driver);
+}