linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi-dw-core.c: Fix error checking for debugfs_create_dir
@ 2023-05-17 17:31 Osama Muhammad
  2023-05-17 21:21 ` Serge Semin
  0 siblings, 1 reply; 2+ messages in thread
From: Osama Muhammad @ 2023-05-17 17:31 UTC (permalink / raw)
  To: broonie, fancer.lancer; +Cc: linux-spi, linux-kernel, 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.

Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
---
 drivers/spi/spi-dw-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
index ae3108c70f50..c9cdf6bbcd0e 100644
--- a/drivers/spi/spi-dw-core.c
+++ b/drivers/spi/spi-dw-core.c
@@ -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;
-- 
2.34.1


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

* Re: [PATCH] spi-dw-core.c: Fix error checking for debugfs_create_dir
  2023-05-17 17:31 [PATCH] spi-dw-core.c: Fix error checking for debugfs_create_dir Osama Muhammad
@ 2023-05-17 21:21 ` Serge Semin
  0 siblings, 0 replies; 2+ messages in thread
From: Serge Semin @ 2023-05-17 21:21 UTC (permalink / raw)
  To: Osama Muhammad; +Cc: broonie, linux-spi, linux-kernel

Hi Osama

On Wed, May 17, 2023 at 10:31:02PM +0500, Osama Muhammad wrote:
> 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
Link: https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L574
for details.

-Serge(y)

> 
> Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
> ---
>  drivers/spi/spi-dw-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
> index ae3108c70f50..c9cdf6bbcd0e 100644
> --- a/drivers/spi/spi-dw-core.c
> +++ b/drivers/spi/spi-dw-core.c
> @@ -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;
> -- 
> 2.34.1
> 

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

end of thread, other threads:[~2023-05-17 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 17:31 [PATCH] spi-dw-core.c: Fix error checking for debugfs_create_dir Osama Muhammad
2023-05-17 21:21 ` Serge Semin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).