Re: [PATCH RFC 2/5] usb:cdns3: Add pci to platform driver wrapper

From: Dan Carpenter
Date: Fri Jun 26 2020 - 13:25:09 EST


On Fri, Jun 26, 2020 at 03:10:32PM +0000, Pawel Laszczak wrote:
> >> +static int cdnsp_pci_probe(struct pci_dev *pdev,
> >> + const struct pci_device_id *id)
> >> +{
> >> + struct platform_device_info plat_info;
> >> + struct cdnsp_wrap *wrap;
> >> + struct resource *res;
> >> + struct pci_dev *func;
> >> + int err;
> >> +
> >> + /*
> >> + * For GADGET/HOST PCI (devfn) function number is 0,
> >> + * for OTG PCI (devfn) function number is 1.
> >> + */
> >> + if (!id || (pdev->devfn != PCI_DEV_FN_HOST_DEVICE &&
> >> + pdev->devfn != PCI_DEV_FN_OTG))
> >> + return -EINVAL;
> >> +
> >> + func = cdnsp_get_second_fun(pdev);
> >> + if (unlikely(!func))
> >> + return -EINVAL;
> >> +
> >> + if (func->class == PCI_CLASS_SERIAL_USB_XHCI ||
> >> + pdev->class == PCI_CLASS_SERIAL_USB_XHCI)
> >> + return -EINVAL;
> >
> >
> >Do we need call pci_put_device(func) before returning?
>
> We don't need.
> Such function doesn't exist.
>

I meant pci_dev_put(). I'm pretty sure that we do need it to match the
pci_get_device() in cdnsp_get_second_fun().

regards,
dan carpenter