From patchwork Thu Mar 15 15:46:54 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: 10284887 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 2954860386 for ; Thu, 15 Mar 2018 15:47:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18CF4260CD for ; Thu, 15 Mar 2018 15:47:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D5E528AC4; Thu, 15 Mar 2018 15:47:17 +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 A9166260CD for ; Thu, 15 Mar 2018 15:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932627AbeCOPrD (ORCPT ); Thu, 15 Mar 2018 11:47:03 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:41196 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932427AbeCOPrB (ORCPT ); Thu, 15 Mar 2018 11:47:01 -0400 Received: by mail-yw0-f196.google.com with SMTP id w12so4898522ywa.8; Thu, 15 Mar 2018 08:47:00 -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=CnxkFjgZaHXIEfsqapDWQ8rOAoLNIb25JHbTqRCojiLT9YatSjR5zQaDu4vNWzmtQb iIpTrNVEo61qx2o5IX21aPGz+AMWQkh6eSrBYxP1cLmKjBtNmmbSHIfbPp78AuRKeJMc PWVcmuP7niMYRG46FKG80EutZOuVjWkAgSoV0jrzsyXX6rbjZ/2Zr0E+ChDTA8FY2MRV IZ2k/GP90EAzaFhc3hp7ELVhGeAJWQ+2dD4F5s2hB5n941YbbaGIZhO+4R5HL3SqPJQB LLovIS3IUxsoctvd3ODFj+OUh0OzaWhmkZfu7Hjt4TBhgevbNjMp2QNxBXi8ljJ3fJ/x lxIA== 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=GnCBovAreUHYNvMn5Hx7sxoMn8Uxc/63SQBGON/io15L46Y0jRzDU9BQn/eqLglZeU Tg212zcXZOQg6vMMICgK8nXd0Q9I812IHZl+l1lctFgdpaLh69rd4/QOlLZKTD2LhAtn YI6CrjE244H6GqgtPN0fypQe2YpmaU6yBs3c0MFWVewaODNNmGdbo7XltpzuihhViGL2 N5tnke4bCOZyCJDpl6IaCHzdF2TMjNWTGF+8fM36SsjCQeQuXe2u7BQI1nvpif80GeWd TOSokbXRMvQBNt+xceT4Ceh3BLmE1jFGZUpaZqu5Req26BdLyVWug6ELjYxE/VYwPKXy lHKA== X-Gm-Message-State: AElRT7GhOR58YuiTdY1fILpalDOTmlhxBR0SyumzXl07HU8JiZ+rKY68 KH0kE1eUntP35heNMQNfUj79wg== X-Google-Smtp-Source: AG47ELsusxOt6zuanODwmjCx+6Vxpcj15RZpGb45/jswpIUeGhowDD/Ci/0Y//Jyvzvcpk/eeZbEmQ== X-Received: by 2002:a25:6843:: with SMTP id d64-v6mr991636ybc.268.1521128820386; Thu, 15 Mar 2018 08:47:00 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id i123sm124624ywd.73.2018.03.15.08.46.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 08:46:59 -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 2/8] gpio: 104-idio-16: Implement get_multiple callback Date: Thu, 15 Mar 2018 11:46:54 -0400 Message-Id: <486eb9bad0440ed305a78d9fc990728cbeb7d43e.1521128287.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];