Received: by 10.213.65.68 with SMTP id h4csp786170imn; Tue, 20 Mar 2018 15:34:44 -0700 (PDT) X-Google-Smtp-Source: AG47ELtek3Cv6PB46l7LHAtWUls7V1LnqYSe8h5+/FG+tabQDX7uBU209Z3YCvuwml/JP13ERQvE X-Received: by 10.101.65.195 with SMTP id b3mr11392967pgq.118.1521585284904; Tue, 20 Mar 2018 15:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521585284; cv=none; d=google.com; s=arc-20160816; b=Nasn8X6hGaKljnqOTtSnvPw3syFtMkivSBlEbVl3HMvwFbo2maSvZeH5OXvkepOzB1 Si3cQ9ZH4hFvumX6sGNLrJN37p81gyIfGA5r7cvPtFfvVKo/FjPtiQmaz2MKUhPvAZWf rdi8URxnB1+TNjOLD5bxjoMc3nwQ/TXbQalxYh4KVHp8skidDhLxOjPlk34Eo/jyaF92 r/3eFHNOfrwCGTP2zwb6Ds6gS/YO0pIwq3lSQNB5ctm/FIwgs/W9jjtW9Mgvj7/XNGGt m3+pGIyUa/GMk8I3jQFIHT9+WrlEYbflg94VXcr2v3+gGwDFAa8UJ7Av/d/NYQ/7+kNo 9S5g== 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=VQiH2LrGDyesFpzB+SIcvnmFO1CHg5rrgpDQgJfovE8=; b=wrbUO86pKEc/A+Lvke8v7uOdm1L3jFBbuo80TLFyL5ijLw2ZSfJSfNCvC7RaVX8kZs phEqtK+mdhKj7BVVsGaZfC05Qa5Y8Etw0Iy/ME3K/8gOjon4g0RRHxHGlJoENkY6gNfH ee2I2FpDhYk0F7550A2bYycG7uGRgW43kK57LL+HuJAb4EbMQdExOvxUWz5AKvfTiNl1 gRn6lY2Ww1TX8QzF7jG3RGlcplNb9LLv2+Ipp00NfWxFEG4GQp5jDEQU/ZxV6ztfxIYE EW0X2jqypozyUbuncvWBKtf430QYl2APIGyR3wVxVaFzyBxEnaVPiQ1RrPdt3mqlxhxu 8QDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ABrb4t3e; 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 u137si1771850pgb.651.2018.03.20.15.34.30; Tue, 20 Mar 2018 15:34:44 -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=ABrb4t3e; 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 S1751913AbeCTWcF (ORCPT + 99 others); Tue, 20 Mar 2018 18:32:05 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:42644 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751758AbeCTWbp (ORCPT ); Tue, 20 Mar 2018 18:31:45 -0400 Received: by mail-pl0-f68.google.com with SMTP id w15-v6so1913616plq.9; Tue, 20 Mar 2018 15:31:45 -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=VQiH2LrGDyesFpzB+SIcvnmFO1CHg5rrgpDQgJfovE8=; b=ABrb4t3ekRBBKHHf8aNC0TMjG9p/+fAuWEvylURWnSbvq6ZF7xdzG14TAuXHnBLXJ8 sW/CxntIzanD9NVtPOpzS0sMZJ08s5xfuASIhErWJ6NWHsk6T/3bHDeYEh90ZMzu70hU N12F7ZdmUXM3PkjLBbrMuvCcj0yeSUACoOF/EWXUnLErWUjSeCXzeQz+oJZqBdH5I1ll jjKUjRqhV+G7XnjUmdqxwXBzrlliAhgpCvyE6ohY/Gj4kzT6j0hvygrJWu8wrqCddycK WQ2Mkda+kn7926H00i2Q6R5JgTePo23+Ub/6qKkLUOF+w/efLw0sKB9G2ugaao82upDB u1Jg== 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=VQiH2LrGDyesFpzB+SIcvnmFO1CHg5rrgpDQgJfovE8=; b=rEzjJdiApzZLOUluk99+8AaFBgkb8KTFHRYT5fNjk2UWnU48t89WuXsiFdEBuyDkVl sNiECka/SmJogYyZo3EYaAFk0GnoHNB8zd+dEizhxwco9tKCpgNemhKwEMCCP5XVVyE7 dgpgIzpJl4074/g/zSk7FBPUGlDMODLXqM7EnsOZJ6OkhO9TRblDlbvY/h4LfYUQqWCb W++5ubY7puye877M1MubQfAmWHZnzpYuPTA/6294UxPnGGU/H4ATsJkRa0DUjMKx/nkM YPJvozN4hnVWRZtAu3WTnXaxaCWoYmhwvaxrHfSNqGhWUy4l+asTRfbZVzeMxSxYqGua zHeA== X-Gm-Message-State: AElRT7GPGs2zmKnUF29PmPuEWlnnbS7HWSQW8Zj270gp2lVMhPe478ch v3WGtiazdLzSNrqmg2hl/3z3gtwX X-Received: by 2002:a17:902:1e5:: with SMTP id b92-v6mr6793974plb.78.1521585104536; Tue, 20 Mar 2018 15:31:44 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Mar 2018 15:31:43 -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 02/14] Input: atmel_mxt_ts - switch from OF to generic device properties Date: Tue, 20 Mar 2018 15:31:26 -0700 Message-Id: <20180320223138.234724-3-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 Instead of using OF-specific APIs to fecth device properties, let's switch to generic device properties API. This will allow us to use device properties on legacy ChromeOS devices and get rid of platform data down the road. Acked-by: Nick Dyer Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/atmel_mxt_ts.c | 59 ++++++++++++------------ 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 20e1224d1a6db..73d9c0254ad76 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -2922,47 +2923,52 @@ static void mxt_input_close(struct input_dev *dev) mxt_stop(data); } -#ifdef CONFIG_OF -static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client) +static const struct mxt_platform_data * +mxt_parse_device_properties(struct i2c_client *client) { + static const char keymap_property[] = "linux,gpio-keymap"; struct mxt_platform_data *pdata; - struct device_node *np = client->dev.of_node; u32 *keymap; - int proplen, ret; - - if (!np) - return ERR_PTR(-ENOENT); + int n_keys; + int error; pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return ERR_PTR(-ENOMEM); - if (of_find_property(np, "linux,gpio-keymap", &proplen)) { - pdata->t19_num_keys = proplen / sizeof(u32); + if (device_property_present(&client->dev, keymap_property)) { + n_keys = device_property_read_u32_array(&client->dev, + keymap_property, + NULL, 0); + if (n_keys <= 0) { + error = n_keys < 0 ? n_keys : -EINVAL; + dev_err(&client->dev, + "invalid/malformed '%s' property: %d\n", + keymap_property, error); + return ERR_PTR(error); + } - keymap = devm_kzalloc(&client->dev, - pdata->t19_num_keys * sizeof(keymap[0]), - GFP_KERNEL); + keymap = devm_kmalloc_array(&client->dev, n_keys, sizeof(u32), + GFP_KERNEL); if (!keymap) return ERR_PTR(-ENOMEM); - ret = of_property_read_u32_array(np, "linux,gpio-keymap", - keymap, pdata->t19_num_keys); - if (ret) - dev_warn(&client->dev, - "Couldn't read linux,gpio-keymap: %d\n", ret); + error = device_property_read_u32_array(&client->dev, + keymap_property, + keymap, n_keys); + if (error) { + dev_err(&client->dev, + "failed to parse '%s' property: %d\n", + keymap_property, error); + return ERR_PTR(error); + } pdata->t19_keymap = keymap; + pdata->t19_num_keys = n_keys; } return pdata; } -#else -static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client) -{ - return ERR_PTR(-ENOENT); -} -#endif #ifdef CONFIG_ACPI @@ -3096,16 +3102,11 @@ mxt_get_platform_data(struct i2c_client *client) if (pdata) return pdata; - pdata = mxt_parse_dt(client); - if (!IS_ERR(pdata) || PTR_ERR(pdata) != -ENOENT) - return pdata; - pdata = mxt_parse_acpi(client); if (!IS_ERR(pdata) || PTR_ERR(pdata) != -ENOENT) return pdata; - dev_err(&client->dev, "No platform data specified\n"); - return ERR_PTR(-EINVAL); + return mxt_parse_device_properties(client); } static const struct dmi_system_id chromebook_T9_suspend_dmi[] = { -- 2.16.2.804.g6dcf76e118-goog