Re: [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter (v2)
On Mon, Oct 29, 2012 at 10:41 AM, Sergey Senozhatsky wrote: > zram: handle mem suffixes in disk size zram_sysfs parameter > > Use memparse() to allow mem suffixes in disksize sysfs number. > Examples: >echo 256K > /sys/block/zram0/disksize >echo 512M > /sys/block/zram0/disksize >echo 1G > /sys/block/zram0/disksize > > Signed-off-by: Sergey Senozhatsky > FWIW, Reviewed-by: Nitin Gupta Thanks, Nitin -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter (v2)
zram: handle mem suffixes in disk size zram_sysfs parameter Use memparse() to allow mem suffixes in disksize sysfs number. Examples: echo 256K > /sys/block/zram0/disksize echo 512M > /sys/block/zram0/disksize echo 1G > /sys/block/zram0/disksize Signed-off-by: Sergey Senozhatsky --- drivers/staging/zram/zram_sysfs.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c index edb0ed4..de1eacf 100644 --- a/drivers/staging/zram/zram_sysfs.c +++ b/drivers/staging/zram/zram_sysfs.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "zram_drv.h" @@ -54,13 +55,12 @@ static ssize_t disksize_show(struct device *dev, static ssize_t disksize_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { - int ret; u64 disksize; struct zram *zram = dev_to_zram(dev); - ret = kstrtoull(buf, 10, ); - if (ret) - return ret; + disksize = memparse(buf, NULL); + if (!disksize) + return -EINVAL; down_write(>init_lock); if (zram->init_done) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter (v2)
zram: handle mem suffixes in disk size zram_sysfs parameter Use memparse() to allow mem suffixes in disksize sysfs number. Examples: echo 256K /sys/block/zram0/disksize echo 512M /sys/block/zram0/disksize echo 1G /sys/block/zram0/disksize Signed-off-by: Sergey Senozhatsky sergey.senozhat...@gmail.com --- drivers/staging/zram/zram_sysfs.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c index edb0ed4..de1eacf 100644 --- a/drivers/staging/zram/zram_sysfs.c +++ b/drivers/staging/zram/zram_sysfs.c @@ -15,6 +15,7 @@ #include linux/device.h #include linux/genhd.h #include linux/mm.h +#include linux/kernel.h #include zram_drv.h @@ -54,13 +55,12 @@ static ssize_t disksize_show(struct device *dev, static ssize_t disksize_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { - int ret; u64 disksize; struct zram *zram = dev_to_zram(dev); - ret = kstrtoull(buf, 10, disksize); - if (ret) - return ret; + disksize = memparse(buf, NULL); + if (!disksize) + return -EINVAL; down_write(zram-init_lock); if (zram-init_done) { -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/2] zram: handle mem suffixes in disk size zram_sysfs parameter (v2)
On Mon, Oct 29, 2012 at 10:41 AM, Sergey Senozhatsky sergey.senozhat...@gmail.com wrote: zram: handle mem suffixes in disk size zram_sysfs parameter Use memparse() to allow mem suffixes in disksize sysfs number. Examples: echo 256K /sys/block/zram0/disksize echo 512M /sys/block/zram0/disksize echo 1G /sys/block/zram0/disksize Signed-off-by: Sergey Senozhatsky sergey.senozhat...@gmail.com FWIW, Reviewed-by: Nitin Gupta ngu...@vflare.org Thanks, Nitin -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/