git: 525dd4acaacc - main - LinuxKPI: implement pci_rescan_bus()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 21 May 2023 00:31:57 UTC
The branch main has been updated by bz:
URL: https://cgit.FreeBSD.org/src/commit/?id=525dd4acaacc59b815131caccfdebc905d4d7bff
commit 525dd4acaacc59b815131caccfdebc905d4d7bff
Author: Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2023-05-16 20:59:30 +0000
Commit: Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2023-05-21 00:31:25 +0000
LinuxKPI: implement pci_rescan_bus()
Try to implement pci_rescan_bus(). pci_rescan_method() is already
doing most of the job. We only have to do the count for the return
value again ourselves.
Sponsored by: The FreeBSD Foundation
MFC after: 10 days
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D40122
---
sys/compat/linuxkpi/common/include/linux/pci.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index 9b2e9269d4d4..cc8dbe2fef11 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -260,6 +260,7 @@ struct pci_driver {
struct pci_bus {
struct pci_dev *self;
+ /* struct pci_bus *parent */
int domain;
int number;
};
@@ -1411,6 +1412,29 @@ pci_stop_and_remove_bus_device(struct pci_dev *pdev)
{
}
+static inline int
+pci_rescan_bus(struct pci_bus *pbus)
+{
+ device_t *devlist, parent;
+ int devcount, error;
+
+ if (!device_is_attached(pbus->self->dev.bsddev))
+ return (0);
+ /* pci_rescan_method() will work on the pcib (parent). */
+ error = BUS_RESCAN(pbus->self->dev.bsddev);
+ if (error != 0)
+ return (0);
+
+ parent = device_get_parent(pbus->self->dev.bsddev);
+ error = device_get_children(parent, &devlist, &devcount);
+ if (error != 0)
+ return (0);
+ if (devcount != 0)
+ free(devlist, M_TEMP);
+
+ return (devcount);
+}
+
/*
* The following functions can be used to attach/detach the LinuxKPI's
* PCI device runtime. The pci_driver and pci_device_id pointer is