staging: media: imx: no need to check return value of debugfs_create functions
Greg Kroah-Hartman
maintainerPATCH 1/1 staging: media: imx: no need to check return value of debugfs_create functions
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.
Cc Rui Miguel Silva <[email protected]>
Cc Steve Longerbeam <[email protected]>
Cc Philipp Zabel <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc NXP Linux Team <[email protected]>
Signed-off-by Greg Kroah-Hartman <[email protected]>
--- drivers/staging/media/imx/imx7-mipi-csis.c | 29 ++++------------------ 1 file changed, 5 insertions(+), 24 deletions(-)
drivers/staging/media/imx/imx7-mipi-csis.c +5 -24
@@ -915,33 +915,14 @@ static int mipi_csis_dump_regs_show(struct seq_file *m, void *private) }DEFINE_SHOW_ATTRIBUTE (mipi_csis_dump_regs); -static int mipi_csis_debugfs_init (struct csi_state *state) +static void mipi_csis_debugfs_init (struct csi_state *state) { -struct dentry *d; - -if (!debugfs_initialized ()) -return -ENODEV ; - state->debugfs_root =debugfs_create_dir (dev_name (state->dev),NULL ); -if (!state->debugfs_root) -return -ENOMEM ; - - d =debugfs_create_bool ("debug_enable" ,0600 , state->debugfs_root, - &state->debug); -if (!d) - goto remove_debugfs; - - d =debugfs_create_file ("dump_regs" ,0600 , state->debugfs_root, - state, &mipi_csis_dump_regs_fops); -if (!d) - goto remove_debugfs; - -return 0 ; - -remove_debugfs: -debugfs_remove_recursive (state->debugfs_root); -return -ENOMEM ; +debugfs_create_bool ("debug_enable" ,0600 , state->debugfs_root, + &state->debug); +debugfs_create_file ("dump_regs" ,0600 , state->debugfs_root, state, + &mipi_csis_dump_regs_fops); }static void mipi_csis_debugfs_exit (struct csi_state *state)
Signature · 1 line
2.26.2
Hi Greg,
Thanks for the cleanup.
Quoted 4 lines · Greg Kroah-Hartman
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.
Quoted 13 lines
Cc Rui Miguel Silva <[email protected]>Cc Steve Longerbeam <[email protected]>Cc Philipp Zabel <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Shawn Guo <[email protected]>Cc Sascha Hauer <[email protected]>Cc Pengutronix Kernel Team <[email protected]>Cc Fabio Estevam <[email protected]>Cc NXP Linux Team <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Reviewed-by Rui Miguel Silva <[email protected]>
Cheers,
Rui
Quoted 50 lines
--- drivers/staging/media/imx/imx7-mipi-csis.c | 29 ++++------------------ 1 file changed, 5 insertions(+), 24 deletions(-)drivers/staging/media/imx/imx7-mipi-csis.c +5
-24@@ -915,33 +915,14 @@ static int mipi_csis_dump_regs_show(struct seq_file *m, void *private) }DEFINE_SHOW_ATTRIBUTE (mipi_csis_dump_regs); -static int mipi_csis_debugfs_init (struct csi_state *state) +static void mipi_csis_debugfs_init (struct csi_state *state) { -struct dentry *d; - -if (!debugfs_initialized ()) -return -ENODEV ; - state->debugfs_root =debugfs_create_dir (dev_name (state->dev),NULL ); -if (!state->debugfs_root) -return -ENOMEM ; - - d =debugfs_create_bool ("debug_enable" ,0600 , state->debugfs_root, - &state->debug); -if (!d) - goto remove_debugfs; - - d =debugfs_create_file ("dump_regs" ,0600 , state->debugfs_root, - state, &mipi_csis_dump_regs_fops); -if (!d) - goto remove_debugfs; - -return 0 ; - -remove_debugfs: -debugfs_remove_recursive (state->debugfs_root); -return -ENOMEM ; +debugfs_create_bool ("debug_enable" ,0600 , state->debugfs_root, + &state->debug); +debugfs_create_file ("dump_regs" ,0600 , state->debugfs_root, state, + &mipi_csis_dump_regs_fops); }static void mipi_csis_debugfs_exit (struct csi_state *state)Signature · 1 line
2.26.2