diff options
Diffstat (limited to 'drivers/lightnvm/pblk-init.c')
-rw-r--r-- | drivers/lightnvm/pblk-init.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 0e37104de596..72ad3e70318c 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c | |||
@@ -347,23 +347,19 @@ fail_destroy_ws: | |||
347 | 347 | ||
348 | static int pblk_get_global_caches(void) | 348 | static int pblk_get_global_caches(void) |
349 | { | 349 | { |
350 | int ret; | 350 | int ret = 0; |
351 | 351 | ||
352 | mutex_lock(&pblk_caches.mutex); | 352 | mutex_lock(&pblk_caches.mutex); |
353 | 353 | ||
354 | if (kref_read(&pblk_caches.kref) > 0) { | 354 | if (kref_get_unless_zero(&pblk_caches.kref)) |
355 | kref_get(&pblk_caches.kref); | 355 | goto out; |
356 | mutex_unlock(&pblk_caches.mutex); | ||
357 | return 0; | ||
358 | } | ||
359 | 356 | ||
360 | ret = pblk_create_global_caches(); | 357 | ret = pblk_create_global_caches(); |
361 | |||
362 | if (!ret) | 358 | if (!ret) |
363 | kref_get(&pblk_caches.kref); | 359 | kref_init(&pblk_caches.kref); |
364 | 360 | ||
361 | out: | ||
365 | mutex_unlock(&pblk_caches.mutex); | 362 | mutex_unlock(&pblk_caches.mutex); |
366 | |||
367 | return ret; | 363 | return ret; |
368 | } | 364 | } |
369 | 365 | ||