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: 2846 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2B3193F330 for ; Sun, 2 Apr 2023 22:10:21 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id i42-20020a0564020f2a00b004fd23c238besf38021409eda.0 for ; Sun, 02 Apr 2023 13:10:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680466221; cv=pass; d=google.com; s=arc-20160816; b=I8bQMmX33ikLLMIFDsF4VlX+tSNIn5RY0VQQ7/Dsl+1mSM3x1CTraxKpVfsxbh9nUM mwEbBU4Mt01YPmDYW1I2wy1HOQ2IneA5CXOGTNReclxGy+YBPdU9NI+brQG3OVtOtsZJ xp8iK4aH9IFLSYyab5DTJd8ewMbd/MS9Hzsh2H3beRY4a0LX23J0OA8yTJPuAqxADFo+ 8Vvvw5VwBl92YsH9KDWwqEKQvHqQOM3rU5+CaB9/toTqlmEcWdV1tPE/ElPCGaQvlh9/ QcuYRVFlxhNi10lO3DKMLQUYS+decdMMhrawbnNHpkjuayDORS2fdbrll6m00f9djAXp oHVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ISih8zdsGyxpopTYxP3z9LBrXfeNIL0/oKcuRUQMSKI=; b=OCddRT6fvjU02AGWj9XdOiHOWdtyzWHH63wL4KKuQAu7Pgage/zvQs6QJdsQCoaSbR qfe/XGpPhvfC4BKxufOHE64nRMzYLPDlz3lYCgF2Dinbr2faRXZ+8EeNbC8SBLUL7EZM EsqMSJsGh+3E3fKduREe7eSxM+IkElWnrbytUK29Eif5IbSaDd68VDC6+iAcY6mrf+02 GbdRxlBVA0yDb4OX675S5ueHK70Mjnlwe6YrxETa8phEt7gmQy+85bnVIpk8GkBTJOIr nte8mj5ofcX7owcNpj7z3kDmoqii7L6HJYDTdYyOHjrZJExmX0Ig/6FHSs2mS9f01jOU 0L+A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BTA0a7k7; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466221; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=ISih8zdsGyxpopTYxP3z9LBrXfeNIL0/oKcuRUQMSKI=; b=GDIOFjww219RZuyEl34ikflmwYClu56knT3j56zuUsW+SfuuauU+Ifa0YNZ8sq6LcW SkGH2rd0QksmNAah6RkdnN7vCnNWwhIVMYx6YHPkGVrkGH32xR4VNvsSJZiSjnLNqWfU /ZXYmm1OqH/YIiMx5vP94E/IyrwFEXSRRHyzs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466221; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender: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=ISih8zdsGyxpopTYxP3z9LBrXfeNIL0/oKcuRUQMSKI=; b=s/gUJDxV//GwPAOlQH8oaZ62sa6qxTYQM2RpSQlG8wqDI2ecBfAlC9K7kdCN8AhD7L nvLO2FNQsWDIbaFjNoPx1XPW+chmNQTbBO4PYDLXJqUM7qQ/8I4295aDRjm7yiDJLdL3 80jHqFtaQqARj0aFqYZ1xakOy8D2ra4Fuk28Y/orNS/6FC5ZmOGMwDKDg/AR4H6CvYHC Uvl3LEeTXieVagWnTnPOHJtVxDVQjiIx4JROATrlWegri0aZr+NHI2Klaqol2hz3GwZd K49bcIQB8gXUDvduxsYi5IUsLINeAx1olAw0qU/3zdeIyvfUDqqwTLp/EvRBilq/o0Hd ewfA== X-Gm-Message-State: AAQBX9clZ+xQO7mPg6xXewQJTqFqU+M6nMHPoypOtbmyLaKEhIVEgILH JaeZOL2cXKPCWX0fxT6tsWPmz1hk X-Google-Smtp-Source: AKy350YrCUVGxlMaCb7c1QGX0+oeWQD3giR5rae//AnCBVlcHiPUSu91/dRdyav09PPGu5GFxLvokg== X-Received: by 2002:a17:907:72d4:b0:930:310:abef with SMTP id du20-20020a17090772d400b009300310abefmr10078711ejc.3.1680466220927; Sun, 02 Apr 2023 13:10:20 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:3203:b0:502:26b1:64e0 with SMTP id g3-20020a056402320300b0050226b164e0ls6805047eda.1.-pod-prod-gmail; Sun, 02 Apr 2023 13:10:19 -0700 (PDT) X-Received: by 2002:a05:6402:2039:b0:502:61d8:233b with SMTP id ay25-20020a056402203900b0050261d8233bmr13878359edb.19.1680466219349; Sun, 02 Apr 2023 13:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680466219; cv=none; d=google.com; s=arc-20160816; b=kr1v5Wf1B69bJojejJ1kM6yH2qFREIHLX5PnNlBm4Wb9n9nHkfEGCyQB0fxoPyYC4Z L3cjWu7nOiKAwB2exvGohjlryr04PeR7PY0upMSH5rPHFxHmNXOLf8exTkaDcpfnywrs bUSY8XZA3aVhiSMAiCthDMpBAD/L+FomtXx+nt9Sn1CN5rZiLW5OS3vlCRONbjnSXZS8 25xJlJ7r5Xw4cIFeIVQYSBiCOw+LTlQU8W44s0cNixJv4WnUlVS0rO/L/wv5u+8biRgM ApiZvzLrZhJWGEshQ2MAHafG42R9Hwql+n5szxT+ZTpsbjFl+Huy7zp1Lq6asaceVfOo qqHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=kMHERFML/oNzDxt2xRgB06w0p+QqR9zI3HtwO5KrpJg=; b=YoAnhSaeQpLJHUdplaGvzwNMRMZUjM+e/WW+B3opMeIJ631KlzpX8wmGAgqYiuCtMT W+0X4NQYRJbS6n5+F2T9VUc2XT1EixMcTiyrNXrUE/zaHTHxqcC3U5OccmbiPNVll3FQ P8uEuGmXQY47Ao4LDReU1SCl/am5ATZnT8EGgkRbgLRJbjgADzciJdhB0+cVb2wXpQ7O Cvn3iTVOHJFoCei0OKSrNZGJgxxy3NWWikb5mu2lllySlZlW6Wu9JxV1rnFlBuJRHbS9 38vaSPg9qkSEd8P2U78qtFVAf6NeQ9jQ9eaJRFloSbJlivVRzhGn8NWxW3S/ROQUXMTq qDqw== 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 dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id lu20-20020a170906fad400b00947abb6b7c9sor3420703ejb.131.2023.04.02.13.10.19 for (Google Transport Security); Sun, 02 Apr 2023 13:10:19 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; 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=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-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BTA0a7k7; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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,