I have a USB device that I am using with Ubuntu 20.04.3. The manufacturer provided a library and a driver.
I can install the driver and get the device to work, but every time the kernel updates I must reinstall the driver to the new tree. I understand that this is the job of dkms and I started working on getting that up as it doesn't look too difficult, but taking a step back I am wondering if there might be a simpler/better way to get the device to work as I think that most of their userbase is windows, so there is not much dev time given to the linux side of things. And anyway I want to understand more about how linux does things.
The driver they supply is a slightly modified Exar driver. Looking at the diffs between their version and the vanilla Exar driver, basically all they did was add their vendor number and product id number to the code so their device would be recognized as compatible to the driver and run the appropriate blocks of code (same as the specific Exar chip they use) when the device matches their device descriptor.
Based on this very helpful page and other sources around the internet, my understanding is that each driver has a modules.alias file that essentially has rules on what types of devices it accepts. Then when the device is plugged in, the system pulls info from the device to make a modalias file for that device. Then the first, most specific driver to match the device modalias to a rule in the modules.alias file is the driver that gets assigned to the device.
So I imagine my device has an Exar chip and could use the Exar driver to make it work if the driver accepted it and recognized it as essentially an Exar chip. But since the manufacturer put their own custom device descriptor, modprobe doesn't recognize the device as being compatible with the vanilla Exar driver.
Rather than copying the driver and modifying it so slightly to make the system honor it as they did, is there a way to tell the system that this device really is compatible with the vanilla Exar driver or has an Exar device hidden within as some kind of sub-device? Like an alias for device descriptors as far as modprobe is concerned?
Or perhaps there's a way to write a different driver for this device that utilizes the underlying exar driver and passes everything through to it rather than copying the code? Then I could get the benefit of updates from the chip manufacturer.
Or should I continue with dkms because the way the manufacturer did it the best way to do it?
I have seen examples on how to bind and unbind drivers to devices with udev rules, but I think that if the driver doen't match, it won't be bound anyway? And even if it did, would that be the "best" way?