diff options
author | njl <njl@FreeBSD.org> | 2004-07-15 16:41:07 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2004-07-15 16:41:07 +0000 |
commit | db94b43487db43e5f96263638944828e61b9dd6f (patch) | |
tree | ff5fb16f534d910b0a40e3a042c69b33da342a77 /sys/dev/fdc/fdc_isa.c | |
parent | c36db208d38f01c3ff26d7b70f852cde01fb15ee (diff) | |
download | FreeBSD-src-db94b43487db43e5f96263638944828e61b9dd6f.zip FreeBSD-src-db94b43487db43e5f96263638944828e61b9dd6f.tar.gz |
Clean up resources properly if attach fails. Always reset ISA drives on
probe.
Diffstat (limited to 'sys/dev/fdc/fdc_isa.c')
-rw-r--r-- | sys/dev/fdc/fdc_isa.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/sys/dev/fdc/fdc_isa.c b/sys/dev/fdc/fdc_isa.c index b14c990..a1a6dd3 100644 --- a/sys/dev/fdc/fdc_isa.c +++ b/sys/dev/fdc/fdc_isa.c @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 2004 M. Warner Losh. * All rights reserved. * @@ -61,7 +61,7 @@ fdctl_wr_isa(fdc_p fdc, u_int8_t v) bus_space_write_1(fdc->ctlt, fdc->ctlh, 0, v); } -static int +int fdc_isa_alloc_resources(device_t dev, struct fdc_data *fdc) { int ispnp, nports; @@ -191,7 +191,6 @@ static int fdc_isa_probe(device_t dev) { int error, ic_type; - int ispnp; struct fdc_data *fdc; fdc = device_get_softc(dev); @@ -202,8 +201,6 @@ fdc_isa_probe(device_t dev) error = ISA_PNP_PROBE(device_get_parent(dev), dev, fdc_ids); if (error == ENXIO) return (ENXIO); - ispnp = (error == 0); - /* Attempt to allocate our resources for the duration of the probe */ error = fdc_isa_alloc_resources(dev, fdc); @@ -211,11 +208,9 @@ fdc_isa_probe(device_t dev) goto out; /* Check that the controller is working. */ - if (!ispnp) { - error = fdc_initial_reset(fdc); - if (error) - goto out; - } + error = fdc_initial_reset(fdc); + if (error) + goto out; /* Try to determine a more specific device type. */ if (fd_cmd(fdc, 1, NE7CMD_VERSION, 1, &ic_type) == 0) { @@ -266,8 +261,20 @@ fdc_isa_attach(device_t dev) break; } } - fdc_isa_alloc_resources(dev, fdc); - return (fdc_attach(dev)); + + error = fdc_isa_alloc_resources(dev, fdc); + if (error) + goto out; + error = fdc_attach(dev); + if (error) + goto out; + error = fdc_hints_probe(dev); + if (error) + goto out; +out: + if (error) + fdc_release_resources(fdc); + return (error); } static device_method_t fdc_methods[] = { @@ -295,4 +302,3 @@ static driver_t fdc_driver = { }; DRIVER_MODULE(fdc, isa, fdc_driver, fdc_devclass, 0, 0); -DRIVER_MODULE(fdc, acpi, fdc_driver, fdc_devclass, 0, 0); |