From patchwork Tue Apr 4 03:25:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9660811 X-Patchwork-Delegate: andy.shevchenko@gmail.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 315F7602B7 for ; Tue, 4 Apr 2017 03:25:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DAC02832B for ; Tue, 4 Apr 2017 03:25:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2263928475; Tue, 4 Apr 2017 03:25:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D982D2832B for ; Tue, 4 Apr 2017 03:25:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752579AbdDDDZb (ORCPT ); Mon, 3 Apr 2017 23:25:31 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33766 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751841AbdDDDZS (ORCPT ); Mon, 3 Apr 2017 23:25:18 -0400 Received: by mail-pg0-f66.google.com with SMTP id 79so34090744pgf.0; Mon, 03 Apr 2017 20:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4lPLUZzBIDK4k30IoFhfAJMD2d6Rgn3YJxs3Y7OjFTc=; b=Pk6bgtJ7IK/HCMJ+QIYPk/MfsfJVG5BuyuxgKDizwkrGGRTsjsDbpo1oh5jUzDD4Ah tcpeTHZDL1YhoTzaMEfi6CyVKTLuP6Jo6kt1QrEqJjA6N1b+jEzBNI+BGSJT/wbAdQWJ NDuLQG47L5hU5HxUW1BDVhnnbDDYLydi/CVkgF/QEY1ymtV0Q1auhQmzIIlgmqCxFvQP Yu1nxYE5t6TZEAi0/1PS6jEKJ+8pS7RedmXP+Oa53q44EZy6zAMrJv65iicEXyAHR2sQ nTl3H12YKkZL2mGJsiQFhYdsqIQAYNJfsst1dxxrCi4GpPXfzLXaQKJy9vMnp03dJZDx QYfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4lPLUZzBIDK4k30IoFhfAJMD2d6Rgn3YJxs3Y7OjFTc=; b=ROoXMvpcIfn512GfgnfPuToaD+9d1mzo+GmPfYRLFtEEmalU/INp8cWeJD4Z5l7LbE wD/wWKNnq7vmFQMd0rd6Wo4PZuxJIySRey13OaAWsrPAOLYFt78W5g2IumHldoEqvUJT vsbiwFilDb/0Fq3pgFUMzjCPCMZSqWCXTCZA4Jw4g8yhpQGyrvHGYZGjV2zXcDSkn7hd EIgrIsvGcaEYr4LOYb+g3tNYe4KMX8qB5lLVTSOtJWaLzNhELVhD4udgzYSF7yzxd5DA h/ITfJfZyZsOw9TOUOEBeWci31KVkcQuC6I5xZ15CWmZ2Fv6z+LxrEMeZZz+8QUeRipO Hwww== X-Gm-Message-State: AFeK/H15g/PACe+E/k9GcHIyPXD0bmj94rMOL3SbeIi7jvafvfkLiD/oucziuUd3+WGOVQ== X-Received: by 10.99.150.17 with SMTP id c17mr10074937pge.160.1491276317676; Mon, 03 Apr 2017 20:25:17 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id i124sm28349926pgd.66.2017.04.03.20.25.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 03 Apr 2017 20:25:17 -0700 (PDT) From: Dmitry Torokhov To: Hans de Goede Cc: Darren Hart , Andy Shevchenko , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] platform/x86: silead_dmi - abort early if DMI does not match Date: Mon, 3 Apr 2017 20:25:14 -0700 Message-Id: <20170404032514.31832-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.12.2.715.g7642488e1d-goog In-Reply-To: <20170404032514.31832-1-dmitry.torokhov@gmail.com> References: <20170404032514.31832-1-dmitry.torokhov@gmail.com> Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is no point in registering I2C bus notifier if DMI data does not match. Signed-off-by: Dmitry Torokhov Reviewed-by: Hans de Goede --- drivers/platform/x86/silead_dmi.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/silead_dmi.c b/drivers/platform/x86/silead_dmi.c index 7f1049951d1c..0eeb49e51c43 100644 --- a/drivers/platform/x86/silead_dmi.c +++ b/drivers/platform/x86/silead_dmi.c @@ -75,21 +75,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) { - const struct dmi_system_id *dmi_id; - const struct silead_ts_dmi_data *ts_data; 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(&client->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(&client->dev, - ts_data->properties); + silead_ts_data->properties); if (error) dev_err(&client->dev, "failed to add properties: %d\n", error); @@ -122,8 +117,15 @@ static struct notifier_block silead_ts_dmi_notifier = { static int __init silead_ts_dmi_init(void) { + const struct dmi_system_id *dmi_id; 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); if (error) pr_err("%s: failed to register i2c bus notifier: %d\n",