From patchwork Wed Sep 7 14:49:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 75670 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp364069qgf; Wed, 7 Sep 2016 07:50:02 -0700 (PDT) X-Received: by 10.98.4.3 with SMTP id 3mr34975260pfe.45.1473259802836; Wed, 07 Sep 2016 07:50:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v27si41628612pfj.178.2016.09.07.07.50.02; Wed, 07 Sep 2016 07:50:02 -0700 (PDT) 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=@baylibre-com.20150623.gappssmtp.com; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754338AbcIGOty (ORCPT + 4 others); Wed, 7 Sep 2016 10:49:54 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:37287 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938729AbcIGOtp (ORCPT ); Wed, 7 Sep 2016 10:49:45 -0400 Received: by mail-wm0-f51.google.com with SMTP id w12so37255798wmf.0 for ; Wed, 07 Sep 2016 07:49:45 -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=ifQcTHyVWngPn/607ZOxus1jGzlGZIcA/gkDV/nWZC4=; b=R1N1UOWOd2YY104YCUoDLNNAJ3lqVCvCD2Sktm6t+rKvh6Gxuk9yZS6IbaeAc3kT0U /2UAZaJnrybOWkUkrz3XVbZsQLbr2AKskA7VwHyQsZR2rWs7WuWdSw/U06brVcrNlBPK cboYaoHrYfCRGHLN5FgL9lI1WqtDbh6MZVEnfZnSqrbZpXgpjd3xn5eYXtWk3sgM0R68 muEuMQVfmYltlGdIMwkKxHQg/VngGTRLTJXAI1U0BztPV7NFo81Y34Txp2JuWcaQIXDO R/wKzqiD7W1F3Tp/Tlib4YTkFNMNLh4mXWK9+ss+AcW65fLaq0eXhY7lxVUe9TPE9v9D notQ== 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=ifQcTHyVWngPn/607ZOxus1jGzlGZIcA/gkDV/nWZC4=; b=U7u1CcsXHC0Nlx8LAp+EpJM7EfPH4eyT/p5ulzwcCQRfnXdRqVkmOoDVFQiEm5N/Z9 +WOlT7sQ/3Yzfmasg8gKieeSbdZdhW00CYYKGQloHzUAYm8xdfVCK+kR7kik2u24sexS jPZzgluNHrPpbuRRjOUjH4UmuyGl+7oV3e+Y9z50KrfgKmFYLE1sg0c8c+HiAu5ka5Qo edKT3LtFmjWEB0A1HYmdO7MUmJ7Sz3LseL/3+1N+DL1WrajSQ8Lm1ELUmZ5UIO4OnQvg hF8vgDsLU4rnrPZNymq3QxTsOu53/tncVsRWGe5ofUDq5VqUv/RDG+NvE9MF+QzHEt9L kTwA== X-Gm-Message-State: AE9vXwOtsp8XR9+LDNqI+0ya2ABofL971gxYK7SQsxBnhVPtabO8+tv3cTlE0J10YozDxgFy X-Received: by 10.28.191.14 with SMTP id p14mr4546328wmf.39.1473259784319; Wed, 07 Sep 2016 07:49:44 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id s8sm8295544wjz.29.2016.09.07.07.49.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Sep 2016 07:49:43 -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 v4 5/5] gpio: pca953x: coding style fixes Date: Wed, 7 Sep 2016 16:49:30 +0200 Message-Id: <1473259770-26224-6-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473259770-26224-1-git-send-email-bgolaszewski@baylibre.com> References: <1473259770-26224-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 | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) -- 2.7.4 -- 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 diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index b08ed52..079c311 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -360,25 +360,27 @@ 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 bankmask, bankval; + int bank_shift, bank, ret; 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); + for (bank = 0; bank < NBANK(chip); bank++) { + bankmask = mask[bank / sizeof(*mask)] >> + ((bank % sizeof(*mask)) * 8); + if (bankmask) { + bankval = bits[bank / sizeof(*bits)] >> + ((bank % sizeof(*bits)) * 8); reg_val[bank] = (reg_val[bank] & ~bankmask) | bankval; } } + ret = i2c_smbus_write_i2c_block_data(chip->client, chip->offset->output << bank_shift, NBANK(chip), reg_val);