Bug Summary

File:dev/pci/pci_subr.c
Warning:line 351, column 2
Value stored to 'interface' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name pci_subr.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -ffreestanding -mcmodel=kernel -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -target-feature -sse2 -target-feature -sse -target-feature -3dnow -target-feature -mmx -target-feature +save-args -disable-red-zone -no-implicit-float -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -nostdsysteminc -nobuiltininc -resource-dir /usr/local/lib/clang/13.0.0 -I /usr/src/sys -I /usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -I /usr/src/sys/arch -I /usr/src/sys/dev/pci/drm/include -I /usr/src/sys/dev/pci/drm/include/uapi -I /usr/src/sys/dev/pci/drm/amd/include/asic_reg -I /usr/src/sys/dev/pci/drm/amd/include -I /usr/src/sys/dev/pci/drm/amd/amdgpu -I /usr/src/sys/dev/pci/drm/amd/display -I /usr/src/sys/dev/pci/drm/amd/display/include -I /usr/src/sys/dev/pci/drm/amd/display/dc -I /usr/src/sys/dev/pci/drm/amd/display/amdgpu_dm -I /usr/src/sys/dev/pci/drm/amd/pm/inc -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu11 -I /usr/src/sys/dev/pci/drm/amd/pm/swsmu/smu12 -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/hwmgr -I /usr/src/sys/dev/pci/drm/amd/pm/powerplay/smumgr -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc -I /usr/src/sys/dev/pci/drm/amd/display/dc/inc/hw -I /usr/src/sys/dev/pci/drm/amd/display/dc/clk_mgr -I /usr/src/sys/dev/pci/drm/amd/display/modules/inc -I /usr/src/sys/dev/pci/drm/amd/display/modules/hdcp -I /usr/src/sys/dev/pci/drm/amd/display/dmub/inc -I /usr/src/sys/dev/pci/drm/i915 -D DDB -D DIAGNOSTIC -D KTRACE -D ACCOUNTING -D KMEMSTATS -D PTRACE -D POOL_DEBUG -D CRYPTO -D SYSVMSG -D SYSVSEM -D SYSVSHM -D UVM_SWAP_ENCRYPT -D FFS -D FFS2 -D FFS_SOFTUPDATES -D UFS_DIRHASH -D QUOTA -D EXT2FS -D MFS -D NFSCLIENT -D NFSSERVER -D CD9660 -D UDF -D MSDOSFS -D FIFO -D FUSE -D SOCKET_SPLICE -D TCP_ECN -D TCP_SIGNATURE -D INET6 -D IPSEC -D PPP_BSDCOMP -D PPP_DEFLATE -D PIPEX -D MROUTING -D MPLS -D BOOT_CONFIG -D USER_PCICONF -D APERTURE -D MTRR -D NTFS -D HIBERNATE -D PCIVERBOSE -D USBVERBOSE -D WSDISPLAY_COMPAT_USL -D WSDISPLAY_COMPAT_RAWKBD -D WSDISPLAY_DEFAULTSCREENS=6 -D X86EMU -D ONEWIREVERBOSE -D MULTIPROCESSOR -D MAXUSERS=80 -D _KERNEL -D CONFIG_DRM_AMD_DC_DCN3_0 -O2 -Wno-pointer-sign -Wno-address-of-packed-member -Wno-constant-conversion -Wno-unused-but-set-variable -Wno-gnu-folding-constant -fdebug-compilation-dir=/usr/src/sys/arch/amd64/compile/GENERIC.MP/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -o /usr/obj/sys/arch/amd64/compile/GENERIC.MP/scan-build/2022-01-12-131800-47421-1 -x c /usr/src/sys/dev/pci/pci_subr.c
1/* $OpenBSD: pci_subr.c,v 1.22 2017/03/22 07:21:39 jsg Exp $ */
2/* $NetBSD: pci_subr.c,v 1.19 1996/10/13 01:38:29 christos Exp $ */
3
4/*
5 * Copyright (c) 1995, 1996 Christopher G. Demetriou. All rights reserved.
6 * Copyright (c) 1994 Charles Hannum. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Charles Hannum.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * PCI autoconfiguration support functions.
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/device.h>
41
42#include <dev/pci/pcireg.h>
43#include <dev/pci/pcivar.h>
44#ifdef PCIVERBOSE1
45#include <dev/pci/pcidevs.h>
46#include <dev/pci/pcidevs_data.h>
47#endif
48
49/*
50 * Descriptions of known PCI classes and subclasses.
51 *
52 * Subclasses are described in the same way as classes, but have a
53 * NULL subclass pointer.
54 */
55struct pci_class {
56 const char *name;
57 int val; /* as wide as pci_{,sub}class_t */
58 const struct pci_class *subclasses;
59};
60
61const struct pci_class pci_subclass_prehistoric[] = {
62 { "miscellaneous", PCI_SUBCLASS_PREHISTORIC_MISC0x00, },
63 { "VGA", PCI_SUBCLASS_PREHISTORIC_VGA0x01, },
64 { 0 }
65};
66
67const struct pci_class pci_subclass_mass_storage[] = {
68 { "SCSI", PCI_SUBCLASS_MASS_STORAGE_SCSI0x00, },
69 { "IDE", PCI_SUBCLASS_MASS_STORAGE_IDE0x01, },
70 { "floppy", PCI_SUBCLASS_MASS_STORAGE_FLOPPY0x02, },
71 { "IPI", PCI_SUBCLASS_MASS_STORAGE_IPI0x03, },
72 { "RAID", PCI_SUBCLASS_MASS_STORAGE_RAID0x04, },
73 { "ATA", PCI_SUBCLASS_MASS_STORAGE_ATA0x05, },
74 { "SATA", PCI_SUBCLASS_MASS_STORAGE_SATA0x06, },
75 { "SAS", PCI_SUBCLASS_MASS_STORAGE_SAS0x07, },
76 { "UFS", PCI_SUBCLASS_MASS_STORAGE_UFS0x09, },
77 { "miscellaneous", PCI_SUBCLASS_MASS_STORAGE_MISC0x80, },
78 { 0 },
79};
80
81const struct pci_class pci_subclass_network[] = {
82 { "ethernet", PCI_SUBCLASS_NETWORK_ETHERNET0x00, },
83 { "token ring", PCI_SUBCLASS_NETWORK_TOKENRING0x01, },
84 { "FDDI", PCI_SUBCLASS_NETWORK_FDDI0x02, },
85 { "ATM", PCI_SUBCLASS_NETWORK_ATM0x03, },
86 { "ISDN", PCI_SUBCLASS_NETWORK_ISDN0x04, },
87 { "WorldFip", PCI_SUBCLASS_NETWORK_WORLDFIP0x05, },
88 { "PCMIG Multi Computing", PCI_SUBCLASS_NETWORK_PCIMGMULTICOMP0x06, },
89 { "InfiniBand", PCI_SUBCLASS_NETWORK_INFINIBAND0x07, },
90 { "miscellaneous", PCI_SUBCLASS_NETWORK_MISC0x80, },
91 { 0 },
92};
93
94const struct pci_class pci_subclass_display[] = {
95 { "VGA", PCI_SUBCLASS_DISPLAY_VGA0x00, },
96 { "XGA", PCI_SUBCLASS_DISPLAY_XGA0x01, },
97 { "3D", PCI_SUBCLASS_DISPLAY_3D0x02, },
98 { "miscellaneous", PCI_SUBCLASS_DISPLAY_MISC0x80, },
99 { 0 },
100};
101
102const struct pci_class pci_subclass_multimedia[] = {
103 { "video", PCI_SUBCLASS_MULTIMEDIA_VIDEO0x00, },
104 { "audio", PCI_SUBCLASS_MULTIMEDIA_AUDIO0x01, },
105 { "telephony", PCI_SUBCLASS_MULTIMEDIA_TELEPHONY0x02, },
106 { "hdaudio", PCI_SUBCLASS_MULTIMEDIA_HDAUDIO0x03, },
107 { "miscellaneous", PCI_SUBCLASS_MULTIMEDIA_MISC0x80, },
108 { 0 },
109};
110
111const struct pci_class pci_subclass_memory[] = {
112 { "RAM", PCI_SUBCLASS_MEMORY_RAM0x00, },
113 { "flash", PCI_SUBCLASS_MEMORY_FLASH0x01, },
114 { "miscellaneous", PCI_SUBCLASS_MEMORY_MISC0x80, },
115 { 0 },
116};
117
118const struct pci_class pci_subclass_bridge[] = {
119 { "host", PCI_SUBCLASS_BRIDGE_HOST0x00, },
120 { "ISA", PCI_SUBCLASS_BRIDGE_ISA0x01, },
121 { "EISA", PCI_SUBCLASS_BRIDGE_EISA0x02, },
122 { "MicroChannel", PCI_SUBCLASS_BRIDGE_MC0x03, },
123 { "PCI", PCI_SUBCLASS_BRIDGE_PCI0x04, },
124 { "PCMCIA", PCI_SUBCLASS_BRIDGE_PCMCIA0x05, },
125 { "NuBus", PCI_SUBCLASS_BRIDGE_NUBUS0x06, },
126 { "CardBus", PCI_SUBCLASS_BRIDGE_CARDBUS0x07, },
127 { "RACEway", PCI_SUBCLASS_BRIDGE_RACEWAY0x08, },
128 { "Semi-transparent PCI", PCI_SUBCLASS_BRIDGE_STPCI0x09, },
129 { "InfiniBand", PCI_SUBCLASS_BRIDGE_INFINIBAND0x0a, },
130 { "miscellaneous", PCI_SUBCLASS_BRIDGE_MISC0x80, },
131 { "advanced switching", PCI_SUBCLASS_BRIDGE_AS0x0b, },
132 { 0 },
133};
134
135const struct pci_class pci_subclass_communications[] = {
136 { "serial", PCI_SUBCLASS_COMMUNICATIONS_SERIAL0x00, },
137 { "parallel", PCI_SUBCLASS_COMMUNICATIONS_PARALLEL0x01, },
138 { "multi-port serial", PCI_SUBCLASS_COMMUNICATIONS_MPSERIAL0x02, },
139 { "modem", PCI_SUBCLASS_COMMUNICATIONS_MODEM0x03, },
140 { "GPIB", PCI_SUBCLASS_COMMUNICATIONS_GPIB0x04, },
141 { "smartcard", PCI_SUBCLASS_COMMUNICATIONS_SMARTCARD0x05, },
142 { "miscellaneous", PCI_SUBCLASS_COMMUNICATIONS_MISC0x80, },
143 { 0 },
144};
145
146const struct pci_class pci_subclass_system[] = {
147 { "interrupt", PCI_SUBCLASS_SYSTEM_PIC0x00, },
148 { "8237 DMA", PCI_SUBCLASS_SYSTEM_DMA0x01, },
149 { "8254 timer", PCI_SUBCLASS_SYSTEM_TIMER0x02, },
150 { "RTC", PCI_SUBCLASS_SYSTEM_RTC0x03, },
151 { "PCI Hot-Plug", PCI_SUBCLASS_SYSTEM_PCIHOTPLUG0x04, },
152 { "SD Host Controller", PCI_SUBCLASS_SYSTEM_SDHC0x05, },
153 { "IOMMU", PCI_SUBCLASS_SYSTEM_IOMMU0x06, },
154 { "root complex event", PCI_SUBCLASS_SYSTEM_ROOTCOMPEVENT0x07, },
155 { "miscellaneous", PCI_SUBCLASS_SYSTEM_MISC0x80, },
156 { 0 },
157};
158
159const struct pci_class pci_subclass_input[] = {
160 { "keyboard", PCI_SUBCLASS_INPUT_KEYBOARD0x00, },
161 { "digitizer", PCI_SUBCLASS_INPUT_DIGITIZER0x01, },
162 { "mouse", PCI_SUBCLASS_INPUT_MOUSE0x02, },
163 { "scanner", PCI_SUBCLASS_INPUT_SCANNER0x03, },
164 { "game port", PCI_SUBCLASS_INPUT_GAMEPORT0x04, },
165 { "miscellaneous", PCI_SUBCLASS_INPUT_MISC0x80, },
166 { 0 },
167};
168
169const struct pci_class pci_subclass_dock[] = {
170 { "generic", PCI_SUBCLASS_DOCK_GENERIC0x00, },
171 { "miscellaneous", PCI_SUBCLASS_DOCK_MISC0x80, },
172 { 0 },
173};
174
175const struct pci_class pci_subclass_processor[] = {
176 { "386", PCI_SUBCLASS_PROCESSOR_3860x00, },
177 { "486", PCI_SUBCLASS_PROCESSOR_4860x01, },
178 { "Pentium", PCI_SUBCLASS_PROCESSOR_PENTIUM0x02, },
179 { "Alpha", PCI_SUBCLASS_PROCESSOR_ALPHA0x10, },
180 { "PowerPC", PCI_SUBCLASS_PROCESSOR_POWERPC0x20, },
181 { "MIPS", PCI_SUBCLASS_PROCESSOR_MIPS0x30, },
182 { "Co-processor", PCI_SUBCLASS_PROCESSOR_COPROC0x40, },
183 { 0 },
184};
185
186const struct pci_class pci_subclass_serialbus[] = {
187 { "Firewire", PCI_SUBCLASS_SERIALBUS_FIREWIRE0x00, },
188 { "ACCESS.bus", PCI_SUBCLASS_SERIALBUS_ACCESS0x01, },
189 { "SSA", PCI_SUBCLASS_SERIALBUS_SSA0x02, },
190 { "USB", PCI_SUBCLASS_SERIALBUS_USB0x03, },
191 /* XXX Fiber Channel/_FIBRECHANNEL */
192 { "Fiber Channel", PCI_SUBCLASS_SERIALBUS_FIBER0x04, },
193 { "SMBus", PCI_SUBCLASS_SERIALBUS_SMBUS0x05, },
194 { "InfiniBand", PCI_SUBCLASS_SERIALBUS_INFINIBAND0x06, },
195 { "IPMI", PCI_SUBCLASS_SERIALBUS_IPMI0x07, },
196 { "SERCOS", PCI_SUBCLASS_SERIALBUS_SERCOS0x08, },
197 { "CANbus", PCI_SUBCLASS_SERIALBUS_CANBUS0x09, },
198 { 0 },
199};
200
201const struct pci_class pci_subclass_wireless[] = {
202 { "IrDA", PCI_SUBCLASS_WIRELESS_IRDA0x00, },
203 { "Consumer IR", PCI_SUBCLASS_WIRELESS_CONSUMERIR0x01, },
204 { "RF", PCI_SUBCLASS_WIRELESS_RF0x10, },
205 { "bluetooth", PCI_SUBCLASS_WIRELESS_BLUETOOTH0x11, },
206 { "broadband", PCI_SUBCLASS_WIRELESS_BROADBAND0x12, },
207 { "802.11a (5 GHz)", PCI_SUBCLASS_WIRELESS_802_11A0x20, },
208 { "802.11b (2.4 GHz)", PCI_SUBCLASS_WIRELESS_802_11B0x21, },
209 { "miscellaneous", PCI_SUBCLASS_WIRELESS_MISC0x80, },
210 { 0 },
211};
212
213const struct pci_class pci_subclass_i2o[] = {
214 { "standard", PCI_SUBCLASS_I2O_STANDARD0x00, },
215 { 0 },
216};
217
218const struct pci_class pci_subclass_satcom[] = {
219 { "TV", PCI_SUBCLASS_SATCOM_TV0x01, },
220 { "audio", PCI_SUBCLASS_SATCOM_AUDIO0x02, },
221 { "voice", PCI_SUBCLASS_SATCOM_VOICE0x03, },
222 { "data", PCI_SUBCLASS_SATCOM_DATA0x04, },
223 { 0 },
224};
225
226const struct pci_class pci_subclass_crypto[] = {
227 { "network/computing", PCI_SUBCLASS_CRYPTO_NETCOMP0x00, },
228 { "entertainment", PCI_SUBCLASS_CRYPTO_ENTERTAINMENT0x10, },
229 { "miscellaneous", PCI_SUBCLASS_CRYPTO_MISC0x80, },
230 { 0 },
231};
232
233const struct pci_class pci_subclass_dasp[] = {
234 { "DPIO", PCI_SUBCLASS_DASP_DPIO0x00, },
235 { "Time and Frequency", PCI_SUBCLASS_DASP_TIMEFREQ0x01, },
236 { "synchronization", PCI_SUBCLASS_DASP_SYNC0x10, },
237 { "management", PCI_SUBCLASS_DASP_MGMT0x20, },
238 { "miscellaneous", PCI_SUBCLASS_DASP_MISC0x80, },
239 { 0 },
240};
241
242const struct pci_class pci_class[] = {
243 { "prehistoric", PCI_CLASS_PREHISTORIC0x00,
244 pci_subclass_prehistoric, },
245 { "mass storage", PCI_CLASS_MASS_STORAGE0x01,
246 pci_subclass_mass_storage, },
247 { "network", PCI_CLASS_NETWORK0x02,
248 pci_subclass_network, },
249 { "display", PCI_CLASS_DISPLAY0x03,
250 pci_subclass_display, },
251 { "multimedia", PCI_CLASS_MULTIMEDIA0x04,
252 pci_subclass_multimedia, },
253 { "memory", PCI_CLASS_MEMORY0x05,
254 pci_subclass_memory, },
255 { "bridge", PCI_CLASS_BRIDGE0x06,
256 pci_subclass_bridge, },
257 { "communications", PCI_CLASS_COMMUNICATIONS0x07,
258 pci_subclass_communications, },
259 { "system", PCI_CLASS_SYSTEM0x08,
260 pci_subclass_system, },
261 { "input", PCI_CLASS_INPUT0x09,
262 pci_subclass_input, },
263 { "dock", PCI_CLASS_DOCK0x0a,
264 pci_subclass_dock, },
265 { "processor", PCI_CLASS_PROCESSOR0x0b,
266 pci_subclass_processor, },
267 { "serial bus", PCI_CLASS_SERIALBUS0x0c,
268 pci_subclass_serialbus, },
269 { "wireless", PCI_CLASS_WIRELESS0x0d,
270 pci_subclass_wireless, },
271 { "I2O", PCI_CLASS_I2O0x0e,
272 pci_subclass_i2o, },
273 { "satellite comm", PCI_CLASS_SATCOM0x0f,
274 pci_subclass_satcom, },
275 { "crypto", PCI_CLASS_CRYPTO0x10,
276 pci_subclass_crypto, },
277 { "DASP", PCI_CLASS_DASP0x11,
278 pci_subclass_dasp, },
279 { "accelerator", PCI_CLASS_ACCELERATOR0x12,
280 NULL((void *)0), },
281 { "instrumentation", PCI_CLASS_INSTRUMENTATION0x13,
282 NULL((void *)0), },
283 { "undefined", PCI_CLASS_UNDEFINED0xff,
284 0, },
285 { 0 },
286};
287
288const char *
289pci_findvendor(pcireg_t id_reg)
290{
291#ifdef PCIVERBOSE1
292 pci_vendor_id_t vendor = PCI_VENDOR(id_reg)(((id_reg) >> 0) & 0xffff);
293 const struct pci_known_vendor *kdp;
294
295 kdp = pci_known_vendors;
296 while (kdp->vendorname != NULL((void *)0)) { /* all have vendor name */
297 if (kdp->vendor == vendor)
298 break;
299 kdp++;
300 }
301 return (kdp->vendorname);
302#else
303 return (NULL((void *)0));
304#endif
305}
306
307const char *
308pci_findproduct(pcireg_t id_reg)
309{
310#ifdef PCIVERBOSE1
311 pci_vendor_id_t vendor = PCI_VENDOR(id_reg)(((id_reg) >> 0) & 0xffff);
312 pci_product_id_t product = PCI_PRODUCT(id_reg)(((id_reg) >> 16) & 0xffff);
313 const struct pci_known_product *pkp;
314
315 pkp = pci_known_products;
316 while (pkp->productname != NULL((void *)0)) { /* all have product name */
317 if (pkp->vendor == vendor && pkp->product == product)
318 break;
319 pkp++;
320 }
321 return (pkp->productname);
322#else
323 return NULL((void *)0);
324#endif
325}
326
327void
328pci_devinfo(pcireg_t id_reg, pcireg_t class_reg, int showclass, char *cp,
329 size_t cp_max)
330{
331 pci_vendor_id_t vendor;
332 pci_product_id_t product;
333 pci_class_t class;
334 pci_subclass_t subclass;
335 pci_interface_t interface;
336 pci_revision_t revision;
337 const char *vendor_namep = NULL((void *)0), *product_namep = NULL((void *)0);
338 const struct pci_class *classp, *subclassp;
339 size_t cp_len = 0;
340#ifdef PCIVERBOSE1
341 const char *unmatched = "unknown ";
342#else
343 const char *unmatched = "";
344#endif
345
346 vendor = PCI_VENDOR(id_reg)(((id_reg) >> 0) & 0xffff);
347 product = PCI_PRODUCT(id_reg)(((id_reg) >> 16) & 0xffff);
348
349 class = PCI_CLASS(class_reg)(((class_reg) >> 24) & 0xff);
350 subclass = PCI_SUBCLASS(class_reg)(((class_reg) >> 16) & 0xff);
351 interface = PCI_INTERFACE(class_reg)(((class_reg) >> 8) & 0xff);
Value stored to 'interface' is never read
352 revision = PCI_REVISION(class_reg)(((class_reg) >> 0) & 0xff);
353
354#ifdef PCIVERBOSE1
355 vendor_namep = pci_findvendor(id_reg);
356 if (vendor_namep != NULL((void *)0))
357 product_namep = pci_findproduct(id_reg);
358#endif /* PCIVERBOSE */
359
360 classp = pci_class;
361 while (classp->name != NULL((void *)0)) {
362 if (class == classp->val)
363 break;
364 classp++;
365 }
366
367 subclassp = (classp->name != NULL((void *)0)) ? classp->subclasses : NULL((void *)0);
368 while (subclassp && subclassp->name != NULL((void *)0)) {
369 if (subclass == subclassp->val)
370 break;
371 subclassp++;
372 }
373
374 if (vendor_namep == NULL((void *)0))
375 snprintf(cp, cp_max, "%svendor 0x%04x product 0x%04x",
376 unmatched, vendor, product);
377 else if (product_namep != NULL((void *)0))
378 snprintf(cp, cp_max, "\"%s %s\"", vendor_namep, product_namep);
379 else
380 snprintf(cp, cp_max, "vendor \"%s\", unknown product 0x%04x",
381 vendor_namep, product);
382 if (showclass && product_namep == NULL((void *)0)) {
383 strlcat(cp, " (", cp_max);
384 cp_len = strlen(cp);
385 if (classp->name == NULL((void *)0))
386 snprintf(cp + cp_len, cp_max - cp_len,
387 "unknown class 0x%02x, subclass 0x%02x",
388 class, subclass);
389 else if (subclassp == NULL((void *)0) || subclassp->name == NULL((void *)0))
390 snprintf(cp + cp_len, cp_max - cp_len,
391 "class %s unknown subclass 0x%02x", classp->name,
392 subclass);
393 else
394 snprintf(cp + cp_len, cp_max - cp_len,
395 "class %s subclass %s", classp->name,
396 subclassp->name);
397#if 0 /* not very useful */
398 cp_len = strlen(cp);
399 snprintf(cp + cp_len, cp_max - cp_len,
400 ", interface 0x%02x", interface);
401#endif
402 cp_len = strlen(cp);
403 snprintf(cp + cp_len, cp_max - cp_len,
404 ", rev 0x%02x)", revision);
405 } else {
406 cp_len = strlen(cp);
407 snprintf(cp + cp_len, cp_max - cp_len, " rev 0x%02x",
408 revision);
409 }
410}