.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright Intel Corporation (C) 2014-2016. All Rights Reserved |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify it |
---|
5 | | - * under the terms and conditions of the GNU General Public License, |
---|
6 | | - * version 2, as published by the Free Software Foundation. |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
---|
9 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
10 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
11 | | - * more details. |
---|
12 | | - * |
---|
13 | | - * You should have received a copy of the GNU General Public License along with |
---|
14 | | - * this program. If not, see <http://www.gnu.org/licenses/>. |
---|
15 | 4 | * |
---|
16 | 5 | * GPIO driver for Altera Arria10 MAX5 System Resource Chip |
---|
17 | 6 | * |
---|
.. | .. |
---|
58 | 47 | static int altr_a10sr_gpio_direction_input(struct gpio_chip *gc, |
---|
59 | 48 | unsigned int nr) |
---|
60 | 49 | { |
---|
61 | | - if (nr >= (ALTR_A10SR_IN_VALID_RANGE_LO - ALTR_A10SR_LED_VALID_SHIFT)) |
---|
62 | | - return 0; |
---|
63 | | - return -EINVAL; |
---|
| 50 | + if (nr < (ALTR_A10SR_IN_VALID_RANGE_LO - ALTR_A10SR_LED_VALID_SHIFT)) |
---|
| 51 | + return -EINVAL; |
---|
| 52 | + |
---|
| 53 | + return 0; |
---|
64 | 54 | } |
---|
65 | 55 | |
---|
66 | 56 | static int altr_a10sr_gpio_direction_output(struct gpio_chip *gc, |
---|
67 | 57 | unsigned int nr, int value) |
---|
68 | 58 | { |
---|
69 | | - if (nr <= (ALTR_A10SR_OUT_VALID_RANGE_HI - ALTR_A10SR_LED_VALID_SHIFT)) { |
---|
70 | | - altr_a10sr_gpio_set(gc, nr, value); |
---|
71 | | - return 0; |
---|
72 | | - } |
---|
73 | | - return -EINVAL; |
---|
| 59 | + if (nr > (ALTR_A10SR_OUT_VALID_RANGE_HI - ALTR_A10SR_LED_VALID_SHIFT)) |
---|
| 60 | + return -EINVAL; |
---|
| 61 | + |
---|
| 62 | + altr_a10sr_gpio_set(gc, nr, value); |
---|
| 63 | + return 0; |
---|
74 | 64 | } |
---|
75 | 65 | |
---|
76 | 66 | static const struct gpio_chip altr_a10sr_gc = { |
---|