From patchwork Tue Oct 22 19:56:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11205317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 901E013B1 for ; Tue, 22 Oct 2019 19:57:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6E725218AE for ; Tue, 22 Oct 2019 19:57:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M1X4k/4z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733018AbfJVT42 (ORCPT ); Tue, 22 Oct 2019 15:56:28 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:35897 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731436AbfJVT41 (ORCPT ); Tue, 22 Oct 2019 15:56:27 -0400 Received: by mail-pf1-f195.google.com with SMTP id y22so11304651pfr.3; Tue, 22 Oct 2019 12:56:27 -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 :mime-version:content-transfer-encoding; bh=v2iQyZaNPZ/YhUqBuQfgPfyRrypQdi8sg7nD0u1rVjw=; b=M1X4k/4zlbz/KNGR2xwrXo2e0X8r9qgqfelrR2wI9PxQhTxb5GxVan0qNd2mY4Ytsz 4HgPIDcQHFRgEe4qMB0C0nOZVSTAGZ3ofjKT7N9mlEFrUK6ZCodrucHaPdDY9BUU/geh CCXXunmcckQxe5LALtPrBXCdmwr8jFIL70+69XITWf/epEzZvlZ3AScCKhmFR4UpJgOJ ER2oGECPBHT2oZBiOgZjtwiE6m2JE8vQGMuE9BgcNuVK7a1Ix0OVXnwnF0OpnO5GIp5I 4NCCRszgIlVoRGkeTVgNf30XZanxmkyT1WOPx2Z/roJ536/92Fwun6gL+8swaR5LkzGZ mCnQ== 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:mime-version:content-transfer-encoding; bh=v2iQyZaNPZ/YhUqBuQfgPfyRrypQdi8sg7nD0u1rVjw=; b=JeQL4VGAfdAsCwkut+5400QvvnqQCM2r3A8muvcdga+NB5f8yd6E6IPGtGyYLT9l9K HSDWmsT1dGH4HpBma3B2XH1oMyk3ZZaRC0JoyI1h+v1uV+UaX+uCXJhm63r7HzMtHkFK //eA/eSPre9mlmlzLCRRl9/RFeG/ur5z6ytYfMjj2f+K/V2+mBWhIcJYZEYXx8F1Wl6h +Rs1Us8JnwQy6UmIt3BGrirbxcttyHvrKR4IE1J+O5PASFgcYvxA+HRDO2vAm2x9yKNs Ae8B6+WSuTnqTwozK83rMSfTd3eO63NSvv1X/zHIDm8VtvdBSJKANqN9Q94VB3O1AlO6 vj1w== X-Gm-Message-State: APjAAAXlbhK+hes/TyU8/lTOMd4XizunS8T5Ft7B4fXzhFXBVkxuQ0sx 2wIw2gqeWss6cijP1u6wVAU= X-Google-Smtp-Source: APXvYqwS3goQM0aCfd+HgBD2kZYBRkYSiB++EnTHqzAOX2Ppu5jElBfDxxDkGFd6xy2kagX/+EXmCA== X-Received: by 2002:aa7:8ac5:: with SMTP id b5mr6221397pfd.66.1571774186887; Tue, 22 Oct 2019 12:56:26 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id c34sm20212715pgb.35.2019.10.22.12.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 12:56:26 -0700 (PDT) From: Dmitry Torokhov To: Martin Kepplinger Cc: Dixit Parmar , Kuninori Morimoto , Matthias Fend , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/8] Input: st1232 - simplify parsing of read buffer Date: Tue, 22 Oct 2019 12:56:15 -0700 Message-Id: <20191022195622.66976-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191022195622.66976-1-dmitry.torokhov@gmail.com> References: <20191022195622.66976-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Avoid complex 2-variable loop when parsing touchscreen data to make the code clearer. Acked-by: Martin Kepplinger Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/st1232.c | 50 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index 1139714e72e2..47033ef3749a 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -57,38 +57,38 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts) { struct st1232_ts_finger *finger = ts->finger; struct i2c_client *client = ts->client; - struct i2c_msg msg[2]; - int error; - int i, y; u8 start_reg = ts->chip_info->start_reg; - u8 *buf = ts->read_buf; - - /* read touchscreen data */ - msg[0].addr = client->addr; - msg[0].flags = 0; - msg[0].len = 1; - msg[0].buf = &start_reg; - - msg[1].addr = ts->client->addr; - msg[1].flags = I2C_M_RD; - msg[1].len = ts->read_buf_len; - msg[1].buf = buf; + struct i2c_msg msg[] = { + { + .addr = client->addr, + .len = sizeof(start_reg), + .buf = &start_reg, + }, + { + .addr = client->addr, + .flags = I2C_M_RD, + .len = ts->read_buf_len, + .buf = ts->read_buf, + } + }; + int ret; + int i; + u8 *buf; - error = i2c_transfer(client->adapter, msg, 2); - if (error < 0) - return error; + ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); + if (ret != ARRAY_SIZE(msg)) + return ret < 0 ? ret : -EIO; - for (i = 0, y = 0; i < ts->chip_info->max_fingers; i++, y += 3) { - finger[i].is_valid = buf[i + y] >> 7; + for (i = 0; i < ts->chip_info->max_fingers; i++) { + buf = &ts->read_buf[i * 4]; + finger[i].is_valid = buf[0] >> 7; if (finger[i].is_valid) { - finger[i].x = ((buf[i + y] & 0x0070) << 4) | - buf[i + y + 1]; - finger[i].y = ((buf[i + y] & 0x0007) << 8) | - buf[i + y + 2]; + finger[i].x = ((buf[0] & 0x70) << 4) | buf[1]; + finger[i].y = ((buf[0] & 0x07) << 8) | buf[2]; /* st1232 includes a z-axis / touch strength */ if (ts->chip_info->have_z) - finger[i].t = buf[i + 6]; + finger[i].t = ts->read_buf[i + 6]; } } From patchwork Tue Oct 22 19:56:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11205303 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 88269139A for ; Tue, 22 Oct 2019 19:56:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 672852184C for ; Tue, 22 Oct 2019 19:56:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B36yGOPV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731436AbfJVT43 (ORCPT ); Tue, 22 Oct 2019 15:56:29 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:35245 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733028AbfJVT43 (ORCPT ); Tue, 22 Oct 2019 15:56:29 -0400 Received: by mail-pg1-f195.google.com with SMTP id c8so5771101pgb.2; Tue, 22 Oct 2019 12:56:28 -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 :mime-version:content-transfer-encoding; bh=KTnOBZV7yx8NmDils5fAf50gZrGC7vwGvWz6YsCLa7I=; b=B36yGOPVjnjNGjTLoIt7BVqcQ2A4Xgmqsf6WNSoXtuxNfa+xAq62kGvdLhk2iFayUi cibSHMGD/P7EHfMfRNlonn7jnkYpRe6akm09HwLCe/1oF3c+UkNyQAwb6+2/sjy40Dnt AjhYG0Y7lBYlvVp0Reuk+fzaG8/qpC//XuqfzBaco+fCSm3SMG2e5vA0ulPXNMyAnqCx 0kQ78Bo9F9cbOU/xZu+DxNckZRSmVkuZwe3Wk6VdpCybRO1UDJ7UOdPlNIx2VQh2AKcW t6NIWMVC6FzCDsz98onm6V1Q0ahY/Ehg23X2EX/yX7IbrFNT9z3eTJkXqmIiNoeinr4a gg+A== 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:mime-version:content-transfer-encoding; bh=KTnOBZV7yx8NmDils5fAf50gZrGC7vwGvWz6YsCLa7I=; b=mWBC0oFRFBhk+2imAQiyDx6GRkCDsxBFcLOfSh6vPc+wC3LV06etQ51OghBdGmPFx9 NE2ZezqVgFHhqHHDM2UpFcDLD19BuSfCTVhUscy1GXeoKZJkU/6k+SLdhtgkOWq+69L1 d6QrcvyJCH29bykw0jIgQaB/LB7spqC8ATMqvPCOS6a4yxuUskM4qTbZORXX8SSMDPty IFLJVnU/gdTTiyZKTsHZf1MyJLTa19phQqmWzSvzTGNI+OrBUlt/KhuqIeNJD2v8ssp2 30QSCv+HqKDQHvl3bhdruZorJqEExXJefJYRC0U/IdaDIXzWaNEY5kC1ezmsl6lG7G9q xdMQ== X-Gm-Message-State: APjAAAWAEvZvu/chR94PdvHwGY/wGnVpfIVJN0F1JqXi4yO152bUG2d9 elsKCI4/TmjsY8vH3F21yNo= X-Google-Smtp-Source: APXvYqwNarsIKzR/4LFw0H3HX4iVDgWFexava5gDwyk/CkpJenhnBQ4BkrFPX50pSryuYiBuxsakRA== X-Received: by 2002:a63:2224:: with SMTP id i36mr5771312pgi.9.1571774187769; Tue, 22 Oct 2019 12:56:27 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id c34sm20212715pgb.35.2019.10.22.12.56.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 12:56:27 -0700 (PDT) From: Dmitry Torokhov To: Martin Kepplinger Cc: Dixit Parmar , Kuninori Morimoto , Matthias Fend , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/8] Input: st1232 - do not unconditionally configure as wakeup source Date: Tue, 22 Oct 2019 12:56:16 -0700 Message-Id: <20191022195622.66976-3-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191022195622.66976-1-dmitry.torokhov@gmail.com> References: <20191022195622.66976-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Do not unconditionally configure the touchscreen as wakeup source but rather rely on I2C core to do that when requested (either via "wakeup-source" device property, or when creating a client with I2C_CLIENT_WAKE flag). Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/st1232.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index 47033ef3749a..f1b97075aa9b 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -266,7 +266,6 @@ static int st1232_ts_probe(struct i2c_client *client, } i2c_set_clientdata(client, ts); - device_init_wakeup(&client->dev, 1); return 0; } From patchwork Tue Oct 22 19:56:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11205315 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7508139A for ; Tue, 22 Oct 2019 19:57:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C59AD21929 for ; Tue, 22 Oct 2019 19:57:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vFY+Gi/J" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733071AbfJVT4b (ORCPT ); Tue, 22 Oct 2019 15:56:31 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45275 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733069AbfJVT4a (ORCPT ); Tue, 22 Oct 2019 15:56:30 -0400 Received: by mail-pg1-f193.google.com with SMTP id r1so10569856pgj.12; Tue, 22 Oct 2019 12:56:30 -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 :mime-version:content-transfer-encoding; bh=IGYkPx9V52TrYmEaMjn2Ckv8a3Uj2F70nwOiXmtkUdM=; b=vFY+Gi/JpeXDDOLXp392Zc0u1FhRoCdC+Yh3C+I3LU/iSCbApslxVR8cVt8wcK7voB 2KAoDFW082z7tpJA7zqSwE6ZaiIHbyBp749sijVDrrqIa7ttPfd4xclhLkV7qu1INE77 4Xg8BTbihoprN4Voz8x6XGBTTcL9OoDmqmA25re1pLGm32+hteedo59tpSYea3y2DtIc sWISqc8Yi7f9Ztq0ihG7D5buJpX7k2Vt0uzjumTwC/O+UKNG3Mv1fpMRZX4+c1jq6buR qFAlcbQYIvAuqt3lnxBVuFR8fhbqP+rMtufzqhUdqLlE36kj5ATXsQzwF09LCoD/u5Ca kbdw== 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:mime-version:content-transfer-encoding; bh=IGYkPx9V52TrYmEaMjn2Ckv8a3Uj2F70nwOiXmtkUdM=; b=VzB0F08bOMS9tNKrgdc1qsZilQWPe1GK5zQez3bEiXRSME1SeOFLfYnZxEnXaVoGo9 uoybXgloQiPqx1pp0XfdzVfe4NTwpFDBTVt4ImMILz99d+h7BXDLjeMn5ayzMGa3OTvX OW50pKw31MuPTNDOzeIVLLdCB8nbuN0I2em7hbOQNC/N0E19o26UQVNJAl5feCHU5mGT ln31Jzz95lxb3yukTcoRAmwg+ER3TcsyXdeZeUnTFwnQAANM91nxh6ZQtzpCG+nKEhyO a2ggE5AS+U966xGUPnCEERV6TMNyfBuqKNBSaeXMtK19ba7x5uO0dYBNQ0GTEV1HWFMx Xwmg== X-Gm-Message-State: APjAAAU6W+J/xhQMlJ8aP49EF9P0OSjfW5henopzlbqG8Mk4raG8vShS tVJBK7DstlOv4N2Kke0H48y6AR4M X-Google-Smtp-Source: APXvYqxe37Zg9/B2PR3UtQn30XIVByBPb8ven8GlJlMYRBD7b+jG1CL9qKSJ9vsqtbTOjn21g9Zabw== X-Received: by 2002:a17:90a:9f81:: with SMTP id o1mr6885073pjp.60.1571774189374; Tue, 22 Oct 2019 12:56:29 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id c34sm20212715pgb.35.2019.10.22.12.56.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 12:56:28 -0700 (PDT) From: Dmitry Torokhov To: Martin Kepplinger Cc: Dixit Parmar , Kuninori Morimoto , Matthias Fend , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] Input: st1232 - rely on I2C core to configure wakeup interrupt Date: Tue, 22 Oct 2019 12:56:17 -0700 Message-Id: <20191022195622.66976-4-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191022195622.66976-1-dmitry.torokhov@gmail.com> References: <20191022195622.66976-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org When I2C client is created with I2C_CLIENT_WAKE flag (which happens either because we have "wakeup-source" device property or the flag was passed in when creating an I2C client manually), I2C core will take care of configuring interrupt as wakeup source on suspend. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/st1232.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index f1b97075aa9b..bb116f41f1c0 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -284,12 +284,10 @@ static int __maybe_unused st1232_ts_suspend(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct st1232_ts_data *ts = i2c_get_clientdata(client); - if (device_may_wakeup(&client->dev)) { - enable_irq_wake(client->irq); - } else { - disable_irq(client->irq); + disable_irq(client->irq); + + if (!device_may_wakeup(&client->dev)) st1232_ts_power(ts, false); - } return 0; } @@ -299,12 +297,10 @@ static int __maybe_unused st1232_ts_resume(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct st1232_ts_data *ts = i2c_get_clientdata(client); - if (device_may_wakeup(&client->dev)) { - disable_irq_wake(client->irq); - } else { + if (!device_may_wakeup(&client->dev)) st1232_ts_power(ts, true); - enable_irq(client->irq); - } + + enable_irq(client->irq); return 0; } From patchwork Tue Oct 22 19:56:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11205313 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C897213B1 for ; Tue, 22 Oct 2019 19:57:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A829C21BE5 for ; Tue, 22 Oct 2019 19:57:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V7KPusGe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733076AbfJVT4c (ORCPT ); Tue, 22 Oct 2019 15:56:32 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46584 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733028AbfJVT4b (ORCPT ); Tue, 22 Oct 2019 15:56:31 -0400 Received: by mail-pg1-f196.google.com with SMTP id e15so10560164pgu.13; Tue, 22 Oct 2019 12:56:30 -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 :mime-version:content-transfer-encoding; bh=r4y/5VwE/UlGgYr3QyrcPLtb/wmsPwbDIuZ2lbakaKE=; b=V7KPusGeHLpRexxKm4l1fM2Nsa/VnUGskG05cKTSasNjuTIF9AaUyaGxuEuk/Yu6eP EKkEPROhrwoyjAFagfkahsh78KGxz8RC011dzgfUDIKrfERY4BY3iQqW4xu0LG5A8MQw VBZ4v+3EpsODL8XmkAI1SCtNC31qaIg84EneMRlual9M3yD5S/xSCQHaxnRxV6Tn5tcI B1p4INFaSAEXIWBV0MnNOFuz3hBW1IoiBGa9KzImg9gBYv1DYioJrrDKx7YC1lkByBDv VudsDID7hLDEYPZ+PMCnSQc6xQ6Sy9Gj/B1bvvbARd1cwh3Ui0WIJbYBxEDxAyKWaLxb RAbQ== 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:mime-version:content-transfer-encoding; bh=r4y/5VwE/UlGgYr3QyrcPLtb/wmsPwbDIuZ2lbakaKE=; b=Es28p0Jzx140SvMBBHSPlUyqrfj4vP6YP7kv+UWRHh+iv/8rolixdxp/VaP2onSA+i q+/M/cbWKY4gFQvQ4ikE7KoSnHLfWCdMzjrwwt+Lq32DF37ZgZtwwHYMH3vbJAmuXc/A 2CKzWyTEqJNbEDILEzIJGSow+ooRfyQ/Wu2W85H2BhNnWFOKiK4jtLR625IuwTRqfgBh 8aSSvHsfK7ohT0ldh+m2Mm+rXoWfwu+4tMNOo5/JDZexjWWFNfC4l1+xnvur6BLO3of/ rT790WfAakbMTvXJXeDqw1s/VRj8H2YZ2fw+c0wRd+s4h21QG56L2dsfD5HyBu6aF+4N OO/g== X-Gm-Message-State: APjAAAX/YxqIMBrLCJFmIYZQvQu3WpK9/L70aXO5OnuZF4tSWN6gohM4 GFE9Bghrp7fW1rEHzS5EgNM= X-Google-Smtp-Source: APXvYqz8ZeChw4ngk4AOKRjiRJinu4KmGpxpDbQ/Vw0A52hWWc8Hz4YetMi2CpkWGKSIxPU8zTYgHQ== X-Received: by 2002:a62:6842:: with SMTP id d63mr6152795pfc.166.1571774190261; Tue, 22 Oct 2019 12:56:30 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id c34sm20212715pgb.35.2019.10.22.12.56.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 12:56:29 -0700 (PDT) From: Dmitry Torokhov To: Martin Kepplinger Cc: Dixit Parmar , Kuninori Morimoto , Matthias Fend , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/8] Input: st1232 - do not reset the chip too early Date: Tue, 22 Oct 2019 12:56:18 -0700 Message-Id: <20191022195622.66976-5-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191022195622.66976-1-dmitry.torokhov@gmail.com> References: <20191022195622.66976-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org We should not be putting the chip into reset while interrupts are enabled and ISR may be running. Fix this by installing a custom devm action and powering off the device/resetting GPIO line from there. This ensures proper ordering. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/st1232.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index bb116f41f1c0..bfea02202ded 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -149,6 +149,11 @@ static void st1232_ts_power(struct st1232_ts_data *ts, bool poweron) gpiod_set_value_cansleep(ts->reset_gpio, !poweron); } +static void st1232_ts_power_off(void *data) +{ + st1232_ts_power(data, false); +} + static const struct st_chip_info st1232_chip_info = { .have_z = true, .max_x = 0x31f, /* 800 - 1 */ @@ -229,6 +234,13 @@ static int st1232_ts_probe(struct i2c_client *client, st1232_ts_power(ts, true); + error = devm_add_action_or_reset(&client->dev, st1232_ts_power_off, ts); + if (error) { + dev_err(&client->dev, + "Failed to install power off action: %d\n", error); + return error; + } + input_dev->name = "st1232-touchscreen"; input_dev->id.bustype = BUS_I2C; input_dev->dev.parent = &client->dev; @@ -270,15 +282,6 @@ static int st1232_ts_probe(struct i2c_client *client, return 0; } -static int st1232_ts_remove(struct i2c_client *client) -{ - struct st1232_ts_data *ts = i2c_get_clientdata(client); - - st1232_ts_power(ts, false); - - return 0; -} - static int __maybe_unused st1232_ts_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); @@ -324,7 +327,6 @@ MODULE_DEVICE_TABLE(of, st1232_ts_dt_ids); static struct i2c_driver st1232_ts_driver = { .probe = st1232_ts_probe, - .remove = st1232_ts_remove, .id_table = st1232_ts_id, .driver = { .name = ST1232_TS_NAME, From patchwork Tue Oct 22 19:56:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11205311 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86A741895 for ; Tue, 22 Oct 2019 19:57:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6576D21D71 for ; Tue, 22 Oct 2019 19:57:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sMf8gR7H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733086AbfJVT4d (ORCPT ); Tue, 22 Oct 2019 15:56:33 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40906 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733078AbfJVT4c (ORCPT ); Tue, 22 Oct 2019 15:56:32 -0400 Received: by mail-pg1-f194.google.com with SMTP id 15so5234784pgt.7; Tue, 22 Oct 2019 12:56:32 -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 :mime-version:content-transfer-encoding; bh=jTkbiAAlMel2JTI9fec6PBcZIJ2pwZr6vga6v88CNRk=; b=sMf8gR7H2RF4QhBDjhzNBuVx5Nw48ChPp0C/xkGvbxrIpLbJbIT/PuphsgN5YVxf9s +YzwtgBLe/aGdE20ptQhlpG1+SN4a94dI9i43Gx4bdyzeVSAyWN+srE3d7ZKG3lViWyI s7nhZgBCC3vqNN4ypkabP8OC+GMI5yoj/8yoWOf3BHQyZTw0XqsKQfmZH+1mLayzbHsb EV6tvtSTU0W105F7s0ymu7iMFUAugvtH9JwWQaGpaVZmAOcw4+g+hoi1uj6OzRdDWB/V yXMjrSbe7Xmma2RR1xSeUWMigaaM12Pv4GN2PEwPTOJeRL+3V98p49Q9bcDUXWW3q/Zr rKhA== 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:mime-version:content-transfer-encoding; bh=jTkbiAAlMel2JTI9fec6PBcZIJ2pwZr6vga6v88CNRk=; b=ZJUsjoZ+nK7pblvbpsUDLSmMUWS7dE1CypUcatA1aw94Qjf7nTDGAa1cvoR76kAOj5 O/l8gSg7cVtE47as37b+I1ZhZzhWkX7skJWqHOskcl75Am0qpwUsVYdTjyvw/vIKLx2E JywoKR7b+YH1/+rIkl/YH98YRLhyL3uEH5CkxH0ahysfTl4ydMCHW6UhoxWdcD9Bw53l Bkg3OKYxpsdO7HMCLlqxf13hOYY4kEHSrKbQNyMtbXfkhbjgzAnL5J4RNdlDH8LG9awj uGvq3Irfqo9P8wz++53D/LWyH6+VzpPxfGQNG1sKY2cUHInh4fXP1eq4YWXrpi/oyV1t 7xyg== X-Gm-Message-State: APjAAAWp34dA9wp+e3/G5zY+YlELCLQDxRFk15mtMAmIh59QjakcKK4G KuR3vFhxGsJRwP64GmHmx+Y= X-Google-Smtp-Source: APXvYqxargZ098lB4IIe5UEpE1uuS09B+gNRGN2EN13mqxC+hC8E0e5VDNiHQyJDrOq7CDCRr57CjA== X-Received: by 2002:a17:90a:8d13:: with SMTP id c19mr6773513pjo.63.1571774191629; Tue, 22 Oct 2019 12:56:31 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id c34sm20212715pgb.35.2019.10.22.12.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 12:56:30 -0700 (PDT) From: Dmitry Torokhov To: Martin Kepplinger Cc: Dixit Parmar , Kuninori Morimoto , Matthias Fend , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/8] Input: st1232 - do not allocate fingers data separately Date: Tue, 22 Oct 2019 12:56:19 -0700 Message-Id: <20191022195622.66976-6-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191022195622.66976-1-dmitry.torokhov@gmail.com> References: <20191022195622.66976-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The finger structure size is quite small and allocating it together with the main driver structure will not increase likelihood of allocation failing, but reduces number of objects needing to be tracked by the allocator and devm. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/st1232.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index bfea02202ded..dfc0c6cb0213 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -50,12 +50,12 @@ struct st1232_ts_data { const struct st_chip_info *chip_info; int read_buf_len; u8 *read_buf; - struct st1232_ts_finger *finger; + struct st1232_ts_finger fingers[]; }; static int st1232_ts_read_data(struct st1232_ts_data *ts) { - struct st1232_ts_finger *finger = ts->finger; + struct st1232_ts_finger *finger = ts->fingers; struct i2c_client *client = ts->client; u8 start_reg = ts->chip_info->start_reg; struct i2c_msg msg[] = { @@ -98,7 +98,7 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts) static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id) { struct st1232_ts_data *ts = dev_id; - struct st1232_ts_finger *finger = ts->finger; + struct st1232_ts_finger *finger = ts->fingers; struct input_dev *input_dev = ts->input_dev; int count = 0; int i, ret; @@ -177,7 +177,6 @@ static int st1232_ts_probe(struct i2c_client *client, { const struct st_chip_info *match; struct st1232_ts_data *ts; - struct st1232_ts_finger *finger; struct input_dev *input_dev; int error; @@ -199,16 +198,13 @@ static int st1232_ts_probe(struct i2c_client *client, return -EINVAL; } - ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); + ts = devm_kzalloc(&client->dev, + struct_size(ts, fingers, match->max_fingers), + GFP_KERNEL); if (!ts) return -ENOMEM; ts->chip_info = match; - ts->finger = devm_kcalloc(&client->dev, - ts->chip_info->max_fingers, sizeof(*finger), - GFP_KERNEL); - if (!ts->finger) - return -ENOMEM; /* allocate a buffer according to the number of registers to read */ ts->read_buf_len = ts->chip_info->max_fingers * 4; From patchwork Tue Oct 22 19:56:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11205305 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E4C0413B1 for ; Tue, 22 Oct 2019 19:56:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C433821872 for ; Tue, 22 Oct 2019 19:56:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BucvffFX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388823AbfJVT4f (ORCPT ); Tue, 22 Oct 2019 15:56:35 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:44926 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388700AbfJVT4f (ORCPT ); Tue, 22 Oct 2019 15:56:35 -0400 Received: by mail-pg1-f195.google.com with SMTP id e10so10572653pgd.11; Tue, 22 Oct 2019 12:56:33 -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 :mime-version:content-transfer-encoding; bh=CyuPGtUaRLfcMYhsRGlBb14GcxLRh4RB3RjBNNR29a8=; b=BucvffFXDdFlhcm5K+i6XepEBuH3I6hj2kr8h+A7Wva/SanlS9qBEkol9e57ZGUi58 vkii8r1fUF+hUZ/BE7TmQSwQH9tN09LNAKZ/pmLLNiK6ODW7WEtLzuJld7kSRqMORl8b 4D5gMyLFk3jDJtbI11gOmAkf3gG3zq+KlI+DlzzGY+sjaMnqccG0//Qwxohr1c/Rh+3f cTy4EYaHCeYjwrXh+d1T6AhjkWSwiUfAgkaOvyomdrxj9q9LnDHGASe1dzh9zHl7jBgE Fwez+fpmDNaByMpSOqiztnPHy1Hp8Pi1rChkAq0evwuWAIifhqoIAr7ZQTXgVGWhBzJN 0BSg== 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:mime-version:content-transfer-encoding; bh=CyuPGtUaRLfcMYhsRGlBb14GcxLRh4RB3RjBNNR29a8=; b=NmXJDE8bt5q+Rp1UllGhYvNCEB9R/m6CQxTZrT5N6PNKSGyzwPMaLpZ7Hw6Ra7yEem hh/fBWuI5q7zrVO7l/MvOFpaZDQe5t935LFW3wHRKrHm5MSY5yq61JxQuAzTadFqN1rf mi7996TAs6a/xars+W7P9FSYXs8N94F7AiZwcF3KsLoCITrIP+tDJboATadW4z5O6RnW ib+FzrCFm5rfHd8YoRWj5LGFYMmkuMHqWAP+WHtgjawRgXyl8LRt0QZpdlHenspJMLcn 4o3od3EnpGKLYtXXAaLiiwH0mltt8Sql7AanI+h472H/p97sB1Cc1k70x+OPGKhJRcvC BbRw== X-Gm-Message-State: APjAAAUb96zcbraxwNwKSOyo4jqMZpMfVsk56+dVhIf4jOSppx3v/rEO mOGV3ft21G56HDgrc6EbZdA= X-Google-Smtp-Source: APXvYqxTQjjndjMGgwC6UPQFk/2FOfoWqxYS1DIz89+JLVXzbz+lB8tQ5lauV2+O9iiV2uBt5LNHlA== X-Received: by 2002:a17:90a:868b:: with SMTP id p11mr7049473pjn.58.1571774192968; Tue, 22 Oct 2019 12:56:32 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id c34sm20212715pgb.35.2019.10.22.12.56.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 12:56:32 -0700 (PDT) From: Dmitry Torokhov To: Martin Kepplinger Cc: Dixit Parmar , Kuninori Morimoto , Matthias Fend , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/8] Input: st1232 - do not set parent device explicitly Date: Tue, 22 Oct 2019 12:56:20 -0700 Message-Id: <20191022195622.66976-7-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191022195622.66976-1-dmitry.torokhov@gmail.com> References: <20191022195622.66976-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org devm_input_allocate_device() already sets parent device for us. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/st1232.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index dfc0c6cb0213..0aee330731c9 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -239,7 +239,6 @@ static int st1232_ts_probe(struct i2c_client *client, input_dev->name = "st1232-touchscreen"; input_dev->id.bustype = BUS_I2C; - input_dev->dev.parent = &client->dev; __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); __set_bit(EV_SYN, input_dev->evbit); From patchwork Tue Oct 22 19:56:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11205309 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DECE139A for ; Tue, 22 Oct 2019 19:56:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D3CD21A4A for ; Tue, 22 Oct 2019 19:56:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q2LvZjBy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388865AbfJVT4g (ORCPT ); Tue, 22 Oct 2019 15:56:36 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39520 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388791AbfJVT4g (ORCPT ); Tue, 22 Oct 2019 15:56:36 -0400 Received: by mail-pf1-f194.google.com with SMTP id v4so11295255pff.6; Tue, 22 Oct 2019 12:56:34 -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 :mime-version:content-transfer-encoding; bh=r0E4wpyrWRiaNA8auIL2vJERHfcV4z20I+V9gMG7Q6s=; b=q2LvZjByonNQdt6+6w10ovlIJ7nlIT54rYOZjPfhdasiCeHq/5pusFSVuUmzoeFlFC 2Qtl/GHsdbA4YZvyOeNSSJSiy9P+lgwFFEKMtTS88KTtvQeAuR+oeeJlVCSqp/Yz59jE lgGXk9q98fAKqVpbgssb/Yi3C8Rj6I1bvrDJdF+/hQ+yuafkXbLsfw/JRi8pu4ZjmaJo U62N02YaLAzx3qE8+WYQfnZMQE34EdMd11JVvOgCZA9YL3x0wb+kvDsOMwSRuRASjqHe hrHntQZI8n1cEPlK/WTIUNhZnTitl22Pep+P6N46zxw62UyclACmizek1cDLEeEQ9p23 /eqA== 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:mime-version:content-transfer-encoding; bh=r0E4wpyrWRiaNA8auIL2vJERHfcV4z20I+V9gMG7Q6s=; b=aO+Rps7/NK7KN7lM4CJi2KyNRZAcB6SjUZ4s+cSv2ejv78sbYaj+QQiC4VvpXYtLhy RtGJ1bnL7fbn26Iq9NgTuDH1HzSCP+gvZoyt+03vYiqpIA+52QDFsjNOqpcZ5lrRCpUz xCzdUQ3zVLTa4vMTbnXkfEx/TiKeyenIb8CJ8Snj45hZ4r+hpVnZBnUt9RMaP0Zw5IWA NqpJLcVOv8CKQbhRb3WKwDIV0Rmoi8AUamRl1e48lHxnOV7imJxM4p7ogxLWeHheskMR 5SpeeZrSRnzOq/BiNo9rozZLV0XNxRFOkFRswtbeHJrvsUCxIV3KxZbrnRgs29W1y8Et qrdA== X-Gm-Message-State: APjAAAXQGC5u4JxVy5zLuntQsDgo+5+7c3DuxL6YmhwcSsevU7h+W3mF NsDArQvKCJKFtgqEeYCzkZY= X-Google-Smtp-Source: APXvYqxaVWtLbPEUwINiwwKiSkp7I36iWsAUBVv1/hXd2B+R2Wq65xCrIwlcdbI9EKxnVzlqszYczg== X-Received: by 2002:aa7:908b:: with SMTP id i11mr6327445pfa.186.1571774193881; Tue, 22 Oct 2019 12:56:33 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id c34sm20212715pgb.35.2019.10.22.12.56.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 12:56:33 -0700 (PDT) From: Dmitry Torokhov To: Martin Kepplinger Cc: Dixit Parmar , Kuninori Morimoto , Matthias Fend , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] Input: st1232 - note that the receive buffer is DMA-safe Date: Tue, 22 Oct 2019 12:56:21 -0700 Message-Id: <20191022195622.66976-8-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191022195622.66976-1-dmitry.torokhov@gmail.com> References: <20191022195622.66976-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The receiving buffer is allocated separately from the main driver data structure, and is naturally DMA-safe, so mark it as such when building I2C transfer message. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/st1232.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index 0aee330731c9..a4a3b82ee69d 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -66,7 +66,7 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts) }, { .addr = client->addr, - .flags = I2C_M_RD, + .flags = I2C_M_RD | I2C_M_DMA_SAFE, .len = ts->read_buf_len, .buf = ts->read_buf, } From patchwork Tue Oct 22 19:56:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 11205307 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5EA4C139A for ; Tue, 22 Oct 2019 19:56:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33C7C21929 for ; Tue, 22 Oct 2019 19:56:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PddPwk0i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388921AbfJVT4h (ORCPT ); Tue, 22 Oct 2019 15:56:37 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:32952 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388843AbfJVT4g (ORCPT ); Tue, 22 Oct 2019 15:56:36 -0400 Received: by mail-pl1-f194.google.com with SMTP id y8so330929plk.0; Tue, 22 Oct 2019 12:56:36 -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 :mime-version:content-transfer-encoding; bh=cDkndy0FNxa9CBg8H+skhv6JC+slFkOzGwJOrt8DmjE=; b=PddPwk0iVzgAN4OagHPAMekQDXdSR6+WSsD+PPeOKkyMjCMEatHhgo4kVO5it/fNhb IpfZK2SyIpA61/a5uxRuXAZbB57ViwDq9kPwz/7x6FJ9815suPsmVS1adPTxrxpownED bc4qB4M1EA04f8Tn2UBiYFiMl479yjnFjFvNKOL7RZnCBSboinL+Uha/yjzZmjoAsRpA 8l9DCCdLKXTrnMmXLXLYyO7wTxOCRUa0YnXz1PNdAtoRQZYB4cYK/SV15wPQK3Qysgna xAmZQWNlVV92VIxUZNKMxb0l45GmIv96nnCnfq4RpvGEK+x5P1ftViNUEzsFG+PwuDuZ isAQ== 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:mime-version:content-transfer-encoding; bh=cDkndy0FNxa9CBg8H+skhv6JC+slFkOzGwJOrt8DmjE=; b=fhk90CP2F0y5Df3JvG03K2j8NeDXRocGErkac4wmPieijxH+iMMCRuSa/Y6Zmc2VTh obrZuWMvl8uXww0/mAcWssTCghW1/le0heG+BnOdA2ooBjR7lKm7G/bKDNI4UxROXSoX MMvsYZd7tqgVyGfdvHu7AxJD+7sHYzqXitOXIEpMLDlCtiAMHjtIuKXBQYZwsFdbSLYB q7/EIG6oy3zK8yhbL/HIP36kb6P5OGR/nHIvHk4T+Za0KpDBBp80+M99GspkrT2n1JBF stf8ZJrqFcAl+HsJqniHi+suTRAS1bKH2i6Sw0c6WmG9hUPOXOw8NcjHnvEH/eGpO/3+ C3RQ== X-Gm-Message-State: APjAAAUVGFcS5Htl/p+yHS4/3TFUU+8Ps+c9+UF3baAAAf5swYTxIyOD D0BRrq4um2kL4z0nRFja2kQ= X-Google-Smtp-Source: APXvYqzAnKSLNYeB8RmInNKMmGD4U31BE1EOTx4zm4dUb0wjTRQ3sRz+hlaBbAXjQ9PTYuEf2ihRhQ== X-Received: by 2002:a17:902:244:: with SMTP id 62mr5720735plc.14.1571774195135; Tue, 22 Oct 2019 12:56:35 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id c34sm20212715pgb.35.2019.10.22.12.56.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 12:56:34 -0700 (PDT) From: Dmitry Torokhov To: Martin Kepplinger Cc: Dixit Parmar , Henrik Rydberg , Kuninori Morimoto , Matthias Fend , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/8] Input: st1232 - switch to using MT-B protocol Date: Tue, 22 Oct 2019 12:56:22 -0700 Message-Id: <20191022195622.66976-9-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191022195622.66976-1-dmitry.torokhov@gmail.com> References: <20191022195622.66976-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Switch the driver to the slotted variant of multitouch protocol (MT-B) with in-kernel tracking of the contacts. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/st1232.c | 110 +++++++++++++++-------------- 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c index a4a3b82ee69d..63b29c7279e2 100644 --- a/drivers/input/touchscreen/st1232.c +++ b/drivers/input/touchscreen/st1232.c @@ -14,23 +14,19 @@ #include #include #include +#include +#include #include #include #include #include #include #include -#include #define ST1232_TS_NAME "st1232-ts" #define ST1633_TS_NAME "st1633-ts" -struct st1232_ts_finger { - u16 x; - u16 y; - u8 t; - bool is_valid; -}; +#define ST_TS_MAX_FINGERS 10 struct st_chip_info { bool have_z; @@ -50,12 +46,10 @@ struct st1232_ts_data { const struct st_chip_info *chip_info; int read_buf_len; u8 *read_buf; - struct st1232_ts_finger fingers[]; }; static int st1232_ts_read_data(struct st1232_ts_data *ts) { - struct st1232_ts_finger *finger = ts->fingers; struct i2c_client *client = ts->client; u8 start_reg = ts->chip_info->start_reg; struct i2c_msg msg[] = { @@ -72,59 +66,69 @@ static int st1232_ts_read_data(struct st1232_ts_data *ts) } }; int ret; - int i; - u8 *buf; ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg)); if (ret != ARRAY_SIZE(msg)) return ret < 0 ? ret : -EIO; + return 0; +} + +static int st1232_ts_parse_and_report(struct st1232_ts_data *ts) +{ + struct input_dev *input = ts->input_dev; + struct input_mt_pos pos[ST_TS_MAX_FINGERS]; + u8 z[ST_TS_MAX_FINGERS]; + int slots[ST_TS_MAX_FINGERS]; + int n_contacts = 0; + int i; + for (i = 0; i < ts->chip_info->max_fingers; i++) { - buf = &ts->read_buf[i * 4]; - finger[i].is_valid = buf[0] >> 7; - if (finger[i].is_valid) { - finger[i].x = ((buf[0] & 0x70) << 4) | buf[1]; - finger[i].y = ((buf[0] & 0x07) << 8) | buf[2]; + u8 *buf = &ts->read_buf[i * 4]; + + if (buf[0] & BIT(7)) { + unsigned int x = ((buf[0] & 0x70) << 4) | buf[1]; + unsigned int y = ((buf[0] & 0x07) << 8) | buf[2]; + + touchscreen_set_mt_pos(&pos[n_contacts], + &ts->prop, x, y); /* st1232 includes a z-axis / touch strength */ if (ts->chip_info->have_z) - finger[i].t = ts->read_buf[i + 6]; + z[n_contacts] = ts->read_buf[i + 6]; + + n_contacts++; } } - return 0; + input_mt_assign_slots(input, slots, pos, n_contacts, 0); + for (i = 0; i < n_contacts; i++) { + input_mt_slot(input, slots[i]); + input_mt_report_slot_state(input, MT_TOOL_FINGER, true); + input_report_abs(input, ABS_MT_POSITION_X, pos[i].x); + input_report_abs(input, ABS_MT_POSITION_Y, pos[i].y); + if (ts->chip_info->have_z) + input_report_abs(input, ABS_MT_TOUCH_MAJOR, z[i]); + } + + input_mt_sync_frame(input); + input_sync(input); + + return n_contacts; } static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id) { struct st1232_ts_data *ts = dev_id; - struct st1232_ts_finger *finger = ts->fingers; - struct input_dev *input_dev = ts->input_dev; - int count = 0; - int i, ret; - - ret = st1232_ts_read_data(ts); - if (ret < 0) - goto end; - - /* multi touch protocol */ - for (i = 0; i < ts->chip_info->max_fingers; i++) { - if (!finger[i].is_valid) - continue; + int count; + int error; - if (ts->chip_info->have_z) - input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, - finger[i].t); + error = st1232_ts_read_data(ts); + if (error) + goto out; - touchscreen_report_pos(input_dev, &ts->prop, - finger[i].x, finger[i].y, true); - input_mt_sync(input_dev); - count++; - } - - /* SYN_MT_REPORT only if no contact */ + count = st1232_ts_parse_and_report(ts); if (!count) { - input_mt_sync(input_dev); if (ts->low_latency_req.dev) { dev_pm_qos_remove_request(&ts->low_latency_req); ts->low_latency_req.dev = NULL; @@ -136,10 +140,7 @@ static irqreturn_t st1232_ts_irq_handler(int irq, void *dev_id) DEV_PM_QOS_RESUME_LATENCY, 100); } - /* SYN_REPORT */ - input_sync(input_dev); - -end: +out: return IRQ_HANDLED; } @@ -198,9 +199,7 @@ static int st1232_ts_probe(struct i2c_client *client, return -EINVAL; } - ts = devm_kzalloc(&client->dev, - struct_size(ts, fingers, match->max_fingers), - GFP_KERNEL); + ts = devm_kzalloc(&client->dev, sizeof(*ts), GFP_KERNEL); if (!ts) return -ENOMEM; @@ -240,11 +239,6 @@ static int st1232_ts_probe(struct i2c_client *client, input_dev->name = "st1232-touchscreen"; input_dev->id.bustype = BUS_I2C; - __set_bit(INPUT_PROP_DIRECT, input_dev->propbit); - __set_bit(EV_SYN, input_dev->evbit); - __set_bit(EV_KEY, input_dev->evbit); - __set_bit(EV_ABS, input_dev->evbit); - if (ts->chip_info->have_z) input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, ts->chip_info->max_area, 0, 0); @@ -256,6 +250,14 @@ static int st1232_ts_probe(struct i2c_client *client, touchscreen_parse_properties(input_dev, true, &ts->prop); + error = input_mt_init_slots(input_dev, ts->chip_info->max_fingers, + INPUT_MT_DIRECT | INPUT_MT_TRACK | + INPUT_MT_DROP_UNUSED); + if (error) { + dev_err(&client->dev, "failed to initialize MT slots\n"); + return error; + } + error = devm_request_threaded_irq(&client->dev, client->irq, NULL, st1232_ts_irq_handler, IRQF_ONESHOT,