From patchwork Mon Mar 12 20:48:51 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: 10277439 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 DF94360211 for ; Mon, 12 Mar 2018 20:49:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0D5028C22 for ; Mon, 12 Mar 2018 20:49:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE20E28E55; Mon, 12 Mar 2018 20:49:31 +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 6AC7328C22 for ; Mon, 12 Mar 2018 20:49:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932451AbeCLUtE (ORCPT ); Mon, 12 Mar 2018 16:49:04 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:37029 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932274AbeCLUtD (ORCPT ); Mon, 12 Mar 2018 16:49:03 -0400 Received: by mail-yw0-f193.google.com with SMTP id j143so6391792ywb.4; Mon, 12 Mar 2018 13:49:02 -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=AWMZdDJW2zxiUpccHlrG6FUHoju3CZK4i2ZptjXAbEzMVFr5v2T+lHr4efGq3HaNEP p6aq5YJx2UREJ8B7VY+vBfRq/paSlPn7CxG5sVA3x5M/Awmoz3jLqcyh8/13IaQpneo3 oKr4HM4AwCdeFefLWI3TsEpsdDKIiuaHfQLs/BRj3wL3ZuMyfvcY8g4v7XsfTPTr6KRh cg5WwKiOCRAlno5JJngOUcWdexFZwhICds1dS++ey6n3wUiNIhConCcLCccslfBf68Ch alMjWDdQNIAYuPNv+MF98aoICnRlaFX1qZulKalu6ZBWN6vfGsjd35G7u6ExgJevQiti OBqw== 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=O5BrsE93+uBPH5Rg34E2GXt6pi21MlpiJuzq4UtbQEFjCxe1Fk/Cv285fCCJe8zjKD myDRAYfz39ogQduEFRE1bnjq1Dx/4pbbuS8yVQWcSbYOOJUpey4MbaEnpJO9cYCHa+HO 0pM+HhxAQ/muZwnXr8RuXm1z6gZZxYmp1n3D3fhWGpt0bPjpkbzDheKD4UjinLFZ5+rp wAXjfE7LvlliJcYD9Hfa2+qb5TlHLz1OxV0DwVv2pOMkqB3txiRH0dsM0pZIFQb0ArTf 4MdySk3j+MrLWoe5nUbloxy0UGbEUFgkZm2xP7wD2q8fpdtM5Co5yLgXAKhtkpbsCbKn fnYQ== X-Gm-Message-State: AElRT7FxY2UwEQJD7aXG0reaAGTIaRvYmFbosy7EsZc/XvFkRyIgDgRb VnCSgHSPwICt29SsalbNMmY= X-Google-Smtp-Source: AG47ELsc7vNXuPDLhvlsvr7ZKbtt5DJFUtFFtFx3YLaXAxkK9B/e/frxcOQT9oyWeytWYH8y6ZkTyg== X-Received: by 10.129.69.10 with SMTP id s10mr5639124ywa.145.1520887742479; Mon, 12 Mar 2018 13:49:02 -0700 (PDT) Received: from localhost ([72.188.97.40]) by smtp.gmail.com with ESMTPSA id h7sm3112890ywf.2.2018.03.12.13.49.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 13:49:01 -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 2/8] gpio: 104-idio-16: Implement get_multiple callback Date: Mon, 12 Mar 2018 16:48:51 -0400 Message-Id: <486eb9bad0440ed305a78d9fc990728cbeb7d43e.1520886945.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];