hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/gpio/gpio-vr41xx.c
....@@ -1,27 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0+
12 /*
23 * Driver for NEC VR4100 series General-purpose I/O Unit.
34 *
45 * Copyright (C) 2002 MontaVista Software Inc.
56 * Author: Yoichi Yuasa <source@mvista.com>
67 * Copyright (C) 2003-2009 Yoichi Yuasa <yuasa@linux-mips.org>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU General Public License
19
- * along with this program; if not, write to the Free Software
20
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
218 */
229 #include <linux/errno.h>
2310 #include <linux/fs.h>
24
-#include <linux/gpio.h>
11
+#include <linux/gpio/driver.h>
2512 #include <linux/init.h>
2613 #include <linux/interrupt.h>
2714 #include <linux/io.h>
....@@ -230,8 +217,6 @@
230217 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
231218 maskl, pendl, maskh, pendh);
232219
233
- atomic_inc(&irq_err_count);
234
-
235220 return -EINVAL;
236221 }
237222
....@@ -384,44 +369,6 @@
384369 return 0;
385370 }
386371
387
-int vr41xx_gpio_pullupdown(unsigned int pin, gpio_pull_t pull)
388
-{
389
- u16 reg, mask;
390
- unsigned long flags;
391
-
392
- if ((giu_flags & GPIO_HAS_PULLUPDOWN_IO) != GPIO_HAS_PULLUPDOWN_IO)
393
- return -EPERM;
394
-
395
- if (pin >= 15)
396
- return -EINVAL;
397
-
398
- mask = 1 << pin;
399
-
400
- spin_lock_irqsave(&giu_lock, flags);
401
-
402
- if (pull == GPIO_PULL_UP || pull == GPIO_PULL_DOWN) {
403
- reg = giu_read(GIUTERMUPDN);
404
- if (pull == GPIO_PULL_UP)
405
- reg |= mask;
406
- else
407
- reg &= ~mask;
408
- giu_write(GIUTERMUPDN, reg);
409
-
410
- reg = giu_read(GIUUSEUPDN);
411
- reg |= mask;
412
- giu_write(GIUUSEUPDN, reg);
413
- } else {
414
- reg = giu_read(GIUUSEUPDN);
415
- reg &= ~mask;
416
- giu_write(GIUUSEUPDN, reg);
417
- }
418
-
419
- spin_unlock_irqrestore(&giu_lock, flags);
420
-
421
- return 0;
422
-}
423
-EXPORT_SYMBOL_GPL(vr41xx_gpio_pullupdown);
424
-
425372 static int vr41xx_gpio_get(struct gpio_chip *chip, unsigned pin)
426373 {
427374 u16 reg, mask;
....@@ -518,10 +465,9 @@
518465
519466 static int giu_probe(struct platform_device *pdev)
520467 {
521
- struct resource *res;
522468 unsigned int trigger, i, pin;
523469 struct irq_chip *chip;
524
- int irq, ret;
470
+ int irq;
525471
526472 switch (pdev->id) {
527473 case GPIO_50PINS_PULLUPDOWN:
....@@ -540,21 +486,14 @@
540486 return -ENODEV;
541487 }
542488
543
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
544
- if (!res)
545
- return -EBUSY;
546
-
547
- giu_base = ioremap(res->start, resource_size(res));
548
- if (!giu_base)
549
- return -ENOMEM;
489
+ giu_base = devm_platform_ioremap_resource(pdev, 0);
490
+ if (IS_ERR(giu_base))
491
+ return PTR_ERR(giu_base);
550492
551493 vr41xx_gpio_chip.parent = &pdev->dev;
552494
553
- ret = gpiochip_add_data(&vr41xx_gpio_chip, NULL);
554
- if (!ret) {
555
- iounmap(giu_base);
495
+ if (gpiochip_add_data(&vr41xx_gpio_chip, NULL))
556496 return -ENODEV;
557
- }
558497
559498 giu_write(GIUINTENL, 0);
560499 giu_write(GIUINTENH, 0);
....@@ -585,7 +524,6 @@
585524 static int giu_remove(struct platform_device *pdev)
586525 {
587526 if (giu_base) {
588
- iounmap(giu_base);
589527 giu_base = NULL;
590528 }
591529