Date: Fri, 23 Mar 2018 15:35:19 +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: r331430 - in head/sys: dev/adlink modules/adlink Message-ID: <201803231535.w2NFZJ6E071772@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Fri Mar 23 15:35:19 2018 New Revision: 331430 URL: https://svnweb.freebsd.org/changeset/base/331430 Log: Convert the PCI ID selection from a simple if into a table. Mark the table with PNP info. Fix compilation by returning FILTER_STRAY in two places, as suggested by comments. Create a simple module from this. Left unconnected because I can't test it as a module. Added: head/sys/modules/adlink/ head/sys/modules/adlink/Makefile (contents, props changed) Modified: head/sys/dev/adlink/adlink.c Modified: head/sys/dev/adlink/adlink.c ============================================================================== --- head/sys/dev/adlink/adlink.c Fri Mar 23 15:35:15 2018 (r331429) +++ head/sys/dev/adlink/adlink.c Fri Mar 23 15:35:19 2018 (r331430) @@ -137,7 +137,7 @@ adlink_intr(void *arg) sc = arg; u = bus_read_4(sc->res[0], 0x38); if (!(u & 0x00800000)) - return; // XXX - FILTER_STRAY? + return (FILTER_STRAY); bus_write_4(sc->res[0], 0x38, u | 0x003f4000); sc->sample += sc->p0->chunksize / 2; @@ -150,7 +150,7 @@ adlink_intr(void *arg) if (sc->p0->state != STATE_RUN) { printf("adlink: stopping %d\n", sc->p0->state); - return; // XXX - FILTER_STRAY? + return (FILTER_STRAY); } pg = pg->next; @@ -346,14 +346,32 @@ adlink_ioctl(struct cdev *dev, u_long cmd, caddr_t dat static devclass_t adlink_devclass; +struct pci_id +{ + uint16_t vendor; + uint16_t device; + const char *desc; +} adlink_id[] = { + { .vendor = 0x10e8, .device = 0x80da, + .desc ="Adlink PCI-9812 4 ch 12 bit 20 msps" } +}; + static int adlink_probe(device_t self) { + int i; + uint16_t vendor, device; - if (pci_get_devid(self) != 0x80da10e8) - return (ENXIO); - device_set_desc(self, "Adlink PCI-9812 4 ch 12 bit 20 msps"); - return (BUS_PROBE_DEFAULT); + vendor = pci_get_vendor(self); + device = pci_get_device(self); + for (i = 0; i < nitems(adlink_id); i++) { + if (adlink_id[i].vendor == vendor && + adlink_id[i].device == device) { + device_set_desc(self, adlink_id[i].desc); + return (BUS_PROBE_DEFAULT); + } + } + return (ENXIO); } static struct resource_spec adlink_res_spec[] = { @@ -420,5 +438,6 @@ static driver_t adlink_driver = { }; DRIVER_MODULE(adlink, pci, adlink_driver, adlink_devclass, 0, 0); - +MODULE_PNP_INFO("U16:vendor;U16:device;D:#", pci, adlink, adlink_id, sizeof(adlink_id[0]), + nitems(adlink_id)); #endif /* _KERNEL */ Added: head/sys/modules/adlink/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/adlink/Makefile Fri Mar 23 15:35:19 2018 (r331430) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +.PATH: ${SRCTOP}/sys/dev/adlink + +KMOD= adlink +SRCS= adlink.c \ + device_if.h bus_if.h + +.include <bsd.kmod.mk>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803231535.w2NFZJ6E071772>