I am learning how to develop a simple driver for a card connected to the USB1 serial port. I wanted to know how the kernel understands that my device should display as / dev / ebbchar. How to switch to / dev / ebbGV? and if I connect another device, why can't I see / dev / ebbchar but / dev / tty0? Thank you In short, how to do the kernel to understand that the board is connecting to USB1, is ebbchar or another device?
My driver initialization function:
static int __init ebbchar_init(void){
printk(KERN_INFO "EBBChar: Initializing the EBBChar LKM\n");
majorNumber = register_chrdev(0, ebbchar, &fops);
if (majorNumber<0){
printk(KERN_ALERT "EBBChar failed to register a major number\n");
return majorNumber;
}
printk(KERN_INFO "EBBChar: registered correctly with major number %d\n", majorNumber);
ebbcharClass = class_create(THIS_MODULE, ebb);
if (IS_ERR(ebbcharClass)){
unregister_chrdev(majorNumber, ebbchar);
printk(KERN_ALERT "Failed to register device class\n");
return PTR_ERR(ebbcharClass);
}
printk(KERN_INFO "EBBChar: device class registered correctly\n");
ebbcharDevice = device_create(ebbcharClass, NULL, MKDEV(majorNumber, 0), NULL, DEVICE_NAME);
if (IS_ERR(ebbcharDevice)){
class_destroy(ebbcharClass);
unregister_chrdev(majorNumber, ebbchar);
printk(KERN_ALERT "Failed to create the device\n");
return PTR_ERR(ebbcharDevice);
}
printk(KERN_INFO "EBBChar: device class created correctly\n");
return 0;
}
thank
source
share