From patchwork Mon Feb 12 10:11:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 127981 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3058130ljc; Mon, 12 Feb 2018 02:11:36 -0800 (PST) X-Google-Smtp-Source: AH8x225z1iAL4sFKE4LJiZFw5C/Pu52h4BpgfxrAsqATqqzS5p/tVBBXcJZcedOfwhtE+nIEeWeN X-Received: by 2002:a17:902:8487:: with SMTP id c7-v6mr10178739plo.7.1518430296614; Mon, 12 Feb 2018 02:11:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518430296; cv=none; d=google.com; s=arc-20160816; b=j5Dd/me6OragUU6sELVt6CqVGmFVQmUEB383CZhShUNoX9pFKJP3t17BFEiicwnrTg QckDgqx0JB8aH2z9nSIqSjWAbCgSkNb8Aa7feBGC31zA855ffwE00F1B4fGdf7S6panb JFbnWxAdMHqGpXNYDCKScgJTXd+MZr+rJfr3rZ+arOi8sEoF3NMLE002aqo/Pc0hlfws bUbVuvm9YYhuifPKxuUh7eLtFHeonP6JplDvcJTHBC2wOH+lakqPNsyzht/4XR3LJzNE 0G81l17dzrVUJFJHcpg9nztVEDMEiTtxLsgk1OhYmZeYMbTKuAKzK/9o5WM87Lqgu+wf Tbsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=syaCAG2Vv/EIy5bKsOuQadnFJZP9+w+41Yno4Aa05DM=; b=mZMxirmxWigUuIxNyOWL99crli9RjsE3eFhQ5iiUgEEfDUal1ApcfKGyEXLcrQWgom gfVxIrT1i4hhBs9ZCyvJB3MGWTZet5u6Rx/htRu/vUwWwPuoj8Stfacb7tnlTTrkczjv 2X94hNEJ+OB4LDOVlZHS2KnZJEc+fd3knpoj5UlCE0ZtEWl02KvABh0SQWVfUJviApgH 4HlVQWlUyCoRVgi1m3Dn0KQJ2pixTDR3hVJd4h82TC9YWFQxxUNFcEoSo8YJWzDmv6H/ ajkaPn44DMJNGIUAhmBUfqa7wlQz8SqiSJw8wliVcvIEmwey+pvWenvwpcmIzq7DDIuO 72Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iFbJENlT; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c23si4369733pfl.392.2018.02.12.02.11.36; Mon, 12 Feb 2018 02:11:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=iFbJENlT; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932702AbeBLKLe (ORCPT + 5 others); Mon, 12 Feb 2018 05:11:34 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:42946 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933650AbeBLKLb (ORCPT ); Mon, 12 Feb 2018 05:11:31 -0500 Received: by mail-lf0-f68.google.com with SMTP id w10so6903181lfc.9 for ; Mon, 12 Feb 2018 02:11:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=lKcp2ft4HfsjDGLAUehwtM4U7Z5iLvsWEHmThK1KPPI=; b=iFbJENlTBnXbCpkLgyW6vA7u0t/sHheSazrc4dReStCyY8/bdwby9I+wg1hq3IPbaT j/7mtXX+FQWmeIdwDvx9cn7wVwo9pmG71pTQj5bY/u3Kk4B1mn0iotL0ELHw3G56chB5 axs7lU/3gkqicK6oSPfDJvBVY/DupUsSycDrs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lKcp2ft4HfsjDGLAUehwtM4U7Z5iLvsWEHmThK1KPPI=; b=jd+/21DQkRSbcbIdSjCNmkXupuzldxL31EVnp9Sb2Se6iETh+lqRu9salwjSzL9FQ/ gTmeXC5xnNlRYuXsmDus3OjeVxBdfROTJHbPOeGaDHGQkSilFFWV7Jk3HOaC/2+QPQw4 r4YAYmBh9ErEK0T/1cIFjNtjtbolzWSZUcZkdeRRpH7LZ8mv2v6vU54trztFgTJS3jL3 sBYDEUY9EUsvNKHFK9265PgHq/uL4otgCfXEQN0spgYxYbKetwPRu8EG/QLWKqT3voUE PuYX9PaQhCUO5gygvddcznpc8tLIOWBGUZPXWI3KDVitffwZkkE+sa4uAV3FMwfmhf0V QFPA== X-Gm-Message-State: APf1xPB0VFiLoqR1HM9OoaK6OfVjrol3sGkvzT5R6NGlprianHsC06KX EN6BloTq5AvQ9gToZt/IEQQwcwSHWQg= X-Received: by 10.46.70.18 with SMTP id t18mr7085722lja.41.1518430289633; Mon, 12 Feb 2018 02:11:29 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l193sm1618055lfg.50.2018.02.12.02.11.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 02:11:28 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Hoan Tran Cc: Linus Walleij Subject: [PATCH 1/2] gpio: dwapb: Use "stride" rather than "size" for register distance Date: Mon, 12 Feb 2018 11:11:24 +0100 Message-Id: <20180212101125.7890-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org This terminology is more precise. Also cut the stride calculation in the preprocessor, it confuses more than it helps when reading the driver. Signed-off-by: Linus Walleij --- drivers/gpio/gpio-dwapb.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Hoan Tran diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 6730c6642ce3..677988f21369 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -53,9 +53,9 @@ #define GPIO_EXT_PORTD 0x5c #define DWAPB_MAX_PORTS 4 -#define GPIO_EXT_PORT_SIZE (GPIO_EXT_PORTB - GPIO_EXT_PORTA) -#define GPIO_SWPORT_DR_SIZE (GPIO_SWPORTB_DR - GPIO_SWPORTA_DR) -#define GPIO_SWPORT_DDR_SIZE (GPIO_SWPORTB_DDR - GPIO_SWPORTA_DDR) +#define GPIO_EXT_PORT_STRIDE 0x04 /* register stride 32 bits */ +#define GPIO_SWPORT_DR_STRIDE 0x0c /* register stride 3*32 bits */ +#define GPIO_SWPORT_DDR_STRIDE 0x0c /* register stride 3*32 bits */ #define GPIO_REG_OFFSET_V2 1 @@ -476,10 +476,10 @@ static int dwapb_gpio_add_port(struct dwapb_gpio *gpio, return -ENOMEM; #endif - dat = gpio->regs + GPIO_EXT_PORTA + (pp->idx * GPIO_EXT_PORT_SIZE); - set = gpio->regs + GPIO_SWPORTA_DR + (pp->idx * GPIO_SWPORT_DR_SIZE); + dat = gpio->regs + GPIO_EXT_PORTA + (pp->idx * GPIO_EXT_PORT_STRIDE); + set = gpio->regs + GPIO_SWPORTA_DR + (pp->idx * GPIO_SWPORT_DR_STRIDE); dirout = gpio->regs + GPIO_SWPORTA_DDR + - (pp->idx * GPIO_SWPORT_DDR_SIZE); + (pp->idx * GPIO_SWPORT_DDR_STRIDE); err = bgpio_init(&port->gc, gpio->dev, 4, dat, set, NULL, dirout, NULL, 0); @@ -710,13 +710,13 @@ static int dwapb_gpio_suspend(struct device *dev) BUG_ON(!ctx); - offset = GPIO_SWPORTA_DDR + idx * GPIO_SWPORT_DDR_SIZE; + offset = GPIO_SWPORTA_DDR + idx * GPIO_SWPORT_DDR_STRIDE; ctx->dir = dwapb_read(gpio, offset); - offset = GPIO_SWPORTA_DR + idx * GPIO_SWPORT_DR_SIZE; + offset = GPIO_SWPORTA_DR + idx * GPIO_SWPORT_DR_STRIDE; ctx->data = dwapb_read(gpio, offset); - offset = GPIO_EXT_PORTA + idx * GPIO_EXT_PORT_SIZE; + offset = GPIO_EXT_PORTA + idx * GPIO_EXT_PORT_STRIDE; ctx->ext = dwapb_read(gpio, offset); /* Only port A can provide interrupts */ @@ -753,13 +753,13 @@ static int dwapb_gpio_resume(struct device *dev) BUG_ON(!ctx); - offset = GPIO_SWPORTA_DR + idx * GPIO_SWPORT_DR_SIZE; + offset = GPIO_SWPORTA_DR + idx * GPIO_SWPORT_DR_STRIDE; dwapb_write(gpio, offset, ctx->data); - offset = GPIO_SWPORTA_DDR + idx * GPIO_SWPORT_DDR_SIZE; + offset = GPIO_SWPORTA_DDR + idx * GPIO_SWPORT_DDR_STRIDE; dwapb_write(gpio, offset, ctx->dir); - offset = GPIO_EXT_PORTA + idx * GPIO_EXT_PORT_SIZE; + offset = GPIO_EXT_PORTA + idx * GPIO_EXT_PORT_STRIDE; dwapb_write(gpio, offset, ctx->ext); /* Only port A can provide interrupts */