Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'intel-pinctrl-v6.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pinctrl/intel into devel

intel-pinctrl for v6.7-1

* Merge "Drop runtime PM support for Baytrail and Lynxpoint pinctrl" (Raag)
* Small improvements here and there in the Intel pin control drivers (Raag)
* Switch to RAII for locking in the Intel core and Cherry View drivers
* Enable non-ACPI enumeration in the Intel Denverton driver
* Use MODULE_DEVICE_TABLE() instead of MODULE_ALIAS() in a couple of drivers
* Introduce array_size.h and use in in the Intel pin control drivers

The following is an automated git shortlog grouped by driver:

baytrail:
- Replace kernel.h by what is actually being used
- drop runtime PM support
- fix debounce disable case

broxton:
- Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()

cherryview:
- reduce scope of PIN_CONFIG_BIAS_HIGH_IMPEDANCE case
- Convert to platform remove callback returning void
- Simplify code with cleanup helpers
- Avoid duplicated I/O
- Replace kernel.h by what is actually being used

denverton:
- Replace MODULE_ALIAS() with MODULE_DEVICE_TABLE()
- Enable platform device in the absence of ACPI enumeration

intel:
- fetch community only when we need it
- refine intel_config_set_pull() function
- Replace kernel.h by what is actually being used
- Simplify code with cleanup helpers

lynxpoint:
- Replace kernel.h by what is actually being used
- drop runtime PM support

merrifield:
- Replace kernel.h by what is actually being used

moorefield:
- Replace kernel.h by what is actually being used
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+208 -296
+1 -1
drivers/pinctrl/core.c
··· 12 12 */ 13 13 #define pr_fmt(fmt) "pinctrl core: " fmt 14 14 15 + #include <linux/array_size.h> 15 16 #include <linux/debugfs.h> 16 17 #include <linux/device.h> 17 18 #include <linux/err.h> 18 19 #include <linux/export.h> 19 20 #include <linux/init.h> 20 - #include <linux/kernel.h> 21 21 #include <linux/kref.h> 22 22 #include <linux/list.h> 23 23 #include <linux/seq_file.h>
+12 -20
drivers/pinctrl/intel/pinctrl-baytrail.c
··· 7 7 */ 8 8 9 9 #include <linux/acpi.h> 10 + #include <linux/array_size.h> 10 11 #include <linux/bitops.h> 11 12 #include <linux/gpio/driver.h> 12 13 #include <linux/init.h> 13 14 #include <linux/interrupt.h> 14 15 #include <linux/io.h> 15 - #include <linux/kernel.h> 16 16 #include <linux/module.h> 17 17 #include <linux/types.h> 18 18 #include <linux/platform_device.h> 19 - #include <linux/pm_runtime.h> 19 + #include <linux/pm.h> 20 20 #include <linux/property.h> 21 21 #include <linux/seq_file.h> 22 22 #include <linux/string_helpers.h> ··· 722 722 723 723 raw_spin_unlock_irqrestore(&byt_lock, flags); 724 724 725 - pm_runtime_get(vg->dev); 726 - 727 725 return 0; 728 726 } 729 727 ··· 732 734 struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctl_dev); 733 735 734 736 byt_gpio_clear_triggering(vg, offset); 735 - pm_runtime_put(vg->dev); 736 737 } 737 738 738 739 static void byt_gpio_direct_irq_check(struct intel_pinctrl *vg, ··· 980 983 981 984 break; 982 985 case PIN_CONFIG_INPUT_DEBOUNCE: 983 - if (arg) 986 + if (arg) { 984 987 conf |= BYT_DEBOUNCE_EN; 985 - else 988 + } else { 986 989 conf &= ~BYT_DEBOUNCE_EN; 990 + 991 + /* 992 + * No need to update the pulse value. 993 + * Debounce is going to be disabled. 994 + */ 995 + break; 996 + } 987 997 988 998 switch (arg) { 989 999 case 375: ··· 1658 1654 return ret; 1659 1655 1660 1656 platform_set_drvdata(pdev, vg); 1661 - pm_runtime_enable(dev); 1662 1657 1663 1658 return 0; 1664 1659 } ··· 1746 1743 return 0; 1747 1744 } 1748 1745 1749 - static int byt_gpio_runtime_suspend(struct device *dev) 1750 - { 1751 - return 0; 1752 - } 1753 - 1754 - static int byt_gpio_runtime_resume(struct device *dev) 1755 - { 1756 - return 0; 1757 - } 1758 - 1759 1746 static const struct dev_pm_ops byt_gpio_pm_ops = { 1760 1747 LATE_SYSTEM_SLEEP_PM_OPS(byt_gpio_suspend, byt_gpio_resume) 1761 - RUNTIME_PM_OPS(byt_gpio_runtime_suspend, byt_gpio_runtime_resume, NULL) 1762 1748 }; 1763 1749 1764 1750 static struct platform_driver byt_gpio_driver = { 1765 1751 .probe = byt_pinctrl_probe, 1766 1752 .driver = { 1767 1753 .name = "byt_gpio", 1768 - .pm = pm_ptr(&byt_gpio_pm_ops), 1754 + .pm = pm_sleep_ptr(&byt_gpio_pm_ops), 1769 1755 .acpi_match_table = byt_gpio_acpi_match, 1770 1756 .suppress_bind_attrs = true, 1771 1757 },
+1 -2
drivers/pinctrl/intel/pinctrl-broxton.c
··· 998 998 { "broxton-pinctrl", (kernel_ulong_t)bxt_pinctrl_soc_data }, 999 999 { } 1000 1000 }; 1001 + MODULE_DEVICE_TABLE(platform, bxt_pinctrl_platform_ids); 1001 1002 1002 1003 static INTEL_PINCTRL_PM_OPS(bxt_pinctrl_pm_ops); 1003 1004 ··· 1027 1026 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>"); 1028 1027 MODULE_DESCRIPTION("Intel Broxton SoC pinctrl/GPIO driver"); 1029 1028 MODULE_LICENSE("GPL v2"); 1030 - MODULE_ALIAS("platform:apollolake-pinctrl"); 1031 - MODULE_ALIAS("platform:broxton-pinctrl"); 1032 1029 MODULE_IMPORT_NS(PINCTRL_INTEL);
+57 -100
drivers/pinctrl/intel/pinctrl-cherryview.c
··· 11 11 */ 12 12 13 13 #include <linux/acpi.h> 14 + #include <linux/array_size.h> 15 + #include <linux/cleanup.h> 14 16 #include <linux/dmi.h> 15 17 #include <linux/gpio/driver.h> 16 - #include <linux/kernel.h> 17 18 #include <linux/module.h> 18 19 #include <linux/platform_device.h> 19 20 #include <linux/seq_file.h> ··· 613 612 } 614 613 615 614 /* When Pad Cfg is locked, driver can only change GPIOTXState or GPIORXState */ 615 + static bool chv_pad_is_locked(u32 ctrl1) 616 + { 617 + return ctrl1 & CHV_PADCTRL1_CFGLOCK; 618 + } 619 + 616 620 static bool chv_pad_locked(struct intel_pinctrl *pctrl, unsigned int offset) 617 621 { 618 - return chv_readl(pctrl, offset, CHV_PADCTRL1) & CHV_PADCTRL1_CFGLOCK; 622 + return chv_pad_is_locked(chv_readl(pctrl, offset, CHV_PADCTRL1)); 619 623 } 620 624 621 625 static void chv_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, 622 626 unsigned int offset) 623 627 { 624 628 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 625 - unsigned long flags; 626 629 u32 ctrl0, ctrl1; 627 - bool locked; 628 630 629 - raw_spin_lock_irqsave(&chv_lock, flags); 630 - 631 - ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); 632 - ctrl1 = chv_readl(pctrl, offset, CHV_PADCTRL1); 633 - locked = chv_pad_locked(pctrl, offset); 634 - 635 - raw_spin_unlock_irqrestore(&chv_lock, flags); 631 + scoped_guard(raw_spinlock_irqsave, &chv_lock) { 632 + ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); 633 + ctrl1 = chv_readl(pctrl, offset, CHV_PADCTRL1); 634 + } 636 635 637 636 if (ctrl0 & CHV_PADCTRL0_GPIOEN) { 638 637 seq_puts(s, "GPIO "); ··· 647 646 648 647 seq_printf(s, "0x%08x 0x%08x", ctrl0, ctrl1); 649 648 650 - if (locked) 649 + if (chv_pad_is_locked(ctrl1)) 651 650 seq_puts(s, " [LOCKED]"); 652 651 } 653 652 ··· 664 663 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 665 664 struct device *dev = pctrl->dev; 666 665 const struct intel_pingroup *grp; 667 - unsigned long flags; 668 666 int i; 669 667 670 668 grp = &pctrl->soc->groups[group]; 671 669 672 - raw_spin_lock_irqsave(&chv_lock, flags); 670 + guard(raw_spinlock_irqsave)(&chv_lock); 673 671 674 672 /* Check first that the pad is not locked */ 675 673 for (i = 0; i < grp->grp.npins; i++) { 676 674 if (chv_pad_locked(pctrl, grp->grp.pins[i])) { 677 - raw_spin_unlock_irqrestore(&chv_lock, flags); 678 675 dev_warn(dev, "unable to set mode for locked pin %u\n", grp->grp.pins[i]); 679 676 return -EBUSY; 680 677 } ··· 712 713 invert_oe ? "" : "not "); 713 714 } 714 715 715 - raw_spin_unlock_irqrestore(&chv_lock, flags); 716 - 717 716 return 0; 718 717 } 719 718 ··· 742 745 unsigned int offset) 743 746 { 744 747 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 745 - unsigned long flags; 746 748 u32 value; 747 749 748 - raw_spin_lock_irqsave(&chv_lock, flags); 750 + guard(raw_spinlock_irqsave)(&chv_lock); 749 751 750 752 if (chv_pad_locked(pctrl, offset)) { 751 753 value = chv_readl(pctrl, offset, CHV_PADCTRL0); 752 754 if (!(value & CHV_PADCTRL0_GPIOEN)) { 753 755 /* Locked so cannot enable */ 754 - raw_spin_unlock_irqrestore(&chv_lock, flags); 755 756 return -EBUSY; 756 757 } 757 758 } else { ··· 784 789 chv_writel(pctrl, offset, CHV_PADCTRL0, value); 785 790 } 786 791 787 - raw_spin_unlock_irqrestore(&chv_lock, flags); 788 - 789 792 return 0; 790 793 } 791 794 ··· 792 799 unsigned int offset) 793 800 { 794 801 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 795 - unsigned long flags; 796 802 797 - raw_spin_lock_irqsave(&chv_lock, flags); 803 + guard(raw_spinlock_irqsave)(&chv_lock); 798 804 799 - if (!chv_pad_locked(pctrl, offset)) 800 - chv_gpio_clear_triggering(pctrl, offset); 805 + if (chv_pad_locked(pctrl, offset)) 806 + return; 801 807 802 - raw_spin_unlock_irqrestore(&chv_lock, flags); 808 + chv_gpio_clear_triggering(pctrl, offset); 803 809 } 804 810 805 811 static int chv_gpio_set_direction(struct pinctrl_dev *pctldev, ··· 806 814 unsigned int offset, bool input) 807 815 { 808 816 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 809 - unsigned long flags; 810 817 u32 ctrl0; 811 818 812 - raw_spin_lock_irqsave(&chv_lock, flags); 819 + guard(raw_spinlock_irqsave)(&chv_lock); 813 820 814 821 ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0) & ~CHV_PADCTRL0_GPIOCFG_MASK; 815 822 if (input) ··· 816 825 else 817 826 ctrl0 |= CHV_PADCTRL0_GPIOCFG_GPO << CHV_PADCTRL0_GPIOCFG_SHIFT; 818 827 chv_writel(pctrl, offset, CHV_PADCTRL0, ctrl0); 819 - 820 - raw_spin_unlock_irqrestore(&chv_lock, flags); 821 828 822 829 return 0; 823 830 } ··· 835 846 { 836 847 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 837 848 enum pin_config_param param = pinconf_to_config_param(*config); 838 - unsigned long flags; 839 849 u32 ctrl0, ctrl1; 840 850 u16 arg = 0; 841 851 u32 term; 842 852 843 - raw_spin_lock_irqsave(&chv_lock, flags); 844 - ctrl0 = chv_readl(pctrl, pin, CHV_PADCTRL0); 845 - ctrl1 = chv_readl(pctrl, pin, CHV_PADCTRL1); 846 - raw_spin_unlock_irqrestore(&chv_lock, flags); 853 + scoped_guard(raw_spinlock_irqsave, &chv_lock) { 854 + ctrl0 = chv_readl(pctrl, pin, CHV_PADCTRL0); 855 + ctrl1 = chv_readl(pctrl, pin, CHV_PADCTRL1); 856 + } 847 857 848 858 term = (ctrl0 & CHV_PADCTRL0_TERM_MASK) >> CHV_PADCTRL0_TERM_SHIFT; 849 859 ··· 894 906 return -EINVAL; 895 907 896 908 break; 909 + } 897 910 898 911 case PIN_CONFIG_DRIVE_PUSH_PULL: 899 912 if (ctrl1 & CHV_PADCTRL1_ODEN) ··· 905 916 if (!(ctrl1 & CHV_PADCTRL1_ODEN)) 906 917 return -EINVAL; 907 918 break; 908 - } 909 919 910 920 default: 911 921 return -ENOTSUPP; ··· 917 929 static int chv_config_set_pull(struct intel_pinctrl *pctrl, unsigned int pin, 918 930 enum pin_config_param param, u32 arg) 919 931 { 920 - unsigned long flags; 921 932 u32 ctrl0, pull; 922 933 923 - raw_spin_lock_irqsave(&chv_lock, flags); 934 + guard(raw_spinlock_irqsave)(&chv_lock); 935 + 924 936 ctrl0 = chv_readl(pctrl, pin, CHV_PADCTRL0); 925 937 926 938 switch (param) { ··· 943 955 pull = CHV_PADCTRL0_TERM_20K << CHV_PADCTRL0_TERM_SHIFT; 944 956 break; 945 957 default: 946 - raw_spin_unlock_irqrestore(&chv_lock, flags); 947 958 return -EINVAL; 948 959 } 949 960 ··· 960 973 pull = CHV_PADCTRL0_TERM_20K << CHV_PADCTRL0_TERM_SHIFT; 961 974 break; 962 975 default: 963 - raw_spin_unlock_irqrestore(&chv_lock, flags); 964 976 return -EINVAL; 965 977 } 966 978 ··· 967 981 break; 968 982 969 983 default: 970 - raw_spin_unlock_irqrestore(&chv_lock, flags); 971 984 return -EINVAL; 972 985 } 973 986 974 987 chv_writel(pctrl, pin, CHV_PADCTRL0, ctrl0); 975 - raw_spin_unlock_irqrestore(&chv_lock, flags); 976 988 977 989 return 0; 978 990 } ··· 978 994 static int chv_config_set_oden(struct intel_pinctrl *pctrl, unsigned int pin, 979 995 bool enable) 980 996 { 981 - unsigned long flags; 982 997 u32 ctrl1; 983 998 984 - raw_spin_lock_irqsave(&chv_lock, flags); 999 + guard(raw_spinlock_irqsave)(&chv_lock); 1000 + 985 1001 ctrl1 = chv_readl(pctrl, pin, CHV_PADCTRL1); 986 1002 987 1003 if (enable) ··· 990 1006 ctrl1 &= ~CHV_PADCTRL1_ODEN; 991 1007 992 1008 chv_writel(pctrl, pin, CHV_PADCTRL1, ctrl1); 993 - raw_spin_unlock_irqrestore(&chv_lock, flags); 994 1009 995 1010 return 0; 996 1011 } ··· 1099 1116 static int chv_gpio_get(struct gpio_chip *chip, unsigned int offset) 1100 1117 { 1101 1118 struct intel_pinctrl *pctrl = gpiochip_get_data(chip); 1102 - unsigned long flags; 1103 1119 u32 ctrl0, cfg; 1104 1120 1105 - raw_spin_lock_irqsave(&chv_lock, flags); 1106 - ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); 1107 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1121 + scoped_guard(raw_spinlock_irqsave, &chv_lock) 1122 + ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); 1108 1123 1109 1124 cfg = ctrl0 & CHV_PADCTRL0_GPIOCFG_MASK; 1110 1125 cfg >>= CHV_PADCTRL0_GPIOCFG_SHIFT; ··· 1115 1134 static void chv_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) 1116 1135 { 1117 1136 struct intel_pinctrl *pctrl = gpiochip_get_data(chip); 1118 - unsigned long flags; 1119 1137 u32 ctrl0; 1120 1138 1121 - raw_spin_lock_irqsave(&chv_lock, flags); 1139 + guard(raw_spinlock_irqsave)(&chv_lock); 1122 1140 1123 1141 ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); 1124 1142 ··· 1127 1147 ctrl0 &= ~CHV_PADCTRL0_GPIOTXSTATE; 1128 1148 1129 1149 chv_writel(pctrl, offset, CHV_PADCTRL0, ctrl0); 1130 - 1131 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1132 1150 } 1133 1151 1134 1152 static int chv_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) 1135 1153 { 1136 1154 struct intel_pinctrl *pctrl = gpiochip_get_data(chip); 1137 1155 u32 ctrl0, direction; 1138 - unsigned long flags; 1139 1156 1140 - raw_spin_lock_irqsave(&chv_lock, flags); 1141 - ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); 1142 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1157 + scoped_guard(raw_spinlock_irqsave, &chv_lock) 1158 + ctrl0 = chv_readl(pctrl, offset, CHV_PADCTRL0); 1143 1159 1144 1160 direction = ctrl0 & CHV_PADCTRL0_GPIOCFG_MASK; 1145 1161 direction >>= CHV_PADCTRL0_GPIOCFG_SHIFT; ··· 1176 1200 irq_hw_number_t hwirq = irqd_to_hwirq(d); 1177 1201 u32 intr_line; 1178 1202 1179 - raw_spin_lock(&chv_lock); 1203 + guard(raw_spinlock)(&chv_lock); 1180 1204 1181 1205 intr_line = chv_readl(pctrl, hwirq, CHV_PADCTRL0); 1182 1206 intr_line &= CHV_PADCTRL0_INTSEL_MASK; 1183 1207 intr_line >>= CHV_PADCTRL0_INTSEL_SHIFT; 1184 1208 chv_pctrl_writel(pctrl, CHV_INTSTAT, BIT(intr_line)); 1185 - 1186 - raw_spin_unlock(&chv_lock); 1187 1209 } 1188 1210 1189 1211 static void chv_gpio_irq_mask_unmask(struct gpio_chip *gc, irq_hw_number_t hwirq, bool mask) 1190 1212 { 1191 1213 struct intel_pinctrl *pctrl = gpiochip_get_data(gc); 1192 1214 u32 value, intr_line; 1193 - unsigned long flags; 1194 1215 1195 - raw_spin_lock_irqsave(&chv_lock, flags); 1216 + guard(raw_spinlock_irqsave)(&chv_lock); 1196 1217 1197 1218 intr_line = chv_readl(pctrl, hwirq, CHV_PADCTRL0); 1198 1219 intr_line &= CHV_PADCTRL0_INTSEL_MASK; ··· 1201 1228 else 1202 1229 value |= BIT(intr_line); 1203 1230 chv_pctrl_writel(pctrl, CHV_INTMASK, value); 1204 - 1205 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1206 1231 } 1207 1232 1208 1233 static void chv_gpio_irq_mask(struct irq_data *d) ··· 1225 1254 { 1226 1255 /* 1227 1256 * Check if the interrupt has been requested with 0 as triggering 1228 - * type. In that case it is assumed that the current values 1257 + * type. If not, bail out, ... 1258 + */ 1259 + if (irqd_get_trigger_type(d) != IRQ_TYPE_NONE) { 1260 + chv_gpio_irq_unmask(d); 1261 + return 0; 1262 + } 1263 + 1264 + /* 1265 + * ...otherwise it is assumed that the current values 1229 1266 * programmed to the hardware are used (e.g BIOS configured 1230 1267 * defaults). 1231 1268 * ··· 1241 1262 * read back the values from hardware now, set correct flow handler 1242 1263 * and update mappings before the interrupt is being used. 1243 1264 */ 1244 - if (irqd_get_trigger_type(d) == IRQ_TYPE_NONE) { 1265 + scoped_guard(raw_spinlock_irqsave, &chv_lock) { 1245 1266 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1246 1267 struct intel_pinctrl *pctrl = gpiochip_get_data(gc); 1247 1268 struct device *dev = pctrl->dev; 1248 1269 struct intel_community_context *cctx = &pctrl->context.communities[0]; 1249 1270 irq_hw_number_t hwirq = irqd_to_hwirq(d); 1250 1271 irq_flow_handler_t handler; 1251 - unsigned long flags; 1252 1272 u32 intsel, value; 1253 1273 1254 - raw_spin_lock_irqsave(&chv_lock, flags); 1255 1274 intsel = chv_readl(pctrl, hwirq, CHV_PADCTRL0); 1256 1275 intsel &= CHV_PADCTRL0_INTSEL_MASK; 1257 1276 intsel >>= CHV_PADCTRL0_INTSEL_SHIFT; ··· 1266 1289 intsel, hwirq); 1267 1290 cctx->intr_lines[intsel] = hwirq; 1268 1291 } 1269 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1270 1292 } 1271 1293 1272 1294 chv_gpio_irq_unmask(d); ··· 1330 1354 struct gpio_chip *gc = irq_data_get_irq_chip_data(d); 1331 1355 struct intel_pinctrl *pctrl = gpiochip_get_data(gc); 1332 1356 irq_hw_number_t hwirq = irqd_to_hwirq(d); 1333 - unsigned long flags; 1334 1357 u32 value; 1335 1358 int ret; 1336 1359 1337 - raw_spin_lock_irqsave(&chv_lock, flags); 1360 + guard(raw_spinlock_irqsave)(&chv_lock); 1338 1361 1339 1362 ret = chv_gpio_set_intr_line(pctrl, hwirq); 1340 - if (ret) { 1341 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1363 + if (ret) 1342 1364 return ret; 1343 - } 1344 1365 1345 1366 /* 1346 1367 * Pins which can be used as shared interrupt are configured in ··· 1378 1405 else if (type & IRQ_TYPE_LEVEL_MASK) 1379 1406 irq_set_handler_locked(d, handle_level_irq); 1380 1407 1381 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1382 - 1383 1408 return 0; 1384 1409 } 1385 1410 ··· 1401 1430 struct intel_community_context *cctx = &pctrl->context.communities[0]; 1402 1431 struct irq_chip *chip = irq_desc_get_chip(desc); 1403 1432 unsigned long pending; 1404 - unsigned long flags; 1405 1433 u32 intr_line; 1406 1434 1407 1435 chained_irq_enter(chip, desc); 1408 1436 1409 - raw_spin_lock_irqsave(&chv_lock, flags); 1410 - pending = chv_pctrl_readl(pctrl, CHV_INTSTAT); 1411 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1437 + scoped_guard(raw_spinlock_irqsave, &chv_lock) 1438 + pending = chv_pctrl_readl(pctrl, CHV_INTSTAT); 1412 1439 1413 1440 for_each_set_bit(intr_line, &pending, community->nirqs) { 1414 1441 unsigned int offset; ··· 1595 1626 void *handler_context, void *region_context) 1596 1627 { 1597 1628 struct intel_pinctrl *pctrl = region_context; 1598 - unsigned long flags; 1599 - acpi_status ret = AE_OK; 1600 1629 1601 - raw_spin_lock_irqsave(&chv_lock, flags); 1630 + guard(raw_spinlock_irqsave)(&chv_lock); 1602 1631 1603 1632 if (function == ACPI_WRITE) 1604 1633 chv_pctrl_writel(pctrl, address, *value); 1605 1634 else if (function == ACPI_READ) 1606 1635 *value = chv_pctrl_readl(pctrl, address); 1607 1636 else 1608 - ret = AE_BAD_PARAMETER; 1637 + return AE_BAD_PARAMETER; 1609 1638 1610 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1611 - 1612 - return ret; 1639 + return AE_OK; 1613 1640 } 1614 1641 1615 1642 static int chv_pinctrl_probe(struct platform_device *pdev) ··· 1693 1728 return 0; 1694 1729 } 1695 1730 1696 - static int chv_pinctrl_remove(struct platform_device *pdev) 1731 + static void chv_pinctrl_remove(struct platform_device *pdev) 1697 1732 { 1698 1733 struct intel_pinctrl *pctrl = platform_get_drvdata(pdev); 1699 1734 const struct intel_community *community = &pctrl->communities[0]; ··· 1701 1736 acpi_remove_address_space_handler(ACPI_HANDLE(&pdev->dev), 1702 1737 community->acpi_space_id, 1703 1738 chv_pinctrl_mmio_access_handler); 1704 - 1705 - return 0; 1706 1739 } 1707 1740 1708 1741 static int chv_pinctrl_suspend_noirq(struct device *dev) 1709 1742 { 1710 1743 struct intel_pinctrl *pctrl = dev_get_drvdata(dev); 1711 1744 struct intel_community_context *cctx = &pctrl->context.communities[0]; 1712 - unsigned long flags; 1713 1745 int i; 1714 1746 1715 - raw_spin_lock_irqsave(&chv_lock, flags); 1747 + guard(raw_spinlock_irqsave)(&chv_lock); 1716 1748 1717 1749 cctx->saved_intmask = chv_pctrl_readl(pctrl, CHV_INTMASK); 1718 1750 ··· 1727 1765 ctx->padctrl1 = chv_readl(pctrl, desc->number, CHV_PADCTRL1); 1728 1766 } 1729 1767 1730 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1731 - 1732 1768 return 0; 1733 1769 } 1734 1770 ··· 1734 1774 { 1735 1775 struct intel_pinctrl *pctrl = dev_get_drvdata(dev); 1736 1776 struct intel_community_context *cctx = &pctrl->context.communities[0]; 1737 - unsigned long flags; 1738 1777 int i; 1739 1778 1740 - raw_spin_lock_irqsave(&chv_lock, flags); 1779 + guard(raw_spinlock_irqsave)(&chv_lock); 1741 1780 1742 1781 /* 1743 1782 * Mask all interrupts before restoring per-pin configuration ··· 1778 1819 chv_pctrl_writel(pctrl, CHV_INTSTAT, 0xffff); 1779 1820 chv_pctrl_writel(pctrl, CHV_INTMASK, cctx->saved_intmask); 1780 1821 1781 - raw_spin_unlock_irqrestore(&chv_lock, flags); 1782 - 1783 1822 return 0; 1784 1823 } 1785 1824 ··· 1792 1835 1793 1836 static struct platform_driver chv_pinctrl_driver = { 1794 1837 .probe = chv_pinctrl_probe, 1795 - .remove = chv_pinctrl_remove, 1838 + .remove_new = chv_pinctrl_remove, 1796 1839 .driver = { 1797 1840 .name = "cherryview-pinctrl", 1798 1841 .pm = pm_sleep_ptr(&chv_pinctrl_pm_ops),
+7
drivers/pinctrl/intel/pinctrl-denverton.c
··· 257 257 }; 258 258 MODULE_DEVICE_TABLE(acpi, dnv_pinctrl_acpi_match); 259 259 260 + static const struct platform_device_id dnv_pinctrl_platform_ids[] = { 261 + { "denverton-pinctrl", (kernel_ulong_t)&dnv_soc_data }, 262 + { } 263 + }; 264 + MODULE_DEVICE_TABLE(platform, dnv_pinctrl_platform_ids); 265 + 260 266 static struct platform_driver dnv_pinctrl_driver = { 261 267 .probe = intel_pinctrl_probe_by_hid, 262 268 .driver = { ··· 270 264 .acpi_match_table = dnv_pinctrl_acpi_match, 271 265 .pm = &dnv_pinctrl_pm_ops, 272 266 }, 267 + .id_table = dnv_pinctrl_platform_ids, 273 268 }; 274 269 275 270 static int __init dnv_pinctrl_init(void)
+83 -115
drivers/pinctrl/intel/pinctrl-intel.c
··· 8 8 */ 9 9 10 10 #include <linux/acpi.h> 11 + #include <linux/cleanup.h> 11 12 #include <linux/gpio/driver.h> 12 13 #include <linux/interrupt.h> 13 14 #include <linux/log2.h> ··· 394 393 { 395 394 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 396 395 const struct intel_pingroup *grp = &pctrl->soc->groups[group]; 397 - unsigned long flags; 398 396 int i; 399 397 400 - raw_spin_lock_irqsave(&pctrl->lock, flags); 398 + guard(raw_spinlock_irqsave)(&pctrl->lock); 401 399 402 400 /* 403 401 * All pins in the groups needs to be accessible and writable 404 402 * before we can enable the mux for this group. 405 403 */ 406 404 for (i = 0; i < grp->grp.npins; i++) { 407 - if (!intel_pad_usable(pctrl, grp->grp.pins[i])) { 408 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 405 + if (!intel_pad_usable(pctrl, grp->grp.pins[i])) 409 406 return -EBUSY; 410 - } 411 407 } 412 408 413 409 /* Now enable the mux setting for each pin in the group */ ··· 425 427 value |= pmode << PADCFG0_PMODE_SHIFT; 426 428 writel(value, padcfg0); 427 429 } 428 - 429 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 430 430 431 431 return 0; 432 432 } ··· 481 485 { 482 486 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 483 487 void __iomem *padcfg0; 484 - unsigned long flags; 485 488 486 489 padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); 487 490 488 - raw_spin_lock_irqsave(&pctrl->lock, flags); 491 + guard(raw_spinlock_irqsave)(&pctrl->lock); 489 492 490 - if (!intel_pad_owned_by_host(pctrl, pin)) { 491 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 493 + if (!intel_pad_owned_by_host(pctrl, pin)) 492 494 return -EBUSY; 493 - } 494 495 495 - if (!intel_pad_is_unlocked(pctrl, pin)) { 496 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 496 + if (!intel_pad_is_unlocked(pctrl, pin)) 497 497 return 0; 498 - } 499 498 500 499 /* 501 500 * If pin is already configured in GPIO mode, we assume that ··· 498 507 * potential glitches on the pin. Otherwise, for the pin in 499 508 * alternative mode, consumer has to supply respective flags. 500 509 */ 501 - if (intel_gpio_get_gpio_mode(padcfg0) == PADCFG0_PMODE_GPIO) { 502 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 510 + if (intel_gpio_get_gpio_mode(padcfg0) == PADCFG0_PMODE_GPIO) 503 511 return 0; 504 - } 505 512 506 513 intel_gpio_set_gpio_mode(padcfg0); 507 - 508 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 509 514 510 515 return 0; 511 516 } ··· 512 525 { 513 526 struct intel_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); 514 527 void __iomem *padcfg0; 515 - unsigned long flags; 516 528 517 529 padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); 518 530 519 - raw_spin_lock_irqsave(&pctrl->lock, flags); 531 + guard(raw_spinlock_irqsave)(&pctrl->lock); 532 + 520 533 __intel_gpio_set_direction(padcfg0, input); 521 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 522 534 523 535 return 0; 524 536 } ··· 534 548 static int intel_config_get_pull(struct intel_pinctrl *pctrl, unsigned int pin, 535 549 enum pin_config_param param, u32 *arg) 536 550 { 537 - const struct intel_community *community; 538 551 void __iomem *padcfg1; 539 - unsigned long flags; 540 552 u32 value, term; 541 553 542 - community = intel_get_community(pctrl, pin); 543 554 padcfg1 = intel_get_padcfg(pctrl, pin, PADCFG1); 544 555 545 - raw_spin_lock_irqsave(&pctrl->lock, flags); 546 - value = readl(padcfg1); 547 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 556 + scoped_guard(raw_spinlock_irqsave, &pctrl->lock) 557 + value = readl(padcfg1); 548 558 549 559 term = (value & PADCFG1_TERM_MASK) >> PADCFG1_TERM_SHIFT; 550 560 ··· 574 592 575 593 break; 576 594 577 - case PIN_CONFIG_BIAS_PULL_DOWN: 595 + case PIN_CONFIG_BIAS_PULL_DOWN: { 596 + const struct intel_community *community = intel_get_community(pctrl, pin); 597 + 578 598 if (!term || value & PADCFG1_TERM_UP) 579 599 return -EINVAL; 580 600 ··· 603 619 } 604 620 605 621 break; 622 + } 606 623 607 624 default: 608 625 return -EINVAL; ··· 616 631 enum pin_config_param param, u32 *arg) 617 632 { 618 633 void __iomem *padcfg2; 619 - unsigned long flags; 620 634 unsigned long v; 621 635 u32 value2; 622 636 ··· 623 639 if (!padcfg2) 624 640 return -ENOTSUPP; 625 641 626 - raw_spin_lock_irqsave(&pctrl->lock, flags); 627 - value2 = readl(padcfg2); 628 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 642 + scoped_guard(raw_spinlock_irqsave, &pctrl->lock) 643 + value2 = readl(padcfg2); 644 + 629 645 if (!(value2 & PADCFG2_DEBEN)) 630 646 return -EINVAL; 631 647 ··· 674 690 { 675 691 unsigned int param = pinconf_to_config_param(config); 676 692 unsigned int arg = pinconf_to_config_argument(config); 677 - const struct intel_community *community; 693 + u32 term = 0, up = 0, value; 678 694 void __iomem *padcfg1; 679 - unsigned long flags; 680 - int ret = 0; 681 - u32 value; 682 - 683 - community = intel_get_community(pctrl, pin); 684 - padcfg1 = intel_get_padcfg(pctrl, pin, PADCFG1); 685 - 686 - raw_spin_lock_irqsave(&pctrl->lock, flags); 687 - 688 - value = readl(padcfg1); 689 - value &= ~(PADCFG1_TERM_MASK | PADCFG1_TERM_UP); 690 695 691 696 /* Set default strength value in case none is given */ 692 697 if (arg == 1) ··· 688 715 case PIN_CONFIG_BIAS_PULL_UP: 689 716 switch (arg) { 690 717 case 20000: 691 - value |= PADCFG1_TERM_20K << PADCFG1_TERM_SHIFT; 718 + term = PADCFG1_TERM_20K; 692 719 break; 693 720 case 5000: 694 - value |= PADCFG1_TERM_5K << PADCFG1_TERM_SHIFT; 721 + term = PADCFG1_TERM_5K; 695 722 break; 696 723 case 4000: 697 - value |= PADCFG1_TERM_4K << PADCFG1_TERM_SHIFT; 724 + term = PADCFG1_TERM_4K; 698 725 break; 699 726 case 1000: 700 - value |= PADCFG1_TERM_1K << PADCFG1_TERM_SHIFT; 727 + term = PADCFG1_TERM_1K; 701 728 break; 702 729 case 833: 703 - value |= PADCFG1_TERM_833 << PADCFG1_TERM_SHIFT; 730 + term = PADCFG1_TERM_833; 704 731 break; 705 732 default: 706 - ret = -EINVAL; 707 - break; 733 + return -EINVAL; 708 734 } 709 735 710 - value |= PADCFG1_TERM_UP; 736 + up = PADCFG1_TERM_UP; 711 737 break; 712 738 713 - case PIN_CONFIG_BIAS_PULL_DOWN: 739 + case PIN_CONFIG_BIAS_PULL_DOWN: { 740 + const struct intel_community *community = intel_get_community(pctrl, pin); 741 + 714 742 switch (arg) { 715 743 case 20000: 716 - value |= PADCFG1_TERM_20K << PADCFG1_TERM_SHIFT; 744 + term = PADCFG1_TERM_20K; 717 745 break; 718 746 case 5000: 719 - value |= PADCFG1_TERM_5K << PADCFG1_TERM_SHIFT; 747 + term = PADCFG1_TERM_5K; 720 748 break; 721 749 case 4000: 722 - value |= PADCFG1_TERM_4K << PADCFG1_TERM_SHIFT; 750 + term = PADCFG1_TERM_4K; 723 751 break; 724 752 case 1000: 725 - if (!(community->features & PINCTRL_FEATURE_1K_PD)) { 726 - ret = -EINVAL; 727 - break; 728 - } 729 - value |= PADCFG1_TERM_1K << PADCFG1_TERM_SHIFT; 753 + if (!(community->features & PINCTRL_FEATURE_1K_PD)) 754 + return -EINVAL; 755 + term = PADCFG1_TERM_1K; 730 756 break; 731 757 case 833: 732 - if (!(community->features & PINCTRL_FEATURE_1K_PD)) { 733 - ret = -EINVAL; 734 - break; 735 - } 736 - value |= PADCFG1_TERM_833 << PADCFG1_TERM_SHIFT; 758 + if (!(community->features & PINCTRL_FEATURE_1K_PD)) 759 + return -EINVAL; 760 + term = PADCFG1_TERM_833; 737 761 break; 738 762 default: 739 - ret = -EINVAL; 740 - break; 763 + return -EINVAL; 741 764 } 742 765 743 - break; 744 - 745 - default: 746 - ret = -EINVAL; 747 766 break; 748 767 } 749 768 750 - if (!ret) 751 - writel(value, padcfg1); 769 + default: 770 + return -EINVAL; 771 + } 752 772 753 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 773 + padcfg1 = intel_get_padcfg(pctrl, pin, PADCFG1); 754 774 755 - return ret; 775 + guard(raw_spinlock_irqsave)(&pctrl->lock); 776 + 777 + value = readl(padcfg1); 778 + value = (value & ~PADCFG1_TERM_MASK) | (term << PADCFG1_TERM_SHIFT); 779 + value = (value & ~PADCFG1_TERM_UP) | up; 780 + writel(value, padcfg1); 781 + 782 + return 0; 756 783 } 757 784 758 785 static int intel_config_set_debounce(struct intel_pinctrl *pctrl, 759 786 unsigned int pin, unsigned int debounce) 760 787 { 761 788 void __iomem *padcfg0, *padcfg2; 762 - unsigned long flags; 763 789 u32 value0, value2; 764 790 765 791 padcfg2 = intel_get_padcfg(pctrl, pin, PADCFG2); ··· 767 795 768 796 padcfg0 = intel_get_padcfg(pctrl, pin, PADCFG0); 769 797 770 - raw_spin_lock_irqsave(&pctrl->lock, flags); 798 + guard(raw_spinlock_irqsave)(&pctrl->lock); 771 799 772 800 value0 = readl(padcfg0); 773 801 value2 = readl(padcfg2); ··· 780 808 unsigned long v; 781 809 782 810 v = order_base_2(debounce * NSEC_PER_USEC / DEBOUNCE_PERIOD_NSEC); 783 - if (v < 3 || v > 15) { 784 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 811 + if (v < 3 || v > 15) 785 812 return -EINVAL; 786 - } 787 813 788 814 /* Enable glitch filter and debouncer */ 789 815 value0 |= PADCFG0_PREGFRXSEL; ··· 791 821 792 822 writel(value0, padcfg0); 793 823 writel(value2, padcfg2); 794 - 795 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 796 824 797 825 return 0; 798 826 } ··· 941 973 int value) 942 974 { 943 975 struct intel_pinctrl *pctrl = gpiochip_get_data(chip); 944 - unsigned long flags; 945 976 void __iomem *reg; 946 977 u32 padcfg0; 947 978 int pin; ··· 953 986 if (!reg) 954 987 return; 955 988 956 - raw_spin_lock_irqsave(&pctrl->lock, flags); 989 + guard(raw_spinlock_irqsave)(&pctrl->lock); 990 + 957 991 padcfg0 = readl(reg); 958 992 if (value) 959 993 padcfg0 |= PADCFG0_GPIOTXSTATE; 960 994 else 961 995 padcfg0 &= ~PADCFG0_GPIOTXSTATE; 962 996 writel(padcfg0, reg); 963 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 964 997 } 965 998 966 999 static int intel_gpio_get_direction(struct gpio_chip *chip, unsigned int offset) 967 1000 { 968 1001 struct intel_pinctrl *pctrl = gpiochip_get_data(chip); 969 - unsigned long flags; 970 1002 void __iomem *reg; 971 1003 u32 padcfg0; 972 1004 int pin; ··· 978 1012 if (!reg) 979 1013 return -EINVAL; 980 1014 981 - raw_spin_lock_irqsave(&pctrl->lock, flags); 982 - padcfg0 = readl(reg); 983 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 1015 + scoped_guard(raw_spinlock_irqsave, &pctrl->lock) 1016 + padcfg0 = readl(reg); 1017 + 984 1018 if (padcfg0 & PADCFG0_PMODE_MASK) 985 1019 return -EINVAL; 986 1020 ··· 1024 1058 1025 1059 pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), &community, &padgrp); 1026 1060 if (pin >= 0) { 1027 - unsigned int gpp, gpp_offset, is_offset; 1061 + unsigned int gpp, gpp_offset; 1062 + void __iomem *is; 1028 1063 1029 1064 gpp = padgrp->reg_num; 1030 1065 gpp_offset = padgroup_offset(padgrp, pin); 1031 - is_offset = community->is_offset + gpp * 4; 1032 1066 1033 - raw_spin_lock(&pctrl->lock); 1034 - writel(BIT(gpp_offset), community->regs + is_offset); 1035 - raw_spin_unlock(&pctrl->lock); 1067 + is = community->regs + community->is_offset + gpp * 4; 1068 + 1069 + guard(raw_spinlock)(&pctrl->lock); 1070 + 1071 + writel(BIT(gpp_offset), is); 1036 1072 } 1037 1073 } 1038 1074 ··· 1048 1080 pin = intel_gpio_to_pin(pctrl, hwirq, &community, &padgrp); 1049 1081 if (pin >= 0) { 1050 1082 unsigned int gpp, gpp_offset; 1051 - unsigned long flags; 1052 1083 void __iomem *reg, *is; 1053 1084 u32 value; 1054 1085 ··· 1057 1090 reg = community->regs + community->ie_offset + gpp * 4; 1058 1091 is = community->regs + community->is_offset + gpp * 4; 1059 1092 1060 - raw_spin_lock_irqsave(&pctrl->lock, flags); 1093 + guard(raw_spinlock_irqsave)(&pctrl->lock); 1061 1094 1062 1095 /* Clear interrupt status first to avoid unexpected interrupt */ 1063 1096 writel(BIT(gpp_offset), is); ··· 1068 1101 else 1069 1102 value |= BIT(gpp_offset); 1070 1103 writel(value, reg); 1071 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 1072 1104 } 1073 1105 } 1074 1106 ··· 1095 1129 struct intel_pinctrl *pctrl = gpiochip_get_data(gc); 1096 1130 unsigned int pin = intel_gpio_to_pin(pctrl, irqd_to_hwirq(d), NULL, NULL); 1097 1131 u32 rxevcfg, rxinv, value; 1098 - unsigned long flags; 1099 1132 void __iomem *reg; 1100 1133 1101 1134 reg = intel_get_padcfg(pctrl, pin, PADCFG0); ··· 1128 1163 else 1129 1164 rxinv = 0; 1130 1165 1131 - raw_spin_lock_irqsave(&pctrl->lock, flags); 1166 + guard(raw_spinlock_irqsave)(&pctrl->lock); 1132 1167 1133 1168 intel_gpio_set_gpio_mode(reg); 1134 1169 ··· 1143 1178 irq_set_handler_locked(d, handle_edge_irq); 1144 1179 else if (type & IRQ_TYPE_LEVEL_MASK) 1145 1180 irq_set_handler_locked(d, handle_level_irq); 1146 - 1147 - raw_spin_unlock_irqrestore(&pctrl->lock, flags); 1148 1181 1149 1182 return 0; 1150 1183 } ··· 1182 1219 1183 1220 for (gpp = 0; gpp < community->ngpps; gpp++) { 1184 1221 const struct intel_padgroup *padgrp = &community->gpps[gpp]; 1185 - unsigned long pending, enabled, gpp_offset; 1222 + unsigned long pending, enabled; 1223 + unsigned int gpp, gpp_offset; 1224 + void __iomem *reg, *is; 1186 1225 1187 - raw_spin_lock(&pctrl->lock); 1226 + gpp = padgrp->reg_num; 1188 1227 1189 - pending = readl(community->regs + community->is_offset + 1190 - padgrp->reg_num * 4); 1191 - enabled = readl(community->regs + community->ie_offset + 1192 - padgrp->reg_num * 4); 1228 + reg = community->regs + community->ie_offset + gpp * 4; 1229 + is = community->regs + community->is_offset + gpp * 4; 1193 1230 1194 - raw_spin_unlock(&pctrl->lock); 1231 + scoped_guard(raw_spinlock, &pctrl->lock) { 1232 + pending = readl(is); 1233 + enabled = readl(reg); 1234 + } 1195 1235 1196 1236 /* Only interrupts that are enabled */ 1197 1237 pending &= enabled; ··· 1230 1264 1231 1265 for (i = 0; i < pctrl->ncommunities; i++) { 1232 1266 const struct intel_community *community; 1233 - void __iomem *base; 1267 + void __iomem *reg, *is; 1234 1268 unsigned int gpp; 1235 1269 1236 1270 community = &pctrl->communities[i]; 1237 - base = community->regs; 1238 1271 1239 1272 for (gpp = 0; gpp < community->ngpps; gpp++) { 1273 + reg = community->regs + community->ie_offset + gpp * 4; 1274 + is = community->regs + community->is_offset + gpp * 4; 1275 + 1240 1276 /* Mask and clear all interrupts */ 1241 - writel(0, base + community->ie_offset + gpp * 4); 1242 - writel(0xffff, base + community->is_offset + gpp * 4); 1277 + writel(0, reg); 1278 + writel(0xffff, is); 1243 1279 } 1244 1280 } 1245 1281 }
+1 -1
drivers/pinctrl/intel/pinctrl-intel.h
··· 10 10 #ifndef PINCTRL_INTEL_H 11 11 #define PINCTRL_INTEL_H 12 12 13 + #include <linux/array_size.h> 13 14 #include <linux/bits.h> 14 15 #include <linux/compiler_types.h> 15 16 #include <linux/gpio/driver.h> 16 17 #include <linux/irq.h> 17 - #include <linux/kernel.h> 18 18 #include <linux/pm.h> 19 19 #include <linux/pinctrl/pinctrl.h> 20 20 #include <linux/spinlock_types.h>
+4 -30
drivers/pinctrl/intel/pinctrl-lynxpoint.c
··· 8 8 */ 9 9 10 10 #include <linux/acpi.h> 11 + #include <linux/array_size.h> 11 12 #include <linux/bitops.h> 12 13 #include <linux/gpio/driver.h> 13 14 #include <linux/interrupt.h> 14 15 #include <linux/io.h> 15 - #include <linux/kernel.h> 16 16 #include <linux/module.h> 17 17 #include <linux/platform_device.h> 18 - #include <linux/pm_runtime.h> 18 + #include <linux/pm.h> 19 19 #include <linux/seq_file.h> 20 20 #include <linux/slab.h> 21 21 #include <linux/types.h> ··· 337 337 unsigned long flags; 338 338 u32 value; 339 339 340 - pm_runtime_get(lg->dev); 341 - 342 340 raw_spin_lock_irqsave(&lg->lock, flags); 343 341 344 342 /* ··· 371 373 lp_gpio_disable_input(conf2); 372 374 373 375 raw_spin_unlock_irqrestore(&lg->lock, flags); 374 - 375 - pm_runtime_put(lg->dev); 376 376 } 377 377 378 378 static int lp_gpio_set_direction(struct pinctrl_dev *pctldev, ··· 837 841 return ret; 838 842 } 839 843 840 - pm_runtime_enable(dev); 841 - 842 - return 0; 843 - } 844 - 845 - static int lp_gpio_remove(struct platform_device *pdev) 846 - { 847 - pm_runtime_disable(&pdev->dev); 848 - return 0; 849 - } 850 - 851 - static int lp_gpio_runtime_suspend(struct device *dev) 852 - { 853 - return 0; 854 - } 855 - 856 - static int lp_gpio_runtime_resume(struct device *dev) 857 - { 858 844 return 0; 859 845 } 860 846 ··· 854 876 return 0; 855 877 } 856 878 857 - static const struct dev_pm_ops lp_gpio_pm_ops = { 858 - SYSTEM_SLEEP_PM_OPS(NULL, lp_gpio_resume) 859 - RUNTIME_PM_OPS(lp_gpio_runtime_suspend, lp_gpio_runtime_resume, NULL) 860 - }; 879 + static DEFINE_SIMPLE_DEV_PM_OPS(lp_gpio_pm_ops, NULL, lp_gpio_resume); 861 880 862 881 static const struct acpi_device_id lynxpoint_gpio_acpi_match[] = { 863 882 { "INT33C7", (kernel_ulong_t)&lptlp_soc_data }, ··· 865 890 866 891 static struct platform_driver lp_gpio_driver = { 867 892 .probe = lp_gpio_probe, 868 - .remove = lp_gpio_remove, 869 893 .driver = { 870 894 .name = "lp_gpio", 871 - .pm = pm_ptr(&lp_gpio_pm_ops), 895 + .pm = pm_sleep_ptr(&lp_gpio_pm_ops), 872 896 .acpi_match_table = lynxpoint_gpio_acpi_match, 873 897 }, 874 898 };
+1 -1
drivers/pinctrl/intel/pinctrl-merrifield.c
··· 6 6 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 7 7 */ 8 8 9 + #include <linux/array_size.h> 9 10 #include <linux/init.h> 10 - #include <linux/kernel.h> 11 11 #include <linux/mod_devicetable.h> 12 12 #include <linux/module.h> 13 13 #include <linux/platform_device.h>
+1 -1
drivers/pinctrl/intel/pinctrl-moorefield.c
··· 6 6 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com> 7 7 */ 8 8 9 + #include <linux/array_size.h> 9 10 #include <linux/init.h> 10 - #include <linux/kernel.h> 11 11 #include <linux/mod_devicetable.h> 12 12 #include <linux/module.h> 13 13 #include <linux/platform_device.h>
+11 -9
drivers/pinctrl/pinconf-generic.c
··· 10 10 11 11 #define pr_fmt(fmt) "generic pinconfig core: " fmt 12 12 13 - #include <linux/kernel.h> 14 - #include <linux/module.h> 15 - #include <linux/init.h> 16 - #include <linux/device.h> 17 - #include <linux/slab.h> 13 + #include <linux/array_size.h> 18 14 #include <linux/debugfs.h> 19 - #include <linux/seq_file.h> 20 - #include <linux/pinctrl/pinctrl.h> 21 - #include <linux/pinctrl/pinconf.h> 22 - #include <linux/pinctrl/pinconf-generic.h> 15 + #include <linux/device.h> 16 + #include <linux/init.h> 17 + #include <linux/module.h> 23 18 #include <linux/of.h> 19 + #include <linux/slab.h> 20 + #include <linux/seq_file.h> 21 + 22 + #include <linux/pinctrl/pinconf-generic.h> 23 + #include <linux/pinctrl/pinconf.h> 24 + #include <linux/pinctrl/pinctrl.h> 25 + 24 26 #include "core.h" 25 27 #include "pinconf.h" 26 28 #include "pinctrl-utils.h"
+8 -6
drivers/pinctrl/pinconf.c
··· 9 9 */ 10 10 #define pr_fmt(fmt) "pinconfig core: " fmt 11 11 12 - #include <linux/kernel.h> 13 - #include <linux/module.h> 14 - #include <linux/init.h> 15 - #include <linux/device.h> 16 - #include <linux/slab.h> 12 + #include <linux/array_size.h> 17 13 #include <linux/debugfs.h> 14 + #include <linux/device.h> 15 + #include <linux/init.h> 16 + #include <linux/module.h> 18 17 #include <linux/seq_file.h> 18 + #include <linux/slab.h> 19 + 19 20 #include <linux/pinctrl/machine.h> 20 - #include <linux/pinctrl/pinctrl.h> 21 21 #include <linux/pinctrl/pinconf.h> 22 + #include <linux/pinctrl/pinctrl.h> 23 + 22 24 #include "core.h" 23 25 #include "pinconf.h" 24 26
+4 -2
drivers/pinctrl/pinctrl-utils.c
··· 6 6 * 7 7 * Author: Laxman Dewangan <ldewangan@nvidia.com> 8 8 */ 9 + #include <linux/array_size.h> 9 10 #include <linux/device.h> 10 11 #include <linux/export.h> 11 - #include <linux/kernel.h> 12 - #include <linux/pinctrl/pinctrl.h> 13 12 #include <linux/of.h> 14 13 #include <linux/slab.h> 14 + 15 + #include <linux/pinctrl/pinctrl.h> 16 + 15 17 #include "core.h" 16 18 #include "pinctrl-utils.h" 17 19
+1 -1
drivers/pinctrl/pinmux.c
··· 12 12 */ 13 13 #define pr_fmt(fmt) "pinmux core: " fmt 14 14 15 + #include <linux/array_size.h> 15 16 #include <linux/ctype.h> 16 17 #include <linux/debugfs.h> 17 18 #include <linux/device.h> 18 19 #include <linux/err.h> 19 20 #include <linux/init.h> 20 - #include <linux/kernel.h> 21 21 #include <linux/list.h> 22 22 #include <linux/module.h> 23 23 #include <linux/radix-tree.h>
+13
include/linux/array_size.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_ARRAY_SIZE_H 3 + #define _LINUX_ARRAY_SIZE_H 4 + 5 + #include <linux/compiler.h> 6 + 7 + /** 8 + * ARRAY_SIZE - get the number of elements in array @arr 9 + * @arr: array to be sized 10 + */ 11 + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) 12 + 13 + #endif /* _LINUX_ARRAY_SIZE_H */
+1 -6
include/linux/kernel.h
··· 13 13 14 14 #include <linux/stdarg.h> 15 15 #include <linux/align.h> 16 + #include <linux/array_size.h> 16 17 #include <linux/limits.h> 17 18 #include <linux/linkage.h> 18 19 #include <linux/stddef.h> ··· 50 49 /* generic data direction definitions */ 51 50 #define READ 0 52 51 #define WRITE 1 53 - 54 - /** 55 - * ARRAY_SIZE - get the number of elements in array @arr 56 - * @arr: array to be sized 57 - */ 58 - #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) 59 52 60 53 #define PTR_IF(cond, ptr) ((cond) ? (ptr) : NULL) 61 54
+1 -1
include/linux/pinctrl/machine.h
··· 11 11 #ifndef __LINUX_PINCTRL_MACHINE_H 12 12 #define __LINUX_PINCTRL_MACHINE_H 13 13 14 - #include <linux/kernel.h> /* ARRAY_SIZE() */ 14 + #include <linux/array_size.h> 15 15 16 16 #include <linux/pinctrl/pinctrl-state.h> 17 17
+1
include/linux/string.h
··· 2 2 #ifndef _LINUX_STRING_H_ 3 3 #define _LINUX_STRING_H_ 4 4 5 + #include <linux/array_size.h> 5 6 #include <linux/compiler.h> /* for inline */ 6 7 #include <linux/types.h> /* for size_t */ 7 8 #include <linux/stddef.h> /* for NULL */