The main problem with the unloadable function/host driver modules was that the "vold" android userspace daemon really didn’t like the USB mass storage /sys entries not being present. If you watched on "adb logcat", it entered a constant segfault cycle; even loading the module didn’t stop it from doing this.
The net result was that it was impossible to mount the phone as a usb storage device. It also chewed the battery quite fast as it was constantly trying to restart vold and logging the error. To solve this, I’ve split the mass_storage function driver into two parts:
- The first, mass_storage_stub.c is compiled into the kernel and is responsible for creating and maintaining the /sys devices, and has stub function calls to support read and writes to/from them.
- The second, mass_storage.c, is compiled into the f_msm_hsusb.ko module and implements the rest of the mass storage function driver.
This way, the bulk of the mass storage code can be unloaded, but the /sys nodes remain behind (and do nothing) so userspace is happy.
Obviously, proper OTG support would be the ideal solution as this is rather a hack. However, this does the job and is much quicker to implement.
Anyway, I think that is enough on it for this evening, so I’ll test/debug it all tomorrow. At least – apart from the vold issue – I know this codebase worked reliably to begin wiith!