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

Configure Feed

Select the types of activity you want to include in your feed.

devres: use guard(spinlock_irqsave) where applicable

Use guard(spinlock_irqsave)(&dev->devres_lock) where it improves the
code.

Some places still use manual spin_lock_irqsave() and spin_unlock() as
changing it to use a scoped_guard() would result in unnecessary churn.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/20260202235210.55176-7-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

+7 -18
+7 -18
drivers/base/devres.c
··· 228 228 { 229 229 struct devres_node *node; 230 230 struct devres_node *tmp; 231 - unsigned long flags; 232 231 233 232 if (!fn) 234 233 return; 235 234 236 - spin_lock_irqsave(&dev->devres_lock, flags); 235 + guard(spinlock_irqsave)(&dev->devres_lock); 237 236 list_for_each_entry_safe_reverse(node, tmp, 238 237 &dev->devres_head, entry) { 239 238 struct devres *dr = container_of(node, struct devres, node); ··· 245 246 continue; 246 247 fn(dev, dr->data, data); 247 248 } 248 - spin_unlock_irqrestore(&dev->devres_lock, flags); 249 249 } 250 250 EXPORT_SYMBOL_GPL(devres_for_each_res); 251 251 ··· 332 334 dr_match_t match, void *match_data) 333 335 { 334 336 struct devres *dr; 335 - unsigned long flags; 336 337 337 - spin_lock_irqsave(&dev->devres_lock, flags); 338 + guard(spinlock_irqsave)(&dev->devres_lock); 338 339 dr = find_dr(dev, release, match, match_data); 339 - spin_unlock_irqrestore(&dev->devres_lock, flags); 340 - 341 340 if (dr) 342 341 return dr->data; 342 + 343 343 return NULL; 344 344 } 345 345 EXPORT_SYMBOL_GPL(devres_find); ··· 396 400 dr_match_t match, void *match_data) 397 401 { 398 402 struct devres *dr; 399 - unsigned long flags; 400 403 401 - spin_lock_irqsave(&dev->devres_lock, flags); 404 + guard(spinlock_irqsave)(&dev->devres_lock); 402 405 dr = find_dr(dev, release, match, match_data); 403 406 if (dr) { 404 407 list_del_init(&dr->node.entry); 405 408 devres_log(dev, &dr->node, "REM"); 406 - } 407 - spin_unlock_irqrestore(&dev->devres_lock, flags); 408 - 409 - if (dr) 410 409 return dr->data; 410 + } 411 + 411 412 return NULL; 412 413 } 413 414 EXPORT_SYMBOL_GPL(devres_remove); ··· 652 659 void devres_close_group(struct device *dev, void *id) 653 660 { 654 661 struct devres_group *grp; 655 - unsigned long flags; 656 662 657 - spin_lock_irqsave(&dev->devres_lock, flags); 658 - 663 + guard(spinlock_irqsave)(&dev->devres_lock); 659 664 grp = find_group(dev, id); 660 665 if (grp) 661 666 add_dr(dev, &grp->node[1]); 662 667 else 663 668 WARN_ON(1); 664 - 665 - spin_unlock_irqrestore(&dev->devres_lock, flags); 666 669 } 667 670 EXPORT_SYMBOL_GPL(devres_close_group); 668 671