git: b8b100db9fcb - stable/14 - csa: Use pci_find_device to simplify clkrun_hack
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 01 Dec 2024 04:57:04 UTC
The branch stable/14 has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=b8b100db9fcbcdf7944ac88557820930fbc7603c
commit b8b100db9fcbcdf7944ac88557820930fbc7603c
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-10-24 14:18:53 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-12-01 02:46:05 +0000
csa: Use pci_find_device to simplify clkrun_hack
Reviewed by: christos, imp
Differential Revision: https://reviews.freebsd.org/D47222
(cherry picked from commit f0bc751d6fb4f7fe46fdaa1486b0ae20b04bb544)
---
sys/dev/sound/pci/csa.c | 47 +++++++++++++----------------------------------
1 file changed, 13 insertions(+), 34 deletions(-)
diff --git a/sys/dev/sound/pci/csa.c b/sys/dev/sound/pci/csa.c
index 662f0de80188..f293a8fc8af8 100644
--- a/sys/dev/sound/pci/csa.c
+++ b/sys/dev/sound/pci/csa.c
@@ -109,46 +109,25 @@ static int
clkrun_hack(int run)
{
#ifdef __i386__
- devclass_t pci_devclass;
- device_t *pci_devices, *pci_children, *busp, *childp;
- int pci_count = 0, pci_childcount = 0;
- int i, j, port;
+ device_t child;
+ int port;
u_int16_t control;
bus_space_tag_t btag;
- if ((pci_devclass = devclass_find("pci")) == NULL) {
- return ENXIO;
- }
+ child = pci_find_device(0x8086, 0x7113);
+ if (child == NULL)
+ return (ENXIO);
- devclass_get_devices(pci_devclass, &pci_devices, &pci_count);
-
- for (i = 0, busp = pci_devices; i < pci_count; i++, busp++) {
- pci_childcount = 0;
- if (device_get_children(*busp, &pci_children, &pci_childcount))
- continue;
- for (j = 0, childp = pci_children; j < pci_childcount; j++, childp++) {
- if (pci_get_vendor(*childp) == 0x8086 && pci_get_device(*childp) == 0x7113) {
- port = (pci_read_config(*childp, 0x41, 1) << 8) + 0x10;
- /* XXX */
- btag = X86_BUS_SPACE_IO;
-
- control = bus_space_read_2(btag, 0x0, port);
- control &= ~0x2000;
- control |= run? 0 : 0x2000;
- bus_space_write_2(btag, 0x0, port, control);
- free(pci_devices, M_TEMP);
- free(pci_children, M_TEMP);
- return 0;
- }
- }
- free(pci_children, M_TEMP);
- }
+ port = (pci_read_config(child, 0x41, 1) << 8) + 0x10;
+ /* XXX */
+ btag = X86_BUS_SPACE_IO;
- free(pci_devices, M_TEMP);
- return ENXIO;
-#else
- return 0;
+ control = bus_space_read_2(btag, 0x0, port);
+ control &= ~0x2000;
+ control |= run? 0 : 0x2000;
+ bus_space_write_2(btag, 0x0, port, control);
#endif
+ return (0);
}
static struct csa_card cards_4610[] = {