Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2684496pxf; Sat, 27 Mar 2021 21:50:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhmR1IbRPT0PV1b5V/QLZ3fLA3VcsscR0ddR9/IYMiOUEJhQ/KdT1gOA4osOUYufuz/cdN X-Received: by 2002:a17:906:b80c:: with SMTP id dv12mr23112840ejb.110.1616907015733; Sat, 27 Mar 2021 21:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616907015; cv=none; d=google.com; s=arc-20160816; b=aOMWQYIoH/ArzIr26DeR6AntQoL3+ieXYojTro8e+BqAZZW93hg9gqyTc/0N2eEKzC HyH44DkSBjW1SMa4aMixEtdocgkuZXVgnlgdcokp+GPfUwao/pwfJ6pxt6LjIzkwX3Wy 4cQJnlGodJzuXnVsrcDD3dZg7RJ7y1ZdVuzwMZcdRxxGLqexTByNICY1VDGLN7ULWqJW u9q1zTtaJMWXYOk5B1Xdc2ZiYciEqyXq1hHsGhTE27bxPeVn1BKXII/M79682M75clX+ bycZTrjfU61+7ech1aGaJnZKgbW5nd4Dqkzq5Tpigp1pjFv1pG1rqusHtDEUAD7sU+zp bW3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=YyUcINWM0TObjk2siXAf/6ABze4wrk4Frd1z8525Vm0=; b=mCV0rUH+0+5xDBEEXgtfgufoqV4uToNVHSBa2czWJyoQpQiK5fOl1h/oeW54Ph4yZt toJp7FHXNCIFNzykUOpsRbP4Rlo69MpUXrcepdsbiC6MtBn7XS9nazay/x5l/FtNmD4i xyyk17Dri5m+5t/uqigv+FFVyPkxmkcLfEWqgAWHiADRa7F1OxbBRMBcD+3L4N9V1kuE u68D3YLjD2NzO5QN6dS7DzFrJyU20NBntdQudsSVLfCqTvnhNpcHt7jm0JGKhBaB9WZe CcbAJ+AVYhbcAuGWPtjwZ7BtyA72TFLydZXCsC2ZuoLKIjGrLtDhR3gZOEkt9YQpB4W6 be/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DWD6nzZ5; 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 co21si10359985edb.513.2021.03.27.21.49.49; Sat, 27 Mar 2021 21:50:15 -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=DWD6nzZ5; 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 S231296AbhC1EoP (ORCPT + 99 others); Sun, 28 Mar 2021 00:44:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbhC1EoN (ORCPT ); Sun, 28 Mar 2021 00:44:13 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5074FC061762; Sat, 27 Mar 2021 21:44:12 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id f10so7268847pgl.9; Sat, 27 Mar 2021 21:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=YyUcINWM0TObjk2siXAf/6ABze4wrk4Frd1z8525Vm0=; b=DWD6nzZ5iT1sy0wkq/AuSeqdGwXvi+gmi8Lpn7dg2Q8YvtxbIinenJJlxZ/G5q71vi jGJx0ZZ7TdQC+XIU7dc2hpenPUjokO6UyeQj2iXVp3QJHeCfqLjj9aMQ9DeRdz2NrKTt T7/cy383ZHHg6JHB2nhltgwJnBqBHQGHIQvdYI6WdLP7ggzsdCq2oh1NqIk54lIO4FmB +grbEvCUAAW1DbFk2+AFGJmVxaWY7/SH9pMPKwC0nVQJVdH/iS5BMsDVvNOGXZ3qxD/5 QNfeIvk+g4ofdLSzmWESJIty5MFREWDnwYCUItpmbfFYsPHijgRmsVQitdoldi9Myy7g du/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YyUcINWM0TObjk2siXAf/6ABze4wrk4Frd1z8525Vm0=; b=c0QspQR3AtmR85LHfkjHoLPCIToyMnbvKKenoN0Lf1RzKCPCee5OBucoqUYr+Av8Ov CeGzUx5lSVm5wc/48A5OPRg+MPuj90XVw66tlAr/DhCgi5BDUP5JMSIyer0xq68k6Jsl ckL/69EpQYct6VL59EpWUSRr8SoVssd7YXV/jk2WKE7ylqYtu/6cRLgv9espXXAzY72F Em7tRw1tE4iHoTb90Po73ydafvTyvSLO3qJBivgFNATwxoaeplzsZoTL+RaZsfm74rOi N+Tv2cgfJgUT8NE1u2ZqoJL6Apzw5Wxz5susCK0MRg+xeNdBve53A42acfM+4GRU0Jtp 2RaA== X-Gm-Message-State: AOAM533UpIiA8myeoiDJ+s7oo9rww/P6JCW/sjnhTzk/hDjaPGkbZ5q0 i7ABOzMdNqj4nNrte7A52tlKk/yqmPI= X-Received: by 2002:a65:538f:: with SMTP id x15mr19144989pgq.429.1616906651839; Sat, 27 Mar 2021 21:44:11 -0700 (PDT) Received: from google.com ([2620:15c:202:201:583b:ffbb:e0ea:e126]) by smtp.gmail.com with ESMTPSA id fa21sm12252916pjb.41.2021.03.27.21.44.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Mar 2021 21:44:10 -0700 (PDT) Date: Sat, 27 Mar 2021 21:44:08 -0700 From: Dmitry Torokhov To: Dmitry Osipenko 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 Subject: Re: [PATCH v1] Input: elants_i2c - fix division by zero if firmware reports zero phys size Message-ID: References: <20210302100824.3423-1-digetx@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210302100824.3423-1-digetx@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); > > -- > 2.29.2 > Thanks. -- Dmitry