Received: by 10.213.65.68 with SMTP id h4csp286640imn; Mon, 12 Mar 2018 13:52:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELug1qQ7ivylpGmAsBy+Yw/+kgfvO+vyWWYUB/hXMIyPXOh8T2rxoOy9vETGLl5kBoWEBFY2 X-Received: by 2002:a17:902:9a05:: with SMTP id v5-v6mr9433187plp.69.1520887933182; Mon, 12 Mar 2018 13:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520887933; cv=none; d=google.com; s=arc-20160816; b=a1kooPJs5AavfV7/U6C21z+ZV8+u8RcISBxcAJMQKl+qX4hMFLuG2ONNkBExxpi0Uq Jlv3mTslVlaZNkcc2p2M/CibtQlP4x2woqhbMzi6xRR9YLquTMk3RWHA6U0Th20xHpcu hKHtwdqWq+Gk7mByuYlxVo0LiHx1O8i96+bPM2XLVH3imWke5V0S8Lomw2ApW/7VUjZ0 4kA+ycQXTq/jrYoJha5unuryXBWOo/ZrsxN/xtiJdeAq7FwIHQg+a4gARRWcFbaqyzS0 hz34L5cgPfDg116QoG+fpO/OO2UIGRf8kUv+DkZWfQO6uGq9Wih1Q+qmvOAsa5sgkr11 v0og== 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=VY12YUu6hlk5Bq7RxTzYRv59jkAS3swOR0Yq8By0ql4=; b=Z/mb85LzDamnJo+TREg/SAEnSwIb74b0Bi8LcW+CrooGueYvBXIg85TFO/aYJkpxqg JzwQTa4a6UqA43XE9k9zqUL7N8fZVQZb1j+ochen4UFFCzEoGOtC5cTZehUPyEpuYTYN Csy/IMOyQAmTSVFUJX+qLVetR2TDfi5lKtkaBIzTHrh1PenUioEtt8lAMNniOuOnt145 hwHvIX2CVgNfDjzvAPHqbdbEo5DnlYU7QW6h1LRTFKJrfBjA9jVxJFlvIGW+11N9wHSZ 5HKmHsH2l6Mp8BWWP4/i79hUuey8QJxc4A3j9BufxtTIY484faz2HEVXbw7SvSYxTDmp M+Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jDqpjZzo; 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 e3-v6si2977998pls.530.2018.03.12.13.51.58; Mon, 12 Mar 2018 13:52:13 -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=jDqpjZzo; 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 S932487AbeCLUtQ (ORCPT + 99 others); Mon, 12 Mar 2018 16:49:16 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:33679 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932274AbeCLUtO (ORCPT ); Mon, 12 Mar 2018 16:49:14 -0400 Received: by mail-yw0-f196.google.com with SMTP id l200so6399457ywb.0; Mon, 12 Mar 2018 13:49:14 -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=VY12YUu6hlk5Bq7RxTzYRv59jkAS3swOR0Yq8By0ql4=; b=jDqpjZzoeDOCRFYPyAnQV06l3UEoxFRIVt6PklIWnDUfKdp4LSK3VLE/ExrdTWTnII IkYmB9LBCZHaD/sbMukUMITbT3x+ZGLchRw3foZrOJri14xcn75bn+Fk6HEFtYnybD0r tuVKvcB6vMzK8sL7XMcU13el7ufrtoXeyKBWjRciqs8O91jnwPzyCNyKf8vq+L2N8Eql AS+nF7C5XResGhnpa30XPbUG8GND1hqihqYzVmeegAmh8PXHp6AkSbVuS4lU0fs2gvX2 oMhDpW1DIsPgWeJ/0TSM27utroEKqZbje/l0R/DwmzS/C1l3f007NX+cfszht8wu8ldN q4qQ== 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=VY12YUu6hlk5Bq7RxTzYRv59jkAS3swOR0Yq8By0ql4=; b=JkQMopFs5c7CZC0C/w3G9JXGGzB0QpKppkX5vtkAq+853zLSztn4GIczBwuk0lP3qn BpZDN59qTtkCXCauqNSUMhARTKTp1VNe4BIfqTaled2KHoXDHfzlEOvi/LWi7Aun0ZWP xJ6tvBjXWKpaXchZfbrcRLIVTjv7RulwtLQBRZ+SOL7cDfMFWmJ9S4s3Mm3VCC3JJ/p2 frEwJDhABHiTQ/MXMfvcRdaPTkc7y68bfSejWHcLbqqL2uIc8jLQUhRNcWiCbX3NAUNI NUIJc8yzPUkN/JeH6lG7LcrSahV2/30PMsZraImpPrF0K9F38PTPPD7Glx6pjr89pgIh ey1A== X-Gm-Message-State: AElRT7Elpn30zZCoZrqfdXPrQYQiS9C4g/IY9lrq6LeYU4v3DUn0iRs9 jeqcABE8/MZhdSS8FJgYcKQ= X-Received: by 10.129.107.11 with SMTP id g11mr2029436ywc.459.1520887753717; Mon, 12 Mar 2018 13:49:13 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id q11sm3215215ywc.106.2018.03.12.13.49.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 13:49:12 -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 3/8] gpio: pci-idio-16: Implement get_multiple callback Date: Mon, 12 Mar 2018 16:49:07 -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 PCI-IDIO-16 series of devices provides 16 optically-isolated digital inputs accessed via two 8-bit ports. Since eight input lines are acquired on a single port input read, the PCI-IDIO-16 GPIO driver may improve multiple input reads by utilizing a get_multiple callback. This patch implements the idio_16_gpio_get_multiple function which serves as the respective get_multiple callback. Signed-off-by: William Breathitt Gray --- drivers/gpio/gpio-pci-idio-16.c | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c index 57d1b7fbf07b..8c5ec301c7ff 100644 --- a/drivers/gpio/gpio-pci-idio-16.c +++ b/drivers/gpio/gpio-pci-idio-16.c @@ -103,6 +103,53 @@ static int idio_16_gpio_get(struct gpio_chip *chip, unsigned int offset) return !!(ioread8(&idio16gpio->reg->in8_15) & (mask >> 24)); } +static int idio_16_gpio_get_multiple(struct gpio_chip *chip, + unsigned long *mask, unsigned long *bits) +{ + struct idio_16_gpio *const idio16gpio = 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 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; + } + + /* read bits from current gpio register */ + switch (i / gpio_reg_size) { + case 0: + port_state = ioread8(&idio16gpio->reg->out0_7); + break; + case 1: + port_state = ioread8(&idio16gpio->reg->out8_15); + break; + case 2: + port_state = ioread8(&idio16gpio->reg->in0_7); + break; + case 3: + port_state = ioread8(&idio16gpio->reg->in8_15); + break; + } + + /* store acquired bits */ + bits[BIT_WORD(i)] |= port_state << bit_word_offset; + } + + return 0; +} + static void idio_16_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) { @@ -299,6 +346,7 @@ static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id) idio16gpio->chip.direction_input = idio_16_gpio_direction_input; idio16gpio->chip.direction_output = idio_16_gpio_direction_output; idio16gpio->chip.get = idio_16_gpio_get; + idio16gpio->chip.get_multiple = idio_16_gpio_get_multiple; idio16gpio->chip.set = idio_16_gpio_set; idio16gpio->chip.set_multiple = idio_16_gpio_set_multiple; -- 2.16.2