Received: by 10.213.65.68 with SMTP id h4csp239010imn; Mon, 12 Mar 2018 12:13:25 -0700 (PDT) X-Google-Smtp-Source: AG47ELtzVEWXL6RtqX84eCcTKOd6MaaenvXUjpKTLySOprzFrhd0VxIMwbKQsUKPXv/9z30LQncy X-Received: by 10.99.125.75 with SMTP id m11mr2862340pgn.391.1520882005658; Mon, 12 Mar 2018 12:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520882005; cv=none; d=google.com; s=arc-20160816; b=BvPm5O8WwBKg+LsEg1j1KfdoGdmdoX9xf9CeaieIvHKk5FO2O0pYONyUDg0rthZq6H u9obWFO0i9b6zPp/snHPn7LaOaDtb9AQwNCmtDxtesrorD6dIukYPkfeP5K5Ji5HyHgN VHanb4TZ2ouUGbkkzE5IPGzEMbLLJDytGwvuLs4Mc60RcSZWAs8dIi+DV9e8N2mWPlvL iJM5kchqymIAVNtsWW29jfDd59g+mrLE4z+p4WkZeZt5e/+8VU/X5weG0oqDLOtxM1rC d9KGniY2AovTfxEpMdMiR1i6LhFaMpOm49ZFuBg2IIHprz7bpyFWUoy7vp0mZ29mtMTX duOg== 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=48D0L/HiOwgQwxPfNlaPY56Izz2v/sJUYOxvzn4bN9k=; b=COiYDFTxYIVa3Zq/tox2iXtwmI90tLUCJOPoZ8RRAcFRH45sMktghp6tnAvH4ay4TN cuB8k/K7InYK44/6G/61J/MkgwuvIb8/qg8igFjMyxUvNcvGyj712Xajjx5AKyON8H2x RCr5x7vXuyJONyJlK/z26zP1qItPKtGBFUoH7VH9CN/v/kYo/kUdCR6FAAqsL6/7ZysE a12StOA24WFD+e348ubuOAxnKY6ULNa52m88rszvLVvNSPOnUrvrQLO/fAEekjDpeURM ChdTU5o8faMBykzeGgkNx9amY87xb4SApi6DUKuvCeNXzAydjzXwoxzphTw8vpoacuZ7 Kx7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=h0UKJqxb; 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 m2-v6si2022697plt.207.2018.03.12.12.13.11; Mon, 12 Mar 2018 12:13:25 -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=h0UKJqxb; 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 S932481AbeCLTJT (ORCPT + 99 others); Mon, 12 Mar 2018 15:09:19 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:39668 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932452AbeCLTJQ (ORCPT ); Mon, 12 Mar 2018 15:09:16 -0400 Received: by mail-pl0-f68.google.com with SMTP id s13-v6so9875346plq.6; Mon, 12 Mar 2018 12:09:16 -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=48D0L/HiOwgQwxPfNlaPY56Izz2v/sJUYOxvzn4bN9k=; b=h0UKJqxbBmHnJQpnT3vFIt//i4Gh+q4plShCvf56+S+BqDfUNwRG8+KscoWP613ss/ N9gm/oQvHQXGZkVldji9B6mHRpTjPGuQ5lovsID9rGLoTyinXvNgzSbO3Ze/0YWvcdjp h+sibLDIH1FcjMx0p5GaATEIgcYdoDQKMioCTR5ufBDuE7pch8JuUN/pjfT1DDrvGsYr n1vseYe2wUMaVrmpfOajP5cGU5GR6WlmyqrwswSBpaBSuHP4Jqt526a95NjxSRzGfrU+ +GglLvpo0L2K8GJt16+1ciDkf9m1eozbhvzEmm3ysotOxZ3OPnoUcFM1S5iLsLdMbmG3 KZcw== 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=48D0L/HiOwgQwxPfNlaPY56Izz2v/sJUYOxvzn4bN9k=; b=t8XOm/wHDvjmG+r7KVskazjRkrDk/7ZRXQVNIxFbd1WLJ/fIQDMsKqHqz2mHem1rFM ApCLOZtVkd5VyxOhDPKWI949ri0AV1grq2yeizL7/3ksxMYWSVAfEPK02tDCuPGH0mBi gq7YmrZbEy+2EgLrKUrNb/siZAszTVAlT/i4t37uGWyUQ3QhwLMNWdZLBg8/aXSex1Wz M8DdlVj7CwPj5QF/mHRdOblFJsZ3K1JYKoVY2NUl5vRujQtYULQqJ/L3Zph/6hjhQlRb Mmy1tUZqiDXCjALoftTFG5hbCFFmYRZcFKDzgm3P8FpPSq5LdennDHZ2q+NWHUMuv8aQ /DSA== X-Gm-Message-State: AElRT7HYEnBlbx8oBJCsDSZAC68yO2xEyLNHea+q3PTJD1VmDUR9+cOV BFc/prmrddddp6YODQ7GUvSmCiPF X-Received: by 2002:a17:902:30f:: with SMTP id 15-v6mr3109604pld.365.1520881755224; Mon, 12 Mar 2018 12:09:15 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 12:09:13 -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 03/14] Input: atmel_mxt_ts - switch ChromeOS ACPI devices to generic props Date: Mon, 12 Mar 2018 12:08:56 -0700 Message-Id: <20180312190907.174301-4-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 Move older ChromeOS devices describing Atmel controllers in ACPI, but not providing enough details to configure the controllers properly, from platform data over to generic device properties. This will allow us remove support for platform data later on, leaving only generic device properties in place. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/atmel_mxt_ts.c | 63 +++++++++++++++--------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 072b78d3c6e00..cf2aac4e79ae8 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -2972,7 +2972,7 @@ mxt_parse_device_properties(struct i2c_client *client) struct mxt_acpi_platform_data { const char *hid; - struct mxt_platform_data pdata; + const struct property_entry *props; }; static unsigned int samus_touchpad_buttons[] = { @@ -2982,14 +2982,16 @@ static unsigned int samus_touchpad_buttons[] = { BTN_LEFT }; +static const struct property_entry samus_touchpad_props[] = { + PROPERTY_ENTRY_U32_ARRAY("linux,gpio-keymap", samus_touchpad_buttons), + { } +}; + static struct mxt_acpi_platform_data samus_platform_data[] = { { /* Touchpad */ .hid = "ATML0000", - .pdata = { - .t19_num_keys = ARRAY_SIZE(samus_touchpad_buttons), - .t19_keymap = samus_touchpad_buttons, - }, + .props = samus_touchpad_props, }, { /* Touchscreen */ @@ -3007,14 +3009,16 @@ static unsigned int chromebook_tp_buttons[] = { BTN_LEFT }; +static const struct property_entry chromebook_tp_props[] = { + PROPERTY_ENTRY_U32_ARRAY("linux,gpio-keymap", chromebook_tp_buttons), + { } +}; + static struct mxt_acpi_platform_data chromebook_platform_data[] = { { /* Touchpad */ .hid = "ATML0000", - .pdata = { - .t19_num_keys = ARRAY_SIZE(chromebook_tp_buttons), - .t19_keymap = chromebook_tp_buttons, - }, + .props = chromebook_tp_props, }, { /* Touchscreen */ @@ -3044,7 +3048,7 @@ static const struct dmi_system_id mxt_dmi_table[] = { { } }; -static const struct mxt_platform_data *mxt_parse_acpi(struct i2c_client *client) +static int mxt_acpi_probe(struct i2c_client *client) { struct acpi_device *adev; const struct dmi_system_id *system_id; @@ -3061,33 +3065,46 @@ static const struct mxt_platform_data *mxt_parse_acpi(struct i2c_client *client) * as a threshold. */ if (client->addr < 0x40) - return ERR_PTR(-ENXIO); + return -ENXIO; adev = ACPI_COMPANION(&client->dev); if (!adev) - return ERR_PTR(-ENOENT); + return -ENOENT; system_id = dmi_first_match(mxt_dmi_table); if (!system_id) - return ERR_PTR(-ENOENT); + return -ENOENT; acpi_pdata = system_id->driver_data; if (!acpi_pdata) - return ERR_PTR(-ENOENT); + return -ENOENT; while (acpi_pdata->hid) { - if (!strcmp(acpi_device_hid(adev), acpi_pdata->hid)) - return &acpi_pdata->pdata; + if (!strcmp(acpi_device_hid(adev), acpi_pdata->hid)) { + /* + * Remove previously installed properties if we + * are probing this device not for the very first + * time. + */ + device_remove_properties(&client->dev); + + /* + * Now install the platform-specific properties + * that are missing from ACPI. + */ + device_add_properties(&client->dev, acpi_pdata->props); + break; + } acpi_pdata++; } - return ERR_PTR(-ENOENT); + return 0; } #else -static const struct mxt_platform_data *mxt_parse_acpi(struct i2c_client *client) +static int mxt_acpi_probe(struct i2c_client *client) { - return ERR_PTR(-ENOENT); + return -ENOENT; } #endif @@ -3100,10 +3117,6 @@ mxt_get_platform_data(struct i2c_client *client) if (pdata) return pdata; - pdata = mxt_parse_acpi(client); - if (!IS_ERR(pdata) || PTR_ERR(pdata) != -ENOENT) - return pdata; - return mxt_parse_device_properties(client); } @@ -3113,6 +3126,10 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) const struct mxt_platform_data *pdata; int error; + error = mxt_acpi_probe(client); + if (error && error != -ENOENT) + return error; + pdata = mxt_get_platform_data(client); if (IS_ERR(pdata)) return PTR_ERR(pdata); -- 2.16.2.660.g709887971b-goog