Skip to content

Commit

Permalink
staging: zram: handle mem suffixes in disk size zram_sysfs parameter
Browse files Browse the repository at this point in the history
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.senozhatsky@gmail.com>
Reviewed-by: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Sergey Senozhatsky authored and Greg Kroah-Hartman committed Oct 31, 2012
1 parent 37b51fd commit 2690784
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/staging/zram/zram_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <linux/device.h>
#include <linux/genhd.h>
#include <linux/mm.h>
#include <linux/kernel.h>

#include "zram_drv.h"

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2690784

Please sign in to comment.