From patchwork Tue Apr 4 03:25:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9660803 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 AD3A1602B7 for ; Tue, 4 Apr 2017 03:25:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A070428475 for ; Tue, 4 Apr 2017 03:25:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92E382847B; Tue, 4 Apr 2017 03:25:19 +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=ham 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 3B1B72832B for ; Tue, 4 Apr 2017 03:25:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751843AbdDDDZS (ORCPT ); Mon, 3 Apr 2017 23:25:18 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35635 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751406AbdDDDZR (ORCPT ); Mon, 3 Apr 2017 23:25:17 -0400 Received: by mail-pg0-f67.google.com with SMTP id g2so33969606pge.2; Mon, 03 Apr 2017 20:25:17 -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; bh=oF8TvzbW9uwhz+sbzgWK+5A6rzZG8xDWrAxVyJHS4r4=; b=dTRmtwa7yRXGOpkbtK9RhdQyCsUxOgbkrYQE3U2EZAqwXdkNPdEHsG3LOHG2P8HiBG V1wfcwr8U8c4FlJg8nc/PuAkoNr7nFNSd7yQ07295mOn7Tk/MorUgp+G1YtKLU1ZNStM 2nm923gBZC5F3BCZyPMip9WgoPs940bQAtXB9fPqsmDDuxZQDPfko+i2evtUWyP9rjVY z5+P9/A2iOC3iKiQfhFc3N6kfhwjbk4M8oQ8DkvHwS5deXv0NJC3jPprrRjUKCEmQbZn QPrVqJ7EURTL7aO7e2CevXv9o1rhUTTUGkPy0+G2fqfo0ULoAq3i8n+zT0PBquykHxwj YjMQ== 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; bh=oF8TvzbW9uwhz+sbzgWK+5A6rzZG8xDWrAxVyJHS4r4=; b=IAdO1dp6rB8uNHAFDWMRTKP6B7163FrkHC/IfTQAakN1fTnA93v+rH8sF3tmR5sXdy FLKWi2Rgbk07uIJbxn6BkdBEVU5LFGPMGYp4ElaPeuiHebQJORh2ZyYXQH6LLj5WWlk0 PXPmRnVzjt9SyU2PRDAjQpMM+PbwLx3lNfzZQG4xBe80JIwlN0UIJxwVaDjLKReYfdGQ ziemniXwncOgKAyu3bxuW0omS8lwbKPo4UYKmaI3YLJ30RRXazHhRT1+u0VWuW/6ZsS7 01CycZELvUtgntslgDMqgIxgZLIN4iSCepesIObozc4HB0V3YidByKYtRkUbZDftmptn 0CWQ== X-Gm-Message-State: AFeK/H3ySi+xFXncxWAe2IsnJJGPpGiPigmf1y/7u8tXKelJXEyOZ39hBpY9sZVnlb8ZYw== X-Received: by 10.98.72.88 with SMTP id v85mr20080544pfa.99.1491276316799; Mon, 03 Apr 2017 20:25:16 -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:16 -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 1/2] platform/x86: silead_dmi - do not treat all devices as i2c_clients Date: Mon, 3 Apr 2017 20:25:13 -0700 Message-Id: <20170404032514.31832-1-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.12.2.715.g7642488e1d-goog 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 I2C bus has both i2c clients and adapter devices, so we must be careful in notifier code and verify that we are actually dealing with an i2c client before using it as such. Fixes: cef9dd85acd7 ("platform/x86: add support for devices with Silead...") Signed-off-by: Dmitry Torokhov Reviewed-by: Hans de Goede --- drivers/platform/x86/silead_dmi.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/silead_dmi.c b/drivers/platform/x86/silead_dmi.c index 02e11fdbf375..7f1049951d1c 100644 --- a/drivers/platform/x86/silead_dmi.c +++ b/drivers/platform/x86/silead_dmi.c @@ -75,9 +75,8 @@ static const struct dmi_system_id silead_ts_dmi_table[] = { { }, }; -static void silead_ts_dmi_add_props(struct device *dev) +static void silead_ts_dmi_add_props(struct i2c_client *client) { - struct i2c_client *client = to_i2c_client(dev); const struct dmi_system_id *dmi_id; const struct silead_ts_dmi_data *ts_data; int error; @@ -87,11 +86,13 @@ static void silead_ts_dmi_add_props(struct device *dev) return; ts_data = dmi_id->driver_data; - if (has_acpi_companion(dev) && + if (has_acpi_companion(&client->dev) && !strncmp(ts_data->acpi_name, client->name, I2C_NAME_SIZE)) { - error = device_add_properties(dev, ts_data->properties); + error = device_add_properties(&client->dev, + ts_data->properties); if (error) - dev_err(dev, "failed to add properties: %d\n", error); + dev_err(&client->dev, + "failed to add properties: %d\n", error); } } @@ -99,10 +100,13 @@ static int silead_ts_dmi_notifier_call(struct notifier_block *nb, unsigned long action, void *data) { struct device *dev = data; + struct i2c_client *client; switch (action) { case BUS_NOTIFY_ADD_DEVICE: - silead_ts_dmi_add_props(dev); + client = i2c_verify_client(dev); + if (client) + silead_ts_dmi_add_props(client); break; default: