hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
....@@ -1,16 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * mt65xx pinctrl driver based on Allwinner A1X pinctrl driver.
34 * Copyright (c) 2014 MediaTek Inc.
45 * Author: Hongzhou.Yang <hongzhou.yang@mediatek.com>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
146 */
157
168 #include <linux/io.h>
....@@ -514,8 +506,8 @@
514506
515507 pins = of_find_property(node, "pinmux", NULL);
516508 if (!pins) {
517
- dev_err(pctl->dev, "missing pins property in node %s .\n",
518
- node->name);
509
+ dev_err(pctl->dev, "missing pins property in node %pOFn .\n",
510
+ node);
519511 return -EINVAL;
520512 }
521513
....@@ -812,7 +804,10 @@
812804 pctl->devdata->spec_dir_set(&reg_addr, offset);
813805
814806 regmap_read(pctl->regmap1, reg_addr, &read_val);
815
- return !(read_val & bit);
807
+ if (read_val & bit)
808
+ return GPIO_LINE_DIRECTION_OUT;
809
+
810
+ return GPIO_LINE_DIRECTION_IN;
816811 }
817812
818813 static int mtk_gpio_get(struct gpio_chip *chip, unsigned offset)
....@@ -990,7 +985,6 @@
990985 static int mtk_eint_init(struct mtk_pinctrl *pctl, struct platform_device *pdev)
991986 {
992987 struct device_node *np = pdev->dev.of_node;
993
- struct resource *res;
994988
995989 if (!of_property_read_bool(np, "interrupt-controller"))
996990 return -ENODEV;
....@@ -999,8 +993,7 @@
999993 if (!pctl->eint)
1000994 return -ENOMEM;
1001995
1002
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1003
- pctl->eint->base = devm_ioremap_resource(&pdev->dev, res);
996
+ pctl->eint->base = devm_platform_ioremap_resource(pdev, 0);
1004997 if (IS_ERR(pctl->eint->base))
1005998 return PTR_ERR(pctl->eint->base);
1006999
....@@ -1046,6 +1039,7 @@
10461039 node = of_parse_phandle(np, "mediatek,pctl-regmap", 0);
10471040 if (node) {
10481041 pctl->regmap1 = syscon_node_to_regmap(node);
1042
+ of_node_put(node);
10491043 if (IS_ERR(pctl->regmap1))
10501044 return PTR_ERR(pctl->regmap1);
10511045 } else if (regmap) {
....@@ -1059,6 +1053,7 @@
10591053 node = of_parse_phandle(np, "mediatek,pctl-regmap", 1);
10601054 if (node) {
10611055 pctl->regmap2 = syscon_node_to_regmap(node);
1056
+ of_node_put(node);
10621057 if (IS_ERR(pctl->regmap2))
10631058 return PTR_ERR(pctl->regmap2);
10641059 }