Received: by 10.213.65.68 with SMTP id h4csp286548imn; Mon, 12 Mar 2018 13:51:56 -0700 (PDT) X-Google-Smtp-Source: AG47ELtbQ5gcQcpaWFqfuD9UJyWptxLZzEXmdOGDr5W5fNBgSV2mnupUQcFx+CDV3CxL+Z16zAH+ X-Received: by 10.101.81.8 with SMTP id f8mr7628673pgq.13.1520887916242; Mon, 12 Mar 2018 13:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520887916; cv=none; d=google.com; s=arc-20160816; b=Tm5zBORP5FfP1U1YGUD/8E3ouwA5Pnc7SJy8xD2g8LKrUCHE+wcTKXqp3BckrnF48k Pnu/aW7n8P1lyfCb/G+PFHnDFGLRjqkumvw/Krr/p6L2YhC15J47hgfSPZ/nWuIijrYn zzSoLtQset27GuYe8wVdkRDft0J1ftEJzpgqB50xMyKPMiR0wxsAZq1+/wQcIvPn8pxT oe4rB9XkRdx2qFYr1TJz2GefyLnZAq/DQ1cpim3B/iTAAzZfXiTtgdz0FeUW7PgrQnAy 6waklgfFOQ8wCdBLJWdDvA6eEVQmrGEy2qgiLnAvZeura4KMxNIShp+AJEcofs1XvbOB +O3A== 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=9f18JN+BWd/gT8Hh1qfUHDGD7k3kMF/bONsOVu5XxaA=; b=fw+Q+zWYkxuIqUU0wsYZ0IFzkQ2rIwKU56g+hlnfwhnxGyPHESGo6pxj32AEsSBL8G c6470wUcv7rAhYi8Jk1oLyADbADnsErfOVhqfDB0VfCpXWhFg9BVmpX4A0409W2N16NP oY+eg+F9aLMo+y23fw7Rwy8yWQTreWZrq1G29cJemwiaL7vF+5a4R3s8NqWIW2zxeiaG SgMNdcqTBS82iI+Z5C/UApzoNAH4solt3y7Hxp8O/mikjrMhJLiObYhC4bc4eSX0eCPM ZrW2GFsSE/Dzfh8t7pfKc/292ws8eFWHoHDmscf1YSLrdZ2KJi8Q8rMYw1cqkn/If5AG IGkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RD2996o4; 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 i11si5431601pgq.332.2018.03.12.13.51.42; Mon, 12 Mar 2018 13:51:56 -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=RD2996o4; 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 S932546AbeCLUuU (ORCPT + 99 others); Mon, 12 Mar 2018 16:50:20 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:33751 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932525AbeCLUuD (ORCPT ); Mon, 12 Mar 2018 16:50:03 -0400 Received: by mail-yw0-f194.google.com with SMTP id l200so6401097ywb.0; Mon, 12 Mar 2018 13:50:03 -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=9f18JN+BWd/gT8Hh1qfUHDGD7k3kMF/bONsOVu5XxaA=; b=RD2996o4D/JrVS0wJM+6zwvXVYEkbt8z/wbrAObUBWZU0EYplTcBB6iuf/x8gzBhPt Z2xZ4x+Eh10AYE0dahzqYe95TdGngUybNNhc6iUySB/MBsajgrYdt/pdOez9qsOhxYBL bCOHp/14K84wxRwP/IiNlKI+gXUXyqTYCmEedCLyH+zGwkpYtPiuDkQhXebJ4xiZeHEw XCcFqfUq9N4MsDTHPaj7wQy4OruVUuX3xH30Y3V0KaxWcuQ3Y8JCZqNx6rRQdHlSXSQs VlBZatwuXHkMOAZiP+x9wgwJoHITo3vVtUjcP9LeyeBJyQIhTX9s6CJLBTxKVvBIr3vk 1MNw== 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=9f18JN+BWd/gT8Hh1qfUHDGD7k3kMF/bONsOVu5XxaA=; b=Hvj9w2BsTWjOpq5f/rINlcP1nd6/fHZC6KLoz9mMdQDEIj92Jm/jp7YKNVAHDk83Sq Z9aCAlnNuj4F17+QQA/iFM5rQ5qr4cucwUeqUYPqeV3LU696JJPr3YkInjcTCTj5hMLy VtQg6gutrPK4JcuWZOZA9RwvJoSjk1fGZeSIwBAnVNPX0KwHqtQo8sNt9a68ppGA7uel uEcNDCWlCpCg2H8eQ+VVXTsFtkZOMZH6jzb4AapSVKxwKiLtKRRDEgGuXyv3IQj7e/Cg QXUOBINwZEc31fhggTjqa+TvS4UnCv26w4BkNLnSZFoqRvKvNsXQdxi7j9+xuC2SQAm4 +jAw== X-Gm-Message-State: AElRT7HjCNPmOmqmrbwtczs/Hf3WOC3F606NQ9ZsfCJKw2/RlPMiWcM3 +y+KXCBn8HhH6QbxPJG9iG0= X-Received: by 10.129.114.213 with SMTP id n204mr5761216ywc.513.1520887803261; Mon, 12 Mar 2018 13:50:03 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id e188sm2629363ywd.37.2018.03.12.13.50.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 13:50:02 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, William Breathitt Gray Subject: [PATCH 6/8] gpio: 104-idi-48: Implement get_multiple callback Date: Mon, 12 Mar 2018 16:49:57 -0400 Message-Id: X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ACCES I/O 104-IDI-48 series of devices provides 48 optically-isolated inputs accessed via six 8-bit ports. Since eight input lines are acquired on a single port input read, the 104-IDI-48 GPIO driver may improve multiple input reads by utilizing a get_multiple callback. This patch implements the idi_48_gpio_get_multiple function which serves as the respective get_multiple callback. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-104-idi-48.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index add859d59766..d82139c3117a 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c @@ -88,6 +88,46 @@ static int idi_48_gpio_get(struct gpio_chip *chip, unsigned offset) return 0; } +static int idi_48_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask, + unsigned long *bits) +{ + struct idi_48_gpio *const idi48gpio = gpiochip_get_data(chip); + unsigned int i; + const unsigned int gpio_reg_size = 8; + unsigned int bit_word_offset; + unsigned int bits_mask; + const unsigned long reg_mask = GENMASK(gpio_reg_size, 0); + unsigned int port; + unsigned int in_port; + unsigned long port_state; + + /* clear bits array to a clean slate */ + for (i = 0; i < chip->ngpio; i += BITS_PER_LONG) + bits[i / BITS_PER_LONG] = 0; + + /* get bits are evaluated a gpio register size at a time */ + for (i = 0; i < chip->ngpio; i += gpio_reg_size) { + bit_word_offset = i % BITS_PER_LONG; + bits_mask = mask[BIT_WORD(i)] & (reg_mask << bit_word_offset); + if (!bits_mask) { + /* no get bits in this register so skip to next one */ + continue; + } + + /* compute input port offset */ + port = i / gpio_reg_size; + in_port = (port > 2) ? port + 1 : port; + + /* get input bits */ + port_state = inb(idi48gpio->base + in_port); + + /* store acquired bits */ + bits[BIT_WORD(i)] |= port_state << bit_word_offset; + } + + return 0; +} + static void idi_48_irq_ack(struct irq_data *data) { } @@ -256,6 +296,7 @@ static int idi_48_probe(struct device *dev, unsigned int id) idi48gpio->chip.get_direction = idi_48_gpio_get_direction; idi48gpio->chip.direction_input = idi_48_gpio_direction_input; idi48gpio->chip.get = idi_48_gpio_get; + idi48gpio->chip.get_multiple = idi_48_gpio_get_multiple; idi48gpio->base = base[id]; raw_spin_lock_init(&idi48gpio->lock); -- 2.16.2