Próbuję napisać własny sterownik USB, ale mam problem z podpięciem go pod hotplug-a. Na razie sterownik nie posiada żadnej funkcjonalności, a to jego kod:
Kod: Zaznacz cały
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/tty.h>
#include <linux/tty_driver.h>
#include <linux/tty_flip.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/spinlock.h>
#include <linux/uaccess.h>
#include <linux/usb.h>
#include "k8055.h"
#define DRIVER_AUTHOR "*****"
#define DRIVER_DESC "Velleman K8055 USB experiment interface board driver"
/* table of devices that work with this driver */
static struct usb_device_id k8055_devices_table []={
{ USB_DEVICE(K8055_VENDOR_ID, K8055_PRODUCT_ID0) },
{ USB_DEVICE(K8055_VENDOR_ID, K8055_PRODUCT_ID1) },
{ USB_DEVICE(K8055_VENDOR_ID, K8055_PRODUCT_ID2) },
{ USB_DEVICE(K8055_VENDOR_ID, K8055_PRODUCT_ID3) },
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE (usb, k8055_devices_table);
/* Structure to hold all of our device specific stuff */
struct k8055 {
struct usb_device* udev; /* the usb device for this device */
struct usb_interface* interface; /* the interface for this device */
unsigned char* interrupt_in_buffer; /* the buffer to receive data */
size_t interrupt_in_size; /* the size of the receive buffer */
__u8 interrupt_in_endpointAddr; /* the address of the interrupt in endpoint */
__u8 interrupt_out_endpointAddr; /* the address of the interrupt out endpoint */
struct kref refcount; /* the reference counter*/
};
static int k8055_probe(struct usb_interface *interface, const struct usb_device_id *id);
static void k8055_disconnect(struct usb_interface *interface);
static struct usb_driver k8055_driver = {
.name = "k8055",
.id_table = k8055_devices_table,
.probe = k8055_probe,
.disconnect = k8055_disconnect,
};
static int k8055_probe(struct usb_interface *interface, const struct usb_device_id *id)
{
printk("Function probe for k8055\n");
return 0;
}
static void k8055_disconnect(struct usb_interface *interface)
{
printk("Function disconnect for k8055\n");
}
static int __init usb_k8055_init(void)
{
int result;
/* register this driver with the USB subsystem */
result = usb_register(&k8055_driver);
if (result)
err("usb_register failed. Error number %d", result);
printk("usb_register(&k8055_driver) result -> %d\n", result);
printk("Function usb_k8055_init for k8055\n");
return result;
}
static void __exit usb_k8055_exit(void)
{
/* deregister this driver with the USB subsystem */
usb_deregister(&k8055_driver);
printk("Function usb_k8055_exit for k8055\n");
}
module_init (usb_k8055_init);
module_exit (usb_k8055_exit);
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL");
Następnie:
Kod: Zaznacz cały
make modules
make modules_install
Ma może ktoś doświadczenie ze sterownikami? Bo na razie nie ma pomysłu co dalej, czy może kompilacja jądra jest nie zbędna? Może ma ktoś jakiś pomysł?