On Tue Oct 8, 2024 at 6:03 PM CEST, Krzysztof Kozlowski wrote: > On 08/10/2024 16:43, Théo Lebrun wrote: > > On Tue Oct 8, 2024 at 3:39 PM CEST, Krzysztof Kozlowski wrote: > >> On Tue, Oct 08, 2024 at 12:29:41PM +0200, Théo Lebrun wrote: > >>> + bool is_eyeq6h = of_device_is_compatible(np, "mobileye,eyeq6h-i2c"); > >>> + bool is_eyeq5 = of_device_is_compatible(np, "mobileye,eyeq5-i2c"); > >> > >> You should use match data, not add compatibles in the middle of code. > >> That's preferred, scallable pattern. What you added here last time does > >> not scale and above change is a proof for that. > > > > I would have used match data if the driver struct had a .of_match_table > > field. `struct amba_driver` does not. Are you recommending the approach > > below? > > > > I don't see how it brings much to the driver but I do get the scaling > > issue as the number of support compatibles increases. This is a fear > > based on what *could* happen in the future though. > > You still have adev->dev.of_node, which you can use for matching in > probe. See for example of_match_device() (and add a note so people will > not convert it to device_get_match_data() blindly). Just sent the new revision [0]. It uses of_match_device() in the same way as was shown in my previous answer to this thread [1]. Followed your recommendation and added a comment to avoid conversions to device_get_match_data(). Thanks! [0]: https://lore.kernel.org/lkml/20241009-mbly-i2c-v2-0-ac9230a8dac5@xxxxxxxxxxx/ [1]: https://lore.kernel.org/lkml/D4QI63B6YQU5.3UPKA7G75J445@xxxxxxxxxxx/ -- Théo Lebrun, Bootlin Embedded Linux and Kernel engineering https://bootlin.com