| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * AXP20x pinctrl and GPIO driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2016 Maxime Ripard <maxime.ripard@free-electrons.com> |
|---|
| 5 | 6 | * 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. |
|---|
| 11 | 7 | */ |
|---|
| 12 | 8 | |
|---|
| 13 | 9 | #include <linux/bitops.h> |
|---|
| .. | .. |
|---|
| 153 | 149 | * going to change the value soon anyway. Default to output. |
|---|
| 154 | 150 | */ |
|---|
| 155 | 151 | if ((val & AXP20X_GPIO_FUNCTIONS) > 2) |
|---|
| 156 | | - return 0; |
|---|
| 152 | + return GPIO_LINE_DIRECTION_OUT; |
|---|
| 157 | 153 | |
|---|
| 158 | 154 | /* |
|---|
| 159 | 155 | * The GPIO directions are the three lowest values. |
|---|
| 160 | 156 | * 2 is input, 0 and 1 are output |
|---|
| 161 | 157 | */ |
|---|
| 162 | | - return val & 2; |
|---|
| 158 | + if (val & 2) |
|---|
| 159 | + return GPIO_LINE_DIRECTION_IN; |
|---|
| 160 | + |
|---|
| 161 | + return GPIO_LINE_DIRECTION_OUT; |
|---|
| 163 | 162 | } |
|---|
| 164 | 163 | |
|---|
| 165 | 164 | static int axp20x_gpio_output(struct gpio_chip *chip, unsigned int offset, |
|---|
| .. | .. |
|---|
| 366 | 365 | pctl->funcs[i].groups = devm_kcalloc(&pdev->dev, |
|---|
| 367 | 366 | npins, sizeof(char *), |
|---|
| 368 | 367 | GFP_KERNEL); |
|---|
| 368 | + if (!pctl->funcs[i].groups) |
|---|
| 369 | + return -ENOMEM; |
|---|
| 369 | 370 | for (pin = 0; pin < npins; pin++) |
|---|
| 370 | 371 | pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name; |
|---|
| 371 | 372 | } |
|---|