Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3066491pxf; Sun, 28 Mar 2021 10:25:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybKht/n1J/vO+nNOU9L0bE5T0U3nVH/U+wTBvnth+dNeE3I5uj/twxDUBOyf37Ryd+ww7a X-Received: by 2002:a05:6402:1d92:: with SMTP id dk18mr24799487edb.161.1616952346235; Sun, 28 Mar 2021 10:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616952346; cv=none; d=google.com; s=arc-20160816; b=BPD+0x0j2o1CwXRpYjM7Ctji2YVxyMhRHR12GhZjpbwR/GKC2t3P7SkptysbcVYsru rEAwZ+8riR8G22g7m1WhQXg6YIewaqkw5fkij77+Edh3JVjlXdhOLpjQlOG3pWDstYBD HzWwNsoFPc03bMr1W3L7mdNIho/7spGOGRWI58d97fw0XvNGqXlnZLcHc4PQ0ZjZ8tL2 j9Pv4ysHooSXeRIRgtHumYmVxfk8ajTK4EtftGrbjFhEvvzuR1Zw+uFY2OU76v61mDAg wezyU1yjjD8ZaQzXx0i5cGUo+/a8f2SEAbMzJOViTKjLoYSlNMTxdcjZHiDDWUi9zkc/ hNiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=m5n0YXOwW9Hi1GIX7USstKgF3p3m11IaefFXa7cKRmM=; b=MAYA2YQrgqX7Yb3qd/khxA6W+pLtm9ojcDOTRz1zzFezR3gmUOrcCHXhcGScJuCXeX v50VU9DU2toqiMClLAbnTtrQ8Kxe/KW9cIVkGy4AFwX4POLB2SU/fvpS/SKtzT8srtkl x2kjU9K/goc3EQHzJQVWwHFJ9+g5lzB0z+C7bQkwB1nRvcIUOIHnSzwfx+t2E1f0MZuM mHrvZIx+neUzbvz39tBleh9nD3VblLTA7J1x+7Y2bc3oa6fMrPLo5Hu9+o9RVRIMjA++ ygvXofMhDRJAD9gMKT6i5bRllzAS/4/KOBNYHoPaeW8ILIb2HJEUSwtvsS+CWzj58z1s vPuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KG3dCp5G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id 11si10875572ejy.63.2021.03.28.10.25.23; Sun, 28 Mar 2021 10:25:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KG3dCp5G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231461AbhC1RV3 (ORCPT + 99 others); Sun, 28 Mar 2021 13:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231340AbhC1RVF (ORCPT ); Sun, 28 Mar 2021 13:21:05 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C17A8C061756; Sun, 28 Mar 2021 10:21:04 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id m12so14902784lfq.10; Sun, 28 Mar 2021 10:21:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=m5n0YXOwW9Hi1GIX7USstKgF3p3m11IaefFXa7cKRmM=; b=KG3dCp5GSUH47Hc4LdQZI/2q+2sU74KRV1LkWlb44jlV8t0LNd9rAUJchmXnEREkEq /kYJkVSUl3siYQIm385XNBBQ9C77ekcH/01si1fudYx3Y2b5V6zQwbcbADBSQI/MakQM 1V5T9CO7mhb93jWtlxvISFxEbNj7t1sydOSow4uf5u9CcvVjpys3Wes/upgxBps4D3lG SmD6mqXf6605g9NgIsHVWzzHmrivf+XsXl4MNwNLXplZ0JHin6I7QRMgrNAenXcmTXYE 6yvMddvTR02ywUBh8bQ/6Fj2AXxiLd+jj8/sFViDJc25fABhQSLRvgVmmpKbDy2NW9A2 KWOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=m5n0YXOwW9Hi1GIX7USstKgF3p3m11IaefFXa7cKRmM=; b=s+tRyqFmhpBmaPanx8yEKxE4AIckLdXfdJ/XIdUYEKPdDFpWBKsDKd478aM7Hx84I5 CqrKYOYCupMer7oPCADM5+V3iw27pQnZBWlanIG2xPQZ0w6JQYGqXIWY4S0tb3sF5chL 7c4ICVbD3TK2BbolcNGSVPjRhTKcGBBghh2rpFT2e+M1QEPLSErpubwGqUrkYVqeuDvy L/tTU3cdHr1BCTLbD2ztJ52BYpP+ikgbORP6gdc7Cd093uecU8wfs734oSPqYGBwYQPj LGEPJgM7BUgbv7idSBSHsuPjvjTrmHi19EC9rvZEsGCtoggeslPizy3a9Eh896wB4kfe sWSw== X-Gm-Message-State: AOAM5307zu2+JTaztGDEpWPXwWSlsiBKl7FGMmV4Aksb3iN3ovDDacYr cLXv7qmDlb7SzgZHHIOitlDk2LE6Qow= X-Received: by 2002:a05:6512:b97:: with SMTP id b23mr14338302lfv.101.1616952063168; Sun, 28 Mar 2021 10:21:03 -0700 (PDT) Received: from ?IPv6:2a00:1370:814d:b259:a10:76ff:fe69:21b6? ([2a00:1370:814d:b259:a10:76ff:fe69:21b6]) by smtp.googlemail.com with ESMTPSA id f26sm1534567lfe.118.2021.03.28.10.21.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Mar 2021 10:21:02 -0700 (PDT) Subject: Re: [PATCH v1] Input: elants_i2c - fix division by zero if firmware reports zero phys size To: Dmitry Torokhov Cc: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Johnny Chuang , Jasper Korten , Svyatoslav Ryhel , linux-input@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210302100824.3423-1-digetx@gmail.com> From: Dmitry Osipenko Message-ID: Date: Sun, 28 Mar 2021 20:21:01 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 28.03.2021 07:44, Dmitry Torokhov пишет: > Hi Dmitry, > > On Tue, Mar 02, 2021 at 01:08:24PM +0300, Dmitry Osipenko wrote: >> Touchscreen firmware of ASUS Transformer TF700T reports zeros for the phys >> size. Hence check whether the size is zero and don't set the resolution in >> this case. >> >> Reported-by: Jasper Korten >> Signed-off-by: Dmitry Osipenko >> --- >> >> Please note that ASUS TF700T isn't yet supported by upstream kernel, >> hence this is not a critical fix. >> >> drivers/input/touchscreen/elants_i2c.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c >> index 4c2b579f6c8b..a2e1cc4192b0 100644 >> --- a/drivers/input/touchscreen/elants_i2c.c >> +++ b/drivers/input/touchscreen/elants_i2c.c >> @@ -1441,14 +1441,16 @@ static int elants_i2c_probe(struct i2c_client *client, >> >> touchscreen_parse_properties(ts->input, true, &ts->prop); >> >> - if (ts->chip_id == EKTF3624) { >> + if (ts->chip_id == EKTF3624 && ts->phy_x && ts->phy_y) { >> /* calculate resolution from size */ >> ts->x_res = DIV_ROUND_CLOSEST(ts->prop.max_x, ts->phy_x); >> ts->y_res = DIV_ROUND_CLOSEST(ts->prop.max_y, ts->phy_y); >> } >> >> - input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); >> - input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); >> + if (ts->x_res > 0) >> + input_abs_set_res(ts->input, ABS_MT_POSITION_X, ts->x_res); > > There is absolutely no difference between setting respluton to 0 vs not > setting it at all, so I dropped the conditionals and applied. > >> + if (ts->y_res > 0) >> + input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); >> if (ts->major_res > 0) > > We could drop this condition as well. > >> input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, ts->major_res); I'll make a follow up patch to clean up this condition, if you haven't done it yet. Thanks!