linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: tegra: no need to check return value of debugfs_create functions
@ 2020-08-18 13:37 Greg Kroah-Hartman
  2020-08-18 14:09 ` Thierry Reding
  2020-09-07  9:50 ` Lorenzo Pieralisi
  0 siblings, 2 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2020-08-18 13:37 UTC (permalink / raw)
  To: linux-pci, linux-tegra
  Cc: Greg Kroah-Hartman, Lorenzo Pieralisi, Rob Herring,
	Bjorn Helgaas, Thierry Reding, Jonathan Hunter, Vidya Sagar,
	Andrew Murray, linux-kernel

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: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Cc: Vidya Sagar <vidyas@nvidia.com>
Cc: Andrew Murray <amurray@thegoodpenguin.co.uk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pci@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/pci/controller/dwc/pcie-tegra194.c | 20 +++++------------
 drivers/pci/controller/pci-tegra.c         | 25 +++++-----------------
 2 files changed, 10 insertions(+), 35 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
index 70498689d0c0..87f8dd63df0a 100644
--- a/drivers/pci/controller/dwc/pcie-tegra194.c
+++ b/drivers/pci/controller/dwc/pcie-tegra194.c
@@ -699,23 +699,16 @@ static void init_host_aspm(struct tegra_pcie_dw *pcie)
 	dw_pcie_writel_dbi(pci, PORT_LOGIC_ACK_F_ASPM_CTRL, val);
 }
 
-static int init_debugfs(struct tegra_pcie_dw *pcie)
+static void init_debugfs(struct tegra_pcie_dw *pcie)
 {
-	struct dentry *d;
-
-	d = debugfs_create_devm_seqfile(pcie->dev, "aspm_state_cnt",
-					pcie->debugfs, aspm_state_cnt);
-	if (IS_ERR_OR_NULL(d))
-		dev_err(pcie->dev,
-			"Failed to create debugfs file \"aspm_state_cnt\"\n");
-
-	return 0;
+	debugfs_create_devm_seqfile(pcie->dev, "aspm_state_cnt", pcie->debugfs,
+				    aspm_state_cnt);
 }
 #else
 static inline void disable_aspm_l12(struct tegra_pcie_dw *pcie) { return; }
 static inline void disable_aspm_l11(struct tegra_pcie_dw *pcie) { return; }
 static inline void init_host_aspm(struct tegra_pcie_dw *pcie) { return; }
-static inline int init_debugfs(struct tegra_pcie_dw *pcie) { return 0; }
+static inline void init_debugfs(struct tegra_pcie_dw *pcie) { return; }
 #endif
 
 static void tegra_pcie_enable_system_interrupts(struct pcie_port *pp)
@@ -1641,10 +1634,7 @@ static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)
 	}
 
 	pcie->debugfs = debugfs_create_dir(name, NULL);
-	if (!pcie->debugfs)
-		dev_err(dev, "Failed to create debugfs\n");
-	else
-		init_debugfs(pcie);
+	init_debugfs(pcie);
 
 	return ret;
 
diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
index c1d34353c29b..e1a6f9db36f7 100644
--- a/drivers/pci/controller/pci-tegra.c
+++ b/drivers/pci/controller/pci-tegra.c
@@ -2601,24 +2601,12 @@ static void tegra_pcie_debugfs_exit(struct tegra_pcie *pcie)
 	pcie->debugfs = NULL;
 }
 
-static int tegra_pcie_debugfs_init(struct tegra_pcie *pcie)
+static void tegra_pcie_debugfs_init(struct tegra_pcie *pcie)
 {
-	struct dentry *file;
-
 	pcie->debugfs = debugfs_create_dir("pcie", NULL);
-	if (!pcie->debugfs)
-		return -ENOMEM;
-
-	file = debugfs_create_file("ports", S_IFREG | S_IRUGO, pcie->debugfs,
-				   pcie, &tegra_pcie_ports_ops);
-	if (!file)
-		goto remove;
-
-	return 0;
 
-remove:
-	tegra_pcie_debugfs_exit(pcie);
-	return -ENOMEM;
+	debugfs_create_file("ports", S_IFREG | S_IRUGO, pcie->debugfs, pcie,
+			    &tegra_pcie_ports_ops);
 }
 
 static int tegra_pcie_probe(struct platform_device *pdev)
@@ -2672,11 +2660,8 @@ static int tegra_pcie_probe(struct platform_device *pdev)
 		goto pm_runtime_put;
 	}
 
-	if (IS_ENABLED(CONFIG_DEBUG_FS)) {
-		err = tegra_pcie_debugfs_init(pcie);
-		if (err < 0)
-			dev_err(dev, "failed to setup debugfs: %d\n", err);
-	}
+	if (IS_ENABLED(CONFIG_DEBUG_FS))
+		tegra_pcie_debugfs_init(pcie);
 
 	return 0;
 
-- 
2.28.0


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

* Re: [PATCH] PCI: tegra: no need to check return value of debugfs_create functions
  2020-08-18 13:37 [PATCH] PCI: tegra: no need to check return value of debugfs_create functions Greg Kroah-Hartman
@ 2020-08-18 14:09 ` Thierry Reding
  2020-09-07  9:50 ` Lorenzo Pieralisi
  1 sibling, 0 replies; 3+ messages in thread
From: Thierry Reding @ 2020-08-18 14:09 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-pci, linux-tegra, Lorenzo Pieralisi, Rob Herring,
	Bjorn Helgaas, Jonathan Hunter, Vidya Sagar, Andrew Murray,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1085 bytes --]

On Tue, Aug 18, 2020 at 03:37:39PM +0200, Greg Kroah-Hartman wrote:
> 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: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Jonathan Hunter <jonathanh@nvidia.com>
> Cc: Vidya Sagar <vidyas@nvidia.com>
> Cc: Andrew Murray <amurray@thegoodpenguin.co.uk>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-pci@vger.kernel.org
> Cc: linux-tegra@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/pci/controller/dwc/pcie-tegra194.c | 20 +++++------------
>  drivers/pci/controller/pci-tegra.c         | 25 +++++-----------------
>  2 files changed, 10 insertions(+), 35 deletions(-)

Looks good to me:

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] PCI: tegra: no need to check return value of debugfs_create functions
  2020-08-18 13:37 [PATCH] PCI: tegra: no need to check return value of debugfs_create functions Greg Kroah-Hartman
  2020-08-18 14:09 ` Thierry Reding
@ 2020-09-07  9:50 ` Lorenzo Pieralisi
  1 sibling, 0 replies; 3+ messages in thread
From: Lorenzo Pieralisi @ 2020-09-07  9:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-pci, linux-tegra, Rob Herring, Bjorn Helgaas,
	Thierry Reding, Jonathan Hunter, Vidya Sagar, Andrew Murray,
	linux-kernel

On Tue, Aug 18, 2020 at 03:37:39PM +0200, Greg Kroah-Hartman wrote:
> 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: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Jonathan Hunter <jonathanh@nvidia.com>
> Cc: Vidya Sagar <vidyas@nvidia.com>
> Cc: Andrew Murray <amurray@thegoodpenguin.co.uk>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-pci@vger.kernel.org
> Cc: linux-tegra@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  drivers/pci/controller/dwc/pcie-tegra194.c | 20 +++++------------
>  drivers/pci/controller/pci-tegra.c         | 25 +++++-----------------
>  2 files changed, 10 insertions(+), 35 deletions(-)

Applied to pci/tegra, thanks.

Lorenzo

> diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
> index 70498689d0c0..87f8dd63df0a 100644
> --- a/drivers/pci/controller/dwc/pcie-tegra194.c
> +++ b/drivers/pci/controller/dwc/pcie-tegra194.c
> @@ -699,23 +699,16 @@ static void init_host_aspm(struct tegra_pcie_dw *pcie)
>  	dw_pcie_writel_dbi(pci, PORT_LOGIC_ACK_F_ASPM_CTRL, val);
>  }
>  
> -static int init_debugfs(struct tegra_pcie_dw *pcie)
> +static void init_debugfs(struct tegra_pcie_dw *pcie)
>  {
> -	struct dentry *d;
> -
> -	d = debugfs_create_devm_seqfile(pcie->dev, "aspm_state_cnt",
> -					pcie->debugfs, aspm_state_cnt);
> -	if (IS_ERR_OR_NULL(d))
> -		dev_err(pcie->dev,
> -			"Failed to create debugfs file \"aspm_state_cnt\"\n");
> -
> -	return 0;
> +	debugfs_create_devm_seqfile(pcie->dev, "aspm_state_cnt", pcie->debugfs,
> +				    aspm_state_cnt);
>  }
>  #else
>  static inline void disable_aspm_l12(struct tegra_pcie_dw *pcie) { return; }
>  static inline void disable_aspm_l11(struct tegra_pcie_dw *pcie) { return; }
>  static inline void init_host_aspm(struct tegra_pcie_dw *pcie) { return; }
> -static inline int init_debugfs(struct tegra_pcie_dw *pcie) { return 0; }
> +static inline void init_debugfs(struct tegra_pcie_dw *pcie) { return; }
>  #endif
>  
>  static void tegra_pcie_enable_system_interrupts(struct pcie_port *pp)
> @@ -1641,10 +1634,7 @@ static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)
>  	}
>  
>  	pcie->debugfs = debugfs_create_dir(name, NULL);
> -	if (!pcie->debugfs)
> -		dev_err(dev, "Failed to create debugfs\n");
> -	else
> -		init_debugfs(pcie);
> +	init_debugfs(pcie);
>  
>  	return ret;
>  
> diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c
> index c1d34353c29b..e1a6f9db36f7 100644
> --- a/drivers/pci/controller/pci-tegra.c
> +++ b/drivers/pci/controller/pci-tegra.c
> @@ -2601,24 +2601,12 @@ static void tegra_pcie_debugfs_exit(struct tegra_pcie *pcie)
>  	pcie->debugfs = NULL;
>  }
>  
> -static int tegra_pcie_debugfs_init(struct tegra_pcie *pcie)
> +static void tegra_pcie_debugfs_init(struct tegra_pcie *pcie)
>  {
> -	struct dentry *file;
> -
>  	pcie->debugfs = debugfs_create_dir("pcie", NULL);
> -	if (!pcie->debugfs)
> -		return -ENOMEM;
> -
> -	file = debugfs_create_file("ports", S_IFREG | S_IRUGO, pcie->debugfs,
> -				   pcie, &tegra_pcie_ports_ops);
> -	if (!file)
> -		goto remove;
> -
> -	return 0;
>  
> -remove:
> -	tegra_pcie_debugfs_exit(pcie);
> -	return -ENOMEM;
> +	debugfs_create_file("ports", S_IFREG | S_IRUGO, pcie->debugfs, pcie,
> +			    &tegra_pcie_ports_ops);
>  }
>  
>  static int tegra_pcie_probe(struct platform_device *pdev)
> @@ -2672,11 +2660,8 @@ static int tegra_pcie_probe(struct platform_device *pdev)
>  		goto pm_runtime_put;
>  	}
>  
> -	if (IS_ENABLED(CONFIG_DEBUG_FS)) {
> -		err = tegra_pcie_debugfs_init(pcie);
> -		if (err < 0)
> -			dev_err(dev, "failed to setup debugfs: %d\n", err);
> -	}
> +	if (IS_ENABLED(CONFIG_DEBUG_FS))
> +		tegra_pcie_debugfs_init(pcie);
>  
>  	return 0;
>  
> -- 
> 2.28.0
> 

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

end of thread, other threads:[~2020-09-07  9:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 13:37 [PATCH] PCI: tegra: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2020-08-18 14:09 ` Thierry Reding
2020-09-07  9:50 ` Lorenzo Pieralisi

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).