From patchwork Thu Sep 8 10:48:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 75760 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp774690qgf; Thu, 8 Sep 2016 03:48:54 -0700 (PDT) X-Received: by 10.66.75.4 with SMTP id y4mr9619761pav.139.1473331734849; Thu, 08 Sep 2016 03:48:54 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cc15si46541434pac.249.2016.09.08.03.48.54; Thu, 08 Sep 2016 03:48:54 -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 S1758951AbcIHKsg (ORCPT + 4 others); Thu, 8 Sep 2016 06:48:36 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:35384 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758945AbcIHKsf (ORCPT ); Thu, 8 Sep 2016 06:48:35 -0400 Received: by mail-wm0-f48.google.com with SMTP id w12so27972187wmf.0 for ; Thu, 08 Sep 2016 03:48:34 -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=I0v5NZ/S5G7QDFBqk7D3U2dO78jHab1U4frxM6jH6lw=; b=E6xEX8/sTdrJ1tlV8Gmv8tK62Yre/9WLMhTwPB3PI+F2ZzHt/LH8IABBuHUs/wUWfz bheI4m6Pb6m/9EjWH9Ra8r3NPkNroC3uWLVumb+XfCkvsitM9Bl790dq9BGcscoN1n/A WMS5pUXy+Ur2eiyw9ZG+O+Ho37z4A9EaLPaot96/zRpX+qLZO3bnfQO8OwIg7mpbadPJ bF4v5VlizW2G9FLSJOd6duNNlzm3NO/o9auganfYx62EdrbXQ/sQe9jgWOgE9yZaSvEb lwg8DmD1U5OSFI2VvCjACa5pOUOR4Gxh6DVqD53TplRfVZzPIRGqG4WzsF82Dug5ku4p p7JQ== 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=I0v5NZ/S5G7QDFBqk7D3U2dO78jHab1U4frxM6jH6lw=; b=hQlFjyOaQoambVlBptrCMLiWux1+sejioD0dGunM+sjQ82TavNH56vi4FXitO3ROgF qmVBfNlVuzr579CBRBtwZ0LPS4Lwkf2jcngfjgEXeTmQWqh0BwI2fhZ7rq9zAL/24pWs yOB7Oyf0uzSOVYtY5Y1jVlbm525u8pgLPZbdq9ApB+K6EDpcva/Xe5+WXQV5ACjMuEEt PwZwCst4mc6naynMlVMzuIjc4XMBM5kTLLITCVMAmdzjPCA1mpHBbA4YjBEsOAAWI7wK CC0tB8GvqRP2gpNUOKkjwUW281YZ2xtIRoPufhadKroxFI3YAG0NTK7rlRddmVPDcJh5 gA+g== X-Gm-Message-State: AE9vXwMnf4Jn3s5KXLlAdkbZYqt7zJV1zuu1FUeeHIpZJ14k5axTiS2OssTrBHPCyz4aB0A3 X-Received: by 10.194.223.73 with SMTP id qs9mr44920180wjc.188.1473331713405; Thu, 08 Sep 2016 03:48:33 -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 t5sm7151832wjm.12.2016.09.08.03.48.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Sep 2016 03:48:32 -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 v5 5/6] gpio: pca953x: coding style fixes Date: Thu, 8 Sep 2016 12:48:21 +0200 Message-Id: <1473331702-26711-6-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473331702-26711-1-git-send-email-bgolaszewski@baylibre.com> References: <1473331702-26711-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(-) -- 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 02893c6..71e1344 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -360,25 +360,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);