From patchwork Wed Sep 7 09:24:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 75613 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp227782qgf; Wed, 7 Sep 2016 02:25:10 -0700 (PDT) X-Received: by 10.66.131.48 with SMTP id oj16mr80113064pab.126.1473240310669; Wed, 07 Sep 2016 02:25:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11si40394694pfk.264.2016.09.07.02.25.10; Wed, 07 Sep 2016 02:25:10 -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 S1757247AbcIGJZH (ORCPT + 4 others); Wed, 7 Sep 2016 05:25:07 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:35450 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757224AbcIGJZE (ORCPT ); Wed, 7 Sep 2016 05:25:04 -0400 Received: by mail-wm0-f46.google.com with SMTP id i204so75603893wma.0 for ; Wed, 07 Sep 2016 02:25:04 -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=ZZmMOxMQ09CH/8wmPw5O1U7Qr1ssan1ZxTNI5heRbxA=; b=MMhUYKudcCHaak0H0anWCsufDhTHNwlS3cRfpXlP2Eo2JsRBwkGBF+UgENDzux6c/P c5PhQmyqHQFvrD+PzvHz8Fp3zz4GNrkz901iAkeufqCgzmYR3b70KJpqNZswbasAA1dt LeiiOBt3IISton2xPggwJPLO6GonqzyB/vsMk63eFCi/L2YpAKbzNztCsIB6+urNNVQ5 FISiuNdjZxmvWW3VFxYoql43kg2x8ui148gT8WqP85X7/ti/iuaeQhwj9ljP8Smx823U VQPI25SQ7Gw3WcTAPb7X6w9mOLo1Hom6VBzZ9bIm2sPgoe+xy/H4xqC+C18DJwP7iW/6 PDUw== 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=ZZmMOxMQ09CH/8wmPw5O1U7Qr1ssan1ZxTNI5heRbxA=; b=gDI6s0ZSJp9kszEAppOGUUs49u3ebT0bCPOPuTxmU3sUf334dOxAhuXMtf4GPqUtKy KGKH9bQpzvthz89m5KdZU9ppgwUANnz8/BcC5gvvLrUfJBFoN46vCi+bOvKRKvo4QpBz r4U10cNw4GPdkWvokH3kpxCyo58v7Cixr4QxDeP2g8eHfNjl55Lm8bxXuZA+DlUxgwOn /Avx2TMGrsQfIHuJP1ikYyIkKMSMAxElS5gfk/avpiG3Q8xpaVso63Q5J3U2C7t5OmnX todZSQ0SuHYwjXtBeVljkL/y5HufmGJa4bxq2CKo0+0iKw1EsyH2nue92gdJSal/ZTRo qaKQ== X-Gm-Message-State: AE9vXwNEonlH6Sc+Cwh0pHjWyeMKII7j6r5QjePxrTqvlfHbRGyeb02vkvqv51NLYjsnS1nn X-Received: by 10.194.142.198 with SMTP id ry6mr39627629wjb.62.1473240303349; Wed, 07 Sep 2016 02:25:03 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id xy4sm29697502wjc.2.2016.09.07.02.25.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Sep 2016 02:25:02 -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 v2 1/5] gpio: pca953x: coding style fixes Date: Wed, 7 Sep 2016 11:24:53 +0200 Message-Id: <1473240297-19881-2-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473240297-19881-1-git-send-email-bgolaszewski@baylibre.com> References: <1473240297-19881-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 --- drivers/gpio/gpio-pca953x.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 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 02f2a56..2312f8d 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -355,13 +355,13 @@ 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); u8 reg_val[MAX_BANK]; - int ret, offset = 0; + int ret, bank, offset = 0; int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ); - int bank; + unsigned int bankmask, bankval; switch (chip->chip_type) { case PCA953X_TYPE: @@ -374,15 +374,16 @@ static void pca953x_gpio_set_multiple(struct gpio_chip *gc, 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, offset << bank_shift, NBANK(chip), reg_val); if (ret) goto exit;