Article 55QHM registering a USB device with 2 minor versions - similar to socketcan

registering a USB device with 2 minor versions - similar to socketcan

by
srirev
from LinuxQuestions.org on (#55QHM)
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.latest?d=yIl2AUoC8zA latest?i=CVDxJm2Mp44:L1TwoFo-Mfw:F7zBnMy latest?i=CVDxJm2Mp44:L1TwoFo-Mfw:V_sGLiP latest?d=qj6IDK7rITs latest?i=CVDxJm2Mp44:L1TwoFo-Mfw:gIN9vFwCVDxJm2Mp44
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments