Received: by 10.213.65.68 with SMTP id h4csp665917imn; Thu, 22 Mar 2018 06:06:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELv9LH5zlUQNGYLUVmhakFFf2cGx+gXEuoLGvjvQbN6286PvHDMULZpSv66izpw/U4Bz8olL X-Received: by 2002:a17:902:8601:: with SMTP id f1-v6mr25128125plo.379.1521723968241; Thu, 22 Mar 2018 06:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521723968; cv=none; d=google.com; s=arc-20160816; b=WBGR8FLnfuR4B62VhzTyMiEOMpCy6sAUGCsq9X3A+7XhMM2bv1gAOl21PwL4fcXS4y jdFlaoia+wZxeMVSGYkOkbb3H5GLI4wkt79UTwbcem3rYxHeQu1XM9pIypqkNxb/40XH 3FNxgE3a/CKQ1UifWVrqzjUhnxeqH+rGYvW9rLhKmXOX+CyVy9s6Ipy1FUg8dwyky5nk SgEpi5B+28Ef5Ymqgi/9Mp+fOupn+0K68kFVy0CTus5R0oyUtm0i0nmuUW0k6bB//xzi mVZnfWMc8JksiCqt7YpoxfB6cVBhpo8n1KDgj3pvqGnTR14x4vKexpuSgAT1JXvBpE4M I95Q== 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=+h8UT5Dqonzntc4wd2Fgi+xwBgZAHcaUa52pq621/nk=; b=MFS4D4GziX9t4Cu1s4uoMd40x0e4j6929hD4Vw23HFu/N52y8ERWD4rv1T5W9f+LM0 OkQdGZLjUkEr8jMTc+ff3FtfFD73skUEKb2hhMvrRxipbO/T0ec4CvGXMzoBiGZAO64p pV6Qwh3YKvXOoLPAfwrZCZRf5BtqmRNcu8M+f+HfBgSmjXc+f1o4wG7xxGuVYHpKUpfc usTyFloUp4dhglEFO5shqC3bUeeSjPy8+y4KF+sMF2nxXWIaIQi/uke8T0lHcXEYxjIr nas2uG6x8frAGrtVvkHTtxjQmXGa6OLfDLfqnk72utnqwwLFQcZ/1+4693Z4fBZWYXXR FFVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fzMgPN4Y; 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 h11-v6si6080116pls.261.2018.03.22.06.05.43; Thu, 22 Mar 2018 06:06:08 -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=fzMgPN4Y; 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 S1755205AbeCVNBb (ORCPT + 99 others); Thu, 22 Mar 2018 09:01:31 -0400 Received: from mail-yb0-f195.google.com ([209.85.213.195]:35567 "EHLO mail-yb0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755104AbeCVNAi (ORCPT ); Thu, 22 Mar 2018 09:00:38 -0400 Received: by mail-yb0-f195.google.com with SMTP id v66-v6so2881893ybv.2; Thu, 22 Mar 2018 06:00:37 -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=+h8UT5Dqonzntc4wd2Fgi+xwBgZAHcaUa52pq621/nk=; b=fzMgPN4YFbcb4TRKhuEdBKw1i9Xz1lbNug40mrv6OeXHv41UsP8A/hm/pbfjsHUuVr Yzw/5VCS5seqh11ncdzuj6cp6fLwZTYqkdoGsC8XLFwYJp9EavTn3SX2f6uM3QD5iQpk 51BLnNoY+qDoU1ET5U3OKh6iXDzFwGL49ZpMIxyER3eF4/byY8be+5VyrY9gDRoO62Zg gV0tf9tfyDgZmaN5UzhpCSYKJDUjdsnMemR7PyugUulqTC3SL9TmfCgICUp1yqB/z17L lfdElf6FXkwIEv+lXldjxMFLB52p5xW46sHwj3O0o+L/f4ai9eNaOCZuOrpUiBrYFN/g TBhQ== 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=+h8UT5Dqonzntc4wd2Fgi+xwBgZAHcaUa52pq621/nk=; b=G3SBN4af3xpgc+DHGcTJHLyBuUTL9Cl3DMmL161u9qOBm/AiI8YKsClV9T4WMn6CSa bnWSuxGGy0yebOiH+H8/fZKN1P76T0oOk/JI4TPRipjWE2WdK5C39rMu/SDgR8kcFhcm YkCnc2X9gB5WIxcepZtzbt3NMJgDv5Dt64Gwq/oWdAygkrgiDJuIpMQVQzIVUFeGyF9L gmpBaT4Q0Qcmsqan5g68raeB6F2eFKu3yCTfsy3/1lU+XlqGiWNtOoFHWA2ewTpVMT2W FSnHChU5YixGELLfEBwGi1i6QSgND5rkEAgBe8mLNF8179QRWerdaVHsAf+1IM3KM0Yd mzHQ== X-Gm-Message-State: AElRT7HWFgj4YsLow7hjnv76U1CzhQxGJJ8f/FzwglVWFh9lYtDwAUrl /rjVZ0ICuKYG6tNanrVbYps= X-Received: by 2002:a25:7345:: with SMTP id o66-v6mr11288017ybc.391.1521723637305; Thu, 22 Mar 2018 06:00:37 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id j187sm2395259ywf.87.2018.03.22.06.00.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Mar 2018 06:00:36 -0700 (PDT) From: William Breathitt Gray To: linus.walleij@linaro.org Cc: andy.shevchenko@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, William Breathitt Gray Subject: [PATCH v4 5/7] gpio: 104-idi-48: Implement get_multiple callback Date: Thu, 22 Mar 2018 09:00:31 -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 | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index add859d59766..f35632609379 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c @@ -14,6 +14,7 @@ * This driver supports the following ACCES devices: 104-IDI-48A, * 104-IDI-48AC, 104-IDI-48B, and 104-IDI-48BC. */ +#include #include #include #include @@ -88,6 +89,51 @@ 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); + size_t i; + 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 */ + port_state = inb(idi48gpio->base + ports[i]); + + /* store acquired bits at respective bits array offset */ + bits[word_index] |= port_state << word_offset; + } + + return 0; +} + static void idi_48_irq_ack(struct irq_data *data) { } @@ -256,6 +302,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