| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * GPIO driver for EXAR XRA1403 16-bit GPIO expander |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2017, General Electric Company |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 8 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 11 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 12 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 13 | | - * more details. |
|---|
| 14 | | - * |
|---|
| 15 | | - * You should have received a copy of the GNU General Public License |
|---|
| 16 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | 6 | */ |
|---|
| 18 | 7 | |
|---|
| 19 | 8 | #include <linux/bitops.h> |
|---|
| .. | .. |
|---|
| 94 | 83 | if (ret) |
|---|
| 95 | 84 | return ret; |
|---|
| 96 | 85 | |
|---|
| 97 | | - return !!(val & BIT(offset % 8)); |
|---|
| 86 | + if (val & BIT(offset % 8)) |
|---|
| 87 | + return GPIO_LINE_DIRECTION_IN; |
|---|
| 88 | + |
|---|
| 89 | + return GPIO_LINE_DIRECTION_OUT; |
|---|
| 98 | 90 | } |
|---|
| 99 | 91 | |
|---|
| 100 | 92 | static int xra1403_get(struct gpio_chip *chip, unsigned int offset) |
|---|
| .. | .. |
|---|
| 129 | 121 | struct xra1403 *xra = gpiochip_get_data(chip); |
|---|
| 130 | 122 | int value[XRA_LAST]; |
|---|
| 131 | 123 | int i; |
|---|
| 124 | + const char *label; |
|---|
| 132 | 125 | unsigned int gcr; |
|---|
| 133 | 126 | unsigned int gsr; |
|---|
| 134 | 127 | |
|---|
| .. | .. |
|---|
| 144 | 137 | |
|---|
| 145 | 138 | gcr = value[XRA_GCR + 1] << 8 | value[XRA_GCR]; |
|---|
| 146 | 139 | gsr = value[XRA_GSR + 1] << 8 | value[XRA_GSR]; |
|---|
| 147 | | - for (i = 0; i < chip->ngpio; i++) { |
|---|
| 148 | | - const char *label = gpiochip_is_requested(chip, i); |
|---|
| 149 | | - |
|---|
| 150 | | - if (!label) |
|---|
| 151 | | - continue; |
|---|
| 152 | | - |
|---|
| 140 | + for_each_requested_gpio(chip, i, label) { |
|---|
| 153 | 141 | seq_printf(s, " gpio-%-3d (%-12s) %s %s\n", |
|---|
| 154 | 142 | chip->base + i, label, |
|---|
| 155 | 143 | (gcr & BIT(i)) ? "in" : "out", |
|---|