On Thu, Dec 16, 2021 at 05:38:04PM +0900, Chanwoo Choi wrote: > > > > To be honest, I'm not sure how this differs from other functions which > > return -EPROBE_DEFER. How do other functions guarantee they will only > > be called from probe()? > > If it is possible to know extcon_get_extcon_dev() will be only callled on probe, > it is no problem. But, it is not able to guarantee that extcon_get_extcon_dev() > is called on probe. Because of this reason, this issue should be handled in each device driver. > > -EPROBE_DEFER is only for probe step. If return -EPROBE_DEFER except for probe, > it is wrong return value. The future is vast and unknowable. We can't really future proof code and we should never try do that if it makes the code more complicated right now. When Andy submitted basically the same patch as me three years ago we worried about future developers so we didn't merge his patch. But three years later no non-probe() were introduced. Meanwhile the bad API created bugs in the kernel for current users. To some extent, we have to trust future developers to do sane things. I have also created a static checker test for people who call EPROBE_DEFER outside of probe functions. I don't know that this test will work. It will take a few days for the call tree to be built. Another option would be to change the warning from "is this called from something besides probe()" to "is this called from an ioctl". That would generate fewer false positives. Or potentially, I could save a most recent function pointer in the call tree. I'll play around with that in the coming months. Anyway, I've attached my first draft just to show you my thinking on this. regards, dan carpenter