Skip to contentSkip to conversation

remove __MOD_* from dm

PATCH In review Greg KH 2 participants 2 messages Dec 20, 2002 – Dec 30, 2002 Device mapper

lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 remove __MOD_* from dm

Here's another patch against 2.5.52-bk that gets rid of the old __MOD_* functions for the newer module api. This also allows the modules to be unloaded.

Joe, please add this to your next round of patches.

thanks,

greg k-h

# DM: convert old __MOD_INC and __MOD_DEC calls to the new style.

drivers/md/dm-target.c +8 -4
diff -Nru a/drivers/md/dm-target.c b/drivers/md/dm-target.c
@@ -46,10 +46,14 @@
 	ti = __find_target_type(name);
 
 	if (ti) {
-		if (ti->use == 0 && ti->tt.module)
-			__MOD_INC_USE_COUNT(ti->tt.module);
+		if (ti->use == 0)
+			if (!try_module_get(ti->tt.module)) {
+				ti = NULL;
+				goto exit;
+			}
 		ti->use++;
 	}
+exit:
 	read_unlock(&_lock);
 
 	return ti;
@@ -86,8 +90,8 @@
 	struct tt_internal *ti = (struct tt_internal *) t;
 
 	read_lock(&_lock);
-	if (--ti->use == 0 && ti->tt.module)
-		__MOD_DEC_USE_COUNT(ti->tt.module);
+	if (--ti->use == 0)
+		module_put(ti->tt.module);
 
 	if (ti->use < 0)
 		BUG();