From owner-p4-projects Sun Dec 22 11:12:47 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B9A8D37B405; Sun, 22 Dec 2002 11:12:42 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 519EB37B401 for ; Sun, 22 Dec 2002 11:12:42 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id EFEEC43EDA for ; Sun, 22 Dec 2002 11:12:41 -0800 (PST) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id gBMJCffh009507 for ; Sun, 22 Dec 2002 11:12:41 -0800 (PST) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id gBMJCf5i009504 for perforce@freebsd.org; Sun, 22 Dec 2002 11:12:41 -0800 (PST) Date: Sun, 22 Dec 2002 11:12:41 -0800 (PST) Message-Id: <200212221912.gBMJCf5i009504@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar Subject: PERFORCE change 22623 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://perforce.freebsd.org/chv.cgi?CH=22623 Change 22623 by marcel@marcel_nfs on 2002/12/22 11:11:43 Convert to the new sioprobe/sioattach interface. While here, remove the sio_pci_unit_kludge function. We consider this the "future" version which according to the comment makes it obsolete :-) Affected files ... .. //depot/projects/ia64/sys/dev/sio/sio_pci.c#10 edit Differences ... ==== //depot/projects/ia64/sys/dev/sio/sio_pci.c#10 (text+ko) ==== @@ -33,16 +33,19 @@ #include #include #include +#include #include + #include -#include +#include + +#include #include #include static int sio_pci_attach(device_t dev); -static void sio_pci_kludge_unit(device_t dev); static int sio_pci_probe(device_t dev); static device_method_t sio_pci_methods[] = { @@ -56,7 +59,7 @@ static driver_t sio_pci_driver = { sio_driver_name, sio_pci_methods, - 0, + sizeof(struct com_s), }; struct pci_ids { @@ -80,70 +83,66 @@ { 0x00000000, NULL, 0 } }; -static int -sio_pci_attach(dev) - device_t dev; +static struct pci_ids * +pci_id(device_t dev) { - u_int32_t type; - struct pci_ids *id; + struct pci_ids *id; + u_int32_t type; type = pci_get_devid(dev); id = pci_ids; while (id->type && id->type != type) id++; - if (id->desc == NULL) - return (ENXIO); - sio_pci_kludge_unit(dev); - return (sioattach(dev, id->rid, 0UL)); + return ((id->desc != NULL) ? id : NULL); } -/* - * Don't cut and paste this to other drivers. It is a horrible kludge - * which will fail to work and also be unnecessary in future versions. - */ -static void -sio_pci_kludge_unit(dev) - device_t dev; +static int +sio_pci_attach(device_t dev) { - devclass_t dc; - int err; - int start; - int unit; + struct com_s *com; + struct pci_ids *id; + struct resource *res; + int error, rid, space; - unit = 0; - start = 0; - while (resource_int_value("sio", unit, "port", &start) == 0 && - start > 0) - unit++; - if (device_get_unit(dev) < unit) { - dc = device_get_devclass(dev); - while (devclass_get_device(dc, unit)) - unit++; - device_printf(dev, "moving to sio%d\n", unit); - err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */ - if (err) - device_printf(dev, "error moving device %d\n", err); - } + com = device_get_softc(dev); + id = pci_id(dev); + rid = (id->rid >= 0) ? id->rid : -id->rid; + space = (id->rid >= 0) ? SYS_RES_IOPORT : SYS_RES_MEMORY; + res = bus_alloc_resource(dev, space, &rid, 0, ~0, 8, RF_ACTIVE); + com->bsh = rman_get_bushandle(res); + com->bst = rman_get_bustag(res); + error = sioattach(dev); + if (error) + bus_release_resource(dev, space, rid, res); + return (error); } static int -sio_pci_probe(dev) - device_t dev; +sio_pci_probe(device_t dev) { - u_int32_t type; - struct pci_ids *id; + struct com_s *com; + struct pci_ids *id; + struct resource *res; + int error, rid, space; - type = pci_get_devid(dev); - id = pci_ids; - while (id->type && id->type != type) - id++; - if (id->desc == NULL) + com = device_get_softc(dev); + id = pci_id(dev); + if (id == NULL) return (ENXIO); device_set_desc(dev, id->desc); + rid = (id->rid >= 0) ? id->rid : -id->rid; + space = (id->rid >= 0) ? SYS_RES_IOPORT : SYS_RES_MEMORY; + res = bus_alloc_resource(dev, space, &rid, 0, ~0, 8, RF_ACTIVE); + com->bsh = rman_get_bushandle(res); + com->bst = rman_get_bustag(res); + #ifdef PC98 SET_FLAG(dev, SET_IFTYPE(COM_IF_NS16550)); #endif - return (sioprobe(dev, id->rid, 0UL, 1)); + + error = sioprobe(dev); + bus_release_resource(dev, space, rid, res); + return (error); } DRIVER_MODULE(sio, pci, sio_pci_driver, sio_devclass, 0, 0); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message