Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Jul 2018 15:55:52 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336068 - in head/sys: dev/amdsmb modules/amdsmb
Message-ID:  <201807071555.w67FtqrL004956@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Sat Jul  7 15:55:52 2018
New Revision: 336068
URL: https://svnweb.freebsd.org/changeset/base/336068

Log:
  Update AMDSMB to use PCI_MATCH
  
  Differential Review: https://reviews.freebsd.org/D16172

Added:
  head/sys/modules/amdsmb/
  head/sys/modules/amdsmb/Makefile   (contents, props changed)
Modified:
  head/sys/dev/amdsmb/amdsmb.c

Modified: head/sys/dev/amdsmb/amdsmb.c
==============================================================================
--- head/sys/dev/amdsmb/amdsmb.c	Sat Jul  7 15:25:16 2018	(r336067)
+++ head/sys/dev/amdsmb/amdsmb.c	Sat Jul  7 15:55:52 2018	(r336068)
@@ -125,24 +125,22 @@ struct amdsmb_softc {
 
 static int	amdsmb_detach(device_t dev);
 
+struct pci_device_table amdsmb_devs[] = {
+	{ PCI_DEV(AMDSMB_VENDORID_AMD, AMDSMB_DEVICEID_AMD8111_SMB2),
+	  PCI_DESCR("AMD-8111 SMBus 2.0 Controller") }
+};
+
 static int
 amdsmb_probe(device_t dev)
 {
-	u_int16_t vid;
-	u_int16_t did;
+	const struct pci_device_table *tbl;
 
-	vid = pci_get_vendor(dev);
-	did = pci_get_device(dev);
+	tbl = PCI_MATCH(dev, amdsmb_devs);
+	if (tbl == NULL)
+		return (ENXIO);
+	device_set_desc(dev, tbl->descr);
 
-	if (vid == AMDSMB_VENDORID_AMD) {
-		switch(did) {
-		case AMDSMB_DEVICEID_AMD8111_SMB2:
-			device_set_desc(dev, "AMD-8111 SMBus 2.0 Controller");
-			return (BUS_PROBE_DEFAULT);
-		}
-	}
-
-	return (ENXIO);
+	return (BUS_PROBE_DEFAULT);
 }
 
 static int

Added: head/sys/modules/amdsmb/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/modules/amdsmb/Makefile	Sat Jul  7 15:55:52 2018	(r336068)
@@ -0,0 +1,8 @@
+# $FreeBSD$
+
+.PATH:	${SRCTOP}/sys/dev/amdsmb
+
+KMOD=	amdsmb
+SRCS=	amdsmb.c bus_if.h device_if.h pci_if.h smbus_if.h
+
+.include <bsd.kmod.mk>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807071555.w67FtqrL004956>