Skip to contentSkip to conversation

spi-dw-core.c: Fix error checking for debugfs_create_dir

PATCH In review Osama Muhammad 2 participants 2 messages May 17, 2023 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi-dw-core.c: Fix error checking for debugfs_create_dir

This patch fixes the error checking in spi-dw-core.c in debugfs_create_dir. The correct way to check if an error occurred is 'IS_ERR' inline function.

---
 drivers/spi/spi-dw-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-dw-core.c +1 -1
index ae3108c70f50..c9cdf6bbcd0e 100644
@@ -63,7 +63,7 @@ static int dw_spi_debugfs_init(struct dw_spi *dws)
 
 	snprintf(name, 32, "dw_spi%d", dws->master->bus_num);
 	dws->debugfs = debugfs_create_dir(name, NULL);
-	if (!dws->debugfs)
+	if (IS_ERR(dws->debugfs))
 		return -ENOMEM;
 
 	dws->regset.regs = dw_spi_dbgfs_regs;
Signature · 1 line
2.34.1
#1 lore raw

Hi Osama

Quoted 3 lines · Osama Muhammad

This patch fixes the error checking in spi-dw-core.c in debugfs_create_dir. The correct way to check if an error occurred is 'IS_ERR' inline function.

AFAICS a correct way to fix this would be to drop the errors check from the implementation and convert the dw_spi_debugfs_init() function to returning void. DebugFS kernel API is designed in a way for the kernel to safely ignore the errors happening during the DebugFS nodes creation. See

for details.

-Serge(y)

Quoted 22 lines
---
 drivers/spi/spi-dw-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-dw-core.c +1 -1
index ae3108c70f50..c9cdf6bbcd0e 100644
@@ -63,7 +63,7 @@ static int dw_spi_debugfs_init(struct dw_spi *dws)
 
 	snprintf(name, 32, "dw_spi%d", dws->master->bus_num);
 	dws->debugfs = debugfs_create_dir(name, NULL);
-	if (!dws->debugfs)
+	if (IS_ERR(dws->debugfs))
 		return -ENOMEM;
 
 	dws->regset.regs = dw_spi_dbgfs_regs;
Signature · 1 line
2.34.1