diff mbox series

PM / sleep: convert to DEFINE_SHOW_ATTRIBUTE

Message ID 20181211162048.21906-1-tiny.windzz@gmail.com (mailing list archive)
State Mainlined
Delegated to: Rafael Wysocki
Headers show
Series PM / sleep: convert to DEFINE_SHOW_ATTRIBUTE | expand

Commit Message

Yangtao Li Dec. 11, 2018, 4:20 p.m. UTC
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 kernel/power/main.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

Comments

Pavel Machek Dec. 11, 2018, 5:42 p.m. UTC | #1
On Tue 2018-12-11 11:20:48, Yangtao Li wrote:
> Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
> 
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>

Acked-by: Pavel Machek <pavel@ucw.cz>

> ---
>  kernel/power/main.c | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/kernel/power/main.c b/kernel/power/main.c
> index 35b50823d83b..98e76cad128b 100644
> --- a/kernel/power/main.c
> +++ b/kernel/power/main.c
> @@ -318,23 +318,12 @@ static int suspend_stats_show(struct seq_file *s, void *unused)
>  
>  	return 0;
>  }
> -
> -static int suspend_stats_open(struct inode *inode, struct file *file)
> -{
> -	return single_open(file, suspend_stats_show, NULL);
> -}
> -
> -static const struct file_operations suspend_stats_operations = {
> -	.open           = suspend_stats_open,
> -	.read           = seq_read,
> -	.llseek         = seq_lseek,
> -	.release        = single_release,
> -};
> +DEFINE_SHOW_ATTRIBUTE(suspend_stats);
>  
>  static int __init pm_debugfs_init(void)
>  {
>  	debugfs_create_file("suspend_stats", S_IFREG | S_IRUGO,
> -			NULL, NULL, &suspend_stats_operations);
> +			NULL, NULL, &suspend_stats_fops);
>  	return 0;
>  }
>
Rafael J. Wysocki Dec. 17, 2018, 11:42 a.m. UTC | #2
On Tuesday, December 11, 2018 5:20:48 PM CET Yangtao Li wrote:
> Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
> 
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
>  kernel/power/main.c | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
> 
> diff --git a/kernel/power/main.c b/kernel/power/main.c
> index 35b50823d83b..98e76cad128b 100644
> --- a/kernel/power/main.c
> +++ b/kernel/power/main.c
> @@ -318,23 +318,12 @@ static int suspend_stats_show(struct seq_file *s, void *unused)
>  
>  	return 0;
>  }
> -
> -static int suspend_stats_open(struct inode *inode, struct file *file)
> -{
> -	return single_open(file, suspend_stats_show, NULL);
> -}
> -
> -static const struct file_operations suspend_stats_operations = {
> -	.open           = suspend_stats_open,
> -	.read           = seq_read,
> -	.llseek         = seq_lseek,
> -	.release        = single_release,
> -};
> +DEFINE_SHOW_ATTRIBUTE(suspend_stats);
>  
>  static int __init pm_debugfs_init(void)
>  {
>  	debugfs_create_file("suspend_stats", S_IFREG | S_IRUGO,
> -			NULL, NULL, &suspend_stats_operations);
> +			NULL, NULL, &suspend_stats_fops);
>  	return 0;
>  }
>  
> 

Applied, thanks!
diff mbox series

Patch

diff --git a/kernel/power/main.c b/kernel/power/main.c
index 35b50823d83b..98e76cad128b 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -318,23 +318,12 @@  static int suspend_stats_show(struct seq_file *s, void *unused)
 
 	return 0;
 }
-
-static int suspend_stats_open(struct inode *inode, struct file *file)
-{
-	return single_open(file, suspend_stats_show, NULL);
-}
-
-static const struct file_operations suspend_stats_operations = {
-	.open           = suspend_stats_open,
-	.read           = seq_read,
-	.llseek         = seq_lseek,
-	.release        = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(suspend_stats);
 
 static int __init pm_debugfs_init(void)
 {
 	debugfs_create_file("suspend_stats", S_IFREG | S_IRUGO,
-			NULL, NULL, &suspend_stats_operations);
+			NULL, NULL, &suspend_stats_fops);
 	return 0;
 }