From ed5c7ac03109c325151ed5ced779c93540418f72 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Thu, 10 Jun 2021 13:04:07 +0530 Subject: device: Add helper function devfn_disable() devfn_disable() function is used to disable a device based on given bus, device function number. This function checks if the device is at enable state and disables the device. Change-Id: Ia4a8bfec7fc95c729a5bb156f88e9aab3bf5dd41 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/55354 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak --- src/device/device.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/device') diff --git a/src/device/device.c b/src/device/device.c index bf97997f55..8337d55300 100644 --- a/src/device/device.c +++ b/src/device/device.c @@ -21,6 +21,13 @@ extern struct device *last_dev; /** Linked list of free resources */ struct resource *free_resources = NULL; +/* Disable a PCI device based on bus, device and function. */ +void devfn_disable(const struct bus *bus, unsigned int devfn) +{ + struct device *dev = pcidev_path_behind(bus, devfn); + if (dev) + dev->enabled = 0; +} /** * Initialize all chips of statically known devices. -- cgit v1.2.3