Commit f22265b6 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Darren Hart (VMware)

platform/x86: silead_dmi - abort early if DMI does not match

There is no point in registering I2C bus notifier if DMI data does not
match.
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
[andy: updated due to previous patch changed]
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent e1053963
...@@ -96,21 +96,16 @@ static const struct dmi_system_id silead_ts_dmi_table[] = { ...@@ -96,21 +96,16 @@ static const struct dmi_system_id silead_ts_dmi_table[] = {
{ }, { },
}; };
static const struct silead_ts_dmi_data *silead_ts_data;
static void silead_ts_dmi_add_props(struct i2c_client *client) static void silead_ts_dmi_add_props(struct i2c_client *client)
{ {
struct device *dev = &client->dev; struct device *dev = &client->dev;
const struct dmi_system_id *dmi_id;
const struct silead_ts_dmi_data *ts_data;
int error; int error;
dmi_id = dmi_first_match(silead_ts_dmi_table);
if (!dmi_id)
return;
ts_data = dmi_id->driver_data;
if (has_acpi_companion(dev) && if (has_acpi_companion(dev) &&
!strncmp(ts_data->acpi_name, client->name, I2C_NAME_SIZE)) { !strncmp(silead_ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
error = device_add_properties(dev, ts_data->properties); error = device_add_properties(dev, silead_ts_data->properties);
if (error) if (error)
dev_err(dev, "failed to add properties: %d\n", error); dev_err(dev, "failed to add properties: %d\n", error);
} }
...@@ -142,8 +137,15 @@ static struct notifier_block silead_ts_dmi_notifier = { ...@@ -142,8 +137,15 @@ static struct notifier_block silead_ts_dmi_notifier = {
static int __init silead_ts_dmi_init(void) static int __init silead_ts_dmi_init(void)
{ {
const struct dmi_system_id *dmi_id;
int error; int error;
dmi_id = dmi_first_match(silead_ts_dmi_table);
if (!dmi_id)
return 0; /* Not an error */
silead_ts_data = dmi_id->driver_data;
error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier); error = bus_register_notifier(&i2c_bus_type, &silead_ts_dmi_notifier);
if (error) if (error)
pr_err("%s: failed to register i2c bus notifier: %d\n", pr_err("%s: failed to register i2c bus notifier: %d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment