Sun Feb 27 14:19:20 2022 UTC ()
drm: Deconditionalize pci_get_segment.


(riastradh)
diff -r1.20 -r1.21 src/sys/external/bsd/drm2/linux/linux_pci.c

cvs diff -r1.20 -r1.21 src/sys/external/bsd/drm2/linux/linux_pci.c (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/linux/linux_pci.c 2021/12/19 12:00:16 1.20
+++ src/sys/external/bsd/drm2/linux/linux_pci.c 2022/02/27 14:19:20 1.21
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: linux_pci.c,v 1.20 2021/12/19 12:00:16 riastradh Exp $ */ 1/* $NetBSD: linux_pci.c,v 1.21 2022/02/27 14:19:20 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2013 The NetBSD Foundation, Inc. 4 * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell. 8 * by Taylor R. Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#ifdef _KERNEL_OPT 32#ifdef _KERNEL_OPT
33#include "acpica.h" 33#include "acpica.h"
34#include "opt_pci.h" 34#include "opt_pci.h"
35#endif 35#endif
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.20 2021/12/19 12:00:16 riastradh Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: linux_pci.c,v 1.21 2022/02/27 14:19:20 riastradh Exp $");
39 39
40#if NACPICA > 0 40#if NACPICA > 0
41#include <dev/acpi/acpivar.h> 41#include <dev/acpi/acpivar.h>
42#include <dev/acpi/acpi_pci.h> 42#include <dev/acpi/acpi_pci.h>
43#endif 43#endif
44 44
45#include <linux/pci.h> 45#include <linux/pci.h>
46 46
47#include <drm/drm_agp_netbsd.h> 47#include <drm/drm_agp_netbsd.h>
48 48
49device_t 49device_t
50pci_dev_dev(struct pci_dev *pdev) 50pci_dev_dev(struct pci_dev *pdev)
51{ 51{
@@ -78,31 +78,27 @@ linux_pci_dev_init(struct pci_dev *pdev, @@ -78,31 +78,27 @@ linux_pci_dev_init(struct pci_dev *pdev,
78 const struct pci_attach_args *pa, int kludges) 78 const struct pci_attach_args *pa, int kludges)
79{ 79{
80 const uint32_t subsystem_id = pci_conf_read(pa->pa_pc, pa->pa_tag, 80 const uint32_t subsystem_id = pci_conf_read(pa->pa_pc, pa->pa_tag,
81 PCI_SUBSYS_ID_REG); 81 PCI_SUBSYS_ID_REG);
82 unsigned i; 82 unsigned i;
83 83
84 memset(pdev, 0, sizeof(*pdev)); /* paranoia */ 84 memset(pdev, 0, sizeof(*pdev)); /* paranoia */
85 85
86 pdev->pd_pa = *pa; 86 pdev->pd_pa = *pa;
87 pdev->pd_kludges = kludges; 87 pdev->pd_kludges = kludges;
88 pdev->pd_rom_vaddr = NULL; 88 pdev->pd_rom_vaddr = NULL;
89 pdev->pd_dev = dev; 89 pdev->pd_dev = dev;
90#if (NACPICA > 0) 90#if (NACPICA > 0)
91#ifdef __HAVE_PCI_GET_SEGMENT 
92 const int seg = pci_get_segment(pa->pa_pc); 91 const int seg = pci_get_segment(pa->pa_pc);
93#else 
94 const int seg = 0; 
95#endif 
96 pdev->pd_ad = acpi_pcidev_find(seg, pa->pa_bus, 92 pdev->pd_ad = acpi_pcidev_find(seg, pa->pa_bus,
97 pa->pa_device, pa->pa_function); 93 pa->pa_device, pa->pa_function);
98#else 94#else
99 pdev->pd_ad = NULL; 95 pdev->pd_ad = NULL;
100#endif 96#endif
101 pdev->pd_saved_state = NULL; 97 pdev->pd_saved_state = NULL;
102 pdev->pd_intr_handles = NULL; 98 pdev->pd_intr_handles = NULL;
103 pdev->pd_drvdata = NULL; 99 pdev->pd_drvdata = NULL;
104 pdev->bus = kmem_zalloc(sizeof(*pdev->bus), KM_NOSLEEP); 100 pdev->bus = kmem_zalloc(sizeof(*pdev->bus), KM_NOSLEEP);
105 pdev->bus->pb_pc = pa->pa_pc; 101 pdev->bus->pb_pc = pa->pa_pc;
106 pdev->bus->pb_dev = parent; 102 pdev->bus->pb_dev = parent;
107 pdev->bus->number = pa->pa_bus; 103 pdev->bus->number = pa->pa_bus;
108 pdev->devfn = PCI_DEVFN(pa->pa_device, pa->pa_function); 104 pdev->devfn = PCI_DEVFN(pa->pa_device, pa->pa_function);