From nobody Thu Oct 24 14:24:21 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XZ7TK5gF1z5bVMy; Thu, 24 Oct 2024 14:24:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XZ7TK4z0mz4GG5; Thu, 24 Oct 2024 14:24:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729779861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=N0E3yJUCgh0xzBSdL+GNOSSdpatQfTRlkbB3XlFWjA0=; b=chOkbFiYJHS4n1CpzNhc2Fn1vTxmjitdDSJBYs6zNShVnEHcmbcZlZ5EfKJXVJKk8CCXPU QoKYJ9tWAeJQ+RxpfBnn9PHZ4lsnHLSo1g1JjOQzrTnSoM8J2VUYUtKud/a+PKC17/XSBi /IyDTaspZ4d5UI4Rh7/vQRNXCjL5aa2qOI3UHeq1dqY64bhxtfVM7BdRNz9qHAx3/w7SPH PwSSXH54fNxaseXlX+i1YPlGWga0SAL4HX45Iu4JiXaQxu2NWHZXlfqHgwIcIol85p4YGV 4KbnOxgEq3pC3Z/4sgiafGKNp6dkBa2nae6GfWoVcvysYLEiogvm9ng/YZo9Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729779861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=N0E3yJUCgh0xzBSdL+GNOSSdpatQfTRlkbB3XlFWjA0=; b=jWrDtwCnNW6YsCXVYSZZ4NKR7/pDMKhZQ25V/iZCWLe/BgroKlhiGu1VCFDu9YP/QQ1vr/ 9ZoWfwpoehkSJf++2f/Z+2uIqLclNtgCV/TfNmX59dE9cMbOiA/cYJ2sXu6/B5x39Wmfre m8YA+Macqv8MiHuyq1jvfZBRZ0EF5KwuGkM7jYRC+6j+gtfi79d9X+GAhLrgpXR58rhzuN EGkUv2EMyYsbeMjQJx0NAYmA7e1qMUKEIlkbiEPkSqrzGOYFs42LHJQ8wZdAppF8uK1cm0 L8YVELLhpfgko0DL/vTTNqyQSh5zEBbVN/0YiT5J2bygM1KXIuDglp4gl8VyNg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729779861; a=rsa-sha256; cv=none; b=VV0dZ7JVTnUPTKaDdQ50PTnvvR5FxtylnjPA8BQ3DwAlXEY0/UPiAWLBoDV9+bpbABGpUw 2T+nBp67Qa/J/K1aSVm4y44H2s9GlI/rGPlk3OxM6n1tmLWGS/uNg9qyfqsSIz0xfxP01h bmClUtm8m2F4tUzNr8ksY0DTHtKl8R9l2oDdL9lLnZFgfe494KPLMNktmMT/LV3F8RB4UD n0lGXSFEWtR7VwVkGKL3pbzu9z38q1fq8h8ZQTkhIwmu18C/0D/vWqTuFj1dyxpq3Z+9Yh IZo23FjnbVz6rWoe5c3fgoTXezWby80bZA2mAczOnLqLcNSMG5ll7FW7vred+w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XZ7TK48d2zmCJ; Thu, 24 Oct 2024 14:24:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49OEOLJ0085580; Thu, 24 Oct 2024 14:24:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49OEOLfV085577; Thu, 24 Oct 2024 14:24:21 GMT (envelope-from git) Date: Thu, 24 Oct 2024 14:24:21 GMT Message-Id: <202410241424.49OEOLfV085577@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: f0bc751d6fb4 - main - csa: Use pci_find_device to simplify clkrun_hack List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f0bc751d6fb4f7fe46fdaa1486b0ae20b04bb544 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f0bc751d6fb4f7fe46fdaa1486b0ae20b04bb544 commit f0bc751d6fb4f7fe46fdaa1486b0ae20b04bb544 Author: John Baldwin AuthorDate: 2024-10-24 14:18:53 +0000 Commit: John Baldwin CommitDate: 2024-10-24 14:24:06 +0000 csa: Use pci_find_device to simplify clkrun_hack Reviewed by: christos, imp Differential Revision: https://reviews.freebsd.org/D47222 --- 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 b1e513928487..6440b73f6341 100644 --- a/sys/dev/sound/pci/csa.c +++ b/sys/dev/sound/pci/csa.c @@ -108,46 +108,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[] = {