.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * AppliedMicro X-Gene SoC GPIO Driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2014, Applied Micro Circuits Corporation |
---|
5 | 6 | * Author: Feng Kan <fkan@apm.com>. |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as |
---|
9 | | - * published by the Free Software Foundation. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | | - * |
---|
16 | | - * You should have received a copy of the GNU General Public License |
---|
17 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
18 | 7 | */ |
---|
19 | 8 | |
---|
20 | 9 | #include <linux/acpi.h> |
---|
.. | .. |
---|
91 | 80 | bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset); |
---|
92 | 81 | bit_offset = GPIO_BIT_OFFSET(offset); |
---|
93 | 82 | |
---|
94 | | - return !!(ioread32(chip->base + bank_offset) & BIT(bit_offset)); |
---|
| 83 | + if (ioread32(chip->base + bank_offset) & BIT(bit_offset)) |
---|
| 84 | + return GPIO_LINE_DIRECTION_IN; |
---|
| 85 | + |
---|
| 86 | + return GPIO_LINE_DIRECTION_OUT; |
---|
95 | 87 | } |
---|
96 | 88 | |
---|
97 | 89 | static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset) |
---|
.. | .. |
---|
166 | 158 | |
---|
167 | 159 | static int xgene_gpio_probe(struct platform_device *pdev) |
---|
168 | 160 | { |
---|
169 | | - struct resource *res; |
---|
170 | 161 | struct xgene_gpio *gpio; |
---|
171 | 162 | int err = 0; |
---|
172 | 163 | |
---|
173 | 164 | gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); |
---|
174 | | - if (!gpio) { |
---|
175 | | - err = -ENOMEM; |
---|
176 | | - goto err; |
---|
177 | | - } |
---|
| 165 | + if (!gpio) |
---|
| 166 | + return -ENOMEM; |
---|
178 | 167 | |
---|
179 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
180 | | - if (!res) { |
---|
181 | | - err = -EINVAL; |
---|
182 | | - goto err; |
---|
183 | | - } |
---|
184 | | - |
---|
185 | | - gpio->base = devm_ioremap_nocache(&pdev->dev, res->start, |
---|
186 | | - resource_size(res)); |
---|
187 | | - if (!gpio->base) { |
---|
188 | | - err = -ENOMEM; |
---|
189 | | - goto err; |
---|
190 | | - } |
---|
| 168 | + gpio->base = devm_platform_ioremap_resource(pdev, 0); |
---|
| 169 | + if (IS_ERR(gpio->base)) |
---|
| 170 | + return PTR_ERR(gpio->base); |
---|
191 | 171 | |
---|
192 | 172 | gpio->chip.ngpio = XGENE_MAX_GPIOS; |
---|
193 | 173 | |
---|
.. | .. |
---|
207 | 187 | if (err) { |
---|
208 | 188 | dev_err(&pdev->dev, |
---|
209 | 189 | "failed to register gpiochip.\n"); |
---|
210 | | - goto err; |
---|
| 190 | + return err; |
---|
211 | 191 | } |
---|
212 | 192 | |
---|
213 | 193 | dev_info(&pdev->dev, "X-Gene GPIO driver registered.\n"); |
---|
214 | 194 | return 0; |
---|
215 | | -err: |
---|
216 | | - dev_err(&pdev->dev, "X-Gene GPIO driver registration failed.\n"); |
---|
217 | | - return err; |
---|
218 | 195 | } |
---|
219 | 196 | |
---|
220 | 197 | static const struct of_device_id xgene_gpio_of_match[] = { |
---|