Received: by 10.192.165.148 with SMTP id m20csp184464imm; Thu, 3 May 2018 17:42:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqd4viXixGox8bu1RNODdXSXld+mQtjgPI4GamKUWhGWmi0fOxZMw/ubiwOnIPIWIYUVQ9w X-Received: by 10.98.55.69 with SMTP id e66mr6520061pfa.43.1525394534740; Thu, 03 May 2018 17:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525394534; cv=none; d=google.com; s=arc-20160816; b=0s7Cz7M5C0JbpkyJGcLOm86bCcKlsXnpWcEntWHVOZdwdV9n28RHTXxPDvQFVVwTg/ a1mq5tCwLN8sdIdOKm/MMz2vfaKzR8aFR8AR2hFDSkZnntOj3Wuz1xXoltW0GXZCNwMI dhpLNpRSM7UG4kEP9hGTmufQzJ8J4AZR1DCpjY0z1arF5NFJDchYGYSX7q9nfpi2XOXn gw+UHDauWV4ogeYZVvBUEnZmPLo6ePxG3TEhxoB8Yhs+XZWNSV7EcMWN8GPldmcv4p9C e0RQ2HHql0CvRnYo+JKXowj4MnL45R56vh0L4cq9TPfejsMr9dV+W70eTzUQP+TR6iBU Begg== 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=19grBSqmsCrfij/ZGvhol3+54rj5qssc741Lhlsjat4=; b=H5TfRjbZ2xwD/6xajfaqbwsd4obl4HLI1woVcXYIhg+DlmwAnUz27ObEQ9ZcuMB/9C BSwJU8ORf9gqaGUFerb5XfFexUetfUUYERZnc2ihD+xZG/eGZ3puxxYd0LfnQPi5/Lp9 kWz0UsBajolRn47CGg2sxQ0zlvKIJGeFCVSBJqsoJtcIsFFpWPZaMnp6u4SvryYfIwIV F4C7bkQp4Hx4I4pPL2w+1u43o48dxNh0w01haA1jIYgVXB+vfx0QShTMVHQEDkZ4k4Oa vs/nhTd2tIHoySG1PRLL/7zQDa7ALAIWk4WX+ohIJP8HIvV3na2c8r6BpICjyQvMmba8 LPnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Yf98W+Hg; 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 b4-v6si9407660plr.582.2018.05.03.17.42.00; Thu, 03 May 2018 17:42:14 -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=Yf98W+Hg; 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 S1751354AbeEDAlp (ORCPT + 99 others); Thu, 3 May 2018 20:41:45 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35938 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750965AbeEDAlm (ORCPT ); Thu, 3 May 2018 20:41:42 -0400 Received: by mail-pg0-f67.google.com with SMTP id z129-v6so10118595pgz.3; Thu, 03 May 2018 17:41:41 -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=19grBSqmsCrfij/ZGvhol3+54rj5qssc741Lhlsjat4=; b=Yf98W+HgCYc6DRqS9YCVFKO//qaXX85rwL8lt/J2DM5tSHJNdBWsbVhI+kWTLVj002 ps9LvbcVlf+US+byqLYgUPdGvDMaxTMmL3LBADJzGdCXmc16rnI0+XfLxk0LP32ZROe2 HoWW703gR6W/HLKt4mj5ER/Im8ybNiwxE+fvubB/ldP1OHJce8pyty+QPzcpyuxpsjGh 95b+T9z/b7UPTeceINJFf/ueNd4WOZFlPu4OD0aiL0YtQRTR5RYLUyx3yAJf+TeO2ji5 NDjU6piNgf0f2EZllYRUIdE1rhyhMi15zQNxpIemXElhhqdFrhn+VCdI+JfPWFIBRvdn rdjA== 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=19grBSqmsCrfij/ZGvhol3+54rj5qssc741Lhlsjat4=; b=QTduj5cr0FMWO6X79KpNeZnKrvt66VACyUe9Ix7lqHtL3hrnOSDNQN8SMJTiOLWTPC p+cvH6oi5VzOEjJ768dvnXKJrQZzvX9gQ2fkqAvyVozA8Q4Es0L+EIV9rlVo2yaXfVlO /90pFmcFpk8II30wNGF0U/KEKlNwljh6RzBkuW9QP3ix0rkt9Kmf60gBGxgh1QgunX0g uZttQUapOhyVfID8IRDZqLJhuMWVoMFAFbu//eeOiIDd4vsJypUHUjHbLKuvVf4n7izX +F10TjAKAsuR7LprpH3IaA/hyPAzXikzXydJJuXa8NhwtqAGWFlGMmBExLTyNMANpN5z tUmw== X-Gm-Message-State: ALQs6tBLmSdNIPDmmpiDMqG2lFpiRQ4S8DkiJY/QEvncKD7HgAMbRBiS cr2Xjgj+sy0OZQFqXbbb9j/XfQjm X-Received: by 2002:a63:9741:: with SMTP id d1-v6mr21116853pgo.447.1525394500813; Thu, 03 May 2018 17:41:40 -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 c187sm27534338pfa.181.2018.05.03.17.41.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 17:41:39 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org, Benson Leung Cc: Nick Dyer , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] Input: atmel_mxt_ts - require device properties present when probing Date: Thu, 3 May 2018 17:41:35 -0700 Message-Id: <20180504004135.67554-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180504004135.67554-1-dmitry.torokhov@gmail.com> References: <20180504004135.67554-1-dmitry.torokhov@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The driver needs help determining whether it is dealing with a touchscreen or a touchpad, and with button mapping. Previously we supported passing this data via device properties, and also had DMI lists for Chromebooks that specified Atmel devices in ACPI, but did not provide enough data there. Now that chromeos_laptop driver is adjusted to supply necessary device properties even for ACPI devices, we can drop the DMI tables and refuse to probe if device properties are not attached to the device. We use presence of "compatible" property to determine if device properties are attached to the device or not and rely on chromeos_laptop to re-probe the device after attaching missing device properties to it. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/atmel_mxt_ts.c | 152 ++--------------------- 1 file changed, 12 insertions(+), 140 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 09194721aed2d..4ac49c6c00060 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -2999,142 +2999,6 @@ static int mxt_parse_device_properties(struct mxt_data *data) return 0; } -#ifdef CONFIG_ACPI - -struct mxt_acpi_platform_data { - const char *hid; - const struct property_entry *props; -}; - -static unsigned int samus_touchpad_buttons[] = { - KEY_RESERVED, - KEY_RESERVED, - KEY_RESERVED, - 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", - .props = samus_touchpad_props, - }, - { - /* Touchscreen */ - .hid = "ATML0001", - }, - { } -}; - -static unsigned int chromebook_tp_buttons[] = { - KEY_RESERVED, - KEY_RESERVED, - KEY_RESERVED, - KEY_RESERVED, - KEY_RESERVED, - 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", - .props = chromebook_tp_props, - }, - { - /* Touchscreen */ - .hid = "ATML0001", - }, - { } -}; - -static const struct dmi_system_id mxt_dmi_table[] = { - { - /* 2015 Google Pixel */ - .ident = "Chromebook Pixel 2", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), - DMI_MATCH(DMI_PRODUCT_NAME, "Samus"), - }, - .driver_data = samus_platform_data, - }, - { - /* Samsung Chromebook Pro */ - .ident = "Samsung Chromebook Pro", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Google"), - DMI_MATCH(DMI_PRODUCT_NAME, "Caroline"), - }, - .driver_data = samus_platform_data, - }, - { - /* Other Google Chromebooks */ - .ident = "Chromebook", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "GOOGLE"), - }, - .driver_data = chromebook_platform_data, - }, - { } -}; - -static int mxt_prepare_acpi_properties(struct i2c_client *client) -{ - struct acpi_device *adev; - const struct dmi_system_id *system_id; - const struct mxt_acpi_platform_data *acpi_pdata; - - adev = ACPI_COMPANION(&client->dev); - if (!adev) - return -ENOENT; - - system_id = dmi_first_match(mxt_dmi_table); - if (!system_id) - return -ENOENT; - - acpi_pdata = system_id->driver_data; - if (!acpi_pdata) - return -ENOENT; - - while (acpi_pdata->hid) { - 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 0; -} -#else -static int mxt_prepare_acpi_properties(struct i2c_client *client) -{ - return -ENOENT; -} -#endif - static const struct dmi_system_id chromebook_T9_suspend_dmi[] = { { .matches = { @@ -3155,6 +3019,18 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) struct mxt_data *data; int error; + /* + * Ignore devices that do not have device properties attached to + * them, as we need help determining whether we are dealing with + * touch screen or touchpad. + * + * So far on x86 the only users of Atmel touch controllers are + * Chromebooks, and chromeos_laptop driver will ensure that + * necessary properties are provided (if firmware does not do that). + */ + if (!device_property_present(&client->dev, "compatible")) + return -ENXIO; + /* * Ignore ACPI devices representing bootloader mode. * @@ -3186,10 +3062,6 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) data->suspend_mode = dmi_check_system(chromebook_T9_suspend_dmi) ? MXT_SUSPEND_T9_CTRL : MXT_SUSPEND_DEEP_SLEEP; - error = mxt_prepare_acpi_properties(client); - if (error && error != -ENOENT) - return error; - error = mxt_parse_device_properties(data); if (error) return error; -- 2.17.0.441.gb46fe60e1d-goog