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

From: Andy Shevchenko
Date: Sun Jan 28 2024 - 09:48:30 EST


On Mon, Jan 22, 2024 at 08:32:37AM +0530, Raag Jadav wrote:
> Simplify error handling in ->probe() function using dev_err_probe() helper.

..

> 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");

This check is bogus. Just remove it completely.

The pcim_iomap_table() fails IFF pcim_iomap_regions() fails.
You have checked the latter already.

--
With Best Regards,
Andy Shevchenko