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

Merge tag 'intel-gpio-v6.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/andy/linux-gpio-intel into gpio/for-next

intel-gpio for v6.8-1

* Use RAII for locking in the Tangier family of drivers (Raag)
* Update Tangier family of drivers to use new PM helpers (Raag)

The following is an automated git shortlog grouped by driver:

elkhartlake:
- reuse pm_ops from Intel Tangier driver

tangier:
- simplify locking using cleanup helpers
- unexport suspend/resume handles
- use EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS() helper

+22 -59
+1 -13
drivers/gpio/gpio-elkhartlake.c
··· 55 55 return 0; 56 56 } 57 57 58 - static int ehl_gpio_suspend(struct device *dev) 59 - { 60 - return tng_gpio_suspend(dev); 61 - } 62 - 63 - static int ehl_gpio_resume(struct device *dev) 64 - { 65 - return tng_gpio_resume(dev); 66 - } 67 - 68 - static DEFINE_SIMPLE_DEV_PM_OPS(ehl_gpio_pm_ops, ehl_gpio_suspend, ehl_gpio_resume); 69 - 70 58 static const struct platform_device_id ehl_gpio_ids[] = { 71 59 { "gpio-elkhartlake" }, 72 60 { } ··· 64 76 static struct platform_driver ehl_gpio_driver = { 65 77 .driver = { 66 78 .name = "gpio-elkhartlake", 67 - .pm = pm_sleep_ptr(&ehl_gpio_pm_ops), 79 + .pm = pm_sleep_ptr(&tng_gpio_pm_ops), 68 80 }, 69 81 .probe = ehl_gpio_probe, 70 82 .id_table = ehl_gpio_ids,
+19 -44
drivers/gpio/gpio-tangier.c
··· 10 10 */ 11 11 12 12 #include <linux/bitops.h> 13 + #include <linux/cleanup.h> 13 14 #include <linux/device.h> 14 15 #include <linux/errno.h> 15 16 #include <linux/export.h> ··· 20 19 #include <linux/math.h> 21 20 #include <linux/module.h> 22 21 #include <linux/pinctrl/pinconf-generic.h> 22 + #include <linux/pm.h> 23 23 #include <linux/spinlock.h> 24 24 #include <linux/string_helpers.h> 25 25 #include <linux/types.h> ··· 93 91 static void tng_gpio_set(struct gpio_chip *chip, unsigned int offset, int value) 94 92 { 95 93 struct tng_gpio *priv = gpiochip_get_data(chip); 96 - unsigned long flags; 97 94 void __iomem *reg; 98 95 u8 shift; 99 96 100 97 reg = gpio_reg_and_bit(chip, offset, value ? GPSR : GPCR, &shift); 101 98 102 - raw_spin_lock_irqsave(&priv->lock, flags); 99 + guard(raw_spinlock_irqsave)(&priv->lock); 103 100 104 101 writel(BIT(shift), reg); 105 - 106 - raw_spin_unlock_irqrestore(&priv->lock, flags); 107 102 } 108 103 109 104 static int tng_gpio_direction_input(struct gpio_chip *chip, unsigned int offset) 110 105 { 111 106 struct tng_gpio *priv = gpiochip_get_data(chip); 112 - unsigned long flags; 113 107 void __iomem *gpdr; 114 108 u32 value; 115 109 u8 shift; 116 110 117 111 gpdr = gpio_reg_and_bit(chip, offset, GPDR, &shift); 118 112 119 - raw_spin_lock_irqsave(&priv->lock, flags); 113 + guard(raw_spinlock_irqsave)(&priv->lock); 120 114 121 115 value = readl(gpdr); 122 116 value &= ~BIT(shift); 123 117 writel(value, gpdr); 124 - 125 - raw_spin_unlock_irqrestore(&priv->lock, flags); 126 118 127 119 return 0; 128 120 } ··· 125 129 int value) 126 130 { 127 131 struct tng_gpio *priv = gpiochip_get_data(chip); 128 - unsigned long flags; 129 132 void __iomem *gpdr; 130 133 u8 shift; 131 134 132 135 gpdr = gpio_reg_and_bit(chip, offset, GPDR, &shift); 133 136 tng_gpio_set(chip, offset, value); 134 137 135 - raw_spin_lock_irqsave(&priv->lock, flags); 138 + guard(raw_spinlock_irqsave)(&priv->lock); 136 139 137 140 value = readl(gpdr); 138 141 value |= BIT(shift); 139 142 writel(value, gpdr); 140 - 141 - raw_spin_unlock_irqrestore(&priv->lock, flags); 142 143 143 144 return 0; 144 145 } ··· 157 164 unsigned int debounce) 158 165 { 159 166 struct tng_gpio *priv = gpiochip_get_data(chip); 160 - unsigned long flags; 161 167 void __iomem *gfbr; 162 168 u32 value; 163 169 u8 shift; 164 170 165 171 gfbr = gpio_reg_and_bit(chip, offset, GFBR, &shift); 166 172 167 - raw_spin_lock_irqsave(&priv->lock, flags); 173 + guard(raw_spinlock_irqsave)(&priv->lock); 168 174 169 175 value = readl(gfbr); 170 176 if (debounce) ··· 171 179 else 172 180 value |= BIT(shift); 173 181 writel(value, gfbr); 174 - 175 - raw_spin_unlock_irqrestore(&priv->lock, flags); 176 182 177 183 return 0; 178 184 } ··· 197 207 { 198 208 struct tng_gpio *priv = irq_data_get_irq_chip_data(d); 199 209 irq_hw_number_t gpio = irqd_to_hwirq(d); 200 - unsigned long flags; 201 210 void __iomem *gisr; 202 211 u8 shift; 203 212 204 213 gisr = gpio_reg_and_bit(&priv->chip, gpio, GISR, &shift); 205 214 206 - raw_spin_lock_irqsave(&priv->lock, flags); 215 + guard(raw_spinlock_irqsave)(&priv->lock); 216 + 207 217 writel(BIT(shift), gisr); 208 - raw_spin_unlock_irqrestore(&priv->lock, flags); 209 218 } 210 219 211 220 static void tng_irq_unmask_mask(struct tng_gpio *priv, u32 gpio, bool unmask) 212 221 { 213 - unsigned long flags; 214 222 void __iomem *gimr; 215 223 u32 value; 216 224 u8 shift; 217 225 218 226 gimr = gpio_reg_and_bit(&priv->chip, gpio, GIMR, &shift); 219 227 220 - raw_spin_lock_irqsave(&priv->lock, flags); 228 + guard(raw_spinlock_irqsave)(&priv->lock); 221 229 222 230 value = readl(gimr); 223 231 if (unmask) ··· 223 235 else 224 236 value &= ~BIT(shift); 225 237 writel(value, gimr); 226 - 227 - raw_spin_unlock_irqrestore(&priv->lock, flags); 228 238 } 229 239 230 240 static void tng_irq_mask(struct irq_data *d) ··· 253 267 void __iomem *gitr = gpio_reg(&priv->chip, gpio, GITR); 254 268 void __iomem *glpr = gpio_reg(&priv->chip, gpio, GLPR); 255 269 u8 shift = gpio % 32; 256 - unsigned long flags; 257 270 u32 value; 258 271 259 - raw_spin_lock_irqsave(&priv->lock, flags); 272 + guard(raw_spinlock_irqsave)(&priv->lock); 260 273 261 274 value = readl(grer); 262 275 if (type & IRQ_TYPE_EDGE_RISING) ··· 296 311 irq_set_handler_locked(d, handle_edge_irq); 297 312 } 298 313 299 - raw_spin_unlock_irqrestore(&priv->lock, flags); 300 - 301 314 return 0; 302 315 } 303 316 ··· 307 324 void __iomem *gwmr = gpio_reg(&priv->chip, gpio, priv->wake_regs.gwmr); 308 325 void __iomem *gwsr = gpio_reg(&priv->chip, gpio, priv->wake_regs.gwsr); 309 326 u8 shift = gpio % 32; 310 - unsigned long flags; 311 327 u32 value; 312 328 313 - raw_spin_lock_irqsave(&priv->lock, flags); 329 + dev_dbg(priv->dev, "%s wake for gpio %lu\n", str_enable_disable(on), gpio); 330 + 331 + guard(raw_spinlock_irqsave)(&priv->lock); 314 332 315 333 /* Clear the existing wake status */ 316 334 writel(BIT(shift), gwsr); ··· 323 339 value &= ~BIT(shift); 324 340 writel(value, gwmr); 325 341 326 - raw_spin_unlock_irqrestore(&priv->lock, flags); 327 - 328 - dev_dbg(priv->dev, "%s wake for gpio %lu\n", str_enable_disable(on), gpio); 329 342 return 0; 330 343 } 331 344 ··· 458 477 } 459 478 EXPORT_SYMBOL_NS_GPL(devm_tng_gpio_probe, GPIO_TANGIER); 460 479 461 - int tng_gpio_suspend(struct device *dev) 480 + static int tng_gpio_suspend(struct device *dev) 462 481 { 463 482 struct tng_gpio *priv = dev_get_drvdata(dev); 464 483 struct tng_gpio_context *ctx = priv->ctx; 465 - unsigned long flags; 466 484 unsigned int base; 467 485 468 - raw_spin_lock_irqsave(&priv->lock, flags); 486 + guard(raw_spinlock_irqsave)(&priv->lock); 469 487 470 488 for (base = 0; base < priv->chip.ngpio; base += 32, ctx++) { 471 489 /* GPLR is RO, values read will be restored using GPSR */ ··· 478 498 ctx->gwmr = readl(gpio_reg(&priv->chip, base, priv->wake_regs.gwmr)); 479 499 } 480 500 481 - raw_spin_unlock_irqrestore(&priv->lock, flags); 482 - 483 501 return 0; 484 502 } 485 - EXPORT_SYMBOL_NS_GPL(tng_gpio_suspend, GPIO_TANGIER); 486 503 487 - int tng_gpio_resume(struct device *dev) 504 + static int tng_gpio_resume(struct device *dev) 488 505 { 489 506 struct tng_gpio *priv = dev_get_drvdata(dev); 490 507 struct tng_gpio_context *ctx = priv->ctx; 491 - unsigned long flags; 492 508 unsigned int base; 493 509 494 - raw_spin_lock_irqsave(&priv->lock, flags); 510 + guard(raw_spinlock_irqsave)(&priv->lock); 495 511 496 512 for (base = 0; base < priv->chip.ngpio; base += 32, ctx++) { 497 513 /* GPLR is RO, values read will be restored using GPSR */ ··· 501 525 writel(ctx->gwmr, gpio_reg(&priv->chip, base, priv->wake_regs.gwmr)); 502 526 } 503 527 504 - raw_spin_unlock_irqrestore(&priv->lock, flags); 505 - 506 528 return 0; 507 529 } 508 - EXPORT_SYMBOL_NS_GPL(tng_gpio_resume, GPIO_TANGIER); 530 + 531 + EXPORT_NS_GPL_SIMPLE_DEV_PM_OPS(tng_gpio_pm_ops, tng_gpio_suspend, tng_gpio_resume, GPIO_TANGIER); 509 532 510 533 MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>"); 511 534 MODULE_AUTHOR("Pandith N <pandith.n@intel.com>");
+2 -2
drivers/gpio/gpio-tangier.h
··· 13 13 #define _GPIO_TANGIER_H_ 14 14 15 15 #include <linux/gpio/driver.h> 16 + #include <linux/pm.h> 16 17 #include <linux/spinlock_types.h> 17 18 #include <linux/types.h> 18 19 ··· 112 111 113 112 int devm_tng_gpio_probe(struct device *dev, struct tng_gpio *gpio); 114 113 115 - int tng_gpio_suspend(struct device *dev); 116 - int tng_gpio_resume(struct device *dev); 114 + extern const struct dev_pm_ops tng_gpio_pm_ops; 117 115 118 116 #endif /* _GPIO_TANGIER_H_ */