From patchwork Mon Sep 5 14:31:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 75428 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp102426qgf; Mon, 5 Sep 2016 07:32:53 -0700 (PDT) X-Received: by 10.67.22.39 with SMTP id hp7mr54837052pad.19.1473085973132; Mon, 05 Sep 2016 07:32:53 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g15si7804947pfk.206.2016.09.05.07.32.52; Mon, 05 Sep 2016 07:32:53 -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 S1755378AbcIEOcw (ORCPT + 4 others); Mon, 5 Sep 2016 10:32:52 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:37936 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754902AbcIEObo (ORCPT ); Mon, 5 Sep 2016 10:31:44 -0400 Received: by mail-wm0-f47.google.com with SMTP id 1so142652238wmz.1 for ; Mon, 05 Sep 2016 07:31:44 -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=Vcm+glORCa9L9O69CESjIhOPDqSodZSLMGPJFdUc2e7IJLA93IJiL4bDoMFfYR0phx DADcTR2QjhIl6hOLRP99cpqMQdfxpMO8VSQOpeJ6yPoaHeZNEHB0Gz7mVU/pJ7pgDw7X rRXy9o83611oEdEbscUkgEwlDEutHXVi1yJO40NR06ATJKYiBN5ys1CUtkLo9eXEfeQ+ lpIjoKK/itJ6U/6Qkf483f5ndy0U376DDQpk4VUnBISOSOav7o/sLSBJTuLwttdBu1yZ 8XMFzvfN+hKPpCExb/siLsQyboKX/rTwZN/uWxs0nykdcwRjX/hmO+psNzpoBR93dwoV /hmQ== 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=PyU8OAnTWkB1b1vDOoUSQ2xq9gcFzg12bGeztRRabmb372jiWk40vSNqqJANdgjjTh qguAU89Wavcvi6Dx4+BTZPmNOTyIADEkOLa9KpqnbDsbJOp7KXST0T7zORrAcBXePJRx k5B5kPIM4VYcdveEDMXb4jqmihOyEEg8go6YFSgL9hVlhT9RAXwfShsP0Y/OwBuZywod TTksjySGgdThca6eMXdH/tVFi4CaSC2UEaeS834W3fAaVWr7qyPPviJLZ97Td25TYs/V BhG/oR+vrj4BtwW/IHyyUGcJckOOU4A+TvBPzFHZr4MzxseBoeYlYKuXGFojKqu92Eq3 Etuw== X-Gm-Message-State: AE9vXwPrCsSSKeX7KsVO4JNJSNa01vukfJJzipmJY3SxJS2h8A6EHBk9DdJ7bc1Swk0SF1SD X-Received: by 10.28.144.2 with SMTP id s2mr15104945wmd.22.1473085903116; Mon, 05 Sep 2016 07:31:43 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id bc10sm28017507wjc.32.2016.09.05.07.31.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Sep 2016 07:31:42 -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 1/5] gpio: pca953x: coding style fixes Date: Mon, 5 Sep 2016 16:31:31 +0200 Message-Id: <1473085895-31711-2-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1473085895-31711-1-git-send-email-bgolaszewski@baylibre.com> References: <1473085895-31711-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;