[U-Boot] [PATCH 12/25] dm: pci: Drop the old version of pci_find_device()

Bin Meng bmeng.cn at gmail.com
Wed Nov 18 05:48:00 CET 2015


On Tue, Nov 17, 2015 at 11:53 AM, Simon Glass <sjg at chromium.org> wrote:
> When driver model is being used, drop this old function.

Nits: can we reword this to something like the commit message in
patch#13, like below?

Move these functions into the compatibility file so that they are not
available by default.

>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>  drivers/pci/pci_common.c | 51 ------------------------------------------------
>  drivers/pci/pci_compat.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 51 insertions(+), 51 deletions(-)
>
> diff --git a/drivers/pci/pci_common.c b/drivers/pci/pci_common.c
> index a64792f..a78a812 100644
> --- a/drivers/pci/pci_common.c
> +++ b/drivers/pci/pci_common.c
> @@ -312,54 +312,3 @@ pci_addr_t pci_hose_phys_to_bus(struct pci_controller *hose,
>
>         return bus_addr;
>  }
> -
> -pci_dev_t pci_find_device(unsigned int vendor, unsigned int device, int index)
> -{
> -       struct pci_device_id ids[2] = { {}, {0, 0} };
> -
> -       ids[0].vendor = vendor;
> -       ids[0].device = device;
> -
> -       return pci_find_devices(ids, index);
> -}
> -
> -pci_dev_t pci_hose_find_devices(struct pci_controller *hose, int busnum,
> -                               struct pci_device_id *ids, int *indexp)
> -{
> -       int found_multi = 0;
> -       u16 vendor, device;
> -       u8 header_type;
> -       pci_dev_t bdf;
> -       int i;
> -
> -       for (bdf = PCI_BDF(busnum, 0, 0);
> -            bdf < PCI_BDF(busnum + 1, 0, 0);
> -            bdf += PCI_BDF(0, 0, 1)) {
> -               if (pci_skip_dev(hose, bdf))
> -                       continue;
> -
> -               if (!PCI_FUNC(bdf)) {
> -                       pci_read_config_byte(bdf, PCI_HEADER_TYPE,
> -                                            &header_type);
> -                       found_multi = header_type & 0x80;
> -               } else {
> -                       if (!found_multi)
> -                               continue;
> -               }
> -
> -               pci_read_config_word(bdf, PCI_VENDOR_ID, &vendor);
> -               pci_read_config_word(bdf, PCI_DEVICE_ID, &device);
> -
> -               for (i = 0; ids[i].vendor != 0; i++) {
> -                       if (vendor == ids[i].vendor &&
> -                           device == ids[i].device) {
> -                               if ((*indexp) <= 0)
> -                                       return bdf;
> -
> -                               (*indexp)--;
> -                       }
> -               }
> -       }
> -
> -       return -1;
> -}
> diff --git a/drivers/pci/pci_compat.c b/drivers/pci/pci_compat.c
> index 712c48f..688c98a 100644
> --- a/drivers/pci/pci_compat.c
> +++ b/drivers/pci/pci_compat.c
> @@ -36,3 +36,54 @@ pci_dev_t pci_find_devices(struct pci_device_id *ids, int index)
>                 return -1;
>         return pci_get_bdf(dev);
>  }
> +
> +pci_dev_t pci_find_device(unsigned int vendor, unsigned int device, int index)
> +{
> +       struct pci_device_id ids[2] = { {}, {0, 0} };
> +
> +       ids[0].vendor = vendor;
> +       ids[0].device = device;
> +
> +       return pci_find_devices(ids, index);
> +}
> +
> +pci_dev_t pci_hose_find_devices(struct pci_controller *hose, int busnum,
> +                               struct pci_device_id *ids, int *indexp)
> +{
> +       int found_multi = 0;
> +       u16 vendor, device;
> +       u8 header_type;
> +       pci_dev_t bdf;
> +       int i;
> +
> +       for (bdf = PCI_BDF(busnum, 0, 0);
> +            bdf < PCI_BDF(busnum + 1, 0, 0);
> +            bdf += PCI_BDF(0, 0, 1)) {
> +               if (pci_skip_dev(hose, bdf))
> +                       continue;
> +
> +               if (!PCI_FUNC(bdf)) {
> +                       pci_read_config_byte(bdf, PCI_HEADER_TYPE,
> +                                            &header_type);
> +                       found_multi = header_type & 0x80;
> +               } else {
> +                       if (!found_multi)
> +                               continue;
> +               }
> +
> +               pci_read_config_word(bdf, PCI_VENDOR_ID, &vendor);
> +               pci_read_config_word(bdf, PCI_DEVICE_ID, &device);
> +
> +               for (i = 0; ids[i].vendor != 0; i++) {
> +                       if (vendor == ids[i].vendor &&
> +                           device == ids[i].device) {
> +                               if ((*indexp) <= 0)
> +                                       return bdf;
> +
> +                               (*indexp)--;
> +                       }
> +               }
> +       }
> +
> +       return -1;
> +}
> --

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>


More information about the U-Boot mailing list