diff mbox series

mm/cma_debug: Use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops

Message ID 1572348687-9951-1-git-send-email-zhongjiang@huawei.com (mailing list archive)
State New, archived
Headers show
Series mm/cma_debug: Use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs fops | expand

Commit Message

zhong jiang Oct. 29, 2019, 11:31 a.m. UTC
It is more clear to use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs
file operation rather than DEFINE_SIMPLE_ATTRIBUTE.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 mm/cma_debug.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Andrew Morton Oct. 29, 2019, 9:36 p.m. UTC | #1
On Tue, 29 Oct 2019 19:31:27 +0800 zhong jiang <zhongjiang@huawei.com> wrote:

> It is more clear to use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs
> file operation rather than DEFINE_SIMPLE_ATTRIBUTE.

hm, they do appear to be identical.

Perhaps DEFINE_DEBUGFS_ATTRIBUTE shouldn't exist, or should be #defined
onto DEFINE_SIMPLE_ATTRIBUTE?
zhong jiang Oct. 30, 2019, 2:42 a.m. UTC | #2
On 2019/10/30 5:36, Andrew Morton wrote:
> On Tue, 29 Oct 2019 19:31:27 +0800 zhong jiang <zhongjiang@huawei.com> wrote:
>
>> It is more clear to use DEFINE_DEBUGFS_ATTRIBUTE to define debugfs
>> file operation rather than DEFINE_SIMPLE_ATTRIBUTE.
> hm, they do appear to be identical.
It seems to  DEFINE_DEBUGFS_ATTRIBUTE is special part of DEFINE_SIMPLE_ATTRUBUTE.  Defined
file operation is different.  but use DEFINE_DEBUGFS_ATTRIBUTE  to define normal fops also feasible.
> Perhaps DEFINE_DEBUGFS_ATTRIBUTE shouldn't exist, or should be #defined
> onto DEFINE_SIMPLE_ATTRIBUTE?
>
>
> .
Debugfs fops has an long existing in kernel.  And file read and write has different implementation.
I tend to keep in the way it was.

Thanks,
zhong jiang
>
diff mbox series

Patch

diff --git a/mm/cma_debug.c b/mm/cma_debug.c
index a7dd9e8..4e6cbe2 100644
--- a/mm/cma_debug.c
+++ b/mm/cma_debug.c
@@ -29,7 +29,7 @@  static int cma_debugfs_get(void *data, u64 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(cma_debugfs_fops, cma_debugfs_get, NULL, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(cma_debugfs_fops, cma_debugfs_get, NULL, "%llu\n");
 
 static int cma_used_get(void *data, u64 *val)
 {
@@ -44,7 +44,7 @@  static int cma_used_get(void *data, u64 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(cma_used_fops, cma_used_get, NULL, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(cma_used_fops, cma_used_get, NULL, "%llu\n");
 
 static int cma_maxchunk_get(void *data, u64 *val)
 {
@@ -66,7 +66,7 @@  static int cma_maxchunk_get(void *data, u64 *val)
 
 	return 0;
 }
-DEFINE_SIMPLE_ATTRIBUTE(cma_maxchunk_fops, cma_maxchunk_get, NULL, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(cma_maxchunk_fops, cma_maxchunk_get, NULL, "%llu\n");
 
 static void cma_add_to_cma_mem_list(struct cma *cma, struct cma_mem *mem)
 {
@@ -126,7 +126,7 @@  static int cma_free_write(void *data, u64 val)
 
 	return cma_free_mem(cma, pages);
 }
-DEFINE_SIMPLE_ATTRIBUTE(cma_free_fops, NULL, cma_free_write, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(cma_free_fops, NULL, cma_free_write, "%llu\n");
 
 static int cma_alloc_mem(struct cma *cma, int count)
 {
@@ -158,7 +158,7 @@  static int cma_alloc_write(void *data, u64 val)
 
 	return cma_alloc_mem(cma, pages);
 }
-DEFINE_SIMPLE_ATTRIBUTE(cma_alloc_fops, NULL, cma_alloc_write, "%llu\n");
+DEFINE_DEBUGFS_ATTRIBUTE(cma_alloc_fops, NULL, cma_alloc_write, "%llu\n");
 
 static void cma_debugfs_add_one(struct cma *cma, struct dentry *root_dentry)
 {