From patchwork Sun Apr 2 20:09:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 78299 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1905600vqo; Sun, 2 Apr 2023 13:26:38 -0700 (PDT) X-Google-Smtp-Source: AKy350YVwpeMXQP12YKI3EsmJQOcCRTMZS8RvdvcS8k0/8/dB5eKPtmS28AqSeT9GCocsVCEzb5k X-Received: by 2002:a17:902:ce8e:b0:1a0:65ae:df32 with SMTP id f14-20020a170902ce8e00b001a065aedf32mr45051861plg.37.1680467198578; Sun, 02 Apr 2023 13:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680467198; cv=none; d=google.com; s=arc-20160816; b=yQ3mMbF26z/z6P7SroR9Hhw0paa+eu+8CifxIqsDIDzjC3tg+xRmYwy1eOGQgm1b9X uZTkKqDrN+9PYK5zIHHvZzT907EbGpmYLNDywn3+KjPiC9ny+eRQGLTXBNjnCYRDPwZd nNqPaRffJggVX+iIGhBhFFk2NkcRbKZjCx/D6yBVqCiFGKyNz87LBumV8cXANpk2SP85 QjdeIcMVgh6Ox7FyFeHsVmo9rDofxvc1DSWq6jzdqoTM714EETbyUHZtw+D7J76Wtr3O sbx+33nNDI7kKYbvp3bgeQzBbiWS8xX3DU8MtDb6JF/miHp7c7e6WAfZQdzsRoB/chSo qv9Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EnxQcOPVYR7k4CaWywjABG48rhsOcDbUEyAkzN67jW8=; b=Zae2OxpdJi3VXXfjA77A0f0yCL2L/k+8DCtPxQKrmYDw1EatUZmFSMpLO7P1+0Bdwj 5ZrcjGPSA7qrGbTL5sCn+DAdHvwI5kUNibQshj5DKcVUjNvHJR1iKM5UEHVns7378B7V S+QMC2OupuQbErLBN35LyujVGjCVUSj7wt0XPxxexfJxuv+TANUOqrFr0RMT1xllt892 +O+ErAkjdwdP03M1Ie2hfmlc3AiIWZYF+oiI3hK5p1BzqCpMLHkDV+GVIHflzudiF5MX iAMPOQdRaq+VA0KdZJfWX/akp4zo2I/kLlzMEF6mJxdsEIibdAQwtdI5dzynqjMqn95T inSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HXrO6Iv+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y188-20020a6364c5000000b00509d00f18efsi6804810pgb.112.2023.04.02.13.26.11; Sun, 02 Apr 2023 13:26:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=HXrO6Iv+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230319AbjDBUKY (ORCPT + 99 others); Sun, 2 Apr 2023 16:10:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230204AbjDBUKS (ORCPT ); Sun, 2 Apr 2023 16:10:18 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 006EF3586 for ; Sun, 2 Apr 2023 13:10:14 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id ek18so109540218edb.6 for ; Sun, 02 Apr 2023 13:10:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EnxQcOPVYR7k4CaWywjABG48rhsOcDbUEyAkzN67jW8=; b=HXrO6Iv+msAIRLMyfiiOA5kgnymy+5OPmnzyNvz5T3phIb7inN94B5NfeW3invv5Dx 14lRxTM1SCca26QYwaWBT99TfFbtx9iyQiOAlcGFnCOpXRmslcYN5GGQ1A13GC/hn3Nm fFlREChISwZ8TLwKbA7sFpOHXKz912jL1kw1E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EnxQcOPVYR7k4CaWywjABG48rhsOcDbUEyAkzN67jW8=; b=8QTRhhvajOkmkSrkE+fuBYWgINBqmRj+Rn+LYEr6MmaNxY7eZppEaQ6TrnDgy/OnVa mZREMxtSdBhPI2p1IqWYLWIk/qo14gPz7B1ca7V0fo/YtzsBWfT8T2RkGcQ9kC8nogr6 IdUXFq7VZcGbbLpdTA48lXS+aA9DMcMCkhjwpDC8P8iCl+3oyIalrVA1AmQUCL8uHvnB VRTNYJp8Ix9K/roEf45jk2xDvUp5nMgUtitjI3VLtxiI+PcUc8DEjQQltBib0cjuDMZS qkXll3djWOJmorp/+zmHm4gCIP94Wploc0YchxXR48Z0v5d3Ru2rT4iasnvDA0GG4Zqc iePw== X-Gm-Message-State: AAQBX9eE8xOkXlzL02MDQvYFqzHw6x3xXZhp8PkU3aIBBLPBVEv920LY XiJ0kN9UEFfeepliz/XZn0jgcN5WG34KId3dnBM= X-Received: by 2002:a17:907:3e1a:b0:932:853c:c958 with SMTP id hp26-20020a1709073e1a00b00932853cc958mr41589723ejc.25.1680466213180; Sun, 02 Apr 2023 13:10:13 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-248-31-153.retail.telecomitalia.it. [95.248.31.153]) by smtp.gmail.com with ESMTPSA id gl18-20020a170906e0d200b00924d38bbdc0sm3553127ejb.105.2023.04.02.13.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 13:10:12 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Dmitry Torokhov , Jonathan Cameron , Oliver Graute , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Wolfram Sang , linux-input@vger.kernel.org Subject: [PATCH 1/9] Input: edt-ft5x06 - fix indentation Date: Sun, 2 Apr 2023 22:09:43 +0200 Message-Id: <20230402200951.1032513-2-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> References: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762097573278813276?= X-GMAIL-MSGID: =?utf-8?q?1762097573278813276?= Matches the alignment to the open parenthesis as suggested by checkpatch. Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 36 ++++++++++++++------------ 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 2746649561c7..daba6472fc65 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -241,11 +241,11 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) /* M09/M12 does not send header or CRC */ if (tsdata->version == EDT_M06) { if (rdbuf[0] != 0xaa || rdbuf[1] != 0xaa || - rdbuf[2] != datalen) { + rdbuf[2] != datalen) { tsdata->header_errors++; dev_err_ratelimited(dev, - "Unexpected header: %02x%02x%02x!\n", - rdbuf[0], rdbuf[1], rdbuf[2]); + "Unexpected header: %02x%02x%02x!\n", + rdbuf[0], rdbuf[1], rdbuf[2]); goto out; } @@ -618,7 +618,7 @@ static void edt_ft5x06_restore_reg_parameters(struct edt_ft5x06_ts_data *tsdata) tsdata->offset_y); if (reg_addr->reg_report_rate != NO_REGISTER) edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate, - tsdata->report_rate); + tsdata->report_rate); } @@ -757,7 +757,8 @@ DEFINE_SIMPLE_ATTRIBUTE(debugfs_mode_fops, edt_ft5x06_debugfs_mode_get, edt_ft5x06_debugfs_mode_set, "%llu\n"); static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file, - char __user *buf, size_t count, loff_t *off) + char __user *buf, size_t count, + loff_t *off) { struct edt_ft5x06_ts_data *tsdata = file->private_data; struct i2c_client *client = tsdata->client; @@ -965,12 +966,12 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client, case 0x70: /* EDT EP0700M09 */ tsdata->version = EDT_M09; snprintf(model_name, EDT_NAME_LEN, "EP0%i%i0M09", - rdbuf[0] >> 4, rdbuf[0] & 0x0F); + rdbuf[0] >> 4, rdbuf[0] & 0x0F); break; case 0xa1: /* EDT EP1010ML00 */ tsdata->version = EDT_M09; snprintf(model_name, EDT_NAME_LEN, "EP%i%i0ML00", - rdbuf[0] >> 4, rdbuf[0] & 0x0F); + rdbuf[0] >> 4, rdbuf[0] & 0x0F); break; case 0x5a: /* Solomon Goldentek Display */ snprintf(model_name, EDT_NAME_LEN, "GKTW50SCED1R0"); @@ -1051,14 +1052,17 @@ static void edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) tsdata->offset = edt_ft5x06_register_read(tsdata, reg_addr->reg_offset); if (reg_addr->reg_offset_x != NO_REGISTER) - tsdata->offset_x = edt_ft5x06_register_read(tsdata, - reg_addr->reg_offset_x); + tsdata->offset_x = + edt_ft5x06_register_read(tsdata, + reg_addr->reg_offset_x); if (reg_addr->reg_offset_y != NO_REGISTER) - tsdata->offset_y = edt_ft5x06_register_read(tsdata, - reg_addr->reg_offset_y); + tsdata->offset_y = + edt_ft5x06_register_read(tsdata, + reg_addr->reg_offset_y); if (reg_addr->reg_report_rate != NO_REGISTER) - tsdata->report_rate = edt_ft5x06_register_read(tsdata, - reg_addr->reg_report_rate); + tsdata->report_rate = + edt_ft5x06_register_read(tsdata, + reg_addr->reg_report_rate); tsdata->num_x = EDT_DEFAULT_NUM_X; if (reg_addr->reg_num_x != NO_REGISTER) tsdata->num_x = edt_ft5x06_register_read(tsdata, @@ -1306,7 +1310,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client) touchscreen_parse_properties(input, true, &tsdata->prop); error = input_mt_init_slots(input, tsdata->max_support_points, - INPUT_MT_DIRECT); + INPUT_MT_DIRECT); if (error) { dev_err(&client->dev, "Unable to init MT slots.\n"); return error; @@ -1320,8 +1324,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client) irq_flags |= IRQF_ONESHOT; error = devm_request_threaded_irq(&client->dev, client->irq, - NULL, edt_ft5x06_ts_isr, irq_flags, - client->name, tsdata); + NULL, edt_ft5x06_ts_isr, irq_flags, + client->name, tsdata); if (error) { dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); return error; From patchwork Sun Apr 2 20:09:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 78300 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1905603vqo; Sun, 2 Apr 2023 13:26:39 -0700 (PDT) X-Google-Smtp-Source: AKy350Y8DoX5XNqMk2+qJ4k6wBul3UQEhyr6yCglQLrW4j9eWHB2hPGwonhL7xEMcrabL8jfmZta X-Received: by 2002:a17:906:13c7:b0:932:c1e2:998b with SMTP id g7-20020a17090613c700b00932c1e2998bmr34156608ejc.15.1680467199568; Sun, 02 Apr 2023 13:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680467199; cv=none; d=google.com; s=arc-20160816; b=Kn9xWkSr5DXrThbMFaxZSMm2qvVV3G3fJXkK7hX8Mw6Pi4rVuQykYR/OQ6jhkV9I1v tLebbpcx6/K/mnnoVcSm2F+n01S+OsOemAs5Ai2oLgVl9noJMy3mo0Eq1vdCjTMZzaGe anqtjGnLgeKx/mU8Kk4iGEMDTl1sV23Zx6+8VDRuy9cJfhtqz7lkkH36hFW9qfrfRLl8 jip0z9AQ2ybsF7NwY03Fa/itCivNujq3p5tNWwMMZNsQSJ71i3xvlAvrH+S1YeLgRy8R XEJBLyntNW0bFHw3UdhsoxtFYcsxSbnKUbh1nvFURqF2IxXfKuQmviO3QNBqepp7Nd3w xOZA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OecrPdtGTbWbu5zwStTncNRELXl4OL8K+L0SCeXpYlI=; b=uhqmToLyUKx7JMC3/7KEzglllr8Gya5Z96oY+IpG1dsIcYLs9sq8YkYpxNYzb8lm+j QQ8xLPxzQan+YZ3lWQwrWvVSgnM61iO9mmmOMWAgEvDNOg8/8tNHX+RPEDsRkrKe8dla st5ZjpOpOwe9nA27ZwTY4LofYh7juptg8KPKKBNNn/hZTlym161nQ1YsP5sBXxfewI39 8XLGb1WJ068U/uELRrhi2QTSr5Ozlr0ZpZvGL5zR3Rx8aF/GLCAboRF7vTFdexVedeC0 epQaDdda97YD7wCmsRu0vHM7h5Kxra2GXLzKH5Y+D7U+LftHQr8sAqQQZRxmi8D5MLiv 9SPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IWyNDbBW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a170906490900b0094404d7e622si3734363ejq.770.2023.04.02.13.26.11; Sun, 02 Apr 2023 13:26:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IWyNDbBW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230332AbjDBUKZ (ORCPT + 99 others); Sun, 2 Apr 2023 16:10:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbjDBUKS (ORCPT ); Sun, 2 Apr 2023 16:10:18 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC7DDB775 for ; Sun, 2 Apr 2023 13:10:16 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id ew6so109436633edb.7 for ; Sun, 02 Apr 2023 13:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466214; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OecrPdtGTbWbu5zwStTncNRELXl4OL8K+L0SCeXpYlI=; b=IWyNDbBWPyhtOqz8w1hZS0whZFFehIBz6EVGbTlKctZ3l9DL+8vSUPor1AUY+m6oG8 b/Mw/jix25vP9jJMu+eIiJZsBsGP6UHRMzfMQ92/40AFJuQQ5KFt96JXWnE2KeNT0SY3 7th7lOBc8od3ECnjY7Gk4inGTQMP8NEZEmic4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466214; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OecrPdtGTbWbu5zwStTncNRELXl4OL8K+L0SCeXpYlI=; b=KrT5p9PZfBtWSRcUr/jmWd0/qZvlxOMMr1dgkWnPhGFSRjajeqasKfa3s6I9TNpi00 XL9ftGFQ8RzNNDuGrexup+M3a15w9VgIa0BJdRgS7LthwXLaSBuPnC6UwwJrm4r6GtMY xNJnFr2F88Q2JVU78OJGE6GvMCmAvk0N5haszgbBShN6rVc3oBRYEubkQzfneggo6VJN +Kh3dIatYDNB7ch4Cf3xgzQLRn872K5al2DBa7fMPnbX9qt6DbD+hoye8UDt76HKF4mQ SFkJFCgqSB6MN8xVSo/d0UL/XtuUWIUJMqV634M9SkNeQzI7T3lxLnE1rPPwXF3W1qcp tWrQ== X-Gm-Message-State: AAQBX9eJLE4s5e+2I+brs9WThs13+2lrSb0g8+WRPjuTn1aao/T5OiZR s7Vnl0arRYzEOfJhdfkStz5QHrINb2kuPpHJOek= X-Received: by 2002:a17:906:ac1:b0:92d:9767:8e0a with SMTP id z1-20020a1709060ac100b0092d97678e0amr29588752ejf.13.1680466214662; Sun, 02 Apr 2023 13:10:14 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-248-31-153.retail.telecomitalia.it. [95.248.31.153]) by smtp.gmail.com with ESMTPSA id gl18-20020a170906e0d200b00924d38bbdc0sm3553127ejb.105.2023.04.02.13.10.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 13:10:14 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Dmitry Torokhov , Jonathan Cameron , Oliver Graute , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Wolfram Sang , linux-input@vger.kernel.org Subject: [PATCH 2/9] Input: edt-ft5x06 - remove unnecessary blank lines Date: Sun, 2 Apr 2023 22:09:44 +0200 Message-Id: <20230402200951.1032513-3-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> References: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762097574341738401?= X-GMAIL-MSGID: =?utf-8?q?1762097574341738401?= It removes unnecessary blank lines so that checkpatch doesn't complain anymore. Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index daba6472fc65..c0ad3e4b6662 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -619,7 +619,6 @@ static void edt_ft5x06_restore_reg_parameters(struct edt_ft5x06_ts_data *tsdata) if (reg_addr->reg_report_rate != NO_REGISTER) edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate, tsdata->report_rate); - } #ifdef CONFIG_DEBUG_FS @@ -1459,7 +1458,6 @@ static int edt_ft5x06_ts_resume(struct device *dev) gpiod_set_value_cansleep(wake_gpio, 1); } - return ret; } From patchwork Sun Apr 2 20:09:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 78294 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1901162vqo; Sun, 2 Apr 2023 13:12:05 -0700 (PDT) X-Google-Smtp-Source: AKy350Zkd7HXEwuh3FQR4fAQqaSlPdyysuhGd34RpcvuqhPD2KsM6KA8UOfew91zVIfty0meF2Y8 X-Received: by 2002:a05:6402:752:b0:4aa:a280:55b5 with SMTP id p18-20020a056402075200b004aaa28055b5mr14763585edy.20.1680466324817; Sun, 02 Apr 2023 13:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680466324; cv=none; d=google.com; s=arc-20160816; b=adtivc9kW56NDYhfMxyMT5IGKi9xKXZCyHkNtnqi7Zyfc+CuqNJcBnDF2uh2FAoZwJ AvaOC6AbpdK/bEwpnsI3hRu0PSQSFZWNMO0IkSyf9gdVJVGFsF54uQkJUPAR7Emp7UCy wb62UtW+gAiBgwgfKVarQTdpMcQMViN9DbQXHr5XCYEIL4chfFL5Ven25Tq9Rn+0qESE fdmp4PsKMVgWE6JO2i6dGmbWvUHqGh2L5mfPg3Lb/O+SFcPKvoO+jxraouwVLtSATauY M3RnGl+AJk4BGv85jP/jO4KrnY6xCJDea4rR6o30UukWotqDtTAFubKhdoWUl7l8eH/s ZtgQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QYEoj3HNykDYYL4XbvupGelYH0ebBXdpkyODlCn0pFQ=; b=KNyoTKj43ZtgUTAA15JWqRHf3fSutSFOl4XLjASsLYJfa3qtj16VyTboaDmvL85FkM q/CTE5oDVW0nfb9rTE/OXpkUQ02jGbJgs6haeKh0Pp4GwjZt+7lC8vw6/gA4N0BHHVdo NHnThgPliEFNJlJcauJqNCgbtwoZkQx0EpFs0vLAt4dP1nehZ6k8U6qatkWkBPQuNxgI mWfuy8tiJwOxBEJsmnA7VZjXfQnzrsAAejmUllM8YlSD4bAo59/9JK35AGrzUEIDUbLB B9IAavHM9NT4gUk/sL/V8+2tIy1QMjOubAIVUfykXvW8P8T/st8Vlkjcf/5eG4aPwrr7 8YYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Q7TzE39D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z8-20020aa7c648000000b005024d6d6d5bsi6511724edr.532.2023.04.02.13.11.41; Sun, 02 Apr 2023 13:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Q7TzE39D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230420AbjDBUK3 (ORCPT + 99 others); Sun, 2 Apr 2023 16:10:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbjDBUKS (ORCPT ); Sun, 2 Apr 2023 16:10:18 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8235BB96 for ; Sun, 2 Apr 2023 13:10:16 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id cn12so109554807edb.4 for ; Sun, 02 Apr 2023 13:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466216; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QYEoj3HNykDYYL4XbvupGelYH0ebBXdpkyODlCn0pFQ=; b=Q7TzE39DQ+L0qB2Qih8MrfiRtgoebzX/vDV9Hs1ivN5YUoBKGDuLNuSZMGLdMoTOI9 qusPXgoWIaxMR1t79Y0Lo1/hRqdm94kPlaOEFI8lcoJviD2+RDFhbSKVva2WJeVyUDvR wwN/js2Ky8cqIlHxrQqil+yqnt0VBTe7p51Os= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466216; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QYEoj3HNykDYYL4XbvupGelYH0ebBXdpkyODlCn0pFQ=; b=DvowN69Qc/tFqdR2IU6qJX4Hf0KgZ1XoAnk3PUN7DV7UaV6d6uO/xXFU5Glv/2hxJr T3mhiyVHi5rIkjZPolLOCTQYtkXsJi38nhk2R+H94eIhVdpkqFjkKfentisdWZjpwUNG kMHg5faA1oDnM0roVrEIqCmgrNz1aU6fmGyHopaa9O0GdAEUNYvRaBrLvdqNnQsP4Xjj LQvTw4ocon+NHjXXmOGp1aKD++ckr4Sj+jkRkN1to+c8TxpW32Wet2vb3Fv6RYu59P7I EPCXnZSXBXk6sSdbXQp3TJwvyG5C49zSM4dW5p8bvcvtObO5fSNOIkvwdv6q0k6UDKWd ttug== X-Gm-Message-State: AAQBX9c1meqXHzyZma3NqoD+Zp9wbSUCFN5LqPANL1WFxrojws+24Cez Z5u2dIXUhysTUAkpEWDY/UaR0hnTY/65yX0YbTw= X-Received: by 2002:a17:906:f754:b0:92e:fcc9:aa22 with SMTP id jp20-20020a170906f75400b0092efcc9aa22mr16072121ejb.37.1680466216192; Sun, 02 Apr 2023 13:10:16 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-248-31-153.retail.telecomitalia.it. [95.248.31.153]) by smtp.gmail.com with ESMTPSA id gl18-20020a170906e0d200b00924d38bbdc0sm3553127ejb.105.2023.04.02.13.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 13:10:15 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Dmitry Torokhov , Jonathan Cameron , Oliver Graute , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Wolfram Sang , linux-input@vger.kernel.org Subject: [PATCH 3/9] Input: edt-ft5x06 - add spaces to ensure format specification Date: Sun, 2 Apr 2023 22:09:45 +0200 Message-Id: <20230402200951.1032513-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> References: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762096657110306162?= X-GMAIL-MSGID: =?utf-8?q?1762096657110306162?= It adds spaces around '-' as recommended by the Linux coding style. Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index c0ad3e4b6662..c96fe6520578 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -183,11 +183,11 @@ static bool edt_ft5x06_ts_check_crc(struct edt_ft5x06_ts_data *tsdata, for (i = 0; i < buflen - 1; i++) crc ^= buf[i]; - if (crc != buf[buflen-1]) { + if (crc != buf[buflen - 1]) { tsdata->crc_errors++; dev_err_ratelimited(&tsdata->client->dev, "crc error: 0x%02x expected, got 0x%02x\n", - crc, buf[buflen-1]); + crc, buf[buflen - 1]); return false; } From patchwork Sun Apr 2 20:09:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 78295 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1901282vqo; Sun, 2 Apr 2023 13:12:17 -0700 (PDT) X-Google-Smtp-Source: AKy350YTz8LU/N2P8/6Z+MMYwS6UnjaQI+zGVckbycIOjLt8BAAjRukKu7lxNWmF2FftkWqm+lzm X-Received: by 2002:a17:907:8b96:b0:941:1cf6:dbe3 with SMTP id tb22-20020a1709078b9600b009411cf6dbe3mr28657834ejc.7.1680466337033; Sun, 02 Apr 2023 13:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680466337; cv=none; d=google.com; s=arc-20160816; b=KXvOT0aFkteGftiLz9u3+omNEMUu7PO6+22lyDYjxTZ/9AhONNLzUbIvmefriAE8Vu KT4TRzBRhZcrdTha82GQyASvC/KMuMi1UEAI95afalEyL2RxyEP4BUajc98MFwUXuDUs CcvX3P+vrVstgHVorc/kDiuCYA3YuCQJwQRVSh38FIrJV9fqn6RU5xW+Gzo+KeZYcn9X Axp3ZXN6WjP/w5xkx0lqDtArrDB85jxOBX0yv+/b4TIu+v4SnLDfkwbtLNO2k6vADk79 skWbCoo06S/9wolcWwZcUs/0VU2/s/3x3CCiDR4Q31Gx3UocvGTXbO/BaKMEjst5UCdT w+TQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/6yCxE8OoG8PeYtqKpR9SG7wxwNS753oO+7UKWNzpVg=; b=YhBeHLsz3QBJO+hBUzQY2IDT53aW18Au8oaS9vfgqr7ucyow7qo+VlzwGbixQBGixo TTytc+Fg1UwBzlWOTRoQo7EfHgZ0IkkHiQiBWahnjJnlVSs5Yh2GsxJNUHbhyXLUqMG8 C1VqyjBFTyzx0+fjJM3ZbMUuJYeJ8KBo7QIz0BcXsktj+bu0q9h37KkAJGeED4Phvjz0 9coydRaek5f7ehomS+ppaGbFWPy5yBq8GmoYDhTpgbk/tRC/TkFE6OQCCFiCf/sg4JBK 4i1IOWYaIzaWTg1lInTrfuDRiQ7oZiIn4RYYynno3LAJIwcwVpFeUJS++hPsjLMEJGYq afqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=N9sz1W2n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kd15-20020a17090798cf00b00931cb794c92si5659573ejc.15.2023.04.02.13.11.53; Sun, 02 Apr 2023 13:12:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=N9sz1W2n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230430AbjDBUKb (ORCPT + 99 others); Sun, 2 Apr 2023 16:10:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230053AbjDBUKU (ORCPT ); Sun, 2 Apr 2023 16:10:20 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7579A3586 for ; Sun, 2 Apr 2023 13:10:19 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id b20so109523438edd.1 for ; Sun, 02 Apr 2023 13:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466217; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/6yCxE8OoG8PeYtqKpR9SG7wxwNS753oO+7UKWNzpVg=; b=N9sz1W2nE5acZfsaVT+YC3J/c7YMv2SuZ2EhIM5begbM7seJrl65wteJHGxYZnCQWg oesgZqYRLy2aeHHLdg/QhWpBFRpVgFeVFrH22NLC1qUQFPGqz5790QzANSU5mSSPpfwv JgV4Jm0WtlkBHy498Qk3sUQD0+18MwQaGeOHY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466217; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/6yCxE8OoG8PeYtqKpR9SG7wxwNS753oO+7UKWNzpVg=; b=qF1w6pA9v+Ucoj6knGCd+uAzX6Iqt3jPklho/HAdJ6e8WvQspk3a3gWUwUsUIUFzDM xFqkjdYy0UwSwTYQiAbwWCZPokwaZOMN8PFBBmXTYG1utyNfzkAqRvZlngQLqNQqvs7R WIXN3n763qYO3Cc1FBZbYsDU9/4056vo9qhI6qAgWj9KQ06Hn9L4Kab5AxNtoSHmnWiy 6TqeBe4D+WH0bRkd2A34O69s/Cm/f+VDeF4JgV3AX7kDYH27QiukhShPxLT0093Xiara gFiOvQTxpTojCV8NR0hpFC+yRYG533Z5lhwmhyfx8/V8kM7DGc3QSgDMrbXYKQy9bG8t Ut4g== X-Gm-Message-State: AAQBX9eol+OLwvl/h4c9xXMVOtOo20HADqrza2EsGLQhXGK2KHbL2nwp xcMASKwvOucgk/72BTnWE/Z8oSEPLmtfSVoOC3A= X-Received: by 2002:a17:906:a150:b0:8a0:7158:15dc with SMTP id bu16-20020a170906a15000b008a0715815dcmr33439578ejb.74.1680466217623; Sun, 02 Apr 2023 13:10:17 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-248-31-153.retail.telecomitalia.it. [95.248.31.153]) by smtp.gmail.com with ESMTPSA id gl18-20020a170906e0d200b00924d38bbdc0sm3553127ejb.105.2023.04.02.13.10.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 13:10:17 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Dmitry Torokhov , Jonathan Cameron , Oliver Graute , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Wolfram Sang , linux-input@vger.kernel.org Subject: [PATCH 4/9] Input: edt-ft5x06 - don't recalculate the CRC Date: Sun, 2 Apr 2023 22:09:46 +0200 Message-Id: <20230402200951.1032513-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> References: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762096669957191903?= X-GMAIL-MSGID: =?utf-8?q?1762096669957191903?= There is no need to recalculate the CRC when the data has not changed. Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index c96fe6520578..d4f39724b259 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -319,7 +319,7 @@ static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata, static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata, u8 addr) { - u8 wrbuf[2], rdbuf[2]; + u8 wrbuf[2], rdbuf[2], crc; int error; switch (tsdata->version) { @@ -333,11 +333,11 @@ static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata, if (error) return error; - if ((wrbuf[0] ^ wrbuf[1] ^ rdbuf[0]) != rdbuf[1]) { + crc = wrbuf[0] ^ wrbuf[1] ^ rdbuf[0]; + if (crc != rdbuf[1]) { dev_err(&tsdata->client->dev, "crc error: 0x%02x expected, got 0x%02x\n", - wrbuf[0] ^ wrbuf[1] ^ rdbuf[0], - rdbuf[1]); + crc, rdbuf[1]); return -EIO; } break; From patchwork Sun Apr 2 20:09:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 78296 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1901311vqo; Sun, 2 Apr 2023 13:12:21 -0700 (PDT) X-Google-Smtp-Source: AKy350b5BI+tI2+TiiLgEK6uyzNr4Yv1Sj+HCDpZD2DOlLu1An1MWSRbs+sHAXpDxlwDFByJCliR X-Received: by 2002:a17:906:e112:b0:933:1b05:8851 with SMTP id gj18-20020a170906e11200b009331b058851mr31574804ejb.16.1680466341542; Sun, 02 Apr 2023 13:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680466341; cv=none; d=google.com; s=arc-20160816; b=fFdYmvEs7LM6bN4PUT+8JwemyJOynuDKuArh/O4MOKP6+NALwbrPirKbM/izJ4nGdF s0SGdSoxJl+GPwfgWcr9X7XH5zSVw9xJJzHSO1oFpO5aDTOffWgmqwHu8aXqypilJ5Nn Gd/ripDW7GVQ2s3Ru0O9Jo3p0CMoDd76+Ya14QZ/ZKswbBT+P0Hj1b1he2j4Y3wiSQ2T j48QuE8f/l4BeDw6cSwpaOr5JhqFYAJvuwK2klQZpXxzdCk1Vkrp4yoFXbS+eBC3HTxI vGd/L82QEC8krzONkHWcoGsQhQWDJcuhuC5N0reDfIWZC6FLa2Oleur6ayvFpq3PhC6y oPkg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kMHERFML/oNzDxt2xRgB06w0p+QqR9zI3HtwO5KrpJg=; b=HAjnaLwJ8LwBCeIh/Q7pfp/8wWw1NkgJZEF13RL2fW3yzkTlfFfdU6/Bbs03O5R7wh /tsgnB2oYedQ0oU5/bOfvjrKcCYkbig+P00CaCjiO0LkApANeufTvRRGnEInmZtGVxUo rEsFMi83FWb6L3V+uK0bzo0vqz3MHsb7SvauJjtcWJZWwyIZtcPEvuPESJCKxdwVtnaF bQN/1JW6GhMt9JCbrTIjc0L6qR5gin27msjWPNNvXbGPjTI9jj84KAfGT+JLSCAlG5+6 4ITM3g4bbMCBrafaDm9uPyXjQMvKYTWy0doajlgo1M5Oo6V13pjwxYhEH0NyeH1uBkyt NPnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BTA0a7k7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u19-20020aa7d993000000b004fd2b14ad0asi6716292eds.85.2023.04.02.13.11.58; Sun, 02 Apr 2023 13:12:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BTA0a7k7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230443AbjDBUKe (ORCPT + 99 others); Sun, 2 Apr 2023 16:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230297AbjDBUKW (ORCPT ); Sun, 2 Apr 2023 16:10:22 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DDAC3586 for ; Sun, 2 Apr 2023 13:10:20 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id eh3so109434009edb.11 for ; Sun, 02 Apr 2023 13:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kMHERFML/oNzDxt2xRgB06w0p+QqR9zI3HtwO5KrpJg=; b=BTA0a7k7iFtvaI2JEereURx8iOMHTUOIQcSCoitVWC3sF+WGnPQVeju6CVDc/6tRB2 ZfpEnkmpRBCSppaEZ5OdsY/Oi+Jo32snp7n7puHWzt7bBzxZonHe9cHpKVYQdPMf9Vl7 ZjEVTpQBasomg2sk23RR/gSl5qHGWIR8C9U5c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kMHERFML/oNzDxt2xRgB06w0p+QqR9zI3HtwO5KrpJg=; b=cnvFworFjtub1Sf05CTd/MmemvOy6+gy83gFLJKqHC6Tl/JKQ0gadZ/cbuF8Kh+7so r1W6sMQCk2Tep5DC4knTxmGSsCMPm01nvdDHQHsurk2aUiN7Io40w19NhEWdINgGC0po PVZ0QKObTDRlmxeWjY5lMipx7djmbbxNeLY4Hh9XlDp7+5vO36KVPtgyt3dlRaVdK4RX djWfysLOqmmiMYiXEcZ7EDuzV+knQ4/P/ubsgCE6TN6MIfmxyzzF7Tc6ZIDeQdAlqeF4 lOwBUTRmef9RMCtoE77gH/L1MR6hwDzig1mK448M70GqzUGj7KX6eBlNGqnSK56AdpjW hpUw== X-Gm-Message-State: AAQBX9dmoUNuONJjCsJx72anaJjmhJ3BEJYDYakD/kzOh5Gfg8mjbTGE dIecZcIJh8o55At1EqfQUbMbjzSKy9unqPARaSY= X-Received: by 2002:a17:906:b049:b0:937:9a24:370b with SMTP id bj9-20020a170906b04900b009379a24370bmr34522323ejb.67.1680466219066; Sun, 02 Apr 2023 13:10:19 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-248-31-153.retail.telecomitalia.it. [95.248.31.153]) by smtp.gmail.com with ESMTPSA id gl18-20020a170906e0d200b00924d38bbdc0sm3553127ejb.105.2023.04.02.13.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 13:10:18 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Dmitry Torokhov , Jonathan Cameron , Oliver Graute , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Wolfram Sang , linux-input@vger.kernel.org Subject: [PATCH 5/9] Input: edt-ft5x06 - remove code duplication Date: Sun, 2 Apr 2023 22:09:47 +0200 Message-Id: <20230402200951.1032513-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> References: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762096674898222949?= X-GMAIL-MSGID: =?utf-8?q?1762096674898222949?= The use of the macros M06_REG_ADDR and M06_REG_CMD avoids code duplication without impacting the application load, and reduces the chances of errors or mistakes. Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index d4f39724b259..7d82f412ab15 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -75,6 +75,9 @@ #define EDT_DEFAULT_NUM_X 1024 #define EDT_DEFAULT_NUM_Y 1024 +#define M06_REG_CMD(factory) ((factory) ? 0xf3 : 0xfc) +#define M06_REG_ADDR(factory, addr) ((factory) ? (addr) & 0x7f : (addr) & 0x3f) + enum edt_pmode { EDT_PMODE_NOT_SUPPORTED, EDT_PMODE_HIBERNATE, @@ -294,8 +297,8 @@ static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata, switch (tsdata->version) { case EDT_M06: - wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc; - wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f; + wrbuf[0] = M06_REG_CMD(tsdata->factory_mode); + wrbuf[1] = M06_REG_ADDR(tsdata->factory_mode, addr); wrbuf[2] = value; wrbuf[3] = wrbuf[0] ^ wrbuf[1] ^ wrbuf[2]; return edt_ft5x06_ts_readwrite(tsdata->client, 4, @@ -324,8 +327,8 @@ static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata, switch (tsdata->version) { case EDT_M06: - wrbuf[0] = tsdata->factory_mode ? 0xf3 : 0xfc; - wrbuf[1] = tsdata->factory_mode ? addr & 0x7f : addr & 0x3f; + wrbuf[0] = M06_REG_CMD(tsdata->factory_mode); + wrbuf[1] = M06_REG_ADDR(tsdata->factory_mode, addr); wrbuf[1] |= tsdata->factory_mode ? 0x80 : 0x40; error = edt_ft5x06_ts_readwrite(tsdata->client, 2, wrbuf, 2, From patchwork Sun Apr 2 20:09:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 78297 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1901421vqo; Sun, 2 Apr 2023 13:12:38 -0700 (PDT) X-Google-Smtp-Source: AKy350Y8D8wWvdJPOo4unGMyegWnTCqasqF423dtCb8K8fzkIpyvlX64pc7L0myU1/uZzC9pNgoK X-Received: by 2002:a05:6402:15a:b0:4f9:deb4:b984 with SMTP id s26-20020a056402015a00b004f9deb4b984mr32671666edu.9.1680466358258; Sun, 02 Apr 2023 13:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680466358; cv=none; d=google.com; s=arc-20160816; b=qdjCOuBK0P1YS0bk2kWo8fNfNuGH45nYzni4sgjIHz/nzlA1LKaqFWLZ+v4sVcOHL8 X58xBxtle8TQQ6y8DWKmnL8/HxD7Olbm55yxxH5PzuGPSSo/55j/3qJh+xrIu/OC06xL PLWg58KO3DJct2Sv/xoAWmDTIKDpQsxKlZMU/bymfEFumtIuEkmMFgD2/6vkIhBLkDX5 jgus2cuQ0TxAwnHGEr2TOcBKZO6hbbvGALdzSnmUmscLcRSPD9lC+nwz9Wk61WEYVWfq uOkv4E4+zEoxp3UMZi73qrqX+CCY/ZinbZHxWQK9Go8DFlk7g+gbUvysdhtkhp43lloJ mrzw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AFjm9UZOr4B7pRsXgqjvbVyzqWT97tUm8W06JvPbgKQ=; b=vIydaCiahMNEDWTFitq15kAkySxH5pKwN9DCaKwxr+zQj+8Zi2svBsHCva7CyEJhV5 7AbZ+kGMBPO+zzeXD2DrYJYBckoiAJjQRdX9tEVblSeQry20CWsZUFepPD3nUzS0JVAC LfnZfEdFC2QAnW9Jep0FZdemdgadEH1hBQfS+bLlUDQZIUOecdn1T4v8/tqljrpDxFJb CBHyIkKU0AwplUHglKOGT/8HpjsAvDYFanwwFuGCaNoFFYms+T+yGFqwbOhSZ6ZMIbJg lt0JsUSFNQ2AY6wym4oXway+qhMzrTi2+s243DHluItLeSG2b2jNDMIDw7+rw1j6C535 LMIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=O3nYWp+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020aa7cb44000000b0050230e4b487si2985853edt.13.2023.04.02.13.12.14; Sun, 02 Apr 2023 13:12:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=O3nYWp+w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230458AbjDBUKi (ORCPT + 99 others); Sun, 2 Apr 2023 16:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230264AbjDBUKX (ORCPT ); Sun, 2 Apr 2023 16:10:23 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C273CC2E for ; Sun, 2 Apr 2023 13:10:22 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id eg48so109411312edb.13 for ; Sun, 02 Apr 2023 13:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AFjm9UZOr4B7pRsXgqjvbVyzqWT97tUm8W06JvPbgKQ=; b=O3nYWp+wncOn7KIYtTsObuYApJsAoEL4q+RnfvaUH7NaoUfBGA9w2AsigwGa8GK0LQ lOmWNaA7mk+nlJB47YhEmoIe7kfLHo6cvpaSiqhXyt/yYkQFqWgbcAzuh9/CKTrtvtnT CFxEU3X2w4DIFV4r9koGIseFEwOsrK8oONBdA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AFjm9UZOr4B7pRsXgqjvbVyzqWT97tUm8W06JvPbgKQ=; b=SPC8Nc5Bf1oesmh1IyXjE1ABTTICphNDu13+EzLgMYfLI4TC/NasgldW0JoIEz5qC9 4PJ4UxAJ/dQxREP1wU23YqyUpTiByCQHZE2melyHvzsYD49rDJHTnE/W2MV5pMc8Lreh GZEZ8AO7ZSU+O9c/AxfF5oKkLfrDVYLaNEA+O89P1p6M1uGHilJOfGnvnIwnxaJs3NQw iQaBakbIyySmH74v2Dw71ee1XyXbUiLL2SkN8ZP/9Mvtl+b6QOTS7XDhbgUTchqGIaCX HFpgayQGJEi3oaTluJs70dzv/neiEgV4XrCxSmE7mNaWePNpzI3UQUaDECYU9eOGdIK5 9dYA== X-Gm-Message-State: AAQBX9edlB6pi4H8JyIBnQriTP0cCG5SGDVIVUmzsP84jJVbkBZhve3A 9TllVxPoLuQCNNO8xAL5qBVXdLltZHLt2HqbUiQ= X-Received: by 2002:a17:907:84a:b0:947:87a2:31d7 with SMTP id ww10-20020a170907084a00b0094787a231d7mr13489859ejb.33.1680466220561; Sun, 02 Apr 2023 13:10:20 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-248-31-153.retail.telecomitalia.it. [95.248.31.153]) by smtp.gmail.com with ESMTPSA id gl18-20020a170906e0d200b00924d38bbdc0sm3553127ejb.105.2023.04.02.13.10.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 13:10:20 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Dmitry Torokhov , Jonathan Cameron , Oliver Graute , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Wolfram Sang , linux-input@vger.kernel.org Subject: [PATCH 6/9] Input: edt-ft5x06 - don't print error messages with dev_dbg() Date: Sun, 2 Apr 2023 22:09:48 +0200 Message-Id: <20230402200951.1032513-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> References: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762096692012825378?= X-GMAIL-MSGID: =?utf-8?q?1762096692012825378?= In some parts of the code, error messages were improperly printed with dev_dbg() calls. In those cases, dev_dbg() has been replaced with dev_err(). Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 7d82f412ab15..89958881fca1 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -783,7 +783,7 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file, error = edt_ft5x06_register_write(tsdata, 0x08, 0x01); if (error) { - dev_dbg(&client->dev, + dev_err(&client->dev, "failed to write 0x08 register, error %d\n", error); goto out; } @@ -797,13 +797,13 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file, if (val < 0) { error = val; - dev_dbg(&client->dev, + dev_err(&client->dev, "failed to read 0x08 register, error %d\n", error); goto out; } if (retries == 0) { - dev_dbg(&client->dev, + dev_err(&client->dev, "timed out waiting for register to settle\n"); error = -ETIMEDOUT; goto out; From patchwork Sun Apr 2 20:09:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 78301 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1905792vqo; Sun, 2 Apr 2023 13:27:27 -0700 (PDT) X-Google-Smtp-Source: AKy350YT/EG4rvpVao0tjbMKkkZFk1Sl0WJoIoCcOVIKJGmBDtbzuRKZ0snedpDkhxJyQGrxLump X-Received: by 2002:a17:906:7f1a:b0:8b1:29ed:e206 with SMTP id d26-20020a1709067f1a00b008b129ede206mr29229331ejr.28.1680467246796; Sun, 02 Apr 2023 13:27:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680467246; cv=none; d=google.com; s=arc-20160816; b=ap/wn8qjrAQiuNRRaLKmyq3bKlsYUKD7QfJUed+FJSIGzOIqozFibAmHVxBPhqid+s kT9RUAn7HZe3CIeg7Z5TJM/MWP/hutEPJ7YW0rNqbVVMbob3KKqMIRiGpXrDXdi6PQcP TFS/+5+23qdi03/pJ4tm0KfrJAZsXK/6JqyoGDG+i+iOgl4QxRCvqrZiUD4vxpw+HiW6 jDYQZifEenONk7/rPrH5vZSYwBYXXhQ8ICrkx7qCLtXjMOS2i9SfBaGuYdDg+CoiSYI5 H5CzYeatK+GmmGSysnhQLOIj0bXpo1fFiooyQ7C6RsbAEZD4x1z2xMBT8Ks/UgsgEBTE 4amA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JemIGhtdjG/TbtBcp8w+D7hK3pU2u0hM7wK5kdSBVec=; b=bTGSAwy6fnYqH35n7pxQZi6QHeewM+9o3Zbe6KtWSr9E5tsQsqyZ0ZwGUl7+mMbdku 1YfIJMPVyrBxbsQLkPg4p+O443DysJYD6PVCdgD/fHnzMNormQskSjddTRtP3nCdmBiU q4UxM9sKZzCeVAT+cSYF4LKGaCGyxt7/E3Z33ckdw9Yxf9FVtrIDubsYleqDBJNvCZj6 Lvz38AsZuYhukXpoZfq0wI6X7ZO3OHxXbavtVZOdQCctlnSrFd6JfWZCk0CuKu6O/rOG 522+5n4+IRCkjHbV+JrtYm/315P7MiPXEGCV38lhvd1aBqze2ChStaA/WEXOSQkGaRsD 9IcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=g9Tvx9lk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a170906490900b0094404d7e622si3734363ejq.770.2023.04.02.13.27.03; Sun, 02 Apr 2023 13:27:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=g9Tvx9lk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231172AbjDBUKr (ORCPT + 99 others); Sun, 2 Apr 2023 16:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230331AbjDBUK1 (ORCPT ); Sun, 2 Apr 2023 16:10:27 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BC69CC05 for ; Sun, 2 Apr 2023 13:10:24 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id eg48so109411485edb.13 for ; Sun, 02 Apr 2023 13:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JemIGhtdjG/TbtBcp8w+D7hK3pU2u0hM7wK5kdSBVec=; b=g9Tvx9lk/kHdQLQp48PShBumMe3X49wtUtPqxvPzc7nR+W4VM4FWh2CQSmNU4uuTH+ lKJoyCf9HKJHTs56uWU6Svf3cMFt4oieNoXsEW4o/NOK9rPLtJNw5OHDu9N4bb0Syw/3 L/J0LajmMQUGAQ7ZD14NR4xh8y6o1jJU0qikE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JemIGhtdjG/TbtBcp8w+D7hK3pU2u0hM7wK5kdSBVec=; b=sQ3mSFfzJoydZKbXzylEidj5VjPHtyNaC9sr4jblbWKFAKYNar75ciUtOWzSAPkRUd Z+ep7Tz/neJQOQQy/Nj2yQnCQSu2kAkyiRVD4m6gH9ueeRsbJUMt2s/m+Y5tsuva7ipF 1f0W0uM6uydSeVcBfl7VR8dq3owv1mUV75QBuPj0gNkkCmuYfaRa+z0T7vLjHqA7utfN nwsNuhopmUti3kuBizrZzlyZHQ26viPbk1HTtLgzmgqbfLAN+/uEfEDB/ug2Ag9WHiS2 PBGoPQQI/xc9T4DAdXwkT69EJkmjOyq0URzMzWU7wUPxhZT23HLXBeNRzxH2lkipXbju PJIA== X-Gm-Message-State: AAQBX9fG9cPq3Th5rr9mNFjoKYFEhRKcAiohbvSA913Nrc0YgRkbeOlv P9bhiM+a3pQPRIZ6x2p9etoKZEipRbxDW4rRuJw= X-Received: by 2002:a05:6402:450:b0:4fa:e8f3:9685 with SMTP id p16-20020a056402045000b004fae8f39685mr31991889edw.28.1680466222111; Sun, 02 Apr 2023 13:10:22 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-248-31-153.retail.telecomitalia.it. [95.248.31.153]) by smtp.gmail.com with ESMTPSA id gl18-20020a170906e0d200b00924d38bbdc0sm3553127ejb.105.2023.04.02.13.10.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 13:10:21 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Dmitry Torokhov , Jonathan Cameron , Oliver Graute , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Wolfram Sang , linux-input@vger.kernel.org Subject: [PATCH 7/9] Input: edt-ft5x06 - convert to use regmap API Date: Sun, 2 Apr 2023 22:09:49 +0200 Message-Id: <20230402200951.1032513-8-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> References: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762096634356348713?= X-GMAIL-MSGID: =?utf-8?q?1762097623905292007?= It replaces custom read/write functions with regmap API, making the driver code more generic. Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 424 +++++++++++++------------ 1 file changed, 214 insertions(+), 210 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 89958881fca1..8aae4c1e6b73 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -3,6 +3,7 @@ * Copyright (C) 2012 Simon Budig, * Daniel Wagener (M09 firmware support) * Lothar Waßmann (DT support) + * Dario Binacchi (regmap support) */ /* @@ -26,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -115,6 +117,8 @@ struct edt_ft5x06_ts_data { struct gpio_desc *reset_gpio; struct gpio_desc *wake_gpio; + struct regmap *regmap; + #if defined(CONFIG_DEBUG_FS) struct dentry *debug_dir; u8 *raw_buffer; @@ -145,37 +149,10 @@ struct edt_i2c_chip_data { int max_support_points; }; -static int edt_ft5x06_ts_readwrite(struct i2c_client *client, - u16 wr_len, u8 *wr_buf, - u16 rd_len, u8 *rd_buf) -{ - struct i2c_msg wrmsg[2]; - int i = 0; - int ret; - - if (wr_len) { - wrmsg[i].addr = client->addr; - wrmsg[i].flags = 0; - wrmsg[i].len = wr_len; - wrmsg[i].buf = wr_buf; - i++; - } - if (rd_len) { - wrmsg[i].addr = client->addr; - wrmsg[i].flags = I2C_M_RD; - wrmsg[i].len = rd_len; - wrmsg[i].buf = rd_buf; - i++; - } - - ret = i2c_transfer(client->adapter, wrmsg, i); - if (ret < 0) - return ret; - if (ret != i) - return -EIO; - - return 0; -} +static const struct regmap_config edt_ft5x06_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; static bool edt_ft5x06_ts_check_crc(struct edt_ft5x06_ts_data *tsdata, u8 *buf, int buflen) @@ -197,6 +174,127 @@ static bool edt_ft5x06_ts_check_crc(struct edt_ft5x06_ts_data *tsdata, return true; } +static int edt_M06_i2c_read(void *context, const void *reg_buf, size_t reg_size, + void *val_buf, size_t val_size) +{ + struct device *dev = context; + struct i2c_client *i2c = to_i2c_client(dev); + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(i2c); + struct i2c_msg xfer[2]; + bool reg_read = false; + u8 addr; + u8 wlen; + u8 wbuf[4], rbuf[3]; + int ret; + + addr = *((u8 *)reg_buf); + wbuf[0] = addr; + switch (addr) { + case 0xf5: + wlen = 3; + wbuf[0] = 0xf5; + wbuf[1] = 0xe; + wbuf[2] = *((u8 *)val_buf); + break; + case 0xf9: + wlen = 1; + break; + default: + wlen = 2; + reg_read = true; + wbuf[0] = M06_REG_CMD(tsdata->factory_mode); + wbuf[1] = M06_REG_ADDR(tsdata->factory_mode, addr); + wbuf[1] |= tsdata->factory_mode ? 0x80 : 0x40; + } + + xfer[0].addr = i2c->addr; + xfer[0].flags = 0; + xfer[0].len = wlen; + xfer[0].buf = wbuf; + + xfer[1].addr = i2c->addr; + xfer[1].flags = I2C_M_RD; + xfer[1].len = reg_read ? 2 : val_size; + xfer[1].buf = reg_read ? rbuf : val_buf; + + ret = i2c_transfer(i2c->adapter, xfer, 2); + if (ret != 2) { + if (ret < 0) + return ret; + + return -EIO; + } + + if (addr == 0xf9) { + u8 *buf = (u8 *)val_buf; + + if (buf[0] != 0xaa || buf[1] != 0xaa || + buf[2] != val_size) { + tsdata->header_errors++; + dev_err_ratelimited(dev, + "Unexpected header: %02x%02x%02x\n", + buf[0], buf[1], buf[2]); + return -EIO; + } + + if (!edt_ft5x06_ts_check_crc(tsdata, val_buf, val_size)) + return -EIO; + } else if (reg_read) { + u8 crc = wbuf[0] ^ wbuf[1] ^ rbuf[0]; + + if (crc != rbuf[1]) { + dev_err(dev, "crc error: 0x%02x expected, got 0x%02x\n", + crc, rbuf[1]); + return -EIO; + } + + *((u8 *)val_buf) = rbuf[0]; + } + + return 0; +} + +static int edt_M06_i2c_write(void *context, const void *data, size_t count) +{ + struct device *dev = context; + struct i2c_client *i2c = to_i2c_client(dev); + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(i2c); + u8 addr, val; + u8 wbuf[4]; + struct i2c_msg xfer; + int ret; + + addr = *((u8 *)data); + val = *((u8 *)data + 1); + + wbuf[0] = M06_REG_CMD(tsdata->factory_mode); + wbuf[1] = M06_REG_ADDR(tsdata->factory_mode, addr); + wbuf[2] = val; + wbuf[3] = wbuf[0] ^ wbuf[1] ^ wbuf[2]; + + xfer.addr = i2c->addr; + xfer.flags = 0; + xfer.len = 4; + xfer.buf = wbuf; + + ret = i2c_transfer(i2c->adapter, &xfer, 1); + if (ret != 1) { + if (ret < 0) + return ret; + + return -EIO; + } + + return 0; +} + +static const struct regmap_config edt_M06_i2c_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .read = edt_M06_i2c_read, + .write = edt_M06_i2c_write, +}; + static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) { struct edt_ft5x06_ts_data *tsdata = dev_id; @@ -232,30 +330,13 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) memset(rdbuf, 0, sizeof(rdbuf)); datalen = tplen * tsdata->max_support_points + offset + crclen; - error = edt_ft5x06_ts_readwrite(tsdata->client, - sizeof(cmd), &cmd, - datalen, rdbuf); + error = regmap_bulk_read(tsdata->regmap, cmd, rdbuf, datalen); if (error) { dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", error); goto out; } - /* M09/M12 does not send header or CRC */ - if (tsdata->version == EDT_M06) { - if (rdbuf[0] != 0xaa || rdbuf[1] != 0xaa || - rdbuf[2] != datalen) { - tsdata->header_errors++; - dev_err_ratelimited(dev, - "Unexpected header: %02x%02x%02x!\n", - rdbuf[0], rdbuf[1], rdbuf[2]); - goto out; - } - - if (!edt_ft5x06_ts_check_crc(tsdata, rdbuf, datalen)) - goto out; - } - for (i = 0; i < tsdata->max_support_points; i++) { u8 *buf = &rdbuf[i * tplen + offset]; @@ -290,79 +371,6 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) return IRQ_HANDLED; } -static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata, - u8 addr, u8 value) -{ - u8 wrbuf[4]; - - switch (tsdata->version) { - case EDT_M06: - wrbuf[0] = M06_REG_CMD(tsdata->factory_mode); - wrbuf[1] = M06_REG_ADDR(tsdata->factory_mode, addr); - wrbuf[2] = value; - wrbuf[3] = wrbuf[0] ^ wrbuf[1] ^ wrbuf[2]; - return edt_ft5x06_ts_readwrite(tsdata->client, 4, - wrbuf, 0, NULL); - - case EDT_M09: - case EDT_M12: - case EV_FT: - case GENERIC_FT: - wrbuf[0] = addr; - wrbuf[1] = value; - - return edt_ft5x06_ts_readwrite(tsdata->client, 2, - wrbuf, 0, NULL); - - default: - return -EINVAL; - } -} - -static int edt_ft5x06_register_read(struct edt_ft5x06_ts_data *tsdata, - u8 addr) -{ - u8 wrbuf[2], rdbuf[2], crc; - int error; - - switch (tsdata->version) { - case EDT_M06: - wrbuf[0] = M06_REG_CMD(tsdata->factory_mode); - wrbuf[1] = M06_REG_ADDR(tsdata->factory_mode, addr); - wrbuf[1] |= tsdata->factory_mode ? 0x80 : 0x40; - - error = edt_ft5x06_ts_readwrite(tsdata->client, 2, wrbuf, 2, - rdbuf); - if (error) - return error; - - crc = wrbuf[0] ^ wrbuf[1] ^ rdbuf[0]; - if (crc != rdbuf[1]) { - dev_err(&tsdata->client->dev, - "crc error: 0x%02x expected, got 0x%02x\n", - crc, rdbuf[1]); - return -EIO; - } - break; - - case EDT_M09: - case EDT_M12: - case EV_FT: - case GENERIC_FT: - wrbuf[0] = addr; - error = edt_ft5x06_ts_readwrite(tsdata->client, 1, - wrbuf, 1, rdbuf); - if (error) - return error; - break; - - default: - return -EINVAL; - } - - return rdbuf[0]; -} - struct edt_ft5x06_attribute { struct device_attribute dattr; size_t field_offset; @@ -396,7 +404,7 @@ static ssize_t edt_ft5x06_setting_show(struct device *dev, struct edt_ft5x06_attribute *attr = container_of(dattr, struct edt_ft5x06_attribute, dattr); u8 *field = (u8 *)tsdata + attr->field_offset; - int val; + unsigned int val; size_t count = 0; int error = 0; u8 addr; @@ -429,9 +437,8 @@ static ssize_t edt_ft5x06_setting_show(struct device *dev, } if (addr != NO_REGISTER) { - val = edt_ft5x06_register_read(tsdata, addr); - if (val < 0) { - error = val; + error = regmap_read(tsdata->regmap, addr, &val); + if (error) { dev_err(&tsdata->client->dev, "Failed to fetch attribute %s, error %d\n", dattr->attr.name, error); @@ -504,7 +511,7 @@ static ssize_t edt_ft5x06_setting_store(struct device *dev, } if (addr != NO_REGISTER) { - error = edt_ft5x06_register_write(tsdata, addr, val); + error = regmap_write(tsdata->regmap, addr, val); if (error) { dev_err(&tsdata->client->dev, "Failed to update attribute %s, error: %d\n", @@ -605,23 +612,19 @@ static const struct attribute_group edt_ft5x06_attr_group = { static void edt_ft5x06_restore_reg_parameters(struct edt_ft5x06_ts_data *tsdata) { struct edt_reg_addr *reg_addr = &tsdata->reg_addr; + struct regmap *regmap = tsdata->regmap; - edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold, - tsdata->threshold); - edt_ft5x06_register_write(tsdata, reg_addr->reg_gain, - tsdata->gain); + regmap_write(regmap, reg_addr->reg_threshold, tsdata->threshold); + regmap_write(regmap, reg_addr->reg_gain, tsdata->gain); if (reg_addr->reg_offset != NO_REGISTER) - edt_ft5x06_register_write(tsdata, reg_addr->reg_offset, - tsdata->offset); + regmap_write(regmap, reg_addr->reg_offset, tsdata->offset); if (reg_addr->reg_offset_x != NO_REGISTER) - edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_x, - tsdata->offset_x); + regmap_write(regmap, reg_addr->reg_offset_x, tsdata->offset_x); if (reg_addr->reg_offset_y != NO_REGISTER) - edt_ft5x06_register_write(tsdata, reg_addr->reg_offset_y, - tsdata->offset_y); + regmap_write(regmap, reg_addr->reg_offset_y, tsdata->offset_y); if (reg_addr->reg_report_rate != NO_REGISTER) - edt_ft5x06_register_write(tsdata, reg_addr->reg_report_rate, - tsdata->report_rate); + regmap_write(regmap, reg_addr->reg_report_rate, + tsdata->report_rate); } #ifdef CONFIG_DEBUG_FS @@ -629,7 +632,7 @@ static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata) { struct i2c_client *client = tsdata->client; int retries = EDT_SWITCH_MODE_RETRIES; - int ret; + unsigned int val; int error; if (tsdata->version != EDT_M06) { @@ -651,7 +654,7 @@ static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata) } /* mode register is 0x3c when in the work mode */ - error = edt_ft5x06_register_write(tsdata, WORK_REGISTER_OPMODE, 0x03); + error = regmap_write(tsdata->regmap, WORK_REGISTER_OPMODE, 0x03); if (error) { dev_err(&client->dev, "failed to switch to factory mode, error %d\n", error); @@ -662,8 +665,9 @@ static int edt_ft5x06_factory_mode(struct edt_ft5x06_ts_data *tsdata) do { mdelay(EDT_SWITCH_MODE_DELAY); /* mode register is 0x01 when in factory mode */ - ret = edt_ft5x06_register_read(tsdata, FACTORY_REGISTER_OPMODE); - if (ret == 0x03) + error = regmap_read(tsdata->regmap, FACTORY_REGISTER_OPMODE, + &val); + if (!error && val == 0x03) break; } while (--retries > 0); @@ -689,11 +693,11 @@ static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata) { struct i2c_client *client = tsdata->client; int retries = EDT_SWITCH_MODE_RETRIES; - int ret; + unsigned int val; int error; /* mode register is 0x01 when in the factory mode */ - error = edt_ft5x06_register_write(tsdata, FACTORY_REGISTER_OPMODE, 0x1); + error = regmap_write(tsdata->regmap, FACTORY_REGISTER_OPMODE, 0x1); if (error) { dev_err(&client->dev, "failed to switch to work mode, error: %d\n", error); @@ -705,8 +709,8 @@ static int edt_ft5x06_work_mode(struct edt_ft5x06_ts_data *tsdata) do { mdelay(EDT_SWITCH_MODE_DELAY); /* mode register is 0x01 when in factory mode */ - ret = edt_ft5x06_register_read(tsdata, WORK_REGISTER_OPMODE); - if (ret == 0x01) + error = regmap_read(tsdata->regmap, WORK_REGISTER_OPMODE, &val); + if (!error && val == 0x01) break; } while (--retries > 0); @@ -765,10 +769,10 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file, struct edt_ft5x06_ts_data *tsdata = file->private_data; struct i2c_client *client = tsdata->client; int retries = EDT_RAW_DATA_RETRIES; - int val, i, error; + unsigned int val; + int i, error; size_t read = 0; int colbytes; - char wrbuf[3]; u8 *rdbuf; if (*off < 0 || *off >= tsdata->raw_bufsize) @@ -781,7 +785,7 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file, goto out; } - error = edt_ft5x06_register_write(tsdata, 0x08, 0x01); + error = regmap_write(tsdata->regmap, 0x08, 0x01); if (error) { dev_err(&client->dev, "failed to write 0x08 register, error %d\n", error); @@ -790,18 +794,18 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file, do { usleep_range(EDT_RAW_DATA_DELAY, EDT_RAW_DATA_DELAY + 100); - val = edt_ft5x06_register_read(tsdata, 0x08); - if (val < 1) + error = regmap_read(tsdata->regmap, 0x08, &val); + if (error) { + dev_err(&client->dev, + "failed to read 0x08 register, error %d\n", + error); + goto out; + } + + if (val == 1) break; } while (--retries > 0); - if (val < 0) { - error = val; - dev_err(&client->dev, - "failed to read 0x08 register, error %d\n", error); - goto out; - } - if (retries == 0) { dev_err(&client->dev, "timed out waiting for register to settle\n"); @@ -812,13 +816,9 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file, rdbuf = tsdata->raw_buffer; colbytes = tsdata->num_y * sizeof(u16); - wrbuf[0] = 0xf5; - wrbuf[1] = 0x0e; for (i = 0; i < tsdata->num_x; i++) { - wrbuf[2] = i; /* column index */ - error = edt_ft5x06_ts_readwrite(tsdata->client, - sizeof(wrbuf), wrbuf, - colbytes, rdbuf); + rdbuf[0] = i; /* column index */ + error = regmap_bulk_read(tsdata->regmap, 0xf5, rdbuf, colbytes); if (error) goto out; @@ -894,8 +894,7 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client, * to have garbage in there */ memset(rdbuf, 0, sizeof(rdbuf)); - error = edt_ft5x06_ts_readwrite(client, 1, "\xBB", - EDT_NAME_LEN - 1, rdbuf); + error = regmap_bulk_read(tsdata->regmap, 0xBB, rdbuf, EDT_NAME_LEN - 1); if (error) return error; @@ -917,6 +916,14 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client, *p++ = '\0'; strscpy(model_name, rdbuf + 1, EDT_NAME_LEN); strscpy(fw_version, p ? p : "", EDT_NAME_LEN); + + regmap_exit(tsdata->regmap); + tsdata->regmap = regmap_init_i2c(client, + &edt_M06_i2c_regmap_config); + if (IS_ERR(tsdata->regmap)) { + dev_err(&client->dev, "regmap allocation failed\n"); + return PTR_ERR(tsdata->regmap); + } } else if (!strncasecmp(rdbuf, "EP0", 3)) { tsdata->version = EDT_M12; @@ -943,15 +950,13 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client, */ tsdata->version = GENERIC_FT; - error = edt_ft5x06_ts_readwrite(client, 1, "\xA6", - 2, rdbuf); + error = regmap_bulk_read(tsdata->regmap, 0xA6, rdbuf, 2); if (error) return error; strscpy(fw_version, rdbuf, 2); - error = edt_ft5x06_ts_readwrite(client, 1, "\xA8", - 1, rdbuf); + error = regmap_bulk_read(tsdata->regmap, 0xA8, rdbuf, 1); if (error) return error; @@ -980,8 +985,7 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client, break; case 0x59: /* Evervision Display with FT5xx6 TS */ tsdata->version = EV_FT; - error = edt_ft5x06_ts_readwrite(client, 1, "\x53", - 1, rdbuf); + error = regmap_bulk_read(tsdata->regmap, 0x53, rdbuf, 1); if (error) return error; strscpy(fw_version, rdbuf, 1); @@ -1003,42 +1007,40 @@ static void edt_ft5x06_ts_get_defaults(struct device *dev, struct edt_ft5x06_ts_data *tsdata) { struct edt_reg_addr *reg_addr = &tsdata->reg_addr; + struct regmap *regmap = tsdata->regmap; u32 val; int error; error = device_property_read_u32(dev, "threshold", &val); if (!error) { - edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold, val); + regmap_write(regmap, reg_addr->reg_threshold, val); tsdata->threshold = val; } error = device_property_read_u32(dev, "gain", &val); if (!error) { - edt_ft5x06_register_write(tsdata, reg_addr->reg_gain, val); + regmap_write(regmap, reg_addr->reg_gain, val); tsdata->gain = val; } error = device_property_read_u32(dev, "offset", &val); if (!error) { if (reg_addr->reg_offset != NO_REGISTER) - edt_ft5x06_register_write(tsdata, - reg_addr->reg_offset, val); + regmap_write(regmap, reg_addr->reg_offset, val); tsdata->offset = val; } error = device_property_read_u32(dev, "offset-x", &val); if (!error) { if (reg_addr->reg_offset_x != NO_REGISTER) - edt_ft5x06_register_write(tsdata, - reg_addr->reg_offset_x, val); + regmap_write(regmap, reg_addr->reg_offset_x, val); tsdata->offset_x = val; } error = device_property_read_u32(dev, "offset-y", &val); if (!error) { if (reg_addr->reg_offset_y != NO_REGISTER) - edt_ft5x06_register_write(tsdata, - reg_addr->reg_offset_y, val); + regmap_write(regmap, reg_addr->reg_offset_y, val); tsdata->offset_y = val; } } @@ -1046,33 +1048,30 @@ static void edt_ft5x06_ts_get_defaults(struct device *dev, static void edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) { struct edt_reg_addr *reg_addr = &tsdata->reg_addr; + struct regmap *regmap = tsdata->regmap; + unsigned int val; - tsdata->threshold = edt_ft5x06_register_read(tsdata, - reg_addr->reg_threshold); - tsdata->gain = edt_ft5x06_register_read(tsdata, reg_addr->reg_gain); + regmap_read(regmap, reg_addr->reg_threshold, &tsdata->threshold); + regmap_read(regmap, reg_addr->reg_gain, &tsdata->gain); if (reg_addr->reg_offset != NO_REGISTER) - tsdata->offset = - edt_ft5x06_register_read(tsdata, reg_addr->reg_offset); + regmap_read(regmap, reg_addr->reg_offset, &tsdata->offset); if (reg_addr->reg_offset_x != NO_REGISTER) - tsdata->offset_x = - edt_ft5x06_register_read(tsdata, - reg_addr->reg_offset_x); + regmap_read(regmap, reg_addr->reg_offset_x, &tsdata->offset_x); if (reg_addr->reg_offset_y != NO_REGISTER) - tsdata->offset_y = - edt_ft5x06_register_read(tsdata, - reg_addr->reg_offset_y); + regmap_read(regmap, reg_addr->reg_offset_y, &tsdata->offset_y); if (reg_addr->reg_report_rate != NO_REGISTER) - tsdata->report_rate = - edt_ft5x06_register_read(tsdata, - reg_addr->reg_report_rate); + regmap_read(regmap, reg_addr->reg_report_rate, + &tsdata->report_rate); tsdata->num_x = EDT_DEFAULT_NUM_X; - if (reg_addr->reg_num_x != NO_REGISTER) - tsdata->num_x = edt_ft5x06_register_read(tsdata, - reg_addr->reg_num_x); + if (reg_addr->reg_num_x != NO_REGISTER) { + if (!regmap_read(regmap, reg_addr->reg_num_x, &val)) + tsdata->num_x = val; + } tsdata->num_y = EDT_DEFAULT_NUM_Y; - if (reg_addr->reg_num_y != NO_REGISTER) - tsdata->num_y = edt_ft5x06_register_read(tsdata, - reg_addr->reg_num_y); + if (reg_addr->reg_num_y != NO_REGISTER) { + if (!regmap_read(regmap, reg_addr->reg_num_y, &val)) + tsdata->num_y = val; + } } static void edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) @@ -1142,7 +1141,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client) const struct i2c_device_id *id = i2c_client_get_device_id(client); const struct edt_i2c_chip_data *chip_data; struct edt_ft5x06_ts_data *tsdata; - u8 buf[2] = { 0xfc, 0x00 }; + unsigned int val; struct input_dev *input; unsigned long irq_flags; int error; @@ -1156,6 +1155,12 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client) return -ENOMEM; } + tsdata->regmap = regmap_init_i2c(client, &edt_ft5x06_i2c_regmap_config); + if (IS_ERR(tsdata->regmap)) { + dev_err(&client->dev, "regmap allocation failed\n"); + return PTR_ERR(tsdata->regmap); + } + chip_data = device_get_match_data(&client->dev); if (!chip_data) chip_data = (const struct edt_i2c_chip_data *)id->driver_data; @@ -1258,6 +1263,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client) tsdata->client = client; tsdata->input = input; tsdata->factory_mode = false; + i2c_set_clientdata(client, tsdata); error = edt_ft5x06_ts_identify(client, tsdata); if (error) { @@ -1269,7 +1275,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client) * Dummy read access. EP0700MLP1 returns bogus data on the first * register read access and ignores writes. */ - edt_ft5x06_ts_readwrite(tsdata->client, 2, buf, 2, buf); + regmap_read(tsdata->regmap, 0x00, &val); edt_ft5x06_ts_set_regs(tsdata); edt_ft5x06_ts_get_defaults(&client->dev, tsdata); @@ -1291,9 +1297,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client) if (tsdata->version == EDT_M06) tsdata->report_rate /= 10; - edt_ft5x06_register_write(tsdata, - tsdata->reg_addr.reg_report_rate, - tsdata->report_rate); + regmap_write(tsdata->regmap, tsdata->reg_addr.reg_report_rate, + tsdata->report_rate); } dev_dbg(&client->dev, @@ -1318,8 +1323,6 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client) return error; } - i2c_set_clientdata(client, tsdata); - irq_flags = irq_get_trigger_type(client->irq); if (irq_flags == IRQF_TRIGGER_NONE) irq_flags = IRQF_TRIGGER_FALLING; @@ -1357,6 +1360,7 @@ static void edt_ft5x06_ts_remove(struct i2c_client *client) struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); edt_ft5x06_ts_teardown_debugfs(tsdata); + regmap_exit(tsdata->regmap); } static int edt_ft5x06_ts_suspend(struct device *dev) @@ -1373,8 +1377,8 @@ static int edt_ft5x06_ts_suspend(struct device *dev) return 0; /* Enter hibernate mode. */ - ret = edt_ft5x06_register_write(tsdata, PMOD_REGISTER_OPMODE, - PMOD_REGISTER_HIBERNATE); + ret = regmap_write(tsdata->regmap, PMOD_REGISTER_OPMODE, + PMOD_REGISTER_HIBERNATE); if (ret) dev_warn(dev, "Failed to set hibernate mode\n"); From patchwork Sun Apr 2 20:09:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 78298 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1901443vqo; Sun, 2 Apr 2023 13:12:42 -0700 (PDT) X-Google-Smtp-Source: AKy350aAXc+twKeFV7XlOpLwIqtHj7EEo0mgxQ1QXXzlU7xSDS6nifg2iHH1h2l95lNXOJ04VqsQ X-Received: by 2002:a17:907:d9e:b0:93a:219d:b167 with SMTP id go30-20020a1709070d9e00b0093a219db167mr44785132ejc.52.1680466362033; Sun, 02 Apr 2023 13:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680466362; cv=none; d=google.com; s=arc-20160816; b=SA9rkAccDiKQGVO+1ndIghE7YP1mSjAqQXSPDw38dgDjRASO/fjhWchJHAktxhfLPU pTZMM8ycgmS89DKcTXEVffGZl5ql2wsNFU8F+cy3g5CHxsUt0pMYj6OZi6aOH2A8ev/7 k1u+HUYavv0GWH+XSeYrKm+bwTrybowu2Z4j/rTB8Y0VL1tO3U/dc03tIXe+wFJZ9DE2 CegFYOj1/40qIWKX6ha/Nz5sTk821aoNu4y+KdUQI0O9dQLD0kv4vBPivTQG/kybahdW mLqj8eFat6bd8TrXs4Yhm4idpO+FbTBQrgDIqmnmk97m0Aaj7iMRUJBPJwea2ajUnfrh 04Cg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vKHTsVqE1aT1cdcOBW/aMh8k9NVa86bMl3ifc5Yx2Wk=; b=C5bOH8UwHZVtUuA6KPzL+BT6f+LIHf5UP6kPtdvRNHqtVnuEnBaVfD+lRvAynIXdzZ wqKeXBbhdUq1zRyB93eq7NkuQ4mV2qdzUzjvmUO5RiyLCQ1/jBK3wbD3uabqDGuPd0Bs 284DwUZzMI32ynCIBe3ZnRPRR79ovzWIALzCBJRKinWRoKTD5mgvyNf3nD7sApXTgvBl iTsgM61sWzHpMRz86uzAP0q8zpJPBOywp8a413E7mgFtpNPxiNyY1MT7uygO0h638VAW ygKEJ6qZ7SokXL54qEvGpobaL5Sx7pLlZ7LH9rmbdN4+ed98MX8aIXVsqSTv7kxnenPN bDrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="ZX/RqwIv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020a170906149200b0093626311338si2095326ejc.936.2023.04.02.13.12.18; Sun, 02 Apr 2023 13:12:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="ZX/RqwIv"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230329AbjDBUKl (ORCPT + 99 others); Sun, 2 Apr 2023 16:10:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230325AbjDBUKZ (ORCPT ); Sun, 2 Apr 2023 16:10:25 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3524FCC3A for ; Sun, 2 Apr 2023 13:10:24 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id b20so109523981edd.1 for ; Sun, 02 Apr 2023 13:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466223; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vKHTsVqE1aT1cdcOBW/aMh8k9NVa86bMl3ifc5Yx2Wk=; b=ZX/RqwIvU3d1R+i4XBGekHVa1JDlG4wFRU98W4Xv93C1RKpIpl8AqMhDMsonFH9Hhf FYkGAXyMFxuk35wSKO0r2zzIwlfuurPtD12iPdlKNqCQyv1LM0Prf0aA2wMY6s5GKM+6 OE8VWzBiI1fJeNDWmFvFldEY0wDcJgVgUhn0k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466223; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vKHTsVqE1aT1cdcOBW/aMh8k9NVa86bMl3ifc5Yx2Wk=; b=S4Y2OQLY6wTtPYWpH4WiDZDr38d3sOVQ4Y/tUuAhC5OfDlQEXZ6SCcJdBdfHLHuH6V M31+dELxdbW5vVVGtwDRlgXpXenqsqQ8sZKQgIz8H/Tvz4rh3q9Np2TgQ0SepnQKXSD+ XJnOXdvi7t8Hp4LyYhTmer0pavcHZdyzUOVu2DJR1QN8BI/iKzOaJHbkxvoYpdRVHQQW u/SMqvJwQCFnm4XITDorldgsFfPyTSToOwwrU5CsYFIaRRY2NreKGhBQk/UAJwQnjGTO uZ6/2IJxE6hU1ELBUnucWS1sfam1zNGjIbXllAMLvweFhrUd1BW9ledk5lCTmH8FBq2X /OeQ== X-Gm-Message-State: AAQBX9cBVs6HTxODKg59xv2UyY+69u7AR8boDGRcyeAWuMegw9CNnY7/ cn273RVs7DDx8OI8+NP3PF66hixnz9Q5IFIf7Hk= X-Received: by 2002:a17:906:4a4e:b0:889:1eb1:7517 with SMTP id a14-20020a1709064a4e00b008891eb17517mr35894731ejv.30.1680466223564; Sun, 02 Apr 2023 13:10:23 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-248-31-153.retail.telecomitalia.it. [95.248.31.153]) by smtp.gmail.com with ESMTPSA id gl18-20020a170906e0d200b00924d38bbdc0sm3553127ejb.105.2023.04.02.13.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 13:10:23 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Dmitry Torokhov , Jonathan Cameron , Oliver Graute , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Wolfram Sang , linux-input@vger.kernel.org Subject: [PATCH 8/9] Input: edt-ft5x06 - unify the crc check Date: Sun, 2 Apr 2023 22:09:50 +0200 Message-Id: <20230402200951.1032513-9-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> References: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762096696355811842?= X-GMAIL-MSGID: =?utf-8?q?1762096696355811842?= With this patch, the CRC is always verified by the same function, even in the case of accessing registers where the number of bytes is minimal. Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 8aae4c1e6b73..fdb32e3591be 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -240,13 +240,10 @@ static int edt_M06_i2c_read(void *context, const void *reg_buf, size_t reg_size, if (!edt_ft5x06_ts_check_crc(tsdata, val_buf, val_size)) return -EIO; } else if (reg_read) { - u8 crc = wbuf[0] ^ wbuf[1] ^ rbuf[0]; - - if (crc != rbuf[1]) { - dev_err(dev, "crc error: 0x%02x expected, got 0x%02x\n", - crc, rbuf[1]); + wbuf[2] = rbuf[0]; + wbuf[3] = rbuf[1]; + if (!edt_ft5x06_ts_check_crc(tsdata, wbuf, 4)) return -EIO; - } *((u8 *)val_buf) = rbuf[0]; } From patchwork Sun Apr 2 20:09:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 78302 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1906203vqo; Sun, 2 Apr 2023 13:29:08 -0700 (PDT) X-Google-Smtp-Source: AKy350YVKF5KlmgoptW9+74aeKty5MqT8/UP5k5te6bPvP1qKdn92B4EqMtZH/7ZoAenr3MiivQ4 X-Received: by 2002:a17:906:1c19:b0:92b:f118:ef32 with SMTP id k25-20020a1709061c1900b0092bf118ef32mr33787421ejg.48.1680467347818; Sun, 02 Apr 2023 13:29:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680467347; cv=none; d=google.com; s=arc-20160816; b=UtB5HxaLXgkki92of1q3MBc+oamAPrPE6jGeuGpOLq3yPi6Sp8uZdhZkW7rJJS2keW 47zocWwCOX0kwc2xUhqY/d51IiJdl+D7/UR6NRhjiPLe0h5rhplWAJ7tfPhxLOmpo/zh HN3BASTrkUDwzxdqvX4J4np9HsS2K37/OGh+ZcXzu/LzRTWzbiXx68vohtZEjrJ03PbB 0qcBreYGymDOO3rzT4MKlNJj9a8tLLWprS2t5FzHPOKXOG28AcqwYw6Cbrptqp12YMoH L5yMeDZyOU7Mn35SGG5Rrxhvfa0Am+Bc+myd4qoiBLeFRaa3bgPRsg9DXPi8IAV9xyUv u1dA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YKRIdGHuZOd/fQcotLl6knbHASupHjbM4BeF84H3jy8=; b=MT4dQctnbVbwWU0wQkGZbrtYgmY/lhBZRwTQmwZrDgFmMEoAkHPH9yyzOr6Xo8qw64 GbCXJOrfJX6PJiaHWl6wY2h2iuK0J4R8MDMDjFadfSDZ2Bi51tFMFKJ/UqJ+vfHmMZ3C M91KAjFQ7JI9gcyEUYHK8+19tssx2BxElgdyiiWC9NOz6VsedBbyfZykH6nA8GMCn627 +o6fOc3CLzCuPkw3mpA2jECX2Po8GXXleR8U785jGpcjotIo2PMibYu0kJpZ5ID8T7j+ sBj8EijhzguzfjWGJi03iuo1J6YNJK1K6G+5ibhOUlNlPJZ+cT0ZmO/jnEJlgscK7ont UZyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KemN7IfE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a170906490900b0094404d7e622si3734363ejq.770.2023.04.02.13.28.43; Sun, 02 Apr 2023 13:29:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KemN7IfE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230380AbjDBUKo (ORCPT + 99 others); Sun, 2 Apr 2023 16:10:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230300AbjDBUK1 (ORCPT ); Sun, 2 Apr 2023 16:10:27 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC25DCDE2 for ; Sun, 2 Apr 2023 13:10:25 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id cn12so109555545edb.4 for ; Sun, 02 Apr 2023 13:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YKRIdGHuZOd/fQcotLl6knbHASupHjbM4BeF84H3jy8=; b=KemN7IfEaOKpyLMRAKesUNvo24XAovAd4ZbIiIGt+CDFvnp3LWFFq8s9nJ1oPJI1YG vkFLJ91RDd4+nFRefEQHRP5s30PMiMsN3BgnytdSGmJjNFJSFwT7zPGEv2fHNFHIMu9q FMrNnNJLaqYIU5iQxiU5i/K8Qb3y2qJgco94I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YKRIdGHuZOd/fQcotLl6knbHASupHjbM4BeF84H3jy8=; b=Ur3hzieMHJYptYs3V+OSLm54r4FErrv1uY7Nfuq/m5n4yzBcZP3kX1D3Vy9PqDF0Hg 7evjAPzqtapXlh3abmIYkBNW+mLcwyjCpKLW5QLRqCzVKD/KMjNjs/2pNTFLFvLqxpie aBiAnaGH8Oy2LCfkiQSMIREXrS+R0zJxLxKQ3ibxOIr2v3e3HofcJQ2sdYSuLd2Ic5jk ogbSpU/4AHwFWYIzNXCqXLsncBvZd8Z19SmoKkhgX++iYkK0MYbCWT6IgxqGtxcftTOK nK9m1wpEB6+f77428TDPF4VKp3FPk1o9+zK4FErJ+naWqkIju3og8SpwLksHdL5QcDkS 3bcw== X-Gm-Message-State: AAQBX9fFvr0DSg/FEI2BAafUD6QIEqwn8rowNLhsJhuGteaPTRfKM3u0 Lf/oJ0bQLzlO40fIgS58ylZj54FvwJ7OzvHHjeo= X-Received: by 2002:a17:906:4796:b0:93f:3084:d6f with SMTP id cw22-20020a170906479600b0093f30840d6fmr34022998ejc.18.1680466224998; Sun, 02 Apr 2023 13:10:24 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-248-31-153.retail.telecomitalia.it. [95.248.31.153]) by smtp.gmail.com with ESMTPSA id gl18-20020a170906e0d200b00924d38bbdc0sm3553127ejb.105.2023.04.02.13.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 13:10:24 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Dmitry Torokhov , Jonathan Cameron , Oliver Graute , =?utf-8?q?Uwe_Kleine-K?= =?utf-8?q?=C3=B6nig?= , Wolfram Sang , linux-input@vger.kernel.org Subject: [PATCH 9/9] Input: edt-ft5x06: Calculate points data length only once Date: Sun, 2 Apr 2023 22:09:51 +0200 Message-Id: <20230402200951.1032513-10-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> References: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762097729836130675?= X-GMAIL-MSGID: =?utf-8?q?1762097729836130675?= It is pointless and expensive to calculate data in the interrupt that depends on the type of touchscreen, which is detected on the driver probe and cannot then be changed. So calculate the size of the data buffer on the driver probe, as well as the data retrieval command, and then use them in the ISR. Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 56 +++++++++++++------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index fdb32e3591be..24ab9e9f5b21 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -135,6 +135,10 @@ struct edt_ft5x06_ts_data { int offset_y; int report_rate; int max_support_points; + int point_len; + u8 tdata_cmd; + int tdata_len; + int tdata_offset; char name[EDT_NAME_LEN]; char fw_version[EDT_NAME_LEN]; @@ -296,38 +300,13 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) { struct edt_ft5x06_ts_data *tsdata = dev_id; struct device *dev = &tsdata->client->dev; - u8 cmd; u8 rdbuf[63]; int i, type, x, y, id; - int offset, tplen, datalen, crclen; int error; - switch (tsdata->version) { - case EDT_M06: - cmd = 0xf9; /* tell the controller to send touch data */ - offset = 5; /* where the actual touch data starts */ - tplen = 4; /* data comes in so called frames */ - crclen = 1; /* length of the crc data */ - break; - - case EDT_M09: - case EDT_M12: - case EV_FT: - case GENERIC_FT: - cmd = 0x0; - offset = 3; - tplen = 6; - crclen = 0; - break; - - default: - goto out; - } - memset(rdbuf, 0, sizeof(rdbuf)); - datalen = tplen * tsdata->max_support_points + offset + crclen; - - error = regmap_bulk_read(tsdata->regmap, cmd, rdbuf, datalen); + error = regmap_bulk_read(tsdata->regmap, tsdata->tdata_cmd, rdbuf, + tsdata->tdata_len); if (error) { dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", error); @@ -335,7 +314,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) } for (i = 0; i < tsdata->max_support_points; i++) { - u8 *buf = &rdbuf[i * tplen + offset]; + u8 *buf = &rdbuf[i * tsdata->point_len + tsdata->tdata_offset]; type = buf[0] >> 6; /* ignore Reserved events */ @@ -1071,6 +1050,26 @@ static void edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) } } +static void edt_ft5x06_ts_set_tdata_parameters(struct edt_ft5x06_ts_data *tsdata) +{ + int crclen; + + if (tsdata->version == EDT_M06) { + tsdata->tdata_cmd = 0xf9; + tsdata->tdata_offset = 5; + tsdata->point_len = 4; + crclen = 1; + } else { + tsdata->tdata_cmd = 0x0; + tsdata->tdata_offset = 3; + tsdata->point_len = 6; + crclen = 0; + } + + tsdata->tdata_len = tsdata->point_len * tsdata->max_support_points + + tsdata->tdata_offset + crclen; +} + static void edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) { struct edt_reg_addr *reg_addr = &tsdata->reg_addr; @@ -1274,6 +1273,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client) */ regmap_read(tsdata->regmap, 0x00, &val); + edt_ft5x06_ts_set_tdata_parameters(tsdata); edt_ft5x06_ts_set_regs(tsdata); edt_ft5x06_ts_get_defaults(&client->dev, tsdata); edt_ft5x06_ts_get_parameters(tsdata);