From patchwork Fri Sep 9 09:17:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 75856 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp243900qgf; Fri, 9 Sep 2016 02:18:45 -0700 (PDT) X-Received: by 10.66.220.194 with SMTP id py2mr4575878pac.77.1473412725014; Fri, 09 Sep 2016 02:18:45 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r90si3062347pfk.194.2016.09.09.02.18.44; Fri, 09 Sep 2016 02:18:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753440AbcIIJSd (ORCPT + 27 others); Fri, 9 Sep 2016 05:18:33 -0400 Received: from mail-wm0-f45.google.com ([74.125.82.45]:35851 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753285AbcIIJSC (ORCPT ); Fri, 9 Sep 2016 05:18:02 -0400 Received: by mail-wm0-f45.google.com with SMTP id b187so20407269wme.1 for ; Fri, 09 Sep 2016 02:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BLSkQ3g6SYwW63feu0yr2Oyukjgke30f2S1MUqm2d0U=; b=EU56wo6XFR0HGNIQhZXBMvDAvPPmn6G0QzRbhgG0ZFimUYBGx/fy6Ud04cjD59KHjy XoX8QL93yJ8J4krfEoGCj3KA3PJGbpbaSotFYCSLKkozWCsI4KEY8ER/OE8zBjHC62zY Z7bdoN6Uw5IKBu8H0tdRCxlAOuI6+HK72qnqTFQZBRw6q0z48DYdvV06mDGj4GwRgmoi Jf26ZJy16QxB0iVpNC7fM3Z7eLDpvJpFT0sLNBMG4fezQqwaPygBVQucDX9Se6LZeZ2M u2v4GNdwdu4m2J+LU48iwvDc3hZeEmtrJ1bRgHmRi7EjKlXHqbMM+84WhNJ6ozLVoAiD KIDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BLSkQ3g6SYwW63feu0yr2Oyukjgke30f2S1MUqm2d0U=; b=AUoqt22R9znwq+KXGaaXYUNE+BKiZQi0SA7a90pBbxmaYJOEPzj1DU8hWlF6UUVreS GGgh7vuvkc0d7YJNX9r2rA7MHFiFDK9VffIxU0Br/yDtTGc8XCCYQ9mrT7Djb+LzIiQq zwxtqV5qQ1Nja2OOzMPhpYZt4rrshkveIG75i5ytWzIgOma/gE3Z9C1KvR1w2Qn1FNom Vf+DJFcTTSOg9oRD/yRKH8+rZwyhXcJ9u0j/ARTc3pCzU043xnoOFWM3UbqDOwbOVFMI 3X70zxHu+uONqJ3oGZ3C2x5Av4INRK0M99iG7MHBVmTo71dKb8iZlRam3jDHVXz01ta7 RAVw== X-Gm-Message-State: AE9vXwOdfnFlSI6nHvSdfXj2aCv8B9g06n2GI7Rh99kjpNVTtlvHNSAE6hUVKYVaRkwzbavM X-Received: by 10.28.153.70 with SMTP id b67mr2022803wme.84.1473412676149; Fri, 09 Sep 2016 02:17:56 -0700 (PDT) Received: from bgdev-debian.lan (jua06-1-82-242-157-225.fbx.proxad.net. [82.242.157.225]) by smtp.gmail.com with ESMTPSA id i127sm1716246wmf.4.2016.09.09.02.17.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Sep 2016 02:17:55 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Alexandre Courbot , Andy Shevchenko , Vignesh R , Yong Li , Geert Uytterhoeven Cc: linux-gpio , LKML , Bartosz Golaszewski Subject: [PATCH v6 5/5] gpio: pca953x: coding style fixes Date: Fri, 9 Sep 2016 11:17:38 +0200 Message-Id: <1473412658-13120-6-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473412658-13120-1-git-send-email-bgolaszewski@baylibre.com> References: <1473412658-13120-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pca953x_gpio_set_multiple() has some coding style issues that make it harder to read. Tweak the code a bit. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko --- drivers/gpio/gpio-pca953x.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index e36a9bf..5d05986 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -362,25 +362,28 @@ exit: } static void pca953x_gpio_set_multiple(struct gpio_chip *gc, - unsigned long *mask, unsigned long *bits) + unsigned long *mask, unsigned long *bits) { struct pca953x_chip *chip = gpiochip_get_data(gc); + unsigned int bank_mask, bank_val; + int bank_shift, bank; u8 reg_val[MAX_BANK]; int ret; - int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); - int bank; + + bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); memcpy(reg_val, chip->reg_output, NBANK(chip)); mutex_lock(&chip->i2c_lock); - for(bank=0; bank> - ((bank % sizeof(*mask)) * 8); - if(bankmask) { - unsigned bankval = bits[bank / sizeof(*bits)] >> - ((bank % sizeof(*bits)) * 8); - reg_val[bank] = (reg_val[bank] & ~bankmask) | bankval; + for (bank = 0; bank < NBANK(chip); bank++) { + bank_mask = mask[bank / sizeof(*mask)] >> + ((bank % sizeof(*mask)) * 8); + if (bank_mask) { + bank_val = bits[bank / sizeof(*bits)] >> + ((bank % sizeof(*bits)) * 8); + reg_val[bank] = (reg_val[bank] & ~bank_mask) | bank_val; } } + ret = i2c_smbus_write_i2c_block_data(chip->client, chip->regs->output << bank_shift, NBANK(chip), reg_val);