From patchwork Sat Mar 17 15:50:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Breathitt Gray X-Patchwork-Id: 10290885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4564760385 for ; Sat, 17 Mar 2018 15:50:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 374A228E90 for ; Sat, 17 Mar 2018 15:50:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ADB728F77; Sat, 17 Mar 2018 15:50:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C78E328E90 for ; Sat, 17 Mar 2018 15:50:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753651AbeCQPu2 (ORCPT ); Sat, 17 Mar 2018 11:50:28 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:37605 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753642AbeCQPu1 (ORCPT ); Sat, 17 Mar 2018 11:50:27 -0400 Received: by mail-yw0-f193.google.com with SMTP id y23so8919858ywy.4; Sat, 17 Mar 2018 08:50:27 -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=5S57FZrDn18lTmUv3cK/UjtCHjKej2R0jpXyStLW50c=; b=Y9NdzJzfQrLYtZBA27fWdeIVjZUnlanb6/7cniFQHAbNymQiTxuJ76fNeJVczZoWH0 YQbdZGuyHFRql0xTbmAjk9A2eJOo8NBRMAm61yxp6yasYEI3sDhUR4jLLIMURvtgWTHn SL6xFlUpdXBpK39ELI4a3pfKa+HvjRz1ioz4UhHmvgKusylToUv8z6b+Z1Rav/R/SbHR m0r+FIsuqwm2dO4FDCWztCsOiprO2GQiMqM1qodjzYgZ3IjG+qAieM0q1dogmApb3MHC hFiCd30bAViie/vFAwA1TKxUExv6FGmOBmdv+CKaJgnjIhF+k1gF64P+KLIYOFJcsOVE 0XRQ== 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=5S57FZrDn18lTmUv3cK/UjtCHjKej2R0jpXyStLW50c=; b=g8PxkCYvCedByauL4i2k09J1wXGAvj03Ijt1RmMQtwGtidmBueooeZDVk3u2RTFqln /GAGb9/yj7WsvGEZUxtTz4qJi3lx+o2MGswpgqIn9Hs/cnXBnxpTcd03Z8+FwKUvA5SD mWUetd+NkoPoDjWunJB4fs6kLauoYVt/d1ijtF2l24H9kJZByRFphoj3X7VPoC1Z2Ly+ ayk9X1KF8cCKxdMPxVINuO8uubajtCT0YqOMFws8BuJAOKfq0zeIK61HkguLWYN4q399 F0DZ1C7dS8hS7p4NBtnbzW9JFB5KacurFbRm1qcHNJZUo4rRVtAdNPF+7d1A3qTz9c64 WM0A== X-Gm-Message-State: AElRT7HSwPz22tg8q+ekcdd275Q44xiwE8lAG/p5Hapu64RctrsyzRu5 QLLi7oVkIWNXYYwTcFWcKIE= X-Google-Smtp-Source: AG47ELvLwpo6hd/N5pUnIvMAMzpwuKHxQNfa2UfF64+062ppzM2bTEk6gTu9gESMAk+8nbhK5jv2vA== X-Received: by 10.13.218.194 with SMTP id c185mr3502901ywe.393.1521301826853; Sat, 17 Mar 2018 08:50:26 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id r12sm225005ywl.108.2018.03.17.08.50.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 17 Mar 2018 08:50:26 -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 v3 2/8] gpio: 104-idio-16: Implement get_multiple callback Date: Sat, 17 Mar 2018 11:50:15 -0400 Message-Id: <486eb9bad0440ed305a78d9fc990728cbeb7d43e.1521301345.git.vilhelm.gray@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: References: Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ACCES I/O 104-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 104-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-104-idio-16.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c index 2f16638a0589..5de5819e5156 100644 --- a/drivers/gpio/gpio-104-idio-16.c +++ b/drivers/gpio/gpio-104-idio-16.c @@ -90,6 +90,20 @@ static int idio_16_gpio_get(struct gpio_chip *chip, unsigned offset) return !!(inb(idio16gpio->base + 5) & (mask>>8)); } +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); + + *bits = 0; + if (*mask & 0xFF0000) + *bits |= (unsigned long)inb(idio16gpio->base + 1) << 16; + if (*mask & 0xFF000000) + *bits |= (unsigned long)inb(idio16gpio->base + 5) << 24; + + return 0; +} + static void idio_16_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct idio_16_gpio *const idio16gpio = gpiochip_get_data(chip); @@ -244,6 +258,7 @@ static int idio_16_probe(struct device *dev, unsigned int 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; idio16gpio->base = base[id];