summaryrefslogtreecommitdiff
path: root/drivers/misc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/vmw_balloon.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index 9ce9b9e0e9b6..c817d8c21641 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -380,16 +380,7 @@ struct vmballoon {
/**
* @shrinker: shrinker interface that is used to avoid over-inflation.
*/
- struct shrinker shrinker;
-
- /**
- * @shrinker_registered: whether the shrinker was registered.
- *
- * The shrinker interface does not handle gracefully the removal of
- * shrinker that was not registered before. This indication allows to
- * simplify the unregistration process.
- */
- bool shrinker_registered;
+ struct shrinker *shrinker;
};
static struct vmballoon balloon;
@@ -1568,29 +1559,27 @@ static unsigned long vmballoon_shrinker_count(struct shrinker *shrinker,
static void vmballoon_unregister_shrinker(struct vmballoon *b)
{
- if (b->shrinker_registered)
- unregister_shrinker(&b->shrinker);
- b->shrinker_registered = false;
+ shrinker_free(b->shrinker);
+ b->shrinker = NULL;
}
static int vmballoon_register_shrinker(struct vmballoon *b)
{
- int r;
-
/* Do nothing if the shrinker is not enabled */
if (!vmwballoon_shrinker_enable)
return 0;
- b->shrinker.scan_objects = vmballoon_shrinker_scan;
- b->shrinker.count_objects = vmballoon_shrinker_count;
- b->shrinker.seeks = DEFAULT_SEEKS;
+ b->shrinker = shrinker_alloc(0, "vmw-balloon");
+ if (!b->shrinker)
+ return -ENOMEM;
- r = register_shrinker(&b->shrinker, "vmw-balloon");
+ b->shrinker->scan_objects = vmballoon_shrinker_scan;
+ b->shrinker->count_objects = vmballoon_shrinker_count;
+ b->shrinker->private_data = b;
- if (r == 0)
- b->shrinker_registered = true;
+ shrinker_register(b->shrinker);
- return r;
+ return 0;
}
/*
@@ -1883,7 +1872,7 @@ static int __init vmballoon_init(void)
error = vmballoon_register_shrinker(&balloon);
if (error)
- goto fail;
+ return error;
/*
* Initialization of compaction must be done after the call to
@@ -1905,9 +1894,6 @@ static int __init vmballoon_init(void)
vmballoon_debugfs_init(&balloon);
return 0;
-fail:
- vmballoon_unregister_shrinker(&balloon);
- return error;
}
/*