hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/gpio/gpio-xgene.c
....@@ -1,20 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * AppliedMicro X-Gene SoC GPIO Driver
34 *
45 * Copyright (c) 2014, Applied Micro Circuits Corporation
56 * 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/>.
187 */
198
209 #include <linux/acpi.h>
....@@ -91,7 +80,10 @@
9180 bank_offset = GPIO_SET_DR_OFFSET + GPIO_BANK_OFFSET(offset);
9281 bit_offset = GPIO_BIT_OFFSET(offset);
9382
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;
9587 }
9688
9789 static int xgene_gpio_dir_in(struct gpio_chip *gc, unsigned int offset)
....@@ -166,28 +158,16 @@
166158
167159 static int xgene_gpio_probe(struct platform_device *pdev)
168160 {
169
- struct resource *res;
170161 struct xgene_gpio *gpio;
171162 int err = 0;
172163
173164 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;
178167
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);
191171
192172 gpio->chip.ngpio = XGENE_MAX_GPIOS;
193173
....@@ -207,14 +187,11 @@
207187 if (err) {
208188 dev_err(&pdev->dev,
209189 "failed to register gpiochip.\n");
210
- goto err;
190
+ return err;
211191 }
212192
213193 dev_info(&pdev->dev, "X-Gene GPIO driver registered.\n");
214194 return 0;
215
-err:
216
- dev_err(&pdev->dev, "X-Gene GPIO driver registration failed.\n");
217
- return err;
218195 }
219196
220197 static const struct of_device_id xgene_gpio_of_match[] = {