dm: pci: Add an inline API to test if a device is on a PCI bus
Introduce device_is_on_pci_bus() which can be utilized by driver to test if a device is on a PCI bus. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
fa43ce842c
commit
1e0f226362
@ -238,7 +238,7 @@ int dm_pci_write_config(struct udevice *dev, int offset, unsigned long value,
|
|||||||
{
|
{
|
||||||
struct udevice *bus;
|
struct udevice *bus;
|
||||||
|
|
||||||
for (bus = dev; device_get_uclass_id(bus->parent) == UCLASS_PCI;)
|
for (bus = dev; device_is_on_pci_bus(bus);)
|
||||||
bus = bus->parent;
|
bus = bus->parent;
|
||||||
return pci_bus_write_config(bus, pci_get_bdf(dev), offset, value, size);
|
return pci_bus_write_config(bus, pci_get_bdf(dev), offset, value, size);
|
||||||
}
|
}
|
||||||
@ -303,7 +303,7 @@ int dm_pci_read_config(struct udevice *dev, int offset, unsigned long *valuep,
|
|||||||
{
|
{
|
||||||
struct udevice *bus;
|
struct udevice *bus;
|
||||||
|
|
||||||
for (bus = dev; device_get_uclass_id(bus->parent) == UCLASS_PCI;)
|
for (bus = dev; device_is_on_pci_bus(bus);)
|
||||||
bus = bus->parent;
|
bus = bus->parent;
|
||||||
return pci_bus_read_config(bus, pci_get_bdf(dev), offset, valuep,
|
return pci_bus_read_config(bus, pci_get_bdf(dev), offset, valuep,
|
||||||
size);
|
size);
|
||||||
|
@ -485,6 +485,17 @@ bool device_is_last_sibling(struct udevice *dev);
|
|||||||
*/
|
*/
|
||||||
int device_set_name(struct udevice *dev, const char *name);
|
int device_set_name(struct udevice *dev, const char *name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* device_is_on_pci_bus - Test if a device is on a PCI bus
|
||||||
|
*
|
||||||
|
* @dev: device to test
|
||||||
|
* @return: true if it is on a PCI bus, false otherwise
|
||||||
|
*/
|
||||||
|
static inline bool device_is_on_pci_bus(struct udevice *dev)
|
||||||
|
{
|
||||||
|
return device_get_uclass_id(dev->parent) == UCLASS_PCI;
|
||||||
|
}
|
||||||
|
|
||||||
/* device resource management */
|
/* device resource management */
|
||||||
typedef void (*dr_release_t)(struct udevice *dev, void *res);
|
typedef void (*dr_release_t)(struct udevice *dev, void *res);
|
||||||
typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);
|
typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);
|
||||||
|
Loading…
Reference in New Issue
Block a user