linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] media: platform: sti: remove bdisp_dbg_declare() and hva_dbg_declare()
@ 2018-12-12 16:27 Yangtao Li
  2018-12-13  8:29 ` Fabien DESSENNE
  0 siblings, 1 reply; 2+ messages in thread
From: Yangtao Li @ 2018-12-12 16:27 UTC (permalink / raw)
  To: fabien.dessenne, mchehab, jean-christophe.trotin
  Cc: linux-media, linux-kernel, Yangtao Li

We already have the DEFINE_SHOW_ATTRIBUTE. There is no need to define
bdisp_dbg_declare and hva_dbg_declare, so remove them. Also use
DEFINE_SHOW_ATTRIBUTE to simplify some code.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 .../media/platform/sti/bdisp/bdisp-debug.c    | 34 ++++++------------
 drivers/media/platform/sti/hva/hva-debugfs.c  | 36 +++++++------------
 2 files changed, 23 insertions(+), 47 deletions(-)

diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c b/drivers/media/platform/sti/bdisp/bdisp-debug.c
index c6a4e2de5c0c..77ca7517fa3e 100644
--- a/drivers/media/platform/sti/bdisp/bdisp-debug.c
+++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
@@ -315,7 +315,7 @@ static void bdisp_dbg_dump_ivmx(struct seq_file *s,
 	seq_puts(s, "Unknown conversion\n");
 }
 
-static int bdisp_dbg_last_nodes(struct seq_file *s, void *data)
+static int last_nodes_show(struct seq_file *s, void *data)
 {
 	/* Not dumping all fields, focusing on significant ones */
 	struct bdisp_dev *bdisp = s->private;
@@ -388,7 +388,7 @@ static int bdisp_dbg_last_nodes(struct seq_file *s, void *data)
 	return 0;
 }
 
-static int bdisp_dbg_last_nodes_raw(struct seq_file *s, void *data)
+static int last_nodes_raw_show(struct seq_file *s, void *data)
 {
 	struct bdisp_dev *bdisp = s->private;
 	struct bdisp_node *node;
@@ -437,7 +437,7 @@ static const char *bdisp_fmt_to_str(struct bdisp_frame frame)
 	}
 }
 
-static int bdisp_dbg_last_request(struct seq_file *s, void *data)
+static int last_request_show(struct seq_file *s, void *data)
 {
 	struct bdisp_dev *bdisp = s->private;
 	struct bdisp_request *request = &bdisp->dbg.copy_request;
@@ -474,7 +474,7 @@ static int bdisp_dbg_last_request(struct seq_file *s, void *data)
 
 #define DUMP(reg) seq_printf(s, #reg " \t0x%08X\n", readl(bdisp->regs + reg))
 
-static int bdisp_dbg_regs(struct seq_file *s, void *data)
+static int regs_show(struct seq_file *s, void *data)
 {
 	struct bdisp_dev *bdisp = s->private;
 	int ret;
@@ -582,7 +582,7 @@ static int bdisp_dbg_regs(struct seq_file *s, void *data)
 
 #define SECOND 1000000
 
-static int bdisp_dbg_perf(struct seq_file *s, void *data)
+static int perf_show(struct seq_file *s, void *data)
 {
 	struct bdisp_dev *bdisp = s->private;
 	struct bdisp_request *request = &bdisp->dbg.copy_request;
@@ -627,27 +627,15 @@ static int bdisp_dbg_perf(struct seq_file *s, void *data)
 	return 0;
 }
 
-#define bdisp_dbg_declare(name) \
-	static int bdisp_dbg_##name##_open(struct inode *i, struct file *f) \
-	{ \
-		return single_open(f, bdisp_dbg_##name, i->i_private); \
-	} \
-	static const struct file_operations bdisp_dbg_##name##_fops = { \
-		.open           = bdisp_dbg_##name##_open, \
-		.read           = seq_read, \
-		.llseek         = seq_lseek, \
-		.release        = single_release, \
-	}
-
 #define bdisp_dbg_create_entry(name) \
 	debugfs_create_file(#name, S_IRUGO, bdisp->dbg.debugfs_entry, bdisp, \
-			    &bdisp_dbg_##name##_fops)
+			    &name##_fops)
 
-bdisp_dbg_declare(regs);
-bdisp_dbg_declare(last_nodes);
-bdisp_dbg_declare(last_nodes_raw);
-bdisp_dbg_declare(last_request);
-bdisp_dbg_declare(perf);
+DEFINE_SHOW_ATTRIBUTE(regs);
+DEFINE_SHOW_ATTRIBUTE(last_nodes);
+DEFINE_SHOW_ATTRIBUTE(last_nodes_raw);
+DEFINE_SHOW_ATTRIBUTE(last_request);
+DEFINE_SHOW_ATTRIBUTE(perf);
 
 int bdisp_debugfs_create(struct bdisp_dev *bdisp)
 {
diff --git a/drivers/media/platform/sti/hva/hva-debugfs.c b/drivers/media/platform/sti/hva/hva-debugfs.c
index 9f7e8ac875d1..7d12a5b5d914 100644
--- a/drivers/media/platform/sti/hva/hva-debugfs.c
+++ b/drivers/media/platform/sti/hva/hva-debugfs.c
@@ -271,7 +271,7 @@ static void hva_dbg_perf_compute(struct hva_ctx *ctx)
  * device debug info
  */
 
-static int hva_dbg_device(struct seq_file *s, void *data)
+static int device_show(struct seq_file *s, void *data)
 {
 	struct hva_dev *hva = s->private;
 
@@ -281,7 +281,7 @@ static int hva_dbg_device(struct seq_file *s, void *data)
 	return 0;
 }
 
-static int hva_dbg_encoders(struct seq_file *s, void *data)
+static int encoders_show(struct seq_file *s, void *data)
 {
 	struct hva_dev *hva = s->private;
 	unsigned int i = 0;
@@ -299,7 +299,7 @@ static int hva_dbg_encoders(struct seq_file *s, void *data)
 	return 0;
 }
 
-static int hva_dbg_last(struct seq_file *s, void *data)
+static int last_show(struct seq_file *s, void *data)
 {
 	struct hva_dev *hva = s->private;
 	struct hva_ctx *last_ctx = &hva->dbg.last_ctx;
@@ -316,7 +316,7 @@ static int hva_dbg_last(struct seq_file *s, void *data)
 	return 0;
 }
 
-static int hva_dbg_regs(struct seq_file *s, void *data)
+static int regs_show(struct seq_file *s, void *data)
 {
 	struct hva_dev *hva = s->private;
 
@@ -325,26 +325,14 @@ static int hva_dbg_regs(struct seq_file *s, void *data)
 	return 0;
 }
 
-#define hva_dbg_declare(name)						  \
-	static int hva_dbg_##name##_open(struct inode *i, struct file *f) \
-	{								  \
-		return single_open(f, hva_dbg_##name, i->i_private);	  \
-	}								  \
-	static const struct file_operations hva_dbg_##name##_fops = {	  \
-		.open		= hva_dbg_##name##_open,		  \
-		.read		= seq_read,				  \
-		.llseek		= seq_lseek,				  \
-		.release	= single_release,			  \
-	}
-
 #define hva_dbg_create_entry(name)					 \
 	debugfs_create_file(#name, 0444, hva->dbg.debugfs_entry, hva, \
-			    &hva_dbg_##name##_fops)
+			    &name##_fops)
 
-hva_dbg_declare(device);
-hva_dbg_declare(encoders);
-hva_dbg_declare(last);
-hva_dbg_declare(regs);
+DEFINE_SHOW_ATTRIBUTE(device);
+DEFINE_SHOW_ATTRIBUTE(encoders);
+DEFINE_SHOW_ATTRIBUTE(last);
+DEFINE_SHOW_ATTRIBUTE(regs);
 
 void hva_debugfs_create(struct hva_dev *hva)
 {
@@ -380,7 +368,7 @@ void hva_debugfs_remove(struct hva_dev *hva)
  * context (instance) debug info
  */
 
-static int hva_dbg_ctx(struct seq_file *s, void *data)
+static int ctx_show(struct seq_file *s, void *data)
 {
 	struct hva_ctx *ctx = s->private;
 
@@ -392,7 +380,7 @@ static int hva_dbg_ctx(struct seq_file *s, void *data)
 	return 0;
 }
 
-hva_dbg_declare(ctx);
+DEFINE_SHOW_ATTRIBUTE(ctx);
 
 void hva_dbg_ctx_create(struct hva_ctx *ctx)
 {
@@ -407,7 +395,7 @@ void hva_dbg_ctx_create(struct hva_ctx *ctx)
 
 	ctx->dbg.debugfs_entry = debugfs_create_file(name, 0444,
 						     hva->dbg.debugfs_entry,
-						     ctx, &hva_dbg_ctx_fops);
+						     ctx, &ctx_fops);
 }
 
 void hva_dbg_ctx_remove(struct hva_ctx *ctx)
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] media: platform: sti: remove bdisp_dbg_declare() and hva_dbg_declare()
  2018-12-12 16:27 [PATCH v3] media: platform: sti: remove bdisp_dbg_declare() and hva_dbg_declare() Yangtao Li
@ 2018-12-13  8:29 ` Fabien DESSENNE
  0 siblings, 0 replies; 2+ messages in thread
From: Fabien DESSENNE @ 2018-12-13  8:29 UTC (permalink / raw)
  To: Yangtao Li, mchehab, Jean Christophe TROTIN; +Cc: linux-media, linux-kernel

Hi,

Thank you for the patch.

Fabien


On 12/12/2018 5:27 PM, Yangtao Li wrote:
> We already have the DEFINE_SHOW_ATTRIBUTE. There is no need to define
> bdisp_dbg_declare and hva_dbg_declare, so remove them. Also use
> DEFINE_SHOW_ATTRIBUTE to simplify some code.
>
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>

Reviewed-by: Fabien Dessenne <fabien.dessenne@st.com>

> ---
>   .../media/platform/sti/bdisp/bdisp-debug.c    | 34 ++++++------------
>   drivers/media/platform/sti/hva/hva-debugfs.c  | 36 +++++++------------
>   2 files changed, 23 insertions(+), 47 deletions(-)
>
> diff --git a/drivers/media/platform/sti/bdisp/bdisp-debug.c b/drivers/media/platform/sti/bdisp/bdisp-debug.c
> index c6a4e2de5c0c..77ca7517fa3e 100644
> --- a/drivers/media/platform/sti/bdisp/bdisp-debug.c
> +++ b/drivers/media/platform/sti/bdisp/bdisp-debug.c
> @@ -315,7 +315,7 @@ static void bdisp_dbg_dump_ivmx(struct seq_file *s,
>   	seq_puts(s, "Unknown conversion\n");
>   }
>   
> -static int bdisp_dbg_last_nodes(struct seq_file *s, void *data)
> +static int last_nodes_show(struct seq_file *s, void *data)
>   {
>   	/* Not dumping all fields, focusing on significant ones */
>   	struct bdisp_dev *bdisp = s->private;
> @@ -388,7 +388,7 @@ static int bdisp_dbg_last_nodes(struct seq_file *s, void *data)
>   	return 0;
>   }
>   
> -static int bdisp_dbg_last_nodes_raw(struct seq_file *s, void *data)
> +static int last_nodes_raw_show(struct seq_file *s, void *data)
>   {
>   	struct bdisp_dev *bdisp = s->private;
>   	struct bdisp_node *node;
> @@ -437,7 +437,7 @@ static const char *bdisp_fmt_to_str(struct bdisp_frame frame)
>   	}
>   }
>   
> -static int bdisp_dbg_last_request(struct seq_file *s, void *data)
> +static int last_request_show(struct seq_file *s, void *data)
>   {
>   	struct bdisp_dev *bdisp = s->private;
>   	struct bdisp_request *request = &bdisp->dbg.copy_request;
> @@ -474,7 +474,7 @@ static int bdisp_dbg_last_request(struct seq_file *s, void *data)
>   
>   #define DUMP(reg) seq_printf(s, #reg " \t0x%08X\n", readl(bdisp->regs + reg))
>   
> -static int bdisp_dbg_regs(struct seq_file *s, void *data)
> +static int regs_show(struct seq_file *s, void *data)
>   {
>   	struct bdisp_dev *bdisp = s->private;
>   	int ret;
> @@ -582,7 +582,7 @@ static int bdisp_dbg_regs(struct seq_file *s, void *data)
>   
>   #define SECOND 1000000
>   
> -static int bdisp_dbg_perf(struct seq_file *s, void *data)
> +static int perf_show(struct seq_file *s, void *data)
>   {
>   	struct bdisp_dev *bdisp = s->private;
>   	struct bdisp_request *request = &bdisp->dbg.copy_request;
> @@ -627,27 +627,15 @@ static int bdisp_dbg_perf(struct seq_file *s, void *data)
>   	return 0;
>   }
>   
> -#define bdisp_dbg_declare(name) \
> -	static int bdisp_dbg_##name##_open(struct inode *i, struct file *f) \
> -	{ \
> -		return single_open(f, bdisp_dbg_##name, i->i_private); \
> -	} \
> -	static const struct file_operations bdisp_dbg_##name##_fops = { \
> -		.open           = bdisp_dbg_##name##_open, \
> -		.read           = seq_read, \
> -		.llseek         = seq_lseek, \
> -		.release        = single_release, \
> -	}
> -
>   #define bdisp_dbg_create_entry(name) \
>   	debugfs_create_file(#name, S_IRUGO, bdisp->dbg.debugfs_entry, bdisp, \
> -			    &bdisp_dbg_##name##_fops)
> +			    &name##_fops)
>   
> -bdisp_dbg_declare(regs);
> -bdisp_dbg_declare(last_nodes);
> -bdisp_dbg_declare(last_nodes_raw);
> -bdisp_dbg_declare(last_request);
> -bdisp_dbg_declare(perf);
> +DEFINE_SHOW_ATTRIBUTE(regs);
> +DEFINE_SHOW_ATTRIBUTE(last_nodes);
> +DEFINE_SHOW_ATTRIBUTE(last_nodes_raw);
> +DEFINE_SHOW_ATTRIBUTE(last_request);
> +DEFINE_SHOW_ATTRIBUTE(perf);
>   
>   int bdisp_debugfs_create(struct bdisp_dev *bdisp)
>   {
> diff --git a/drivers/media/platform/sti/hva/hva-debugfs.c b/drivers/media/platform/sti/hva/hva-debugfs.c
> index 9f7e8ac875d1..7d12a5b5d914 100644
> --- a/drivers/media/platform/sti/hva/hva-debugfs.c
> +++ b/drivers/media/platform/sti/hva/hva-debugfs.c
> @@ -271,7 +271,7 @@ static void hva_dbg_perf_compute(struct hva_ctx *ctx)
>    * device debug info
>    */
>   
> -static int hva_dbg_device(struct seq_file *s, void *data)
> +static int device_show(struct seq_file *s, void *data)
>   {
>   	struct hva_dev *hva = s->private;
>   
> @@ -281,7 +281,7 @@ static int hva_dbg_device(struct seq_file *s, void *data)
>   	return 0;
>   }
>   
> -static int hva_dbg_encoders(struct seq_file *s, void *data)
> +static int encoders_show(struct seq_file *s, void *data)
>   {
>   	struct hva_dev *hva = s->private;
>   	unsigned int i = 0;
> @@ -299,7 +299,7 @@ static int hva_dbg_encoders(struct seq_file *s, void *data)
>   	return 0;
>   }
>   
> -static int hva_dbg_last(struct seq_file *s, void *data)
> +static int last_show(struct seq_file *s, void *data)
>   {
>   	struct hva_dev *hva = s->private;
>   	struct hva_ctx *last_ctx = &hva->dbg.last_ctx;
> @@ -316,7 +316,7 @@ static int hva_dbg_last(struct seq_file *s, void *data)
>   	return 0;
>   }
>   
> -static int hva_dbg_regs(struct seq_file *s, void *data)
> +static int regs_show(struct seq_file *s, void *data)
>   {
>   	struct hva_dev *hva = s->private;
>   
> @@ -325,26 +325,14 @@ static int hva_dbg_regs(struct seq_file *s, void *data)
>   	return 0;
>   }
>   
> -#define hva_dbg_declare(name)						  \
> -	static int hva_dbg_##name##_open(struct inode *i, struct file *f) \
> -	{								  \
> -		return single_open(f, hva_dbg_##name, i->i_private);	  \
> -	}								  \
> -	static const struct file_operations hva_dbg_##name##_fops = {	  \
> -		.open		= hva_dbg_##name##_open,		  \
> -		.read		= seq_read,				  \
> -		.llseek		= seq_lseek,				  \
> -		.release	= single_release,			  \
> -	}
> -
>   #define hva_dbg_create_entry(name)					 \
>   	debugfs_create_file(#name, 0444, hva->dbg.debugfs_entry, hva, \
> -			    &hva_dbg_##name##_fops)
> +			    &name##_fops)
>   
> -hva_dbg_declare(device);
> -hva_dbg_declare(encoders);
> -hva_dbg_declare(last);
> -hva_dbg_declare(regs);
> +DEFINE_SHOW_ATTRIBUTE(device);
> +DEFINE_SHOW_ATTRIBUTE(encoders);
> +DEFINE_SHOW_ATTRIBUTE(last);
> +DEFINE_SHOW_ATTRIBUTE(regs);
>   
>   void hva_debugfs_create(struct hva_dev *hva)
>   {
> @@ -380,7 +368,7 @@ void hva_debugfs_remove(struct hva_dev *hva)
>    * context (instance) debug info
>    */
>   
> -static int hva_dbg_ctx(struct seq_file *s, void *data)
> +static int ctx_show(struct seq_file *s, void *data)
>   {
>   	struct hva_ctx *ctx = s->private;
>   
> @@ -392,7 +380,7 @@ static int hva_dbg_ctx(struct seq_file *s, void *data)
>   	return 0;
>   }
>   
> -hva_dbg_declare(ctx);
> +DEFINE_SHOW_ATTRIBUTE(ctx);
>   
>   void hva_dbg_ctx_create(struct hva_ctx *ctx)
>   {
> @@ -407,7 +395,7 @@ void hva_dbg_ctx_create(struct hva_ctx *ctx)
>   
>   	ctx->dbg.debugfs_entry = debugfs_create_file(name, 0444,
>   						     hva->dbg.debugfs_entry,
> -						     ctx, &hva_dbg_ctx_fops);
> +						     ctx, &ctx_fops);
>   }
>   
>   void hva_dbg_ctx_remove(struct hva_ctx *ctx)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-12-13  8:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-12 16:27 [PATCH v3] media: platform: sti: remove bdisp_dbg_declare() and hva_dbg_declare() Yangtao Li
2018-12-13  8:29 ` Fabien DESSENNE

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).