[PATCH v1 2/3] pwm: dwc: simplify error handling

Raag Jadav
2024-01-22T03:02:54Z

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 | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
index fd64313cb38d..8f8035b047c1 100644
--- a/drivers/pwm/pwm-dwc.c
+++ b/drivers/pwm/pwm-dwc.c
@@ -68,24 +68,18 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
int 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));

base = pcim_iomap_table(pci)[0];
- if (!base) {
- dev_err(dev, "Base address missing\n");
- return -ENOMEM;
- }
+ if (!base)
+ return dev_err_probe(dev, -ENOMEM, "Base address missing\n");

info = (const struct dwc_pwm_info *)id->driver_data;
ret = dwc_pwm_init(dev, info, base);
--
2.35.3