hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/gpio/gpio-xlp.c
....@@ -1,18 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2003-2015 Broadcom Corporation
34 * All Rights Reserved
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License version 2 as
7
- * published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU General Public License for more details.
135 */
146
15
-#include <linux/gpio.h>
7
+#include <linux/gpio/driver.h>
168 #include <linux/platform_device.h>
179 #include <linux/of_device.h>
1810 #include <linux/module.h>
....@@ -298,22 +290,18 @@
298290 static int xlp_gpio_probe(struct platform_device *pdev)
299291 {
300292 struct gpio_chip *gc;
301
- struct resource *iores;
293
+ struct gpio_irq_chip *girq;
302294 struct xlp_gpio_priv *priv;
303295 void __iomem *gpio_base;
304296 int irq_base, irq, err;
305297 int ngpio;
306298 u32 soc_type;
307299
308
- iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
309
- if (!iores)
310
- return -ENODEV;
311
-
312300 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
313301 if (!priv)
314302 return -ENOMEM;
315303
316
- gpio_base = devm_ioremap_resource(&pdev->dev, iores);
304
+ gpio_base = devm_platform_ioremap_resource(pdev, 0);
317305 if (IS_ERR(gpio_base))
318306 return PTR_ERR(gpio_base);
319307
....@@ -408,27 +396,27 @@
408396 irq_base = 0;
409397 }
410398
399
+ girq = &gc->irq;
400
+ girq->chip = &xlp_gpio_irq_chip;
401
+ girq->parent_handler = xlp_gpio_generic_handler;
402
+ girq->num_parents = 1;
403
+ girq->parents = devm_kcalloc(&pdev->dev, 1,
404
+ sizeof(*girq->parents),
405
+ GFP_KERNEL);
406
+ if (!girq->parents)
407
+ return -ENOMEM;
408
+ girq->parents[0] = irq;
409
+ girq->first = irq_base;
410
+ girq->default_type = IRQ_TYPE_NONE;
411
+ girq->handler = handle_level_irq;
412
+
411413 err = gpiochip_add_data(gc, priv);
412414 if (err < 0)
413415 return err;
414416
415
- err = gpiochip_irqchip_add(gc, &xlp_gpio_irq_chip, irq_base,
416
- handle_level_irq, IRQ_TYPE_NONE);
417
- if (err) {
418
- dev_err(&pdev->dev, "Could not connect irqchip to gpiochip!\n");
419
- goto out_gpio_remove;
420
- }
421
-
422
- gpiochip_set_chained_irqchip(gc, &xlp_gpio_irq_chip, irq,
423
- xlp_gpio_generic_handler);
424
-
425417 dev_info(&pdev->dev, "registered %d GPIOs\n", gc->ngpio);
426418
427419 return 0;
428
-
429
-out_gpio_remove:
430
- gpiochip_remove(gc);
431
- return err;
432420 }
433421
434422 #ifdef CONFIG_ACPI