Received: by 10.192.165.148 with SMTP id m20csp3220636imm; Mon, 7 May 2018 08:36:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoQMKRkyrXKohxZyycK3MXLvApesIlYcTEJBwT3TZz2ObA4gAlBk40BZAuLEwtc5xdGqsvQ X-Received: by 2002:a24:6793:: with SMTP id u141-v6mr2665291itc.0.1525707398423; Mon, 07 May 2018 08:36:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525707398; cv=none; d=google.com; s=arc-20160816; b=fLwEDsU0SAB0m7hhTGI6bqpxHG6EOZZxSf6YhCoIRIM/TqmAI8ldYy3SvT38C//blj 08S4qe9AdUJc44Szas9AXpIIGkjrxcLccir+cNex1GZK9qqDDMRVSc2t9ISvoWwklDD7 EpSWP2owl1pNwuFH0Xczbswmy4b1n90XnERAZaETGXM6uIU81h9MrDNE5cuvKbwRATvR BjshgWXilVddUC/Mzx0G15NX1wcceWfIvMnGNip3CCPk5Pfty6UvGb72xaOH+IohkMPJ B1ZIKKrRfEQRJxWcjxvsJ2+xhNZjXii9dtgjJ0E6aVGtYcsrkg+IiCwYEQE6cNTRh4e0 2AbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=slf1J3iHpjNeA4Hre3fVutRjHc1MIIIvq7nrD4k34rM=; b=p6dV93pkk2jRQfAbNFVHZQU54xxRE3MAWU/RoTpcUNko8PUH9mU0gPrj8j2XkI1jGs YuYxChgvLesN3ZcEidUY1dyeB6EdJbbiM43oj4wazKffFxYAtKjxwiV8j89qTGO+5EHv iKS/KBTKh1KgrOOP9mLwLd1DdViShgVrl9VDz/CU5FKvit4OZp3mRZIL2WJBv35AOB2Z bbOObzBKoYWPJIduuFTEs/gbOu4y/NdFgB+MT1TvJPqeR1yPIpcys0mdGFcfnWWQVjGk RuEYRHuDZe2jXbckJ1WySvoFYobFcFBeXmEjENtcZRubHcTY1eBGcLKyT/rBGgU4IxQb +n9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jzbjUguM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b17-v6si20147174ioa.15.2018.05.07.08.36.24; Mon, 07 May 2018 08:36:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jzbjUguM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752474AbeEGPgI (ORCPT + 99 others); Mon, 7 May 2018 11:36:08 -0400 Received: from mail-yb0-f194.google.com ([209.85.213.194]:37649 "EHLO mail-yb0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbeEGPgG (ORCPT ); Mon, 7 May 2018 11:36:06 -0400 Received: by mail-yb0-f194.google.com with SMTP id i13-v6so10065139ybl.4; Mon, 07 May 2018 08:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=slf1J3iHpjNeA4Hre3fVutRjHc1MIIIvq7nrD4k34rM=; b=jzbjUguMyPfC7OG+Y7MjACzVW+8Wlo3yhczhz9LxwllDJN2Z5fheH4rV865HhS5U5i UI2SqQeF7kmDunxiuHACjTvvUc3L4maKbIrU2CyeLSXbC4pjV3cHjxKYI4GsHCWz3BmG +41Cv6JB8s9G29sRgO19gDLYToujHFosYT6VTFM26ouQYkJdyopoAo6y7Wozvlav88+k qhr5hfXh3GyBkUAXBgY7gbAHypORi5XylhK+OSnil+rnkE/NjJS68KqGV8Gx+lpf7SIX /+Y+cX3VDxsZwL+P2RfQYwWVLsZ+LiUq5UQaeMYddbNm2i8Ch66RBFclzHjExroD7YTq SXyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=slf1J3iHpjNeA4Hre3fVutRjHc1MIIIvq7nrD4k34rM=; b=KLwnQUYfvU24lN9sfCf89G7it9+vi7CGjs+YdIutzksGPderhmocD6erDz6M4Gp5wp qJqznMKWPmUlRutfdWPHlEpmF79ckeVHXn80bIiHYTbb2W803SNLeG0gXe8io31JtVUk p2DactMWAROafv+5t9K7HxIPY4BhFHoazOaSQo+u2Y8TxZtwejWayy4y/Dwl2OvgmLs6 qvt5xkwRjq8x7AYzZz2uFbD6/o9hjJdcOhlvqM3EUgCudVpxkS2iSU9wyw+b6L4tjt+B aoV+/7Nxb7OtYbm8KWZUt9hrIoyLg4XzhUXS7SlVpDDtM7TeU1obQ+JsLNEGac8wqJHG rbYQ== X-Gm-Message-State: ALKqPwfTT36t5BwVAktRM/NalgCwrLEh+vnO/+tgrzmp/sk6UTU55kBL Qw761wLs9bm66/5Fsym0EOo= X-Received: by 2002:a25:854b:: with SMTP id f11-v6mr1233010ybn.358.1525707365806; Mon, 07 May 2018 08:36:05 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id c205-v6sm7736864ywb.42.2018.05.07.08.36.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 08:36:05 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray Subject: [PATCH 3/7] gpio: 104-idi-48: Utilize for_each_set_port_word macro Date: Mon, 7 May 2018 11:35:59 -0400 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace boilerplate code in the get_multiple callback with the for_each_set_port_word macro in order to simplify and improve clarity. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-104-idi-48.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index 2c9738adb3a6..414dc8de0bd8 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c @@ -94,41 +94,17 @@ static int idi_48_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, { struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip); size_t i; + size_t word; + unsigned int offset; static const size_t ports[] = { 0, 1, 2, 4, 5, 6 }; - const unsigned int gpio_reg_size = 8; - unsigned int bits_offset; - size_t word_index; - unsigned int word_offset; - unsigned long word_mask; - const unsigned long port_mask = GENMASK(gpio_reg_size - 1, 0); unsigned long port_state; /* clear bits array to a clean slate */ bitmap_zero(bits, chip->ngpio); - /* get bits are evaluated a gpio port register at a time */ - for (i = 0; i < ARRAY_SIZE(ports); i++) { - /* gpio offset in bits array */ - bits_offset = i * gpio_reg_size; - - /* word index for bits array */ - word_index = BIT_WORD(bits_offset); - - /* gpio offset within current word of bits array */ - word_offset = bits_offset % BITS_PER_LONG; - - /* mask of get bits for current gpio within current word */ - word_mask = mask[word_index] & (port_mask << word_offset); - if (!word_mask) { - /* no get bits in this port so skip to next one */ - continue; - } - - /* read bits from current gpio port */ + for_each_set_port_word(i, word, offset, mask, ARRAY_SIZE(ports), 8) { port_state = inb(idi48gpio->base + ports[i]); - - /* store acquired bits at respective bits array offset */ - bits[word_index] |= port_state << word_offset; + bits[word] |= port_state << offset; } return 0; -- 2.17.0