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: 667940 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sVs8R0M1Wz9ryn for ; Fri, 9 Sep 2016 19:19:03 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b=EU56wo6X; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753444AbcIIJTC (ORCPT ); Fri, 9 Sep 2016 05:19:02 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:38442 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753184AbcIIJR5 (ORCPT ); Fri, 9 Sep 2016 05:17:57 -0400 Received: by mail-wm0-f52.google.com with SMTP id 1so21438725wmz.1 for ; Fri, 09 Sep 2016 02:17:56 -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=H+xjd7QtywDeMrotydMvdPcd55JTmlhR2v1T9pXH07vA1U6MMA8j/rHoNCCihYOP5n lnQCFZseuwfpoAu+/Ssbl6I+7AyZpby0lK0BBeteQyjdRhlZttVKTOtaTYeSKTGvm5RA IaXdyzKVQ9uwxkeerYoK86nvoAfbrvmToooO7ZrFN4MpyY4kEiVRhVeJmriMaTvsnsOR nhBc0VwMAZpIvuudxqx+zD+ER1tbr5ZSfHv8r08QxpQXk2RHKa9/zezQeEOaaKwEkZMp gO10ilYu41cC+OS1Qhcm0zxQvoglCY/aPczfqHfHV3m3/tVbegEN/o46kQjoOfe2HHPo ZPrA== X-Gm-Message-State: AE9vXwP/CwZcMHgGHY4QNITj+Fp12Ox3XvBLffYPSuEkegc+efQNtg7pe3LES/TcptI4Ys9t 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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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(-) 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);