LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 07-15-2020, 12:01 AM   #1
srirev
LQ Newbie
 
Registered: Jul 2020
Posts: 2

Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Socketcan question - reason for no candump output? mlb81 Linux - Newbie 0 12-05-2016 07:45 PM
USB driver not registering the device jjd3592 Linux - Newbie 2 04-26-2016 10:05 AM
[SOLVED] Minor versions masayk Slackware 20 04-08-2013 08:58 AM
upgrading debian minor build versions and from stable to testing Cultist Debian 3 03-23-2012 08:45 PM
2.6 kernel device registering Michael_S Linux - Hardware 0 07-13-2006 01:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 08:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration