crypto: cleanup debugfs usage
Subsystems (5)
cover crypto: cleanup debugfs usage
When calling debugfs code, there is no need to ever check the return value of the call, as no logic should ever change if a call works properly or not. Fix up a bunch of crypto-specific code to not care about the results of debugfs.
Greg Kroah-Hartman (7):
crypto: qat: no need to check return value of debugfs_create functions
crypto: ccrree: no need to check return value of debugfs_create
functions
crypto: axis: no need to check return value of debugfs_create
functions
crypto: cavium: zip: no need to check return value of debugfs_create
functions
crypto: cavium: nitrox: no need to check return value of
debugfs_create functions
crypto: ccp: no need to check return value of debugfs_create functions
crypto: caam: no need to check return value of debugfs_create
functions
drivers/crypto/axis/artpec6_crypto.c | 9 ---- drivers/crypto/caam/ctrl.c | 21 +++----- drivers/crypto/caam/intern.h | 1 - drivers/crypto/cavium/nitrox/nitrox_debugfs.c | 27 ++-------- drivers/crypto/cavium/nitrox/nitrox_debugfs.h | 5 +- drivers/crypto/cavium/nitrox/nitrox_main.c | 4 +- drivers/crypto/cavium/zip/zip_main.c | 52 ++++--------------- drivers/crypto/ccp/ccp-debugfs.c | 36 +++---------- drivers/crypto/ccree/cc_debugfs.c | 22 ++------ drivers/crypto/ccree/cc_debugfs.h | 8 +-- drivers/crypto/ccree/cc_driver.c | 7 +-- drivers/crypto/qat/qat_c3xxx/adf_drv.c | 5 -- drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 5 -- drivers/crypto/qat/qat_c62x/adf_drv.c | 5 -- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 5 -- drivers/crypto/qat/qat_common/adf_cfg.c | 7 --- drivers/crypto/qat/qat_common/adf_transport.c | 6 --- .../qat/qat_common/adf_transport_debug.c | 15 ------ drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 5 -- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 5 -- 20 files changed, 38 insertions(+), 212 deletions(-)
Signature · 1 line
2.20.1
PATCH 1/7 crypto: qat: 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.
--- drivers/crypto/qat/qat_c3xxx/adf_drv.c | 5 ----- drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 5 ----- drivers/crypto/qat/qat_c62x/adf_drv.c | 5 ----- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 5 ----- drivers/crypto/qat/qat_common/adf_cfg.c | 7 ------- drivers/crypto/qat/qat_common/adf_transport.c | 6 ------ .../crypto/qat/qat_common/adf_transport_debug.c | 15 --------------- drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 5 ----- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 5 ----- 9 files changed, 58 deletions(-)
drivers/crypto/qat/qat_c3xxx/adf_drv.c +0 -5
@@ -193,11 +193,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) PCI_FUNC(pdev->devfn)); accel_dev->debugfs_dir =debugfs_create_dir (name,NULL ); -if (!accel_dev->debugfs_dir) { -dev_err (&pdev->dev,"Could not create debugfs dir %s\n" , name); - ret = -EINVAL ; - goto out_err; - }/* Create device configuration table */ ret =adf_cfg_dev_add (accel_dev);
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +0 -5
@@ -177,11 +177,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) PCI_FUNC(pdev->devfn)); accel_dev->debugfs_dir =debugfs_create_dir (name,NULL ); -if (!accel_dev->debugfs_dir) { -dev_err (&pdev->dev,"Could not create debugfs dir %s\n" , name); - ret = -EINVAL ; - goto out_err; - }/* Create device configuration table */ ret =adf_cfg_dev_add (accel_dev);
drivers/crypto/qat/qat_c62x/adf_drv.c +0 -5
@@ -193,11 +193,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) PCI_FUNC(pdev->devfn)); accel_dev->debugfs_dir =debugfs_create_dir (name,NULL ); -if (!accel_dev->debugfs_dir) { -dev_err (&pdev->dev,"Could not create debugfs dir %s\n" , name); - ret = -EINVAL ; - goto out_err; - }/* Create device configuration table */ ret =adf_cfg_dev_add (accel_dev);
drivers/crypto/qat/qat_c62xvf/adf_drv.c +0 -5
@@ -177,11 +177,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) PCI_FUNC(pdev->devfn)); accel_dev->debugfs_dir =debugfs_create_dir (name,NULL ); -if (!accel_dev->debugfs_dir) { -dev_err (&pdev->dev,"Could not create debugfs dir %s\n" , name); - ret = -EINVAL ; - goto out_err; - }/* Create device configuration table */ ret =adf_cfg_dev_add (accel_dev);
drivers/crypto/qat/qat_common/adf_cfg.c +0 -7
@@ -141,13 +141,6 @@ int adf_cfg_dev_add(struct adf_accel_dev *accel_dev) accel_dev->debugfs_dir, dev_cfg_data, &qat_dev_cfg_fops); -if (!dev_cfg_data->debug) { -dev_err (&GET_DEV (accel_dev), -"Failed to create qat cfg debugfs entry.\n" ); -kfree (dev_cfg_data); - accel_dev->cfg =NULL ; -return -EFAULT ; - }return 0 ; }EXPORT_SYMBOL_GPL (adf_cfg_dev_add);
drivers/crypto/qat/qat_common/adf_transport.c +0 -6
@@ -486,12 +486,6 @@ int adf_init_etr_data(struct adf_accel_dev *accel_dev)/* accel_dev->debugfs_dir should always be non-NULL here */ etr_data->debug =debugfs_create_dir ("transport" , accel_dev->debugfs_dir); -if (!etr_data->debug) { -dev_err (&GET_DEV (accel_dev), -"Unable to create transport debugfs entry\n" ); - ret = -ENOENT ; - goto err_bank_debug; - }for (i =0 ; i < num_banks; i++) { ret = adf_init_bank(accel_dev, &etr_data->banks[i], i,
drivers/crypto/qat/qat_common/adf_transport_debug.c +0 -15
@@ -163,11 +163,6 @@ int adf_ring_debugfs_add(struct adf_etr_ring_data *ring, const char *name) ring_debug->debug =debugfs_create_file (entry_name,S_IRUSR , ring->bank->bank_debug_dir, ring, &adf_ring_debug_fops); -if (!ring_debug->debug) { -pr_err ("QAT: Failed to create ring debug entry.\n" ); -kfree (ring_debug); -return -EFAULT ; - } ring->ring_debug = ring_debug;return 0 ; }
@@ -271,19 +266,9 @@ int adf_bank_debugfs_add(struct adf_etr_bank_data *bank)snprintf (name,sizeof (name),"bank_%02d" , bank->bank_number); bank->bank_debug_dir =debugfs_create_dir (name, parent); -if (!bank->bank_debug_dir) { -pr_err ("QAT: Failed to create bank debug dir.\n" ); -return -EFAULT ; - } - bank->bank_debug_cfg =debugfs_create_file ("config" ,S_IRUSR , bank->bank_debug_dir, bank, &adf_bank_debug_fops); -if (!bank->bank_debug_cfg) { -pr_err ("QAT: Failed to create bank debug entry.\n" ); -debugfs_remove (bank->bank_debug_dir); -return -EFAULT ; - }return 0 ; }
drivers/crypto/qat/qat_dh895xcc/adf_drv.c +0 -5
@@ -193,11 +193,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) PCI_FUNC(pdev->devfn)); accel_dev->debugfs_dir =debugfs_create_dir (name,NULL ); -if (!accel_dev->debugfs_dir) { -dev_err (&pdev->dev,"Could not create debugfs dir %s\n" , name); - ret = -EINVAL ; - goto out_err; - }/* Create device configuration table */ ret =adf_cfg_dev_add (accel_dev);
drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +0 -5
@@ -177,11 +177,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) PCI_FUNC(pdev->devfn)); accel_dev->debugfs_dir =debugfs_create_dir (name,NULL ); -if (!accel_dev->debugfs_dir) { -dev_err (&pdev->dev,"Could not create debugfs dir %s\n" , name); - ret = -EINVAL ; - goto out_err; - }/* Create device configuration table */ ret =adf_cfg_dev_add (accel_dev);
Signature · 1 line
2.20.1
PATCH 2/7 crypto: ccrree: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/crypto/ccree/cc_debugfs.c | 22 +++------------------- drivers/crypto/ccree/cc_debugfs.h | 8 ++------ drivers/crypto/ccree/cc_driver.c | 7 +------ 3 files changed, 6 insertions(+), 31 deletions(-)
drivers/crypto/ccree/cc_debugfs.c +3 -19
@@ -39,11 +39,9 @@ static struct debugfs_reg32 debug_regs[] = { CC_DEBUG_REG(AXIM_MON_COMP), }; -int __init cc_debugfs_global_init (void ) +void __init cc_debugfs_global_init (void ) { cc_debugfs_dir =debugfs_create_dir ("ccree" ,NULL ); - -return !cc_debugfs_dir; } void __exit cc_debugfs_global_fini(void)
@@ -56,7 +54,6 @@ int cc_debugfs_init(struct cc_drvdata *drvdata)struct device *dev =drvdata_to_dev (drvdata);struct cc_debugfs_ctx *ctx;struct debugfs_regset32 *regset; -struct dentry *file; debug_regs[0 ].offset = drvdata->sig_offset; debug_regs[1 ].offset = drvdata->ver_offset;
@@ -74,22 +71,9 @@ int cc_debugfs_init(struct cc_drvdata *drvdata) regset->base = drvdata->cc_base; ctx->dir =debugfs_create_dir (drvdata->plat_dev->name, cc_debugfs_dir); -if (!ctx->dir) -return -ENFILE ; - - file =debugfs_create_regset32 ("regs" ,0400 , ctx->dir, regset); -if (!file) { -debugfs_remove (ctx->dir); -return -ENFILE ; - } - file =debugfs_create_bool ("coherent" ,0400 , ctx->dir, - &drvdata->coherent); - -if (!file) { -debugfs_remove_recursive (ctx->dir); -return -ENFILE ; - } +debugfs_create_regset32 ("regs" ,0400 , ctx->dir, regset); +debugfs_create_bool ("coherent" ,0400 , ctx->dir, &drvdata->coherent); drvdata->debugfs = ctx;
drivers/crypto/ccree/cc_debugfs.h +2 -6
@@ -5,7 +5,7 @@#define __CC_DEBUGFS_H__#ifdef CONFIG_DEBUG_FS -int cc_debugfs_global_init (void ); +void cc_debugfs_global_init (void );void cc_debugfs_global_fini (void );int cc_debugfs_init (struct cc_drvdata *drvdata);
@@ -13,11 +13,7 @@ void cc_debugfs_fini(struct cc_drvdata *drvdata);#else -static inline int cc_debugfs_global_init (void ) -{ -return 0 ; -} - +static inline void cc_debugfs_global_init (void ) {}static inline void cc_debugfs_global_fini (void ) {}static inline int cc_debugfs_init (struct cc_drvdata *drvdata)
drivers/crypto/ccree/cc_driver.c +1 -6
@@ -538,13 +538,8 @@ static struct platform_driver ccree_driver = {static int __init ccree_init (void ) { -int ret; -cc_hash_global_init (); - - ret =cc_debugfs_global_init (); -if (ret) -return ret; +cc_debugfs_global_init ();return platform_driver_register (&ccree_driver); }
Signature · 1 line
2.20.1
Gilad Ben-Yossef
maintainerRe: [PATCH 2/7] crypto: ccrree: no need to check return value of debugfs_create functions
Hi,
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.
I get the part about not failing loading the driver just because some debugs entry isn't available, but wont it be weird if debugfs_create_dir() fails but debugfs_create_regset32() succeeds and we suddenly have weird files in the debugfs root dir?
Not the end of the world of course but maybe it's better to avoid trying to create the files if the directory is not available?
Thanks,
Gilad
Quoted 111 lines
Cc Yael Chemla <[email protected]>Cc Gilad Ben-Yossef <[email protected]>Cc Herbert Xu <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/crypto/ccree/cc_debugfs.c | 22 +++------------------- drivers/crypto/ccree/cc_debugfs.h | 8 ++------ drivers/crypto/ccree/cc_driver.c | 7 +------ 3 files changed, 6 insertions(+), 31 deletions(-)drivers/crypto/ccree/cc_debugfs.c +3
-19@@ -39,11 +39,9 @@ static struct debugfs_reg32 debug_regs[] = { CC_DEBUG_REG(AXIM_MON_COMP), }; -int __init cc_debugfs_global_init (void ) +void __init cc_debugfs_global_init (void ) { cc_debugfs_dir =debugfs_create_dir ("ccree" ,NULL ); - -return !cc_debugfs_dir; } void __exit cc_debugfs_global_fini(void)@@ -56,7 +54,6 @@ int cc_debugfs_init(struct cc_drvdata *drvdata)struct device *dev =drvdata_to_dev (drvdata);struct cc_debugfs_ctx *ctx;struct debugfs_regset32 *regset; -struct dentry *file; debug_regs[0 ].offset = drvdata->sig_offset; debug_regs[1 ].offset = drvdata->ver_offset;@@ -74,22 +71,9 @@ int cc_debugfs_init(struct cc_drvdata *drvdata) regset->base = drvdata->cc_base; ctx->dir =debugfs_create_dir (drvdata->plat_dev->name, cc_debugfs_dir); -if (!ctx->dir) -return -ENFILE ; - - file =debugfs_create_regset32 ("regs" ,0400 , ctx->dir, regset); -if (!file) { -debugfs_remove (ctx->dir); -return -ENFILE ; - } - file =debugfs_create_bool ("coherent" ,0400 , ctx->dir, - &drvdata->coherent); - -if (!file) { -debugfs_remove_recursive (ctx->dir); -return -ENFILE ; - } +debugfs_create_regset32 ("regs" ,0400 , ctx->dir, regset); +debugfs_create_bool ("coherent" ,0400 , ctx->dir, &drvdata->coherent); drvdata->debugfs = ctx;drivers/crypto/ccree/cc_debugfs.h +2
-6@@ -5,7 +5,7 @@#define __CC_DEBUGFS_H__#ifdef CONFIG_DEBUG_FS -int cc_debugfs_global_init (void ); +void cc_debugfs_global_init (void );void cc_debugfs_global_fini (void );int cc_debugfs_init (struct cc_drvdata *drvdata);@@ -13,11 +13,7 @@ void cc_debugfs_fini(struct cc_drvdata *drvdata);#else -static inline int cc_debugfs_global_init (void ) -{ -return 0 ; -} - +static inline void cc_debugfs_global_init (void ) {}static inline void cc_debugfs_global_fini (void ) {}static inline int cc_debugfs_init (struct cc_drvdata *drvdata)drivers/crypto/ccree/cc_driver.c +1
-7@@ -538,13 +538,8 @@ static struct platform_driver ccree_driver = {static int __init ccree_init (void ) { -int ret; -cc_hash_global_init (); - - ret =cc_debugfs_global_init (); -if (ret) -return ret; +cc_debugfs_global_init ();return platform_driver_register (&ccree_driver); } --2.20.1
Signature · 4 lines
Gilad Ben-Yossef Chief Coffee Drinker values of β will give rise to dom!
Re: [PATCH 2/7] crypto: ccrree: no need to check return value of debugfs_create functions
Quoted 11 lines · Gilad Ben-Yossef
Hi,
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 6 lines
I get the part about not failing loading the driver just because some debugs entry isn't available, but wont it be weird if
debugfs_create_dir()fails butdebugfs_create_regset32()succeeds and we suddenly have weird files in the debugfs root dir?
Not the end of the world of course but maybe it's better to avoid trying to create the files if the directory is not available?
See this patch to handle that theoretical issue:
https://lore.kernel.org/lkml/[email protected]/T/#me91cc3d16185be13d64f85c8477c543cbda9baf6
thanks,
greg k-h
Re: [PATCH 2/7] crypto: ccrree: no need to check return value of debugfs_create functions
Quoted 20 lines · Greg Kroah-Hartman
Quoted 11 lines · Gilad Ben-Yossef
Hi,
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 6 lines
I get the part about not failing loading the driver just because some debugs entry isn't available, but wont it be weird if
debugfs_create_dir()fails butdebugfs_create_regset32()succeeds and we suddenly have weird files in the debugfs root dir?
Not the end of the world of course but maybe it's better to avoid trying to create the files if the directory is not available?
Quoted 4 lines
See this patch to handle that theoretical issue:
https://lore.kernel.org/lkml/[email protected]/T/#me91cc3d16185be13d64f85c8477c543cbda9baf6
Ah, sorry. I've missed that.
Thanks!
Gilad
Signature · 4 lines
Gilad Ben-Yossef Chief Coffee Drinker values of β will give rise to dom!
PATCH 3/7 crypto: axis: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/crypto/axis/artpec6_crypto.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/crypto/axis/artpec6_crypto.c +0 -9
@@ -2984,12 +2984,6 @@ static void artpec6_crypto_init_debugfs(void) { dbgfs_root =debugfs_create_dir ("artpec6_crypto" ,NULL ); -if (!dbgfs_root ||IS_ERR (dbgfs_root)) { - dbgfs_root =NULL ; -pr_err ("%s: Could not initialise debugfs!\n" ,MODULE_NAME ); -return ; - } -#ifdef CONFIG_FAULT_INJECTION fault_create_debugfs_attr ("fail_status_read" , dbgfs_root, &artpec6_crypto_fail_status_read);
@@ -3001,9 +2995,6 @@ static void artpec6_crypto_init_debugfs(void)static void artpec6_crypto_free_debugfs (void ) { -if (!dbgfs_root) -return ; -debugfs_remove_recursive (dbgfs_root); dbgfs_root =NULL ; }
Signature · 1 line
2.20.1
Re: [PATCH 3/7] crypto: axis: no need to check return value of debugfs_create functions
Quoted 11 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.
Cc Jesper Nilsson <[email protected]>Cc Lars Persson <[email protected]>Cc Herbert Xu <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 3 lines
--- drivers/crypto/axis/artpec6_crypto.c | 9 --------- 1 file changed, 9 deletions(-)
Thanks,
Lars
PATCH 4/7 crypto: cavium: zip: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/crypto/cavium/zip/zip_main.c | 52 ++++++---------------------- 1 file changed, 11 insertions(+), 41 deletions(-)
drivers/crypto/cavium/zip/zip_main.c +11 -41
@@ -618,41 +618,23 @@ static const struct file_operations zip_regs_fops = {/* Root directory for thunderx_zip debugfs entry */ static struct dentry *zip_debugfs_root; -static int __init zip_debugfs_init (void ) +static void __init zip_debugfs_init (void ) { -struct dentry *zip_stats, *zip_clear, *zip_regs; -if (!debugfs_initialized ()) -return -ENODEV ; +return ; zip_debugfs_root =debugfs_create_dir ("thunderx_zip" ,NULL ); -if (!zip_debugfs_root) -return -ENOMEM ;/* Creating files for entries inside thunderx_zip directory */ - zip_stats =debugfs_create_file ("zip_stats" ,0444 , - zip_debugfs_root, -NULL , &zip_stats_fops); -if (!zip_stats) - goto failed_to_create; - - zip_clear =debugfs_create_file ("zip_clear" ,0444 , - zip_debugfs_root, -NULL , &zip_clear_fops); -if (!zip_clear) - goto failed_to_create; - - zip_regs =debugfs_create_file ("zip_regs" ,0444 , - zip_debugfs_root, -NULL , &zip_regs_fops); -if (!zip_regs) - goto failed_to_create; +debugfs_create_file ("zip_stats" ,0444 , zip_debugfs_root,NULL , + &zip_stats_fops); -return 0 ; +debugfs_create_file ("zip_clear" ,0444 , zip_debugfs_root,NULL , + &zip_clear_fops); + +debugfs_create_file ("zip_regs" ,0444 , zip_debugfs_root,NULL , + &zip_regs_fops); -failed_to_create: -debugfs_remove_recursive (zip_debugfs_root); -return -ENOENT ; } static void __exit zip_debugfs_exit(void)
@@ -661,13 +643,8 @@ static void __exit zip_debugfs_exit(void) }#else -static int __init zip_debugfs_init (void ) -{ -return 0 ; -} - +static void __init zip_debugfs_init (void ) { } static void __exit zip_debugfs_exit(void) { } -#endif /* debugfs - end */
@@ -691,17 +668,10 @@ static int __init zip_init_module(void) }/* comp-decomp statistics are handled with debugfs interface */ - ret =zip_debugfs_init (); -if (ret <0 ) { -zip_err ("ZIP: debugfs initialization failed\n" ); - goto err_crypto_unregister; - } +zip_debugfs_init ();return ret; -err_crypto_unregister: -zip_unregister_compression_device (); - err_pci_unregister:pci_unregister_driver (&zip_driver);return ret;
Signature · 1 line
2.20.1
Re: [PATCH 4/7] crypto: cavium: zip: no need to check return value of debugfs_create functions
Quoted 10 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.
Cc Herbert Xu <[email protected]>Cc "David S. Miller" <[email protected]>Cc Robert Richter <[email protected]>Cc Jan Glauber <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 3 lines
--- drivers/crypto/cavium/zip/zip_main.c | 52 ++++++---------------------- 1 file changed, 11 insertions(+), 41 deletions(-)
thanks,
Jan
PATCH 5/7 crypto: cavium: nitrox: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/crypto/cavium/nitrox/nitrox_debugfs.c | 27 ++++--------------- drivers/crypto/cavium/nitrox/nitrox_debugfs.h | 5 ++-- drivers/crypto/cavium/nitrox/nitrox_main.c | 4 +-- 3 files changed, 8 insertions(+), 28 deletions(-)
drivers/crypto/cavium/nitrox/nitrox_debugfs.c +5 -22
@@ -55,31 +55,14 @@ void nitrox_debugfs_exit(struct nitrox_device *ndev) ndev->debugfs_dir =NULL ; } -int nitrox_debugfs_init (struct nitrox_device *ndev) +void nitrox_debugfs_init (struct nitrox_device *ndev) { -struct dentry *dir, *f; +struct dentry *dir; dir =debugfs_create_dir (KBUILD_MODNAME ,NULL ); -if (!dir) -return -ENOMEM ; ndev->debugfs_dir = dir; - f =debugfs_create_file ("firmware" ,0400 , dir, ndev, - &firmware_fops); -if (!f) - goto err; - f =debugfs_create_file ("device" ,0400 , dir, ndev, - &device_fops); -if (!f) - goto err; - f =debugfs_create_file ("stats" ,0400 , dir, ndev, - &stats_fops); -if (!f) - goto err; - -return 0 ; - -err: -nitrox_debugfs_exit (ndev); -return -ENODEV ; +debugfs_create_file ("firmware" ,0400 , dir, ndev, &firmware_fops); +debugfs_create_file ("device" ,0400 , dir, ndev, &device_fops); +debugfs_create_file ("stats" ,0400 , dir, ndev, &stats_fops); }
drivers/crypto/cavium/nitrox/nitrox_debugfs.h +2 -3
@@ -5,12 +5,11 @@#include "nitrox_dev.h" #ifdef CONFIG_DEBUG_FS -int nitrox_debugfs_init (struct nitrox_device *ndev); +void nitrox_debugfs_init (struct nitrox_device *ndev);void nitrox_debugfs_exit (struct nitrox_device *ndev);#else -static inline int nitrox_debugfs_init (struct nitrox_device *ndev) +static inline void nitrox_debugfs_init (struct nitrox_device *ndev) { -return 0 ; }static inline void nitrox_debugfs_exit (struct nitrox_device *ndev)
drivers/crypto/cavium/nitrox/nitrox_main.c +1 -3
@@ -404,9 +404,7 @@ static int nitrox_probe(struct pci_dev *pdev,if (err) goto pf_hw_fail; - err =nitrox_debugfs_init (ndev); -if (err) - goto pf_hw_fail; +nitrox_debugfs_init (ndev);/* clear the statistics */ atomic64_set (&ndev->stats.posted,0 );
Signature · 1 line
2.20.1
PATCH 6/7 crypto: ccp: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/crypto/ccp/ccp-debugfs.c | 36 +++++++------------------------- 1 file changed, 7 insertions(+), 29 deletions(-)
drivers/crypto/ccp/ccp-debugfs.c +7 -29
@@ -286,10 +286,7 @@ void ccp5_debugfs_setup(struct ccp_device *ccp) {struct ccp_cmd_queue *cmd_q;char name[MAX_NAME_LEN +1 ]; -struct dentry *debugfs_info; -struct dentry *debugfs_stats;struct dentry *debugfs_q_instance; -struct dentry *debugfs_q_stats;int i;if (!debugfs_initialized ())
@@ -299,24 +296,14 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)if (!ccp_debugfs_dir) ccp_debugfs_dir =debugfs_create_dir (KBUILD_MODNAME ,NULL );mutex_unlock (&ccp_debugfs_lock); -if (!ccp_debugfs_dir) -return ; ccp->debugfs_instance =debugfs_create_dir (ccp->name, ccp_debugfs_dir); -if (!ccp->debugfs_instance) - goto err; - debugfs_info =debugfs_create_file ("info" ,0400 , - ccp->debugfs_instance, ccp, - &ccp_debugfs_info_ops); -if (!debugfs_info) - goto err; +debugfs_create_file ("info" ,0400 , ccp->debugfs_instance, ccp, + &ccp_debugfs_info_ops); - debugfs_stats =debugfs_create_file ("stats" ,0600 , - ccp->debugfs_instance, ccp, - &ccp_debugfs_stats_ops); -if (!debugfs_stats) - goto err; +debugfs_create_file ("stats" ,0600 , ccp->debugfs_instance, ccp, + &ccp_debugfs_stats_ops);for (i =0 ; i < ccp->cmd_q_count; i++) { cmd_q = &ccp->cmd_q[i];
@@ -325,21 +312,12 @@ void ccp5_debugfs_setup(struct ccp_device *ccp) debugfs_q_instance =debugfs_create_dir (name, ccp->debugfs_instance); -if (!debugfs_q_instance) - goto err; - - debugfs_q_stats = -debugfs_create_file ("stats" ,0600 , - debugfs_q_instance, cmd_q, - &ccp_debugfs_queue_ops); -if (!debugfs_q_stats) - goto err; + +debugfs_create_file ("stats" ,0600 , debugfs_q_instance, cmd_q, + &ccp_debugfs_queue_ops); }return ; - -err: -debugfs_remove_recursive (ccp->debugfs_instance); }void ccp5_debugfs_destroy (void )
Signature · 1 line
2.20.1
Re: [PATCH 6/7] crypto: ccp: no need to check return value of debugfs_create functions
Quoted 3 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.
Stupid question(s) time.
If we don't care about failures (because the subsystem handles them without our involvement) why do these functions even have return values? Why haven't they been changed to void so that they reflect the current style of intended use?
I realize I'm old fashioned, but if a failure occurs, I've always been of a mind to kick out and not try to do any further work. But debugfs is to be treated as an exception to that paradigm? Carry on, ignore errors, don't worry about it?
That said,
Quoted 81 lines
Cc Tom Lendacky <[email protected]>Cc Gary Hook <[email protected]>Cc Herbert Xu <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/crypto/ccp/ccp-debugfs.c | 36 +++++++------------------------- 1 file changed, 7 insertions(+), 29 deletions(-)drivers/crypto/ccp/ccp-debugfs.c +7
-29@@ -286,10 +286,7 @@ void ccp5_debugfs_setup(struct ccp_device *ccp) {struct ccp_cmd_queue *cmd_q;char name[MAX_NAME_LEN +1 ]; -struct dentry *debugfs_info; -struct dentry *debugfs_stats;struct dentry *debugfs_q_instance; -struct dentry *debugfs_q_stats;int i;if (!debugfs_initialized ())@@ -299,24 +296,14 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)if (!ccp_debugfs_dir) ccp_debugfs_dir =debugfs_create_dir (KBUILD_MODNAME ,NULL );mutex_unlock (&ccp_debugfs_lock); -if (!ccp_debugfs_dir) -return ; ccp->debugfs_instance =debugfs_create_dir (ccp->name, ccp_debugfs_dir); -if (!ccp->debugfs_instance) - goto err; - debugfs_info =debugfs_create_file ("info" ,0400 , - ccp->debugfs_instance, ccp, - &ccp_debugfs_info_ops); -if (!debugfs_info) - goto err; +debugfs_create_file ("info" ,0400 , ccp->debugfs_instance, ccp, + &ccp_debugfs_info_ops); - debugfs_stats =debugfs_create_file ("stats" ,0600 , - ccp->debugfs_instance, ccp, - &ccp_debugfs_stats_ops); -if (!debugfs_stats) - goto err; +debugfs_create_file ("stats" ,0600 , ccp->debugfs_instance, ccp, + &ccp_debugfs_stats_ops);for (i =0 ; i < ccp->cmd_q_count; i++) { cmd_q = &ccp->cmd_q[i];@@ -325,21 +312,12 @@ void ccp5_debugfs_setup(struct ccp_device *ccp) debugfs_q_instance =debugfs_create_dir (name, ccp->debugfs_instance); -if (!debugfs_q_instance) - goto err; - - debugfs_q_stats = -debugfs_create_file ("stats" ,0600 , - debugfs_q_instance, cmd_q, - &ccp_debugfs_queue_ops); -if (!debugfs_q_stats) - goto err; + +debugfs_create_file ("stats" ,0600 , debugfs_q_instance, cmd_q, + &ccp_debugfs_queue_ops); }return ; - -err: -debugfs_remove_recursive (ccp->debugfs_instance); }void ccp5_debugfs_destroy (void )
Re: [PATCH 6/7] crypto: ccp: no need to check return value of debugfs_create functions
Quoted 11 lines · Gary R Hook
Quoted 3 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.
Stupid question(s) time.
If we don't care about failures (because the subsystem handles them without our involvement) why do these functions even have return values? Why haven't they been changed to void so that they reflect the current style of intended use?
Because on "normal" operations, you use the return value for something (i.e. a parent directory to pass to other functions, or a value so you can remove the file later).
Quoted 4 lines
I realize I'm old fashioned, but if a failure occurs, I've always been of a mind to kick out and not try to do any further work. But debugfs is to be treated as an exception to that paradigm? Carry on, ignore errors, don't worry about it?
Yes, that is the case here, it goes against what everyone normally thinks about kernel development :)
thanks,
greg k-h
PATCH 7/7 crypto: caam: no need to check return value of debugfs_create functions
In reply to Greg Kroah-HartmanWhen 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.
--- drivers/crypto/caam/ctrl.c | 21 ++++++--------------- drivers/crypto/caam/intern.h | 1 - 2 files changed, 6 insertions(+), 16 deletions(-)
drivers/crypto/caam/ctrl.c +6 -15
@@ -863,27 +863,18 @@ static int caam_probe(struct platform_device *pdev)/* Internal covering keys (useful in non-secure mode only) */ ctrlpriv->ctl_kek_wrap.data = (__force void *)&ctrlpriv->ctrl->kek[0 ]; ctrlpriv->ctl_kek_wrap.size =KEK_KEY_SIZE *sizeof (u32); - ctrlpriv->ctl_kek =debugfs_create_blob ("kek" , -S_IRUSR | -S_IRGRP |S_IROTH , - ctrlpriv->ctl, - &ctrlpriv->ctl_kek_wrap); +debugfs_create_blob ("kek" ,S_IRUSR |S_IRGRP |S_IROTH , ctrlpriv->ctl, + &ctrlpriv->ctl_kek_wrap); ctrlpriv->ctl_tkek_wrap.data = (__force void *)&ctrlpriv->ctrl->tkek[0 ]; ctrlpriv->ctl_tkek_wrap.size =KEK_KEY_SIZE *sizeof (u32); - ctrlpriv->ctl_tkek =debugfs_create_blob ("tkek" , -S_IRUSR | -S_IRGRP |S_IROTH , - ctrlpriv->ctl, - &ctrlpriv->ctl_tkek_wrap); +debugfs_create_blob ("tkek" ,S_IRUSR |S_IRGRP |S_IROTH , ctrlpriv->ctl, + &ctrlpriv->ctl_tkek_wrap); ctrlpriv->ctl_tdsk_wrap.data = (__force void *)&ctrlpriv->ctrl->tdsk[0 ]; ctrlpriv->ctl_tdsk_wrap.size =KEK_KEY_SIZE *sizeof (u32); - ctrlpriv->ctl_tdsk =debugfs_create_blob ("tdsk" , -S_IRUSR | -S_IRGRP |S_IROTH , - ctrlpriv->ctl, - &ctrlpriv->ctl_tdsk_wrap); +debugfs_create_blob ("tdsk" ,S_IRUSR |S_IRGRP |S_IROTH , ctrlpriv->ctl, + &ctrlpriv->ctl_tdsk_wrap);#endif return 0 ;
drivers/crypto/caam/intern.h +0 -1
@@ -106,7 +106,6 @@ struct caam_drv_private {struct dentry *dfs_root;struct dentry *ctl;/* controller dir */ struct debugfs_blob_wrapper ctl_kek_wrap, ctl_tkek_wrap, ctl_tdsk_wrap; -struct dentry *ctl_kek, *ctl_tkek, *ctl_tdsk;#endif };
Signature · 1 line
2.20.1
Re: [PATCH 7/7] crypto: caam: no need to check return value of debugfs_create functions
Quoted 10 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.
Cc "Horia Geantă" <[email protected]>Cc Aymen Sghaier <[email protected]>Cc Herbert Xu <[email protected]>Cc "David S. Miller" <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Thanks,
Horia
Herbert Xu
maintainerQuoted 32 lines · Greg Kroah-Hartman
When calling debugfs code, there is no need to ever check the return value of the call, as no logic should ever change if a call works properly or not. Fix up a bunch of crypto-specific code to not care about the results of debugfs.
Greg Kroah-Hartman (7):
crypto: qat: no need to check return value ofdebugfs_createfunctions
crypto: ccrree: no need to check return value ofdebugfs_create
functions
crypto: axis: no need to check return value ofdebugfs_create
functions
crypto: cavium: zip: no need to check return value ofdebugfs_create
functions
crypto: cavium: nitrox: no need to check return value of
debugfs_createfunctions
crypto: ccp: no need to check return value ofdebugfs_createfunctions
crypto: caam: no need to check return value ofdebugfs_create
functionsdrivers/crypto/axis/artpec6_crypto.c | 9 ---- drivers/crypto/caam/ctrl.c | 21 +++----- drivers/crypto/caam/intern.h | 1 - drivers/crypto/cavium/nitrox/nitrox_debugfs.c | 27 ++-------- drivers/crypto/cavium/nitrox/nitrox_debugfs.h | 5 +- drivers/crypto/cavium/nitrox/nitrox_main.c | 4 +- drivers/crypto/cavium/zip/zip_main.c | 52 ++++--------------- drivers/crypto/ccp/ccp-debugfs.c | 36 +++---------- drivers/crypto/ccree/cc_debugfs.c | 22 ++------ drivers/crypto/ccree/cc_debugfs.h | 8 +-- drivers/crypto/ccree/cc_driver.c | 7 +-- drivers/crypto/qat/qat_c3xxx/adf_drv.c | 5 -- drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 5 --
Quoted 8 lines
drivers/crypto/qat/qat_c62x/adf_drv.c | 5 -- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 5 -- drivers/crypto/qat/qat_common/adf_cfg.c | 7 --- drivers/crypto/qat/qat_common/adf_transport.c | 6 --- .../qat/qat_common/adf_transport_debug.c | 15 ------ drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 5 -- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 5 -- 20 files changed, 38 insertions(+), 212 deletions(-)
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt