summaryrefslogtreecommitdiff
path: root/drivers/mtd/mtd_blkdevs.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-08-23 09:33:57 +0200
committerMiquel Raynal <miquel.raynal@bootlin.com>2021-08-23 10:01:11 +0200
commit560a3915e3df09125d7b20088a177b2872d2d680 (patch)
treee6c110218ec2e49702e4866674d7daf5035be381 /drivers/mtd/mtd_blkdevs.c
parent89843828399ec825f8ec3e614634a428a951a2b3 (diff)
mtd_blkdevs: remove blktrans_ref_mutex
blktrans_ref_mutex is not actually needed. The kref is serialized internally, and devnum assignment in add_mtd_blktrans_dev happens before the disk is added and thus any of the block_device_operations methods otherwise using it are called. It is also already serialized by the global mtd_table_mutex. 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-7-hch@lst.de
Diffstat (limited to 'drivers/mtd/mtd_blkdevs.c')
-rw-r--r--drivers/mtd/mtd_blkdevs.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index eb15a84cb650..84bcad1b7408 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -23,7 +23,6 @@
#include "mtdcore.h"
static LIST_HEAD(blktrans_majors);
-static DEFINE_MUTEX(blktrans_ref_mutex);
static void blktrans_dev_release(struct kref *kref)
{
@@ -41,18 +40,13 @@ static struct mtd_blktrans_dev *blktrans_dev_get(struct gendisk *disk)
{
struct mtd_blktrans_dev *dev = disk->private_data;
- mutex_lock(&blktrans_ref_mutex);
kref_get(&dev->ref);
- mutex_unlock(&blktrans_ref_mutex);
-
return dev;
}
static void blktrans_dev_put(struct mtd_blktrans_dev *dev)
{
- mutex_lock(&blktrans_ref_mutex);
kref_put(&dev->ref, blktrans_dev_release);
- mutex_unlock(&blktrans_ref_mutex);
}
@@ -299,7 +293,6 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
lockdep_assert_held(&mtd_table_mutex);
- mutex_lock(&blktrans_ref_mutex);
list_for_each_entry(d, &tr->devs, list) {
if (new->devnum == -1) {
/* Use first free number */
@@ -311,7 +304,6 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
}
} else if (d->devnum == new->devnum) {
/* Required number taken */
- mutex_unlock(&blktrans_ref_mutex);
return -EBUSY;
} else if (d->devnum > new->devnum) {
/* Required number was free */
@@ -329,14 +321,11 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
* minor numbers and that the disk naming code below can cope
* with this number. */
if (new->devnum > (MINORMASK >> tr->part_bits) ||
- (tr->part_bits && new->devnum >= 27 * 26)) {
- mutex_unlock(&blktrans_ref_mutex);
+ (tr->part_bits && new->devnum >= 27 * 26))
return ret;
- }
list_add_tail(&new->list, &tr->devs);
added:
- mutex_unlock(&blktrans_ref_mutex);
mutex_init(&new->lock);
kref_init(&new->ref);