diff options
Diffstat (limited to 'drivers/staging/zram')
-rw-r--r-- | drivers/staging/zram/Kconfig | 7 | ||||
-rw-r--r-- | drivers/staging/zram/zram_drv.c | 53 | ||||
-rw-r--r-- | drivers/staging/zram/zram_drv.h | 2 | ||||
-rw-r--r-- | drivers/staging/zram/zram_sysfs.c | 31 |
4 files changed, 10 insertions, 83 deletions
diff --git a/drivers/staging/zram/Kconfig b/drivers/staging/zram/Kconfig index 06f741a..3bec4db 100644 --- a/drivers/staging/zram/Kconfig +++ b/drivers/staging/zram/Kconfig @@ -28,10 +28,3 @@ config ZRAM_DEBUG help This option adds additional debugging code to the compressed RAM block device driver. - -config ZRAM_FOR_ANDROID - bool "Optimize zram behavior for android" - depends on ZRAM && ANDROID - default n - help - This option enables modified zram behavior optimized for android diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 5258c78..aab4ec4 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -32,16 +32,12 @@ #include <linux/lzo.h> #include <linux/string.h> #include <linux/vmalloc.h> -#ifdef CONFIG_ZRAM_FOR_ANDROID -#include <linux/swap.h> -#endif /* CONFIG_ZRAM_FOR_ANDROID */ - #include "zram_drv.h" /* Globals */ static int zram_major; -struct zram *zram_devices; +struct zram *devices; /* Module params (documentation at end) */ unsigned int num_devices; @@ -137,22 +133,6 @@ static void zram_set_disksize(struct zram *zram, size_t totalram_bytes) zram->disksize &= PAGE_MASK; } -#ifdef CONFIG_ZRAM_FOR_ANDROID -/* - * Swap header (1st page of swap device) contains information - * about a swap file/partition. Prepare such a header for the - * given ramzswap device so that swapon can identify it as a - * swap partition. - */ -static void setup_swap_header(struct zram *zram, union swap_header *s) -{ - s->info.version = 1; - s->info.last_page = (zram->disksize >> PAGE_SHIFT) - 1; - s->info.nr_badpages = 0; - memcpy(s->magic.magic, "SWAPSPACE2", 10); -} -#endif /* CONFIG_ZRAM_FOR_ANDROID */ - static void zram_free_page(struct zram *zram, size_t index) { u32 clen; @@ -521,10 +501,6 @@ int zram_init_device(struct zram *zram) { int ret; size_t num_pages; -#ifdef CONFIG_ZRAM_FOR_ANDROID - struct page *page; - union swap_header *swap_header; -#endif /* CONFIG_ZRAM_FOR_ANDROID */ mutex_lock(&zram->init_lock); @@ -559,19 +535,6 @@ int zram_init_device(struct zram *zram) goto fail; } -#ifdef CONFIG_ZRAM_FOR_ANDROID - page = alloc_page(__GFP_ZERO); - if (!page) { - pr_err("Error allocating swap header page\n"); - ret = -ENOMEM; - goto fail; - } - zram->table[0].page = page; - zram_set_flag(zram, 0, ZRAM_UNCOMPRESSED); - swap_header = kmap(page); - setup_swap_header(zram, swap_header); - kunmap(page); -#endif /* CONFIG_ZRAM_FOR_ANDROID */ set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); /* zram devices sort of resembles non-rotational disks */ @@ -715,14 +678,14 @@ static int __init zram_init(void) /* Allocate the device array and initialize each one */ pr_info("Creating %u devices ...\n", num_devices); - zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL); - if (!zram_devices) { + devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL); + if (!devices) { ret = -ENOMEM; goto unregister; } for (dev_id = 0; dev_id < num_devices; dev_id++) { - ret = create_device(&zram_devices[dev_id], dev_id); + ret = create_device(&devices[dev_id], dev_id); if (ret) goto free_devices; } @@ -731,8 +694,8 @@ static int __init zram_init(void) free_devices: while (dev_id) - destroy_device(&zram_devices[--dev_id]); - kfree(zram_devices); + destroy_device(&devices[--dev_id]); + kfree(devices); unregister: unregister_blkdev(zram_major, "zram"); out: @@ -745,7 +708,7 @@ static void __exit zram_exit(void) struct zram *zram; for (i = 0; i < num_devices; i++) { - zram = &zram_devices[i]; + zram = &devices[i]; destroy_device(zram); if (zram->init_done) @@ -754,7 +717,7 @@ static void __exit zram_exit(void) unregister_blkdev(zram_major, "zram"); - kfree(zram_devices); + kfree(devices); pr_debug("Cleanup done!\n"); } diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index 3ad9486..408b2c0 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -120,7 +120,7 @@ struct zram { struct zram_stats stats; }; -extern struct zram *zram_devices; +extern struct zram *devices; extern unsigned int num_devices; #ifdef CONFIG_SYSFS extern struct attribute_group zram_disk_attr_group; diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c index 8a23554..6996eb3 100644 --- a/drivers/staging/zram/zram_sysfs.c +++ b/drivers/staging/zram/zram_sysfs.c @@ -35,7 +35,7 @@ static struct zram *dev_to_zram(struct device *dev) struct zram *zram = NULL; for (i = 0; i < num_devices; i++) { - zram = &zram_devices[i]; + zram = &devices[i]; if (disk_to_dev(zram->disk) == dev) break; } @@ -80,41 +80,12 @@ static ssize_t initstate_show(struct device *dev, return sprintf(buf, "%u\n", zram->init_done); } -#ifdef CONFIG_ZRAM_FOR_ANDROID -extern int swapon(const char*specialfile, int swap_flags); - -static ssize_t initstate_store(struct device *dev, - struct device_attribute *attr, const char *buf, - size_t len) -{ - int ret; - unsigned long do_init; - struct zram *zram = dev_to_zram(dev); - - if (zram->init_done) { - pr_info("the device is initialized device\n"); - return -EBUSY; - } - - ret = strict_strtoul(buf, 10, &do_init); - if (ret) - return ret; - if (!do_init) - return -EINVAL; - - zram_init_device(zram); - swapon("/dev/block/zram0", 0); - return len; -} -#else static inline ssize_t initstate_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { return 0; } -#endif /* CONFIG_ZRAM_FOR_ANDROID */ - static ssize_t reset_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) |