registering a USB device with 2 minor versions - similar to socketcan
Our device ( USB to CAN device ) has two CAN channels. SOCKETCAN framework allows creation of 2 netdev for both the channels. These 2 netdev s are known to user applications and it's easy to communicate with SOCKETCAN driver.
But I plan to write a USB driver for my device, but the device gets registered as single device.
static struct usb_class_driver mydevice_class = {
.name = "abc_candev_%d",
.devnode = candev_devnode,
.fops = &mycandev_fops,
.minor_base = USB_CAN__MINOR_BASE,
};
...
ret = usb_register_dev(intf, &mydevice_class); // inside probe function
...
I access the device in open as below:,
static int mycandev_open(struct inode *inode, struct file *file)
{
struct mycan_device *dev;
struct usb_interface *interface;
int subminor;
int retval = 0;
subminor = iminor(inode);
printk(KERN_DEBUG " mycandev_open------- subminor, %d ", subminor);
interface = usb_find_interface(&mycandriver, subminor);
...
}
Client uses "/dev/abc_candev_0" in open system call. Is it possible to register the single device with 2 minor versions so that in open, handling is easy? Otherwise, I need to have another ioctl call to handle the channel specific after open.
In my device struct, I have one private struct to handle the channel specific.
Better approach is all I am looking.
|