Message ID | 20200817160734.12402-8-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,01/10] media: ipu3-cio2: Simplify cleanup code | expand |
Hi Andy, Thank you for the patch. On Mon, Aug 17, 2020 at 07:07:31PM +0300, Andy Shevchenko wrote: > pcim_iomap_table() won't fail if previous pcim_iomap_regions() hasn't. > Since we check pcim_iomap_regions() for failure the check close to > pcim_iomap_table() is bogus and not needed. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > --- > v2: new patch > drivers/media/pci/intel/ipu3/ipu3-cio2.c | 9 +-------- > 1 file changed, 1 insertion(+), 8 deletions(-) > > diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c > index 57310d7874ce..f5c27c1aa9a2 100644 > --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c > +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c > @@ -1715,7 +1715,6 @@ static int cio2_pci_probe(struct pci_dev *pci_dev, > const struct pci_device_id *id) > { > struct cio2_device *cio2; > - void __iomem *const *iomap; > int r; > > cio2 = devm_kzalloc(&pci_dev->dev, sizeof(*cio2), GFP_KERNEL); > @@ -1738,13 +1737,7 @@ static int cio2_pci_probe(struct pci_dev *pci_dev, > return -ENODEV; > } > > - iomap = pcim_iomap_table(pci_dev); > - if (!iomap) { > - dev_err(&pci_dev->dev, "failed to iomap table\n"); > - return -ENODEV; > - } > - > - cio2->base = iomap[CIO2_PCI_BAR]; > + cio2->base = pcim_iomap_table(pci_dev)[CIO2_PCI_BAR]; pcim_iomap_table() can return NULL if devres_alloc() runs out of memory. > > pci_set_drvdata(pci_dev, cio2); >
On Fri, Oct 9, 2020 at 4:22 AM Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > On Mon, Aug 17, 2020 at 07:07:31PM +0300, Andy Shevchenko wrote: > > pcim_iomap_table() won't fail if previous pcim_iomap_regions() hasn't. > > Since we check pcim_iomap_regions() for failure the check close to > > pcim_iomap_table() is bogus and not needed. > > + cio2->base = pcim_iomap_table(pci_dev)[CIO2_PCI_BAR]; > > pcim_iomap_table() can return NULL if devres_alloc() runs out of memory. True. And this is checked by pcim_iomap_regions(). So, dup check is not necessary.
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 57310d7874ce..f5c27c1aa9a2 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -1715,7 +1715,6 @@ static int cio2_pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) { struct cio2_device *cio2; - void __iomem *const *iomap; int r; cio2 = devm_kzalloc(&pci_dev->dev, sizeof(*cio2), GFP_KERNEL); @@ -1738,13 +1737,7 @@ static int cio2_pci_probe(struct pci_dev *pci_dev, return -ENODEV; } - iomap = pcim_iomap_table(pci_dev); - if (!iomap) { - dev_err(&pci_dev->dev, "failed to iomap table\n"); - return -ENODEV; - } - - cio2->base = iomap[CIO2_PCI_BAR]; + cio2->base = pcim_iomap_table(pci_dev)[CIO2_PCI_BAR]; pci_set_drvdata(pci_dev, cio2);
pcim_iomap_table() won't fail if previous pcim_iomap_regions() hasn't. Since we check pcim_iomap_regions() for failure the check close to pcim_iomap_table() is bogus and not needed. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- v2: new patch drivers/media/pci/intel/ipu3/ipu3-cio2.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)