Received: by 10.213.65.68 with SMTP id h4csp238918imn; Mon, 12 Mar 2018 12:13:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELvUC8o3E02p74vcwdYF9cCSYTb+WJhtQ7BuTfntmCMmCfqGHoBDmUtW7xW+bwcziOr+pJqZ X-Received: by 10.99.141.200 with SMTP id z191mr7434780pgd.418.1520881997359; Mon, 12 Mar 2018 12:13:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520881997; cv=none; d=google.com; s=arc-20160816; b=KBWpC4XORTBP+nsAqj2qhKJBMKDalRFxrIaQou3bsuGr+y8guIErNLaBinxjbJJ8IF 7Gg8wwBgaxgLm8jFDc43J6SCVew+TAE9yEkNg0ZKfizHDp2Ew7ap90WTbPw0dL0hGczs SrouoX/a/9a+EsJgNIoMbBKlonWDCc2xFMtA5Zbx8pm1h45ijkjEOoLJQwPLeobrhCrW yqn7tIk4R+vb1EGFxWc+nkJEm9m7N2QKt/5Zid1sZ6Yl18cAEw4SVoohK7XZWYCpxSRY pmnc0RzxU9W+QfNzlZ3miJ4XZU41grGjU2WMIxMxz9NTMjqH7khy/EnQ9pN2dWE6qoGJ 4BFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=n2ZLFjstDuX0vvZC8BK0DT/cqCIuOoGBUXHLHwWm39A=; b=Jc46vXe+5x69GQZvXkLt9+N2o4QLnh6bWc3qKMgjaCRZKNj0+krXQh8a491UmcV6g3 DrnhkzhymR+NrJfPqn3Ns0kSKn8xgrIcEadkjTqYorqa31N3qLRV3rYb/R0yG+egjYC2 naah4FF+e5nft08MLJeO/cdhU/GCZNDIUteIJqMtWnS0dDhIhjTttG9hIZ2CPC+HAeIl 2FjoSNPR8BanciKnjkbv2iM99tO9zqdICO7voeNnN03Nkcwcf7P1cxDnSjFChbvxaOkP xpnIb1WTjal6zri8ham/8Yb+f4isfpPGSfjtHGJGL1cogLyeZwuNiFh0z+tPkWzvT10Z NYtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=afyj5/mf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r16si6141772pfl.163.2018.03.12.12.13.02; Mon, 12 Mar 2018 12:13:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=afyj5/mf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932747AbeCLTLY (ORCPT + 99 others); Mon, 12 Mar 2018 15:11:24 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:40156 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751377AbeCLTJU (ORCPT ); Mon, 12 Mar 2018 15:09:20 -0400 Received: by mail-pl0-f65.google.com with SMTP id x3-v6so3366004plo.7; Mon, 12 Mar 2018 12:09:20 -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=n2ZLFjstDuX0vvZC8BK0DT/cqCIuOoGBUXHLHwWm39A=; b=afyj5/mf0Yhhw2OfBC5WcTNd7r6G+hSlrp+Oro7jCZZ2QJZLPXQGMmPeEaekuCneQ9 VS6UDAwDaFPGNPIRSWY5fELEXtYIGAs8VkZWSgG63eONMLEEWLvAQVJCVve94XExA99j CXukfmTtZIFrOmjdnK3MWea0zoFzkaS8dx/6Dg5mwxYj1s1/w6qcnlOfMZ9VAPZwtAK4 ETB6kAqkOcz9l5hzt/8CJvVkrlRf9AwX/xgkLAYBi+mPLhCQI6j7/DQ+yhgA1ZgPAXo9 rgRVKXTQpPt3ykK4Z1CNkONmXld7vxcITYxaT/N7SwgHfBtMEBnp8NEWXHqwoJoQS7Gm RZhg== 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=n2ZLFjstDuX0vvZC8BK0DT/cqCIuOoGBUXHLHwWm39A=; b=T8TDcYMKDWWtBLrhae6CyRE1UI/O9UQkY2mL7gpTkZz1rZVW+BJXyrQJ+qAMwR6lOl VdSmjN0eRehwEpDanPtbQPe7nmX4gm9EBwp4FEZMyZDoTxR9uy+VPyKNkCLLlHhqgRO+ simCADWmqe0ehyORKeVqkO7WZqHzgbWLuyLPGPLhu8oIXQB6r8h/yu+Qi6JinQl6ue5f lc1OMMI5vi//znS4/KOvgithf3OdRALBobrfQY3KMBBQlETqCdUdchJCQuL26JPynj3K dQAuaPOYF5sh3V1qPLg/nrkYIHy7GFhwu7h9Chy5USTf0ek09ng/2L49SuE+qv903SNA JhMQ== X-Gm-Message-State: AElRT7EOe1Q75MQt8wYoWEFcqKpTghgmYkM/87LTXxs0cJoT9u9ws/lD jA3l+dYkqTM/UnZeEsaqEEHMaRPz X-Received: by 2002:a17:902:127:: with SMTP id 36-v6mr5357110plb.194.1520881759419; Mon, 12 Mar 2018 12:09:19 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:0:1000:1511:8de6:27a8:ed13:2ef5]) by smtp.gmail.com with ESMTPSA id s67sm18038477pfg.104.2018.03.12.12.09.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 12:09:18 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org, Benson Leung Cc: Nick Dyer , Olof Johansson , linux-kernel@vger.kernel.org Subject: [PATCH 07/14] platform/chrome: chromeos_laptop - factor out getting IRQ from DMI Date: Mon, 12 Mar 2018 12:09:00 -0700 Message-Id: <20180312190907.174301-8-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.16.2.660.g709887971b-goog In-Reply-To: <20180312190907.174301-1-dmitry.torokhov@gmail.com> References: <20180312190907.174301-1-dmitry.torokhov@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will make code instantiating I2C device a bit clearer. Signed-off-by: Dmitry Torokhov --- drivers/platform/chrome/chromeos_laptop.c | 35 +++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/platform/chrome/chromeos_laptop.c b/drivers/platform/chrome/chromeos_laptop.c index 08ce7a105e768..96e962ff38e87 100644 --- a/drivers/platform/chrome/chromeos_laptop.c +++ b/drivers/platform/chrome/chromeos_laptop.c @@ -120,36 +120,47 @@ static struct i2c_board_info atmel_1664s_device = { .flags = I2C_CLIENT_WAKE, }; +static int chromeos_laptop_get_irq_from_dmi(const char *dmi_name) +{ + const struct dmi_device *dmi_dev; + const struct dmi_dev_onboard *dev_data; + + dmi_dev = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD, dmi_name, NULL); + if (!dmi_dev) { + pr_err("failed to find DMI device '%s'\n", dmi_name); + return -ENOENT; + } + + dev_data = dmi_dev->device_data; + if (!dev_data) { + pr_err("failed to get data from DMI for '%s'\n", dmi_name); + return -EINVAL; + } + + return dev_data->instance; +} + static struct i2c_client *__add_probed_i2c_device( const char *name, int bus, struct i2c_board_info *info, const unsigned short *alt_addr_list) { - const struct dmi_device *dmi_dev; - const struct dmi_dev_onboard *dev_data; struct i2c_adapter *adapter; struct i2c_client *client = NULL; const unsigned short addr_list[] = { info->addr, I2C_CLIENT_END }; if (bus < 0) return NULL; + /* * If a name is specified, look for irq platform information stashed * in DMI_DEV_TYPE_DEV_ONBOARD by the Chrome OS custom system firmware. */ if (name) { - dmi_dev = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD, name, NULL); - if (!dmi_dev) { - pr_err("failed to dmi find device %s\n", name); - return NULL; - } - dev_data = (struct dmi_dev_onboard *)dmi_dev->device_data; - if (!dev_data) { - pr_err("failed to get data from dmi for %s\n", name); + info->irq = chromeos_laptop_get_irq_from_dmi(name); + if (info->irq < 0) return NULL; - } - info->irq = dev_data->instance; } adapter = i2c_get_adapter(bus); -- 2.16.2.660.g709887971b-goog