Received: by 10.213.65.68 with SMTP id h4csp38808imn; Thu, 15 Mar 2018 08:54:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELs4/QEjh+WhhnWJ5XmF6/BxxTMqNN9ZZGxAGglnX1GpZ03kTIT8JNMNOzngDeEQpictPDCX X-Received: by 10.101.82.1 with SMTP id o1mr7207713pgp.37.1521129297912; Thu, 15 Mar 2018 08:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521129297; cv=none; d=google.com; s=arc-20160816; b=ZvUvCtSnWRjJ5PZ/JT/RsCt/GV7hj8Jn9P0kLey6BSVY4NOn8jHkMvGlZHFQm+w+w7 rt+NaAqBx6DF64o26BExj2XVzIfA72+T5Vjkjo46bJ0Uru9L8ZP05gd7oyPGoYwSj68H OHOW47nrnPrRmVOOlPMrsOyrGBWkh6Eo4pmWH73a6Ns1g0aI/XxccMmmDdR0NH/Yl2KC 0SDMGMehTmsscZGxjiBHAFr9Gvy88zBBXXNjpGB/i1uks6ZJJSJR8/lLv24Dzo9tXiaF xfQnXt+NCSmoYXdvCF5Z93SeX1hgPaE1f4xikpO1mKgX2zp5H0pXrzsBp/kF/HQTsD4n AabA== 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=rGzDOGiFHbXxrpPvsk2rmMzjICyw2CxgzfYECs2EGrU=; b=tUePkL6w5DwI6Z6iQVoYeg2uGAQRnWxlyLAODpvfdrvTVSHmkp0LjC9xbqeHs/FPsr B2C7zQCsTSyksn4CieRjQ0p1s2qI6iNT9U9dNZJMKJyY8WsQooLFOATvqoSfvIQQK91q oqf2uCpSjnO13ljzMb2KaJaqFPfdAw984dJojhpD60udPc4BNw/Vl8MZ7mtJnFuh0vNu Y3LYlwZ2M9eVlV/WS/vuz7Z92PDOPubGo9ksScyi0Bha7DIGbHqNOG4vuE0tTqF8pUre n8ttiDc7FFkS2GjQiWYGAsnDPKRJ2EL6vmieSi2y60kYs+wy844hrRAnMT3B/UpoO38Y zU+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Gby6Ug+Z; 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 h10si1539382pgc.296.2018.03.15.08.54.43; Thu, 15 Mar 2018 08:54:57 -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=Gby6Ug+Z; 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 S932789AbeCOPx0 (ORCPT + 99 others); Thu, 15 Mar 2018 11:53:26 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:35829 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932755AbeCOPxY (ORCPT ); Thu, 15 Mar 2018 11:53:24 -0400 Received: by mail-yw0-f193.google.com with SMTP id c20so4927582ywa.2; Thu, 15 Mar 2018 08:53:24 -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=rGzDOGiFHbXxrpPvsk2rmMzjICyw2CxgzfYECs2EGrU=; b=Gby6Ug+ZHxa9xSX3116XI/H6TTYHTu/tTEIbp7Ucp4EjeQgepwzJWRwPqTwRDfS5Zc M7jKrD6AbU4L16iHOhGVjhBOYRkz2J4mXZewWyh4pOjooX3FOtJPAwkVpNk87ww71FCr pq6oeWf9IDjRjStXACdbdmpA7aBoB8ak8dZobBZd+HN2pqb16tGtsbu5sgQJLEGCVjAT iEbTJkanSy7witg/0q6H9Q3NeWM7lI1giQl3vIkQBhMTZTwRF/S9HgJRarzDg5k3loKi dO6Sv/tuQcwp0A5tN0dGaoC5cKoc1UixB0sQ5EyCZvASHafi1TqkGO1VbqwQBq4+d/+X ZGKg== 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=rGzDOGiFHbXxrpPvsk2rmMzjICyw2CxgzfYECs2EGrU=; b=iJn38ifibzx8aQE3eBGeIndNBISmhJrXVAsaXMXB1pLE+TYF/haZE6fcDym8XxpxSb soi7BsVt/CAPWnRFx+ar5B5GIM9aD8AZD9h/qLSZQ5BJSFe1dtX3Vqhpn9wQhflG2yK7 2ssWilnlgsT59lQgxnj2mttHElq0+cDwKWsMNfCDBvIqmIoQGfd47OxR5x5K5jK0x0uv k2Qa79WH5sgzOeu7/oXJera/USWVRiWQAAy9KbXDttepDp4icVBfpdrdzSAp/nnZlyca Qz3h9BCMF7WVcklwSS0AOHh9owA4AY5zSrhebhKO9Rjnw7Lr/yp4i3s2tSleqQ23VkVJ pZ4g== X-Gm-Message-State: AElRT7H1ALdKC10zMp8tDd2L9LMaFpXHCTpr0J8HkmM7yDTyVa9cF2W1 lIJx2eXwRNLP5OkDp2Jb5Mo= X-Received: by 2002:a25:ad96:: with SMTP id z22-v6mr6142115ybi.296.1521129203836; Thu, 15 Mar 2018 08:53:23 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id y195sm2071527ywy.103.2018.03.15.08.53.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 08:53:23 -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, linux-iio@vger.kernel.org, William Breathitt Gray Subject: [PATCH v2 6/8] gpio: 104-idi-48: Implement get_multiple callback Date: Thu, 15 Mar 2018 11:53:17 -0400 Message-Id: <5ec68441ce758b17c21264a1a1bb5ab98b5263e8.1521128287.git.vilhelm.gray@gmail.com> 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 | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index add859d59766..1beb6b0591ee 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c @@ -88,6 +88,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 mask_word; + const unsigned long port_mask = GENMASK(gpio_reg_size, 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(idi48egpio->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 +301,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