I've been tasked with updating a driver on a Raspberry Pi 4 running Raspbian. I'm told I need to apply this patch https://lkml.org/lkml/2019/4/1/1050 in order to get my USB modem to work.
You are in luck in the sense that that patch has already been applied. Here is the relevant source file in what is approximately the current Pi kernel source:
I also checked 4.14, since that LKML post appears to be dated 2019 and refers to 4.14. You can check your current kernel version with
uname -r. If it is less than 4.14 you should upgrade.
If you already have a current kernel but the modem still does not work, this is probably not such great news (perhaps consider an XY problem here). To dispell any doubts, you can read up on how the
patch utility works (see also
man patch); in short the lines marked on the left with
+ in that patch file are to be added to the target. The rest is there for context.
What that amounts to is simply adding the USB ID for a particular make and model of device; there's no real functional code there. These are used by the kernel to associate USB devices (which provide an ID) with drivers. You can see these with
lsusb (you may need to
apt install usbutils). That modem will appear as
2c7c:0512. The first number is the
QUECTEL_VENDOR_ID, the second the
QUECTEL_PRODUCT_EM12 ID. Note
lsusb will show it regardless of whether an appropriate driver is loaded or available (ie., this does not indicate it works).
I don't think these are strictly necessary in order to use the driver; you can manually load it (
sudo modprobe option; you can see if it is loaded with
lsmod | grep option). The ID, again, is so it can be automatically loaded when the device is plugged in.