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

mtd: mtdblock: remove the needless mtdblks_lock

The global lock mtdblks_lock was used to protect the original mtdblks
array to avoid race conditions. As the mtdblks array was already gone,
but the mtdblks_lock is left, and it causes latency when open/release dev.
So we need to remove it here.

Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Gu Zheng and committed by
Brian Norris
362376a7 0b56d2d4

-10
-10
drivers/mtd/mtdblock.c
··· 45 45 enum { STATE_EMPTY, STATE_CLEAN, STATE_DIRTY } cache_state; 46 46 }; 47 47 48 - static DEFINE_MUTEX(mtdblks_lock); 49 - 50 48 /* 51 49 * Cache stuff... 52 50 * ··· 284 286 285 287 pr_debug("mtdblock_open\n"); 286 288 287 - mutex_lock(&mtdblks_lock); 288 289 if (mtdblk->count) { 289 290 mtdblk->count++; 290 - mutex_unlock(&mtdblks_lock); 291 291 return 0; 292 292 } 293 293 ··· 298 302 mtdblk->cache_data = NULL; 299 303 } 300 304 301 - mutex_unlock(&mtdblks_lock); 302 - 303 305 pr_debug("ok\n"); 304 306 305 307 return 0; ··· 308 314 struct mtdblk_dev *mtdblk = container_of(mbd, struct mtdblk_dev, mbd); 309 315 310 316 pr_debug("mtdblock_release\n"); 311 - 312 - mutex_lock(&mtdblks_lock); 313 317 314 318 mutex_lock(&mtdblk->cache_mutex); 315 319 write_cached_data(mtdblk); ··· 322 330 mtd_sync(mbd->mtd); 323 331 vfree(mtdblk->cache_data); 324 332 } 325 - 326 - mutex_unlock(&mtdblks_lock); 327 333 328 334 pr_debug("ok\n"); 329 335 }