diff options
author | Ganesh Mahendran <opensource.ganesh@gmail.com> | 2014-12-12 19:57:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-13 15:42:50 -0500 |
commit | 083914eab96fabddfc715f0436e082eb375c5704 (patch) | |
tree | a4d60aa9d39cf9687ee7b047447096673a94edc1 | |
parent | 181366561ac1e1a7bc3b91dbe45e7614a2f758b9 (diff) |
zram: use DEVICE_ATTR_[RW|RO|WO] to define zram sys device attribute
In current zram, we use DEVICE_ATTR() to define sys device attributes.
SO, we need to set (S_IRUGO | S_IWUSR) permission and other arguments
manually. Linux already provids the macro DEVICE_ATTR_[RW|RO|WO] to
define sys device attribute. It is simple and readable.
This patch uses kernel defined macro DEVICE_ATTR_[RW|RO|WO] to define
zram device attribute.
Signed-off-by: Ganesh Mahendran <opensource.ganesh@gmail.com>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/block/zram/zram_drv.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 976eab6f35b9..bd8bda386e02 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
@@ -44,15 +44,14 @@ static const char *default_compressor = "lzo"; | |||
44 | static unsigned int num_devices = 1; | 44 | static unsigned int num_devices = 1; |
45 | 45 | ||
46 | #define ZRAM_ATTR_RO(name) \ | 46 | #define ZRAM_ATTR_RO(name) \ |
47 | static ssize_t zram_attr_##name##_show(struct device *d, \ | 47 | static ssize_t name##_show(struct device *d, \ |
48 | struct device_attribute *attr, char *b) \ | 48 | struct device_attribute *attr, char *b) \ |
49 | { \ | 49 | { \ |
50 | struct zram *zram = dev_to_zram(d); \ | 50 | struct zram *zram = dev_to_zram(d); \ |
51 | return scnprintf(b, PAGE_SIZE, "%llu\n", \ | 51 | return scnprintf(b, PAGE_SIZE, "%llu\n", \ |
52 | (u64)atomic64_read(&zram->stats.name)); \ | 52 | (u64)atomic64_read(&zram->stats.name)); \ |
53 | } \ | 53 | } \ |
54 | static struct device_attribute dev_attr_##name = \ | 54 | static DEVICE_ATTR_RO(name); |
55 | __ATTR(name, S_IRUGO, zram_attr_##name##_show, NULL); | ||
56 | 55 | ||
57 | static inline int init_done(struct zram *zram) | 56 | static inline int init_done(struct zram *zram) |
58 | { | 57 | { |
@@ -994,20 +993,15 @@ static const struct block_device_operations zram_devops = { | |||
994 | .owner = THIS_MODULE | 993 | .owner = THIS_MODULE |
995 | }; | 994 | }; |
996 | 995 | ||
997 | static DEVICE_ATTR(disksize, S_IRUGO | S_IWUSR, | 996 | static DEVICE_ATTR_RW(disksize); |
998 | disksize_show, disksize_store); | 997 | static DEVICE_ATTR_RO(initstate); |
999 | static DEVICE_ATTR(initstate, S_IRUGO, initstate_show, NULL); | 998 | static DEVICE_ATTR_WO(reset); |
1000 | static DEVICE_ATTR(reset, S_IWUSR, NULL, reset_store); | 999 | static DEVICE_ATTR_RO(orig_data_size); |
1001 | static DEVICE_ATTR(orig_data_size, S_IRUGO, orig_data_size_show, NULL); | 1000 | static DEVICE_ATTR_RO(mem_used_total); |
1002 | static DEVICE_ATTR(mem_used_total, S_IRUGO, mem_used_total_show, NULL); | 1001 | static DEVICE_ATTR_RW(mem_limit); |
1003 | static DEVICE_ATTR(mem_limit, S_IRUGO | S_IWUSR, mem_limit_show, | 1002 | static DEVICE_ATTR_RW(mem_used_max); |
1004 | mem_limit_store); | 1003 | static DEVICE_ATTR_RW(max_comp_streams); |
1005 | static DEVICE_ATTR(mem_used_max, S_IRUGO | S_IWUSR, mem_used_max_show, | 1004 | static DEVICE_ATTR_RW(comp_algorithm); |
1006 | mem_used_max_store); | ||
1007 | static DEVICE_ATTR(max_comp_streams, S_IRUGO | S_IWUSR, | ||
1008 | max_comp_streams_show, max_comp_streams_store); | ||
1009 | static DEVICE_ATTR(comp_algorithm, S_IRUGO | S_IWUSR, | ||
1010 | comp_algorithm_show, comp_algorithm_store); | ||
1011 | 1005 | ||
1012 | ZRAM_ATTR_RO(num_reads); | 1006 | ZRAM_ATTR_RO(num_reads); |
1013 | ZRAM_ATTR_RO(num_writes); | 1007 | ZRAM_ATTR_RO(num_writes); |