All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] staging: vc04_services: no need to check debugfs return values
@ 2018-06-01 11:09 Greg Kroah-Hartman
  2018-06-01 11:10 ` [PATCH 2/6] staging: vc04_services: remove odd vchiq_debugfs_top() wrapper Greg Kroah-Hartman
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-06-01 11:09 UTC (permalink / raw)
  To: linux-arm-kernel

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Clean up the vchiq_arm code by not caring about the value of debugfs
calls.  This ends up removing a number of lines of code that are not
needed.

Cc: Eric Anholt <eric@anholt.net>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Keerthi Reddy <keerthigd4990@gmail.com>
Cc: linux-rpi-kernel at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 .../interface/vchiq_arm/vchiq_arm.c           | 13 +---
 .../interface/vchiq_arm/vchiq_debugfs.c       | 72 +++----------------
 .../interface/vchiq_arm/vchiq_debugfs.h       |  4 +-
 3 files changed, 15 insertions(+), 74 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index aaa264f3b598..bc05c69383b8 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -2018,7 +2018,6 @@ vchiq_open(struct inode *inode, struct file *file)
 	vchiq_log_info(vchiq_arm_log_level, "vchiq_open");
 	switch (dev) {
 	case VCHIQ_MINOR: {
-		int ret;
 		VCHIQ_STATE_T *state = vchiq_get_state();
 		VCHIQ_INSTANCE_T instance;
 
@@ -2035,11 +2034,7 @@ vchiq_open(struct inode *inode, struct file *file)
 		instance->state = state;
 		instance->pid = current->tgid;
 
-		ret = vchiq_debugfs_add_instance(instance);
-		if (ret != 0) {
-			kfree(instance);
-			return ret;
-		}
+		vchiq_debugfs_add_instance(instance);
 
 		sema_init(&instance->insert_event, 0);
 		sema_init(&instance->remove_event, 0);
@@ -3630,9 +3625,7 @@ static int vchiq_probe(struct platform_device *pdev)
 		goto failed_device_create;
 
 	/* create debugfs entries */
-	err = vchiq_debugfs_init();
-	if (err != 0)
-		goto failed_debugfs_init;
+	vchiq_debugfs_init();
 
 	vchiq_log_info(vchiq_arm_log_level,
 		"vchiq: initialised - version %d (min %d), device %d.%d",
@@ -3645,8 +3638,6 @@ static int vchiq_probe(struct platform_device *pdev)
 
 	return 0;
 
-failed_debugfs_init:
-	device_destroy(vchiq_class, vchiq_devid);
 failed_device_create:
 	class_destroy(vchiq_class);
 failed_class_create:
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
index 766b4fe5f32c..103fec955e2c 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
@@ -158,15 +158,12 @@ static const struct file_operations debugfs_log_fops = {
 };
 
 /* create an entry under <debugfs>/vchiq/log for each log category */
-static int vchiq_debugfs_create_log_entries(struct dentry *top)
+static void vchiq_debugfs_create_log_entries(struct dentry *top)
 {
 	struct dentry *dir;
 	size_t i;
-	int ret = 0;
 
 	dir = debugfs_create_dir("log", vchiq_debugfs_top());
-	if (!dir)
-		return -ENOMEM;
 	debugfs_info.log_categories = dir;
 
 	for (i = 0; i < n_log_entries; i++) {
@@ -177,14 +174,8 @@ static int vchiq_debugfs_create_log_entries(struct dentry *top)
 					  debugfs_info.log_categories,
 					  levp,
 					  &debugfs_log_fops);
-		if (!dir) {
-			ret = -ENOMEM;
-			break;
-		}
-
 		vchiq_debugfs_log_entries[i].dir = dir;
 	}
-	return ret;
 }
 
 static int debugfs_usecount_show(struct seq_file *f, void *offset)
@@ -268,43 +259,22 @@ static const struct file_operations debugfs_trace_fops = {
 };
 
 /* add an instance (process) to the debugfs entries */
-int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
+void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
 {
 	char pidstr[16];
-	struct dentry *top, *use_count, *trace;
+	struct dentry *top;
 	struct dentry *clients = vchiq_clients_top();
 
 	snprintf(pidstr, sizeof(pidstr), "%d",
 		 vchiq_instance_get_pid(instance));
 
 	top = debugfs_create_dir(pidstr, clients);
-	if (!top)
-		goto fail_top;
-
-	use_count = debugfs_create_file("use_count",
-					0444, top,
-					instance,
-					&debugfs_usecount_fops);
-	if (!use_count)
-		goto fail_use_count;
-
-	trace = debugfs_create_file("trace",
-				    0644, top,
-				    instance,
-				    &debugfs_trace_fops);
-	if (!trace)
-		goto fail_trace;
-
-	vchiq_instance_get_debugfs_node(instance)->dentry = top;
 
-	return 0;
+	debugfs_create_file("use_count", 0444, top, instance,
+			    &debugfs_usecount_fops);
+	debugfs_create_file("trace", 0644, top, instance, &debugfs_trace_fops);
 
-fail_trace:
-	debugfs_remove(use_count);
-fail_use_count:
-	debugfs_remove(top);
-fail_top:
-	return -ENOMEM;
+	vchiq_instance_get_debugfs_node(instance)->dentry = top;
 }
 
 void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
@@ -314,31 +284,13 @@ void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
 	debugfs_remove_recursive(node->dentry);
 }
 
-int vchiq_debugfs_init(void)
+void vchiq_debugfs_init(void)
 {
-	BUG_ON(debugfs_info.vchiq_cfg_dir != NULL);
-
 	debugfs_info.vchiq_cfg_dir = debugfs_create_dir("vchiq", NULL);
-	if (debugfs_info.vchiq_cfg_dir == NULL)
-		goto fail;
-
 	debugfs_info.clients = debugfs_create_dir("clients",
 				vchiq_debugfs_top());
-	if (!debugfs_info.clients)
-		goto fail;
 
-	if (vchiq_debugfs_create_log_entries(vchiq_debugfs_top()) != 0)
-		goto fail;
-
-	return 0;
-
-fail:
-	vchiq_debugfs_deinit();
-	vchiq_log_error(vchiq_arm_log_level,
-		"%s: failed to create debugfs directory",
-		__func__);
-
-	return -ENOMEM;
+	vchiq_debugfs_create_log_entries(vchiq_debugfs_top());
 }
 
 /* remove all the debugfs entries */
@@ -360,18 +312,16 @@ static struct dentry *vchiq_debugfs_top(void)
 
 #else /* CONFIG_DEBUG_FS */
 
-int vchiq_debugfs_init(void)
+void vchiq_debugfs_init(void)
 {
-	return 0;
 }
 
 void vchiq_debugfs_deinit(void)
 {
 }
 
-int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
+void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
 {
-	return 0;
 }
 
 void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h
index 1d95e3d70621..3af6397ada19 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h
@@ -40,11 +40,11 @@ typedef struct vchiq_debugfs_node_struct {
     struct dentry *dentry;
 } VCHIQ_DEBUGFS_NODE_T;
 
-int vchiq_debugfs_init(void);
+void vchiq_debugfs_init(void);
 
 void vchiq_debugfs_deinit(void);
 
-int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance);
+void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance);
 
 void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance);
 
-- 
2.17.1

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

* [PATCH 2/6] staging: vc04_services: remove odd vchiq_debugfs_top() wrapper
  2018-06-01 11:09 [PATCH 1/6] staging: vc04_services: no need to check debugfs return values Greg Kroah-Hartman
@ 2018-06-01 11:10 ` Greg Kroah-Hartman
  2018-06-01 11:10 ` [PATCH 3/6] staging: vc04_services: move client dbg directory into static variable Greg Kroah-Hartman
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-06-01 11:10 UTC (permalink / raw)
  To: linux-arm-kernel

vchiq_debugfs_top() is only a wrapper around a pointer to a dentry, so
just use the dentry directly instead, making it a static variable
instead of part of a static structure.

This also removes the pointless BUG_ON() when checking that dentry as no
one should ever care if debugfs is working or not, and the kernel should
really not panic over something as trivial as that.

Suggested-by: Eric Anholt <eric@anholt.net>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Keerthi Reddy <keerthigd4990@gmail.com>
Cc: linux-rpi-kernel at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 .../interface/vchiq_arm/vchiq_debugfs.c       | 24 +++++++------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
index 103fec955e2c..8b46256a97fc 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
@@ -53,9 +53,6 @@
 
 /* Top-level debug info */
 struct vchiq_debugfs_info {
-	/* Global 'vchiq' debugfs entry used by all instances */
-	struct dentry *vchiq_cfg_dir;
-
 	/* one entry per client process */
 	struct dentry *clients;
 
@@ -65,6 +62,9 @@ struct vchiq_debugfs_info {
 
 static struct vchiq_debugfs_info debugfs_info;
 
+/* Global 'vchiq' debugfs entry used by all instances */
+struct dentry *vchiq_dbg_dir;
+
 /* Log category debugfs entries */
 struct vchiq_debugfs_log_entry {
 	const char *name;
@@ -82,7 +82,6 @@ static struct vchiq_debugfs_log_entry vchiq_debugfs_log_entries[] = {
 static int n_log_entries = ARRAY_SIZE(vchiq_debugfs_log_entries);
 
 static struct dentry *vchiq_clients_top(void);
-static struct dentry *vchiq_debugfs_top(void);
 
 static int debugfs_log_show(struct seq_file *f, void *offset)
 {
@@ -163,7 +162,7 @@ static void vchiq_debugfs_create_log_entries(struct dentry *top)
 	struct dentry *dir;
 	size_t i;
 
-	dir = debugfs_create_dir("log", vchiq_debugfs_top());
+	dir = debugfs_create_dir("log", vchiq_dbg_dir);
 	debugfs_info.log_categories = dir;
 
 	for (i = 0; i < n_log_entries; i++) {
@@ -286,17 +285,16 @@ void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
 
 void vchiq_debugfs_init(void)
 {
-	debugfs_info.vchiq_cfg_dir = debugfs_create_dir("vchiq", NULL);
-	debugfs_info.clients = debugfs_create_dir("clients",
-				vchiq_debugfs_top());
+	vchiq_dbg_dir = debugfs_create_dir("vchiq", NULL);
+	debugfs_info.clients = debugfs_create_dir("clients", vchiq_dbg_dir);
 
-	vchiq_debugfs_create_log_entries(vchiq_debugfs_top());
+	vchiq_debugfs_create_log_entries(vchiq_dbg_dir);
 }
 
 /* remove all the debugfs entries */
 void vchiq_debugfs_deinit(void)
 {
-	debugfs_remove_recursive(vchiq_debugfs_top());
+	debugfs_remove_recursive(vchiq_dbg_dir);
 }
 
 static struct dentry *vchiq_clients_top(void)
@@ -304,12 +302,6 @@ static struct dentry *vchiq_clients_top(void)
 	return debugfs_info.clients;
 }
 
-static struct dentry *vchiq_debugfs_top(void)
-{
-	BUG_ON(debugfs_info.vchiq_cfg_dir == NULL);
-	return debugfs_info.vchiq_cfg_dir;
-}
-
 #else /* CONFIG_DEBUG_FS */
 
 void vchiq_debugfs_init(void)
-- 
2.17.1

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

* [PATCH 3/6] staging: vc04_services: move client dbg directory into static variable
  2018-06-01 11:09 [PATCH 1/6] staging: vc04_services: no need to check debugfs return values Greg Kroah-Hartman
  2018-06-01 11:10 ` [PATCH 2/6] staging: vc04_services: remove odd vchiq_debugfs_top() wrapper Greg Kroah-Hartman
@ 2018-06-01 11:10 ` Greg Kroah-Hartman
  2018-06-01 11:10 ` [PATCH 4/6] staging: vc04_services: remove struct vchiq_debugfs_info Greg Kroah-Hartman
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-06-01 11:10 UTC (permalink / raw)
  To: linux-arm-kernel

This does not need to be part of a wrapper function, or in a structure,
just properly reference it directly as a single variable.

The whole variable will be going away soon anyway, this is just a step
toward that direction.

Suggested-by: Eric Anholt <eric@anholt.net>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Keerthi Reddy <keerthigd4990@gmail.com>
Cc: linux-rpi-kernel at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 .../interface/vchiq_arm/vchiq_debugfs.c        | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
index 8b46256a97fc..12ed560c95a7 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
@@ -53,17 +53,15 @@
 
 /* Top-level debug info */
 struct vchiq_debugfs_info {
-	/* one entry per client process */
-	struct dentry *clients;
-
 	/* log categories */
 	struct dentry *log_categories;
 };
 
 static struct vchiq_debugfs_info debugfs_info;
 
-/* Global 'vchiq' debugfs entry used by all instances */
+/* Global 'vchiq' debugfs and clients entry used by all instances */
 struct dentry *vchiq_dbg_dir;
+struct dentry *vchiq_dbg_clients;
 
 /* Log category debugfs entries */
 struct vchiq_debugfs_log_entry {
@@ -81,8 +79,6 @@ static struct vchiq_debugfs_log_entry vchiq_debugfs_log_entries[] = {
 };
 static int n_log_entries = ARRAY_SIZE(vchiq_debugfs_log_entries);
 
-static struct dentry *vchiq_clients_top(void);
-
 static int debugfs_log_show(struct seq_file *f, void *offset)
 {
 	int *levp = f->private;
@@ -262,12 +258,11 @@ void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
 {
 	char pidstr[16];
 	struct dentry *top;
-	struct dentry *clients = vchiq_clients_top();
 
 	snprintf(pidstr, sizeof(pidstr), "%d",
 		 vchiq_instance_get_pid(instance));
 
-	top = debugfs_create_dir(pidstr, clients);
+	top = debugfs_create_dir(pidstr, vchiq_dbg_clients);
 
 	debugfs_create_file("use_count", 0444, top, instance,
 			    &debugfs_usecount_fops);
@@ -286,7 +281,7 @@ void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
 void vchiq_debugfs_init(void)
 {
 	vchiq_dbg_dir = debugfs_create_dir("vchiq", NULL);
-	debugfs_info.clients = debugfs_create_dir("clients", vchiq_dbg_dir);
+	vchiq_dbg_clients = debugfs_create_dir("clients", vchiq_dbg_dir);
 
 	vchiq_debugfs_create_log_entries(vchiq_dbg_dir);
 }
@@ -297,11 +292,6 @@ void vchiq_debugfs_deinit(void)
 	debugfs_remove_recursive(vchiq_dbg_dir);
 }
 
-static struct dentry *vchiq_clients_top(void)
-{
-	return debugfs_info.clients;
-}
-
 #else /* CONFIG_DEBUG_FS */
 
 void vchiq_debugfs_init(void)
-- 
2.17.1

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

* [PATCH 4/6] staging: vc04_services: remove struct vchiq_debugfs_info
  2018-06-01 11:09 [PATCH 1/6] staging: vc04_services: no need to check debugfs return values Greg Kroah-Hartman
  2018-06-01 11:10 ` [PATCH 2/6] staging: vc04_services: remove odd vchiq_debugfs_top() wrapper Greg Kroah-Hartman
  2018-06-01 11:10 ` [PATCH 3/6] staging: vc04_services: move client dbg directory into static variable Greg Kroah-Hartman
@ 2018-06-01 11:10 ` Greg Kroah-Hartman
  2018-06-01 11:10 ` [PATCH 5/6] staging: vc04_services: vchiq_debugfs_log_entry can be a void * Greg Kroah-Hartman
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-06-01 11:10 UTC (permalink / raw)
  To: linux-arm-kernel

This structure, and the one static variable that was declared with it,
were not being used for anything.  The log_categories field was being
set, but never used again.  So just remove it entirely as it is not
needed at all.

Suggested-by: Eric Anholt <eric@anholt.net>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Keerthi Reddy <keerthigd4990@gmail.com>
Cc: linux-rpi-kernel at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 .../interface/vchiq_arm/vchiq_debugfs.c            | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
index 12ed560c95a7..f18cd56c3634 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
@@ -51,14 +51,6 @@
 #define VCHIQ_LOG_INFO_STR    "info"
 #define VCHIQ_LOG_TRACE_STR   "trace"
 
-/* Top-level debug info */
-struct vchiq_debugfs_info {
-	/* log categories */
-	struct dentry *log_categories;
-};
-
-static struct vchiq_debugfs_info debugfs_info;
-
 /* Global 'vchiq' debugfs and clients entry used by all instances */
 struct dentry *vchiq_dbg_dir;
 struct dentry *vchiq_dbg_clients;
@@ -159,16 +151,12 @@ static void vchiq_debugfs_create_log_entries(struct dentry *top)
 	size_t i;
 
 	dir = debugfs_create_dir("log", vchiq_dbg_dir);
-	debugfs_info.log_categories = dir;
 
 	for (i = 0; i < n_log_entries; i++) {
 		void *levp = (void *)vchiq_debugfs_log_entries[i].plevel;
 
 		dir = debugfs_create_file(vchiq_debugfs_log_entries[i].name,
-					  0644,
-					  debugfs_info.log_categories,
-					  levp,
-					  &debugfs_log_fops);
+					  0644, dir, levp, &debugfs_log_fops);
 		vchiq_debugfs_log_entries[i].dir = dir;
 	}
 }
-- 
2.17.1

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

* [PATCH 5/6] staging: vc04_services: vchiq_debugfs_log_entry can be a void *
  2018-06-01 11:09 [PATCH 1/6] staging: vc04_services: no need to check debugfs return values Greg Kroah-Hartman
                   ` (2 preceding siblings ...)
  2018-06-01 11:10 ` [PATCH 4/6] staging: vc04_services: remove struct vchiq_debugfs_info Greg Kroah-Hartman
@ 2018-06-01 11:10 ` Greg Kroah-Hartman
  2018-06-01 11:10 ` [PATCH 6/6] staging: vc04_services: no need to save the log debufs dentries Greg Kroah-Hartman
  2018-06-01 17:09 ` [PATCH 1/6] staging: vc04_services: no need to check debugfs return values Eric Anholt
  5 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-06-01 11:10 UTC (permalink / raw)
  To: linux-arm-kernel

There's no need to set this to be int * when it is only used as a void *.
This lets us remove the unneeded cast, and unneeded temporary variable
the one place it is referenced in the code.

Suggested-by: Eric Anholt <eric@anholt.net>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Keerthi Reddy <keerthigd4990@gmail.com>
Cc: linux-rpi-kernel at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 .../vc04_services/interface/vchiq_arm/vchiq_debugfs.c     | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
index f18cd56c3634..2b353d2d25ce 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
@@ -58,7 +58,7 @@ struct dentry *vchiq_dbg_clients;
 /* Log category debugfs entries */
 struct vchiq_debugfs_log_entry {
 	const char *name;
-	int *plevel;
+	void *plevel;
 	struct dentry *dir;
 };
 
@@ -153,10 +153,10 @@ static void vchiq_debugfs_create_log_entries(struct dentry *top)
 	dir = debugfs_create_dir("log", vchiq_dbg_dir);
 
 	for (i = 0; i < n_log_entries; i++) {
-		void *levp = (void *)vchiq_debugfs_log_entries[i].plevel;
-
 		dir = debugfs_create_file(vchiq_debugfs_log_entries[i].name,
-					  0644, dir, levp, &debugfs_log_fops);
+					  0644, dir,
+					  vchiq_debugfs_log_entries[i].plevel,
+					  &debugfs_log_fops);
 		vchiq_debugfs_log_entries[i].dir = dir;
 	}
 }
-- 
2.17.1

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

* [PATCH 6/6] staging: vc04_services: no need to save the log debufs dentries
  2018-06-01 11:09 [PATCH 1/6] staging: vc04_services: no need to check debugfs return values Greg Kroah-Hartman
                   ` (3 preceding siblings ...)
  2018-06-01 11:10 ` [PATCH 5/6] staging: vc04_services: vchiq_debugfs_log_entry can be a void * Greg Kroah-Hartman
@ 2018-06-01 11:10 ` Greg Kroah-Hartman
  2018-06-01 17:09 ` [PATCH 1/6] staging: vc04_services: no need to check debugfs return values Eric Anholt
  5 siblings, 0 replies; 7+ messages in thread
From: Greg Kroah-Hartman @ 2018-06-01 11:10 UTC (permalink / raw)
  To: linux-arm-kernel

The log entry dentries are only set, never referenced, so no need to
keep them around.  Remove the pointer from struct
vchiq_debugfs_log_entry as it is not needed anymore and get rid of the
separate vchiq_debugfs_create_log_entries() function as it is only used
in one place.

Suggested-by: Eric Anholt <eric@anholt.net>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Keerthi Reddy <keerthigd4990@gmail.com>
Cc: linux-rpi-kernel at lists.infradead.org
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 .../interface/vchiq_arm/vchiq_debugfs.c       | 29 +++++++------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
index 2b353d2d25ce..38805504d462 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
@@ -59,7 +59,6 @@ struct dentry *vchiq_dbg_clients;
 struct vchiq_debugfs_log_entry {
 	const char *name;
 	void *plevel;
-	struct dentry *dir;
 };
 
 static struct vchiq_debugfs_log_entry vchiq_debugfs_log_entries[] = {
@@ -144,23 +143,6 @@ static const struct file_operations debugfs_log_fops = {
 	.release	= single_release,
 };
 
-/* create an entry under <debugfs>/vchiq/log for each log category */
-static void vchiq_debugfs_create_log_entries(struct dentry *top)
-{
-	struct dentry *dir;
-	size_t i;
-
-	dir = debugfs_create_dir("log", vchiq_dbg_dir);
-
-	for (i = 0; i < n_log_entries; i++) {
-		dir = debugfs_create_file(vchiq_debugfs_log_entries[i].name,
-					  0644, dir,
-					  vchiq_debugfs_log_entries[i].plevel,
-					  &debugfs_log_fops);
-		vchiq_debugfs_log_entries[i].dir = dir;
-	}
-}
-
 static int debugfs_usecount_show(struct seq_file *f, void *offset)
 {
 	VCHIQ_INSTANCE_T instance = f->private;
@@ -268,10 +250,19 @@ void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance)
 
 void vchiq_debugfs_init(void)
 {
+	struct dentry *dir;
+	int i;
+
 	vchiq_dbg_dir = debugfs_create_dir("vchiq", NULL);
 	vchiq_dbg_clients = debugfs_create_dir("clients", vchiq_dbg_dir);
 
-	vchiq_debugfs_create_log_entries(vchiq_dbg_dir);
+	/* create an entry under <debugfs>/vchiq/log for each log category */
+	dir = debugfs_create_dir("log", vchiq_dbg_dir);
+
+	for (i = 0; i < n_log_entries; i++)
+		debugfs_create_file(vchiq_debugfs_log_entries[i].name, 0644,
+				    dir, vchiq_debugfs_log_entries[i].plevel,
+				    &debugfs_log_fops);
 }
 
 /* remove all the debugfs entries */
-- 
2.17.1

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

* [PATCH 1/6] staging: vc04_services: no need to check debugfs return values
  2018-06-01 11:09 [PATCH 1/6] staging: vc04_services: no need to check debugfs return values Greg Kroah-Hartman
                   ` (4 preceding siblings ...)
  2018-06-01 11:10 ` [PATCH 6/6] staging: vc04_services: no need to save the log debufs dentries Greg Kroah-Hartman
@ 2018-06-01 17:09 ` Eric Anholt
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Anholt @ 2018-06-01 17:09 UTC (permalink / raw)
  To: linux-arm-kernel

Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:

> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
>
> Clean up the vchiq_arm code by not caring about the value of debugfs
> calls.  This ends up removing a number of lines of code that are not
> needed.

This series is:

Reviewed-by: Eric Anholt <eric@anholt.net>

Thanks for the cleanups!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180601/d86564ed/attachment.sig>

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

end of thread, other threads:[~2018-06-01 17:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-01 11:09 [PATCH 1/6] staging: vc04_services: no need to check debugfs return values Greg Kroah-Hartman
2018-06-01 11:10 ` [PATCH 2/6] staging: vc04_services: remove odd vchiq_debugfs_top() wrapper Greg Kroah-Hartman
2018-06-01 11:10 ` [PATCH 3/6] staging: vc04_services: move client dbg directory into static variable Greg Kroah-Hartman
2018-06-01 11:10 ` [PATCH 4/6] staging: vc04_services: remove struct vchiq_debugfs_info Greg Kroah-Hartman
2018-06-01 11:10 ` [PATCH 5/6] staging: vc04_services: vchiq_debugfs_log_entry can be a void * Greg Kroah-Hartman
2018-06-01 11:10 ` [PATCH 6/6] staging: vc04_services: no need to save the log debufs dentries Greg Kroah-Hartman
2018-06-01 17:09 ` [PATCH 1/6] staging: vc04_services: no need to check debugfs return values Eric Anholt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.