On Wed, Aug 11, 2021 at 11:05:06PM +0200, Heiner Kallweit wrote: > On 11.08.2021 17:52, Andy Shevchenko wrote: > > On Fri, Aug 06, 2021 at 11:18:05PM +0200, Heiner Kallweit wrote: > >> - Use an initializer for struct i2c_board_info info > >> - Use dmi_match() > >> - Simplify loop logic > > > > I'm wondering if changing this to a DMI match table will give better result. > > > > Something like > > (Sorry I forgot APIs, but plenty of examples are under PDx86: drivers/platform/x86): > > > > struct dmi_..._id *id; > > > > id = dmi_..._match(); > > if (!id) { > > pci_warn(); > > return; > > } > > > > i2c_new_client_device(...); > > > We could do something like the following. Whether it's better may be a > question of personal taste. I have no strong opinion here and would leave > it to Jean. > > const struct dmi_system_id lis3_id_table[] = { > { > .driver_data = (void *)0x29, > .matches = { > DMI_MATCH(DMI_PRODUCT_NAME, "Latitude E5550"), > }, > }, > ... > > dmi_system_id *id = dmi_first_match(lis3_id_table); > if (id) > i2c_new_client_device(..., (unsigned int)id->driver_data; > else > lament() Yep, my point here that this has less indentation of the code, no unneeded for-loop (which will be inside DMI APIs, etc). But yes, I agree that this is rather matter of taste. -- With Best Regards, Andy Shevchenko