[v2,3/5] pwm: dwc: simplify error handling

Message ID 20240208070529.28562-4-raag.jadav@intel.com
State New
Headers
Series DesignWare PWM improvements |

Commit Message

Raag Jadav Feb. 8, 2024, 7:05 a.m. UTC
  Simplify error handling in ->probe() function using dev_err_probe() helper.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/pwm/pwm-dwc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
  

Comments

Andy Shevchenko Feb. 8, 2024, 5:22 p.m. UTC | #1
On Thu, Feb 08, 2024 at 12:35:27PM +0530, Raag Jadav wrote:
> Simplify error handling in ->probe() function using dev_err_probe() helper.

..

> +		return dev_err_probe(dev, ret, "Failed to enable device (%pe)\n", ERR_PTR(ret));

Have you checked the output?
Note, it will duplicate error codes which we don't want.

..

> +		return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret));

Ditto.
  
Raag Jadav Feb. 9, 2024, 8:33 p.m. UTC | #2
On Thu, Feb 08, 2024 at 07:22:13PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 08, 2024 at 12:35:27PM +0530, Raag Jadav wrote:
> > Simplify error handling in ->probe() function using dev_err_probe() helper.
> 
> ...
> 
> > +		return dev_err_probe(dev, ret, "Failed to enable device (%pe)\n", ERR_PTR(ret));
> 
> Have you checked the output?
> Note, it will duplicate error codes which we don't want.

True. Does it make sense to remove it?

Raag
  
Andy Shevchenko Feb. 12, 2024, 11:52 a.m. UTC | #3
On Fri, Feb 09, 2024 at 10:33:01PM +0200, Raag Jadav wrote:
> On Thu, Feb 08, 2024 at 07:22:13PM +0200, Andy Shevchenko wrote:
> > On Thu, Feb 08, 2024 at 12:35:27PM +0530, Raag Jadav wrote:

..

> > > +		return dev_err_probe(dev, ret, "Failed to enable device (%pe)\n", ERR_PTR(ret));
> > 
> > Have you checked the output?
> > Note, it will duplicate error codes which we don't want.
> 
> True. Does it make sense to remove it?

"...which we don't want." had been stated above :-)
  

Patch

diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
index 47d76f5367fe..e1e3c62ecc56 100644
--- a/drivers/pwm/pwm-dwc.c
+++ b/drivers/pwm/pwm-dwc.c
@@ -51,18 +51,14 @@  static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
 	int i, ret;
 
 	ret = pcim_enable_device(pci);
-	if (ret) {
-		dev_err(dev, "Failed to enable device (%pe)\n", ERR_PTR(ret));
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to enable device (%pe)\n", ERR_PTR(ret));
 
 	pci_set_master(pci);
 
 	ret = pcim_iomap_regions(pci, BIT(0), pci_name(pci));
-	if (ret) {
-		dev_err(dev, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret));
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to iomap PCI BAR (%pe)\n", ERR_PTR(ret));
 
 	info = (const struct dwc_pwm_info *)id->driver_data;