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

mtd_blkdevs: use lockdep_assert_held

Use lockdep_assert_held to ensure mtd_table_mutex is held instead of
mutex_trylock games.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210823073359.705281-3-hch@lst.de

authored by

Christoph Hellwig and committed by
Miquel Raynal
f214eebf 799ae31c

+2 -8
+2 -8
drivers/mtd/mtd_blkdevs.c
··· 310 310 struct gendisk *gd; 311 311 int ret; 312 312 313 - if (mutex_trylock(&mtd_table_mutex)) { 314 - mutex_unlock(&mtd_table_mutex); 315 - BUG(); 316 - } 313 + lockdep_assert_held(&mtd_table_mutex); 317 314 318 315 mutex_lock(&blktrans_ref_mutex); 319 316 list_for_each_entry(d, &tr->devs, list) { ··· 440 443 { 441 444 unsigned long flags; 442 445 443 - if (mutex_trylock(&mtd_table_mutex)) { 444 - mutex_unlock(&mtd_table_mutex); 445 - BUG(); 446 - } 446 + lockdep_assert_held(&mtd_table_mutex); 447 447 448 448 if (old->disk_attributes) 449 449 sysfs_remove_group(&disk_to_dev(old->disk)->kobj,