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

pinctrl: pinctrl-adi2: Remove nested lock+irqsave that resue flags.

Also avoid use NULL pointer in error message.

v2-changes:
- use port pinter only after checking

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Sonic Zhang and committed by
Linus Walleij
010c51e1 a047914e

+22 -18
+22 -18
drivers/pinctrl/pinctrl-adi2.c
··· 247 247 unsigned pintbit = hwirq_to_pintbit(port, d->hwirq); 248 248 249 249 spin_lock_irqsave(&port->lock, flags); 250 - spin_lock_irqsave(&port->pint->lock, flags); 250 + spin_lock(&port->pint->lock); 251 251 252 252 if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) { 253 253 if (readl(&regs->invert_set) & pintbit) ··· 258 258 259 259 writel(pintbit, &regs->request); 260 260 261 - spin_unlock_irqrestore(&port->pint->lock, flags); 261 + spin_unlock(&port->pint->lock); 262 262 spin_unlock_irqrestore(&port->lock, flags); 263 263 } 264 264 ··· 270 270 unsigned pintbit = hwirq_to_pintbit(port, d->hwirq); 271 271 272 272 spin_lock_irqsave(&port->lock, flags); 273 - spin_lock_irqsave(&port->pint->lock, flags); 273 + spin_lock(&port->pint->lock); 274 274 275 275 if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) { 276 276 if (readl(&regs->invert_set) & pintbit) ··· 282 282 writel(pintbit, &regs->request); 283 283 writel(pintbit, &regs->mask_clear); 284 284 285 - spin_unlock_irqrestore(&port->pint->lock, flags); 285 + spin_unlock(&port->pint->lock); 286 286 spin_unlock_irqrestore(&port->lock, flags); 287 287 } 288 288 ··· 293 293 struct gpio_pint_regs *regs = port->pint->regs; 294 294 295 295 spin_lock_irqsave(&port->lock, flags); 296 - spin_lock_irqsave(&port->pint->lock, flags); 296 + spin_lock(&port->pint->lock); 297 297 298 298 writel(hwirq_to_pintbit(port, d->hwirq), &regs->mask_clear); 299 299 300 - spin_unlock_irqrestore(&port->pint->lock, flags); 300 + spin_unlock(&port->pint->lock); 301 301 spin_unlock_irqrestore(&port->lock, flags); 302 302 } 303 303 ··· 308 308 struct gpio_pint_regs *regs = port->pint->regs; 309 309 310 310 spin_lock_irqsave(&port->lock, flags); 311 - spin_lock_irqsave(&port->pint->lock, flags); 311 + spin_lock(&port->pint->lock); 312 312 313 313 writel(hwirq_to_pintbit(port, d->hwirq), &regs->mask_set); 314 314 315 - spin_unlock_irqrestore(&port->pint->lock, flags); 315 + spin_unlock(&port->pint->lock); 316 316 spin_unlock_irqrestore(&port->lock, flags); 317 317 } 318 318 ··· 320 320 { 321 321 unsigned long flags; 322 322 struct gpio_port *port = irq_data_get_irq_chip_data(d); 323 - struct gpio_pint_regs *regs = port->pint->regs; 323 + struct gpio_pint_regs *regs; 324 324 325 325 if (!port) { 326 - dev_err(port->dev, "GPIO IRQ %d :Not exist\n", d->irq); 326 + pr_err("GPIO IRQ %d :Not exist\n", d->irq); 327 327 return -ENODEV; 328 328 } 329 329 330 + regs = port->pint->regs; 331 + 330 332 spin_lock_irqsave(&port->lock, flags); 331 - spin_lock_irqsave(&port->pint->lock, flags); 333 + spin_lock(&port->pint->lock); 332 334 333 335 port_setup(port, d->hwirq, true); 334 336 writew(BIT(d->hwirq), &port->regs->dir_clear); ··· 338 336 339 337 writel(hwirq_to_pintbit(port, d->hwirq), &regs->mask_set); 340 338 341 - spin_unlock_irqrestore(&port->pint->lock, flags); 339 + spin_unlock(&port->pint->lock); 342 340 spin_unlock_irqrestore(&port->lock, flags); 343 341 344 342 return 0; ··· 351 349 struct gpio_pint_regs *regs = port->pint->regs; 352 350 353 351 spin_lock_irqsave(&port->lock, flags); 354 - spin_lock_irqsave(&port->pint->lock, flags); 352 + spin_lock(&port->pint->lock); 355 353 356 354 writel(hwirq_to_pintbit(port, d->hwirq), &regs->mask_clear); 357 355 358 - spin_unlock_irqrestore(&port->pint->lock, flags); 356 + spin_unlock(&port->pint->lock); 359 357 spin_unlock_irqrestore(&port->lock, flags); 360 358 } 361 359 ··· 363 361 { 364 362 unsigned long flags; 365 363 struct gpio_port *port = irq_data_get_irq_chip_data(d); 366 - struct gpio_pint_regs *pint_regs = port->pint->regs; 364 + struct gpio_pint_regs *pint_regs; 367 365 unsigned pintmask; 368 366 unsigned int irq = d->irq; 369 367 int ret = 0; 370 368 char buf[16]; 371 369 372 370 if (!port) { 373 - dev_err(port->dev, "GPIO IRQ %d :Not exist\n", irq); 371 + pr_err("GPIO IRQ %d :Not exist\n", d->irq); 374 372 return -ENODEV; 375 373 } 374 + 375 + pint_regs = port->pint->regs; 376 376 377 377 pintmask = hwirq_to_pintbit(port, d->hwirq); 378 378 379 379 spin_lock_irqsave(&port->lock, flags); 380 - spin_lock_irqsave(&port->pint->lock, flags); 380 + spin_lock(&port->pint->lock); 381 381 382 382 /* In case of interrupt autodetect, set irq type to edge sensitive. */ 383 383 if (type == IRQ_TYPE_PROBE) ··· 420 416 } 421 417 422 418 out: 423 - spin_unlock_irqrestore(&port->pint->lock, flags); 419 + spin_unlock(&port->pint->lock); 424 420 spin_unlock_irqrestore(&port->lock, flags); 425 421 426 422 return ret;