]> git.ipfire.org Git - thirdparty/u-boot.git/blame - drivers/core/util.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[thirdparty/u-boot.git] / drivers / core / util.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
6494d708
SG
2/*
3 * Copyright (c) 2013 Google, Inc
6494d708
SG
4 */
5
d678a59d 6#include <common.h>
6dd4b014 7#include <dm/device.h>
e601ab1b 8#include <dm/ofnode.h>
6dd4b014 9#include <dm/read.h>
766c28a5 10#include <dm/util.h>
b08c8c48 11#include <linux/libfdt.h>
6494d708
SG
12#include <vsprintf.h>
13
6494d708
SG
14int list_count_items(struct list_head *head)
15{
16 struct list_head *node;
17 int count = 0;
18
19 list_for_each(node, head)
20 count++;
21
22 return count;
23}
27326c7e 24
95397385 25#if CONFIG_IS_ENABLED(OF_REAL)
6dd4b014
SG
26int pci_get_devfn(struct udevice *dev)
27{
28 struct fdt_pci_addr addr;
29 int ret;
30
31 /* Extract the devfn from fdt_pci_addr */
32 ret = ofnode_read_pci_addr(dev_ofnode(dev), FDT_PCI_SPACE_CONFIG,
f69d3d6d 33 "reg", &addr, NULL);
6dd4b014
SG
34 if (ret) {
35 if (ret != -ENOENT)
36 return -EINVAL;
37 }
38
39 return addr.phys_hi & 0xff00;
40}
41#endif