Platform: x86: chromeos_laptop: make dmi_check_callback return 1
PATCH 1/1 Platform: x86: chromeos_laptop: make dmi_check_callback return 1
We only care about if there is any successful match from the dmi table or no match at all, we can make dmi_check_system return immediately if we have a successful match instead of iterate thorough the whole table.
--- drivers/platform/x86/chromeos_laptop.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/platform/x86/chromeos_laptop.c +7 -7
@@ -207,7 +207,7 @@ static int __init setup_cyapa_smbus_tp(const struct dmi_system_id *id) {/* add cyapa touchpad on smbus */ tp =add_smbus_device ("trackpad" , &cyapa_device); -return 0 ; +return 1 ; }static int __init setup_atmel_224s_tp (const struct dmi_system_id *id)
@@ -219,7 +219,7 @@ static int __init setup_atmel_224s_tp(const struct dmi_system_id *id)/* add atmel mxt touchpad on VGA DDC GMBus */ tp =add_probed_i2c_device ("trackpad" ,I2C_ADAPTER_VGADDC , &atmel_224s_tp_device, addr_list); -return 0 ; +return 1 ; }static int __init setup_atmel_1664s_ts (const struct dmi_system_id *id)
@@ -231,7 +231,7 @@ static int __init setup_atmel_1664s_ts(const struct dmi_system_id *id)/* add atmel mxt touch device on PANEL GMBus */ ts =add_probed_i2c_device ("touchscreen" ,I2C_ADAPTER_PANEL , &atmel_1664s_device, addr_list); -return 0 ; +return 1 ; }
@@ -239,7 +239,7 @@ static int __init setup_isl29018_als(const struct dmi_system_id *id) {/* add isl29018 light sensor */ als =add_smbus_device ("lightsensor" , &isl_als_device); -return 0 ; +return 1 ; }static int __init setup_isl29023_als (const struct dmi_system_id *id)
@@ -247,21 +247,21 @@ static int __init setup_isl29023_als(const struct dmi_system_id *id)/* add isl29023 light sensor on Panel GMBus */ als =add_i2c_device ("lightsensor" ,I2C_ADAPTER_PANEL , &isl_als_device); -return 0 ; +return 1 ; }static int __init setup_tsl2583_als (const struct dmi_system_id *id) {/* add tsl2583 light sensor on smbus */ als =add_smbus_device (NULL , &tsl2583_als_device); -return 0 ; +return 1 ; }static int __init setup_tsl2563_als (const struct dmi_system_id *id) {/* add tsl2563 light sensor on smbus */ als =add_smbus_device (NULL , &tsl2563_als_device); -return 0 ; +return 1 ; }static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
Signature · 1 line
1.7.9.5
Actually, the way that this table is set up currently, we rely on the possibility of multiple matches, so it is necessary to go through the whole thing.
Look carefully at the chromeos_laptop_dmi_table. You'll see that boards like Link and Lumpy show up multiple times in the table to instantiate different devices.
Returning 1 will simply stop on the first device it finds in the list.
Benson
Quoted 75 lines · Axel Lin
We only care about if there is any successful match from the dmi table or no match at all, we can make
dmi_check_systemreturn immediately if we have a successful match instead of iterate thorough the whole table.Signed-off-by Axel Lin <[email protected]>--- drivers/platform/x86/chromeos_laptop.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/platform/x86/chromeos_laptop.c +7
-8@@ -207,7 +207,7 @@ static int __init setup_cyapa_smbus_tp(const struct dmi_system_id *id) {/* add cyapa touchpad on smbus */ tp =add_smbus_device ("trackpad" , &cyapa_device); -return 0 ; +return 1 ; }static int __init setup_atmel_224s_tp (const struct dmi_system_id *id)@@ -219,7 +219,7 @@ static int __init setup_atmel_224s_tp(const struct dmi_system_id *id)/* add atmel mxt touchpad on VGA DDC GMBus */ tp =add_probed_i2c_device ("trackpad" ,I2C_ADAPTER_VGADDC , &atmel_224s_tp_device, addr_list); -return 0 ; +return 1 ; }static int __init setup_atmel_1664s_ts (const struct dmi_system_id *id)@@ -231,7 +231,7 @@ static int __init setup_atmel_1664s_ts(const struct dmi_system_id *id)/* add atmel mxt touch device on PANEL GMBus */ ts =add_probed_i2c_device ("touchscreen" ,I2C_ADAPTER_PANEL , &atmel_1664s_device, addr_list); -return 0 ; +return 1 ; }@@ -239,7 +239,7 @@ static int __init setup_isl29018_als(const struct dmi_system_id *id) {/* add isl29018 light sensor */ als =add_smbus_device ("lightsensor" , &isl_als_device); -return 0 ; +return 1 ; }static int __init setup_isl29023_als (const struct dmi_system_id *id)@@ -247,21 +247,21 @@ static int __init setup_isl29023_als(const struct dmi_system_id *id)/* add isl29023 light sensor on Panel GMBus */ als =add_i2c_device ("lightsensor" ,I2C_ADAPTER_PANEL , &isl_als_device); -return 0 ; +return 1 ; }static int __init setup_tsl2583_als (const struct dmi_system_id *id) {/* add tsl2583 light sensor on smbus */ als =add_smbus_device (NULL , &tsl2583_als_device); -return 0 ; +return 1 ; }static int __init setup_tsl2563_als (const struct dmi_system_id *id) {/* add tsl2563 light sensor on smbus */ als =add_smbus_device (NULL , &tsl2563_als_device); -return 0 ; +return 1 ; }static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = { --
Quoted 4 lines
1.7.9.5
--
Benson Leung
Software Engineer, Chrom* OS
[email protected]
Quoted 75 lines · Axel Lin
We only care about if there is any successful match from the dmi table or no match at all, we can make
dmi_check_systemreturn immediately if we have a successful match instead of iterate thorough the whole table.Signed-off-by Axel Lin <[email protected]>--- drivers/platform/x86/chromeos_laptop.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/platform/x86/chromeos_laptop.c +7
-8@@ -207,7 +207,7 @@ static int __init setup_cyapa_smbus_tp(const struct dmi_system_id *id) {/* add cyapa touchpad on smbus */ tp =add_smbus_device ("trackpad" , &cyapa_device); -return 0 ; +return 1 ; }static int __init setup_atmel_224s_tp (const struct dmi_system_id *id)@@ -219,7 +219,7 @@ static int __init setup_atmel_224s_tp(const struct dmi_system_id *id)/* add atmel mxt touchpad on VGA DDC GMBus */ tp =add_probed_i2c_device ("trackpad" ,I2C_ADAPTER_VGADDC , &atmel_224s_tp_device, addr_list); -return 0 ; +return 1 ; }static int __init setup_atmel_1664s_ts (const struct dmi_system_id *id)@@ -231,7 +231,7 @@ static int __init setup_atmel_1664s_ts(const struct dmi_system_id *id)/* add atmel mxt touch device on PANEL GMBus */ ts =add_probed_i2c_device ("touchscreen" ,I2C_ADAPTER_PANEL , &atmel_1664s_device, addr_list); -return 0 ; +return 1 ; }@@ -239,7 +239,7 @@ static int __init setup_isl29018_als(const struct dmi_system_id *id) {/* add isl29018 light sensor */ als =add_smbus_device ("lightsensor" , &isl_als_device); -return 0 ; +return 1 ; }static int __init setup_isl29023_als (const struct dmi_system_id *id)@@ -247,21 +247,21 @@ static int __init setup_isl29023_als(const struct dmi_system_id *id)/* add isl29023 light sensor on Panel GMBus */ als =add_i2c_device ("lightsensor" ,I2C_ADAPTER_PANEL , &isl_als_device); -return 0 ; +return 1 ; }static int __init setup_tsl2583_als (const struct dmi_system_id *id) {/* add tsl2583 light sensor on smbus */ als =add_smbus_device (NULL , &tsl2583_als_device); -return 0 ; +return 1 ; }static int __init setup_tsl2563_als (const struct dmi_system_id *id) {/* add tsl2563 light sensor on smbus */ als =add_smbus_device (NULL , &tsl2563_als_device); -return 0 ; +return 1 ; }static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = { --
Quoted 4 lines
1.7.9.5
--
Benson Leung
Software Engineer, Chrom* OS
[email protected]