Nov. 8, 2021
12:38 a.m.
On Sun, 07 Nov 2021 18:16:55 -0600, Drew Abbott said:
You mentioned that this shouldn't be called in an irq context, but the unplug event is detected with an irq. Where should I be calling kernel_power_off() if not in the irq context? I think one way of doing this would be to set a value that a heartbeat function reads in the irq, and then the heartbeat function calls the shutdown, but this driver doesn't use a heartbeat. Where else would I handle this?
There's a whole bunch of ways to schedule work in the kernel, it doesn't have to be a heartbeat function. Plenty of drivers are split into IRQ and non-IRQ parts (sometimes called the top and bottom parts of the driver). See how they get info from the IRQ part to the non-IRQ part.