[U-Boot] [PATCH 13/25] dm: pci: Drop the old version of pci_find_class()
Bin Meng
bmeng.cn at gmail.com
Wed Nov 18 05:48:05 CET 2015
On Tue, Nov 17, 2015 at 11:53 AM, Simon Glass <sjg at chromium.org> wrote:
> Move this function into the compatibility file so that it is not available
> by default.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> drivers/pci/pci_common.c | 42 ------------------------------------------
> drivers/pci/pci_compat.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 42 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/pci/pci_common.c b/drivers/pci/pci_common.c
> index a78a812..b46be1b 100644
> --- a/drivers/pci/pci_common.c
> +++ b/drivers/pci/pci_common.c
> @@ -79,48 +79,6 @@ const char *pci_class_str(u8 class)
> };
> }
>
> -pci_dev_t pci_find_class(uint find_class, int index)
> -{
> - int bus;
> - int devnum;
> - pci_dev_t bdf;
> - uint32_t class;
> -
> - for (bus = 0; bus <= pci_last_busno(); bus++) {
> - for (devnum = 0; devnum < PCI_MAX_PCI_DEVICES - 1; devnum++) {
> - pci_read_config_dword(PCI_BDF(bus, devnum, 0),
> - PCI_CLASS_REVISION, &class);
> - if (class >> 16 == 0xffff)
> - continue;
> -
> - for (bdf = PCI_BDF(bus, devnum, 0);
> - bdf <= PCI_BDF(bus, devnum,
> - PCI_MAX_PCI_FUNCTIONS - 1);
> - bdf += PCI_BDF(0, 0, 1)) {
> - pci_read_config_dword(bdf, PCI_CLASS_REVISION,
> - &class);
> - class >>= 8;
> -
> - if (class != find_class)
> - continue;
> - /*
> - * Decrement the index. We want to return the
> - * correct device, so index is 0 for the first
> - * matching device, 1 for the second, etc.
> - */
> - if (index) {
> - index--;
> - continue;
> - }
> - /* Return index'th controller. */
> - return bdf;
> - }
> - }
> - }
> -
> - return -ENODEV;
> -}
> -
> __weak int pci_skip_dev(struct pci_controller *hose, pci_dev_t dev)
> {
> /*
> diff --git a/drivers/pci/pci_compat.c b/drivers/pci/pci_compat.c
> index 688c98a..5f238ca 100644
> --- a/drivers/pci/pci_compat.c
> +++ b/drivers/pci/pci_compat.c
> @@ -87,3 +87,45 @@ pci_dev_t pci_hose_find_devices(struct pci_controller *hose, int busnum,
>
> return -1;
> }
> +
> +pci_dev_t pci_find_class(uint find_class, int index)
> +{
> + int bus;
> + int devnum;
> + pci_dev_t bdf;
> + uint32_t class;
> +
> + for (bus = 0; bus <= pci_last_busno(); bus++) {
> + for (devnum = 0; devnum < PCI_MAX_PCI_DEVICES - 1; devnum++) {
> + pci_read_config_dword(PCI_BDF(bus, devnum, 0),
> + PCI_CLASS_REVISION, &class);
> + if (class >> 16 == 0xffff)
> + continue;
> +
> + for (bdf = PCI_BDF(bus, devnum, 0);
> + bdf <= PCI_BDF(bus, devnum,
> + PCI_MAX_PCI_FUNCTIONS - 1);
> + bdf += PCI_BDF(0, 0, 1)) {
> + pci_read_config_dword(bdf, PCI_CLASS_REVISION,
> + &class);
> + class >>= 8;
> +
> + if (class != find_class)
> + continue;
> + /*
> + * Decrement the index. We want to return the
> + * correct device, so index is 0 for the first
> + * matching device, 1 for the second, etc.
> + */
> + if (index) {
> + index--;
> + continue;
> + }
> + /* Return index'th controller. */
> + return bdf;
> + }
> + }
> + }
> +
> + return -ENODEV;
> +}
> --
Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
More information about the U-Boot
mailing list