From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21058C43603 for ; Tue, 10 Dec 2019 00:19:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E67692080D for ; Tue, 10 Dec 2019 00:19:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="i0XscqF4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727602AbfLJATe (ORCPT ); Mon, 9 Dec 2019 19:19:34 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:61015 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727304AbfLJATU (ORCPT ); Mon, 9 Dec 2019 19:19:20 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 47X0ws4XrzzLy; Tue, 10 Dec 2019 01:16:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1575937005; bh=J1UtFVWRaaOezDGDF6HSdi8ypeDqB+/Qknt3TL2K7FU=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=i0XscqF4kH3hybzld3O5NYlb83BWA7wvZqt6U1dSV+Yi/eEigU+dnSw2xOscLBczv dJ9MnDMXlzGT50VhguhqNFgDoalsjFU1767T7P8yRZ1sufT4KVprNKSmAgiHamlMye R1O3uQqYOnxlred+O+jnaBoRadbsTQmouQb9cceczYaDT8bz3v2tpzqiAVPP1nxIKA jBFZqnVvbEDrPG+SoC4vXHrvos7+zoIlgo36NWXbxpkmEhg5lKbXXrS7hu8ApP3eru H4eHfs8jcJrve3tfTcJZ66ILQH7ekfLCryPRRNAJRtadSZbscfnyhU7EDkix6O8PRU IvnuthGoE0KOw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.101.4 at mail Date: Tue, 10 Dec 2019 01:19:18 +0100 Message-Id: <5b017222a771fcef78876a18bcd80603c29c25f0.1575936961.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 4/6] input: elants: detect max_x/y from hardware MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , linux-kernel@vger.kernel.org, Dmitry Osipenko Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Read max_x/y from hardware when not specified in devicetree. elants_i2c_initialize() call is moved after inputdev allocation (but still before making it visible) to allow the function to see DT-provided values. Signed-off-by: Michał Mirosław --- drivers/input/touchscreen/elants_i2c.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 02bd5e3e2171..2e6c9aa60496 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -498,9 +498,11 @@ static int elants_i2c_query_ts_info(struct elants_data *ts) rows, cols, osr); } else { /* translate trace number to TS resolution */ - ts->prop.max_x = ELAN_TS_RESOLUTION(rows, osr); + if (!ts->prop.max_x) + ts->prop.max_x = ELAN_TS_RESOLUTION(rows, osr); ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, phy_x); - ts->prop.max_y = ELAN_TS_RESOLUTION(cols, osr); + if (!ts->prop.max_y) + ts->prop.max_y = ELAN_TS_RESOLUTION(cols, osr); ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, phy_y); } @@ -1235,12 +1237,6 @@ static int elants_i2c_probe(struct i2c_client *client, return -ENXIO; } - error = elants_i2c_initialize(ts); - if (error) { - dev_err(&client->dev, "failed to initialize: %d\n", error); - return error; - } - ts->input = devm_input_allocate_device(&client->dev); if (!ts->input) { dev_err(&client->dev, "Failed to allocate input device\n"); @@ -1252,6 +1248,12 @@ static int elants_i2c_probe(struct i2c_client *client, touchscreen_parse_properties(ts->input, true, &ts->prop); + error = elants_i2c_initialize(ts); + if (error) { + dev_err(&client->dev, "failed to initialize: %d\n", error); + return error; + } + __set_bit(BTN_TOUCH, ts->input->keybit); __set_bit(EV_ABS, ts->input->evbit); __set_bit(EV_KEY, ts->input->evbit); -- 2.20.1