hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/pinctrl/pinctrl-axp209.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * AXP20x pinctrl and GPIO driver
34 *
45 * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com>
56 * Copyright (C) 2017 Quentin Schulz <quentin.schulz@free-electrons.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License as published by the
9
- * Free Software Foundation; either version 2 of the License, or (at your
10
- * option) any later version.
117 */
128
139 #include <linux/bitops.h>
....@@ -153,13 +149,16 @@
153149 * going to change the value soon anyway. Default to output.
154150 */
155151 if ((val & AXP20X_GPIO_FUNCTIONS) > 2)
156
- return 0;
152
+ return GPIO_LINE_DIRECTION_OUT;
157153
158154 /*
159155 * The GPIO directions are the three lowest values.
160156 * 2 is input, 0 and 1 are output
161157 */
162
- return val & 2;
158
+ if (val & 2)
159
+ return GPIO_LINE_DIRECTION_IN;
160
+
161
+ return GPIO_LINE_DIRECTION_OUT;
163162 }
164163
165164 static int axp20x_gpio_output(struct gpio_chip *chip, unsigned int offset,
....@@ -366,6 +365,8 @@
366365 pctl->funcs[i].groups = devm_kcalloc(&pdev->dev,
367366 npins, sizeof(char *),
368367 GFP_KERNEL);
368
+ if (!pctl->funcs[i].groups)
369
+ return -ENOMEM;
369370 for (pin = 0; pin < npins; pin++)
370371 pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name;
371372 }