On Fri, Nov 12, 2021 at 12:54:00AM -0800, Aayush Agarwal wrote: > When two cavium cards are inserted and on booting OS, > nitrox_debugfs_init() is called twice and thus tries to create > 'n5pf' directory twice inside '/'. This causes the 'File exists' error. > > This error was handled before > 'commit 97a93b2b5839 ("crypto: cavium/nitrox - no need to check return > value of debugfs_create functions")' > > This commit handles the error by redirecting the code by checking > if 'n5pf' directory exists already using 'debugfs_lookup()' function. > > Tested-by: Evan Xuan <jian.xuan@xxxxxxxxxx> > Signed-off-by: Aayush Agarwal <aayush.a.agarwal@xxxxxxxxxx> > --- > drivers/crypto/cavium/nitrox/nitrox_main.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/crypto/cavium/nitrox/nitrox_main.c b/drivers/crypto/cavium/nitrox/nitrox_main.c > index 6c61817996a3..1eee05e30f05 100644 > --- a/drivers/crypto/cavium/nitrox/nitrox_main.c > +++ b/drivers/crypto/cavium/nitrox/nitrox_main.c > @@ -7,6 +7,7 @@ > #include <linux/mutex.h> > #include <linux/pci.h> > #include <linux/pci_ids.h> > +#include <linux/debugfs.h> > > #include "nitrox_dev.h" > #include "nitrox_common.h" > @@ -479,6 +480,13 @@ static int nitrox_probe(struct pci_dev *pdev, > if (err) > goto pf_hw_fail; > > + struct dentry *check_dir = debugfs_lookup(KBUILD_MODNAME, NULL); > + > + if (check_dir != NULL) { > + dput(check_dir); > + goto pf_hw_fail; Why is this a "failure"? > + } > + > nitrox_debugfs_init(ndev); Why not just put the "check" logic in this function instead? You want to have per-device directories in debugfs for this device, right? If so, then this function should handle that, not the nitrox_probe() call. thanks, greg k-h