Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4393046pxb; Tue, 2 Mar 2021 14:12:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvzF4qdkEA7EZKfY/2WQ8ceEf9C2fU2wb92TBxbd7VqUwsnJhuM1CEiRoFgCK9kEUfyUTA X-Received: by 2002:a05:6402:30a2:: with SMTP id df2mr11078055edb.29.1614723157306; Tue, 02 Mar 2021 14:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614723157; cv=none; d=google.com; s=arc-20160816; b=NsMMnEpmSEkeBUZSxOv4TOusHIjl4y2U7axsmxMWBvYQtwqOfnUI3Ci6PRT9wTfA4U bq+EYDbXY5rltuOokm92ZO11BK3LBH9zFwA+WqGio/zZ22fcNtdrbNsylvjCGCLssUKE YMneSK7ECfX9FTNio0K01Zb2LjNB8stcsHNYFX3spAXT6llzcLwc9sFPsV/N2en2AwDx XPh0e6Jck3Q3eALJ4StnIdH9iRZF37eH3/fR8UrIg4U4EUYBB1W3Lg003x9ptM90fAmj +5EgZukQKHwQ666wtZrXalMjxk0G4z/HnQrn+7zR5s1H/dTnnCXirlwo6ntmVHmkgxVR rE+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=sfUQ5KkuJugRcswoXUIYuj0VO0djxRHGJcsWdg+KZjU=; b=alt39swqAckRLUtmLvFyBU8a+mgRDFyEsyDAm9iqiWqRqfJTAvk51fKmQYf7RJIvfX /yg8JSbx3L3p+1isr2izv94UMAMkx8TPVosmIFlujPY2llK0bJM54qtiXOjImHtr4gd6 h0tOvH8h1ikmLuPou03tSFuHm02unn5hzeEaDlj1pOcF6gFO7k8ghBavAWZTXHCr6ELA YqNej1V1UF+NYTcvwtUnUMTpNS1b/6XNg54by4Xdzx+7Q5ajn7R1iuY26WRv298mWsPI eNxK5FksZGAIupb+BQwM+ZzYG2cK/brcapexXdImD3t1SExduZxixiRJC0UKmHelokFH +Rjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SREfkOV5; 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 c10si13287950edu.423.2021.03.02.14.12.14; Tue, 02 Mar 2021 14:12:37 -0800 (PST) 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=SREfkOV5; 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 S1382831AbhCBK1H (ORCPT + 99 others); Tue, 2 Mar 2021 05:27:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1838287AbhCBKJS (ORCPT ); Tue, 2 Mar 2021 05:09:18 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29666C061756; Tue, 2 Mar 2021 02:08:37 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id k9so10466502lfo.12; Tue, 02 Mar 2021 02:08:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sfUQ5KkuJugRcswoXUIYuj0VO0djxRHGJcsWdg+KZjU=; b=SREfkOV5YjngyaW6kgRMW6XmqLOOigj8+ADhOCMufJ1iRRUMuNBWbHsCqjUzWWt6RG vqIWfYG3W9ZJBvpHPygONmzb9jyvmYo8JlsNZVPPu26vKOGFUwdYvLcDbUFzTizQbxIb k8M8URlvwnPCw7E3jD0s1PQEzjVkb3vAtm/RzPLZz/HA+RAnsuPv2IY0fZ8ErMCiHdPX MGTznypCqMUo8xtrz2aXggKnx251MUiU6sL9p9EiQNgPxi+9DUtfgEWN74vOmC/iqW6x sPA1esYehtYg6JsvtvY6gu/9od9X3IhrHgWd4s6JP+PMEP+KwUhwvqa9BOOYZqjs7tra hcxQ== 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:mime-version :content-transfer-encoding; bh=sfUQ5KkuJugRcswoXUIYuj0VO0djxRHGJcsWdg+KZjU=; b=Rdm7PfEZ7RNQj01dcYqo1P0H4VUDDDRonoiWWmVvYTkCr2YBbnqP//WmgtvoQJAsla R4nqL+HISPxpcLs7LnesuCboE2T/IdNoa+QPtf5vgM0tenJGMrSjhcN5aSdllSTT3Qu1 zEZ3KyaajiGpwHZxKiepf1s08A/cr5alFchEHDcQKRzNCsmRJ5yugrHoBxAXMqKOCaE7 BsGIhQ+7Pp5g4035UXX9gdi3mxzRyQcvshZG6B0JESiTLC97i3Zz1hVO3tn4iUJLBhKm rVr5nj0hvxLjL1IA6cPzcP04zZ2IfAyMcfbl03unwpsLAlANyWKB+wsWB2xNB4ersG1U p+/Q== X-Gm-Message-State: AOAM530+umB0GBY+2Koe//HsWYYQCQ6xY7D/XwTIudyOlnS32anyt6GA ZWFKHickiZ8KIYuQpoXfoe8= X-Received: by 2002:a05:6512:547:: with SMTP id h7mr12285352lfl.529.1614679715517; Tue, 02 Mar 2021 02:08:35 -0800 (PST) Received: from localhost.localdomain (109-252-193-52.dynamic.spd-mgts.ru. [109.252.193.52]) by smtp.gmail.com with ESMTPSA id g10sm1725052lfe.90.2021.03.02.02.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 02:08:34 -0800 (PST) From: Dmitry Osipenko To: Dmitry Torokhov , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Johnny Chuang , Jasper Korten , Svyatoslav Ryhel Cc: linux-input@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] Input: elants_i2c - fix division by zero if firmware reports zero phys size Date: Tue, 2 Mar 2021 13:08:24 +0300 Message-Id: <20210302100824.3423-1-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + if (ts->y_res > 0) + input_abs_set_res(ts->input, ABS_MT_POSITION_Y, ts->y_res); if (ts->major_res > 0) input_abs_set_res(ts->input, ABS_MT_TOUCH_MAJOR, ts->major_res); -- 2.29.2