Received: by 10.213.65.68 with SMTP id h4csp787057imn; Tue, 20 Mar 2018 15:36:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELtb6j2QFQKg+w98ET6Z2Ncn6SgnKxQPbwT6JJucLB25rPg7OMnRlIaXZVmogxBIO7DSkOfK X-Received: by 2002:a17:902:b102:: with SMTP id q2-v6mr18246653plr.151.1521585383385; Tue, 20 Mar 2018 15:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521585383; cv=none; d=google.com; s=arc-20160816; b=jCevCvtbwEH20ZPuRKTEs4h4tyoeJgaIvJBc0kT8IHupWhs7EhN/aPMQyE4pPUhaCz nX3DqppxSO7SBXgie/coaxovQGlQL2E5deCnCjurrbfg3lscphyLRQGytkHowULdP1p7 PO1xQjULs3F9Q1XYEEH0F5WQwzz+h5RHiVV9UW1ZeTgj9UtpwXB1XJqf4J/fwv7DmnFJ ykjYH67nPLQ0ySbb2EITWQTYv0n7KkVqo72zZQJpD0YtgeFyO+QebyHdRwnVUK7L8UCw dPZg8sD+jcxXZDXnvwl5jyhTG7b63rInB9Fcm3kXqzO08hi4vSx1tKSvwicISOZs1XLL 1sAA== 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=vZU4MdkhoGSWlez8/qRQBLppc1tywziU5AZr0eUkheM=; b=WTN0lJ9yQL/GLkBrxPQYtuSYHl32NNMBUoD9q2b1b/T0Wdz/gP8ggUQh44atkZYSfW jc/Hq/MLb/R9BXuOcyW7Dg3iVsy/3ZWOKk7EXOhE7cKVbNTnN2p9LJCD3hBCi+1KGmrd w4hpeh8zpDGzs0lDwOvtw/RzDw1fvRcTBq9dArfjZD4Mpz/bmA8u/uxPwocyrcb4Jib6 H1LzI8YqtSN2qtdpacf/z7aF0zC4HAn6vjvj5/bkkyNGrQTzyo8OgR/T9iFVF/8Sbi35 QdqQvLWPxHaSVmtXE146p4En0oIwVzyhprqv6V5cMAbUTtAEyDJTQkhxSAmFGg0Wjjgb xD0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D4vGhWxv; 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 v129si1792574pgv.722.2018.03.20.15.36.09; Tue, 20 Mar 2018 15:36:23 -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=D4vGhWxv; 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 S1752004AbeCTWeY (ORCPT + 99 others); Tue, 20 Mar 2018 18:34:24 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34091 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751667AbeCTWbv (ORCPT ); Tue, 20 Mar 2018 18:31:51 -0400 Received: by mail-pf0-f195.google.com with SMTP id j20so1237733pfi.1; Tue, 20 Mar 2018 15:31:51 -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=vZU4MdkhoGSWlez8/qRQBLppc1tywziU5AZr0eUkheM=; b=D4vGhWxvZA85+hcQPXDF0VuYkubA2bEa3pFWyCwhOfcBL+OqIgSgJrAnUbLqZCQLOK QZHBqx6I/hQVEuJXgW2zw3u63xPlw9pOzACAI5bzxhVB/oCpSDbJsOz62jF90ib9xEz5 GNXPHDJ8vmBMdG9KIZQHELqb2pckx/Xu1njjM6xY0ySyJcYSDqDhm/KG/QdcC3cFRv6g LeDMGhvTnNnJSxKVFaig6xlKJGBp0rTIA/JZ5nzj+rfzsSBjb/TSDRLfpcWukBmWygBK ioRxrfdELIwVYMWcdpijrno5SRbs2YoWKqCVEGLOMKehnojgVfmye/4WlcPZjluIh1y8 UJcg== 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=vZU4MdkhoGSWlez8/qRQBLppc1tywziU5AZr0eUkheM=; b=rSWL40Vil9teC1ChH5a0NKw4ba9ZT+/fQw6RAE4QPZ0W5wJIRihyCMwTBIEcKNAoAL Qf4oYwjXbfkZCt9OZhKuk/OGBAbK3hEoXJsq5Fnbf8ABFZef9Z13zEth2srPeth/5pgE t/5n79EHsO86uMO5a+7yqVAhHS8r3GjJnbM5WL80e0YGK9gw3L+weqs30lzyE9sYmrB8 7YHdb5j1Tm0o8YzjWVMQGU8QdwffEiAaCcTiqqIEpIs8yaHtu2sMIquN6PiSVV0HZfub OaK5S8Z54AstL9HMoA/ijaDmmXzAM4Tx99TnFInAUQt4CmlT5QXTXw2NbiQ/BAq79rQW rYvw== X-Gm-Message-State: AElRT7GBHAA+5Utknvehb5fzSmXpVBtMLX3IV8vQkLZqUEAOBNyJOpi9 7TKafPvpOPfnfF443ePO3KTkeC8N X-Received: by 10.99.180.6 with SMTP id s6mr8025916pgf.81.1521585110535; Tue, 20 Mar 2018 15:31:50 -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 r20sm6108360pff.165.2018.03.20.15.31.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Mar 2018 15:31:49 -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 v2 07/14] platform/chrome: chromeos_laptop - factor out getting IRQ from DMI Date: Tue, 20 Mar 2018 15:31:31 -0700 Message-Id: <20180320223138.234724-8-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.16.2.804.g6dcf76e118-goog In-Reply-To: <20180320223138.234724-1-dmitry.torokhov@gmail.com> References: <20180320223138.234724-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.804.g6dcf76e118-goog