Commit efd54f43 authored by Noah Watkins's avatar Noah Watkins Committed by Greg Kroah-Hartman

staging: zram: make global var "num_devices" use unique name

The global variable "num_devices" is too general to be
global. This patch switches the name to be "zram_num_devices".
Signed-off-by: default avatarNoah Watkins <noahwatkins@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 43801f6e
...@@ -40,7 +40,7 @@ static int zram_major; ...@@ -40,7 +40,7 @@ static int zram_major;
struct zram *zram_devices; struct zram *zram_devices;
/* Module params (documentation at end) */ /* Module params (documentation at end) */
unsigned int num_devices; unsigned int zram_num_devices;
static void zram_stat_inc(u32 *v) static void zram_stat_inc(u32 *v)
{ {
...@@ -780,9 +780,9 @@ static int __init zram_init(void) ...@@ -780,9 +780,9 @@ static int __init zram_init(void)
{ {
int ret, dev_id; int ret, dev_id;
if (num_devices > max_num_devices) { if (zram_num_devices > max_num_devices) {
pr_warning("Invalid value for num_devices: %u\n", pr_warning("Invalid value for num_devices: %u\n",
num_devices); zram_num_devices);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -794,20 +794,20 @@ static int __init zram_init(void) ...@@ -794,20 +794,20 @@ static int __init zram_init(void)
goto out; goto out;
} }
if (!num_devices) { if (!zram_num_devices) {
pr_info("num_devices not specified. Using default: 1\n"); pr_info("num_devices not specified. Using default: 1\n");
num_devices = 1; zram_num_devices = 1;
} }
/* Allocate the device array and initialize each one */ /* Allocate the device array and initialize each one */
pr_info("Creating %u devices ...\n", num_devices); pr_info("Creating %u devices ...\n", zram_num_devices);
zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL); zram_devices = kzalloc(zram_num_devices * sizeof(struct zram), GFP_KERNEL);
if (!zram_devices) { if (!zram_devices) {
ret = -ENOMEM; ret = -ENOMEM;
goto unregister; goto unregister;
} }
for (dev_id = 0; dev_id < num_devices; dev_id++) { for (dev_id = 0; dev_id < zram_num_devices; dev_id++) {
ret = create_device(&zram_devices[dev_id], dev_id); ret = create_device(&zram_devices[dev_id], dev_id);
if (ret) if (ret)
goto free_devices; goto free_devices;
...@@ -830,7 +830,7 @@ static void __exit zram_exit(void) ...@@ -830,7 +830,7 @@ static void __exit zram_exit(void)
int i; int i;
struct zram *zram; struct zram *zram;
for (i = 0; i < num_devices; i++) { for (i = 0; i < zram_num_devices; i++) {
zram = &zram_devices[i]; zram = &zram_devices[i];
destroy_device(zram); destroy_device(zram);
...@@ -844,8 +844,8 @@ static void __exit zram_exit(void) ...@@ -844,8 +844,8 @@ static void __exit zram_exit(void)
pr_debug("Cleanup done!\n"); pr_debug("Cleanup done!\n");
} }
module_param(num_devices, uint, 0); module_param(zram_num_devices, uint, 0);
MODULE_PARM_DESC(num_devices, "Number of zram devices"); MODULE_PARM_DESC(zram_num_devices, "Number of zram devices");
module_init(zram_init); module_init(zram_init);
module_exit(zram_exit); module_exit(zram_exit);
......
...@@ -124,7 +124,7 @@ struct zram { ...@@ -124,7 +124,7 @@ struct zram {
}; };
extern struct zram *zram_devices; extern struct zram *zram_devices;
extern unsigned int num_devices; extern unsigned int zram_num_devices;
#ifdef CONFIG_SYSFS #ifdef CONFIG_SYSFS
extern struct attribute_group zram_disk_attr_group; extern struct attribute_group zram_disk_attr_group;
#endif #endif
......
...@@ -34,7 +34,7 @@ static struct zram *dev_to_zram(struct device *dev) ...@@ -34,7 +34,7 @@ static struct zram *dev_to_zram(struct device *dev)
int i; int i;
struct zram *zram = NULL; struct zram *zram = NULL;
for (i = 0; i < num_devices; i++) { for (i = 0; i < zram_num_devices; i++) {
zram = &zram_devices[i]; zram = &zram_devices[i];
if (disk_to_dev(zram->disk) == dev) if (disk_to_dev(zram->disk) == dev)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment