hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/gpio/gpio-xra1403.c
....@@ -1,19 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * GPIO driver for EXAR XRA1403 16-bit GPIO expander
34 *
45 * 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/>.
176 */
187
198 #include <linux/bitops.h>
....@@ -94,7 +83,10 @@
9483 if (ret)
9584 return ret;
9685
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;
9890 }
9991
10092 static int xra1403_get(struct gpio_chip *chip, unsigned int offset)
....@@ -129,6 +121,7 @@
129121 struct xra1403 *xra = gpiochip_get_data(chip);
130122 int value[XRA_LAST];
131123 int i;
124
+ const char *label;
132125 unsigned int gcr;
133126 unsigned int gsr;
134127
....@@ -144,12 +137,7 @@
144137
145138 gcr = value[XRA_GCR + 1] << 8 | value[XRA_GCR];
146139 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) {
153141 seq_printf(s, " gpio-%-3d (%-12s) %s %s\n",
154142 chip->base + i, label,
155143 (gcr & BIT(i)) ? "in" : "out",