Deleted Added
full compact
ata-card.c (136688) ata-card.c (137493)
1/*-
2 * Copyright (c) 1998 - 2004 S�ren Schmidt <sos@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 - 2004 S�ren Schmidt <sos@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/ata/ata-card.c 136688 2004-10-19 10:29:00Z le $");
30__FBSDID("$FreeBSD: head/sys/dev/ata/ata-card.c 137493 2004-11-10 00:33:05Z imp $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/ata.h>
35#include <sys/kernel.h>
36#include <sys/module.h>
37#include <sys/bus.h>
38#include <sys/malloc.h>

--- 61 unchanged lines hidden (view full) ---

100 atadev->mode = ata_limit_mode(atadev, mode, ATA_PIO_MAX);
101}
102
103static int
104ata_pccard_probe(device_t dev)
105{
106 struct ata_channel *ch = device_get_softc(dev);
107 struct resource *io, *altio;
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/ata.h>
35#include <sys/kernel.h>
36#include <sys/module.h>
37#include <sys/bus.h>
38#include <sys/malloc.h>

--- 61 unchanged lines hidden (view full) ---

100 atadev->mode = ata_limit_mode(atadev, mode, ATA_PIO_MAX);
101}
102
103static int
104ata_pccard_probe(device_t dev)
105{
106 struct ata_channel *ch = device_get_softc(dev);
107 struct resource *io, *altio;
108 int i, rid, len;
108 int i, rid;
109
110 /* allocate the io range to get start and length */
111 rid = ATA_IOADDR_RID;
109
110 /* allocate the io range to get start and length */
111 rid = ATA_IOADDR_RID;
112 len = bus_get_resource_count(dev, SYS_RES_IOPORT, rid);
113 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
114 ATA_IOSIZE, RF_ACTIVE);
115 if (!io)
116 return ENXIO;
117
118 /* setup the resource vectors */
119 for (i = ATA_DATA; i <= ATA_STATUS; i++) {
120 ch->r_io[i].res = io;
121 ch->r_io[i].offset = i;
122 }
123
124 /*
125 * if we got more than the default ATA_IOSIZE ports, this is a device
126 * where altio is located at offset 14 into "normal" io space.
127 */
112 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
113 ATA_IOSIZE, RF_ACTIVE);
114 if (!io)
115 return ENXIO;
116
117 /* setup the resource vectors */
118 for (i = ATA_DATA; i <= ATA_STATUS; i++) {
119 ch->r_io[i].res = io;
120 ch->r_io[i].offset = i;
121 }
122
123 /*
124 * if we got more than the default ATA_IOSIZE ports, this is a device
125 * where altio is located at offset 14 into "normal" io space.
126 */
128 if (len > ATA_IOSIZE) {
127 if (rman_get_size(io) > ATA_IOSIZE) {
129 ch->r_io[ATA_ALTSTAT].res = io;
130 ch->r_io[ATA_ALTSTAT].offset = 14;
131 }
132 else {
133 rid = ATA_ALTADDR_RID;
134 altio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
135 ATA_ALTIOSIZE, RF_ACTIVE);
136 if (!altio) {

--- 19 unchanged lines hidden (view full) ---

156ata_pccard_detach(device_t dev)
157{
158 struct ata_channel *ch = device_get_softc(dev);
159 int i;
160
161 free(ch->device[MASTER].param, M_ATA);
162 ch->device[MASTER].param = NULL;
163 ata_detach(dev);
128 ch->r_io[ATA_ALTSTAT].res = io;
129 ch->r_io[ATA_ALTSTAT].offset = 14;
130 }
131 else {
132 rid = ATA_ALTADDR_RID;
133 altio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
134 ATA_ALTIOSIZE, RF_ACTIVE);
135 if (!altio) {

--- 19 unchanged lines hidden (view full) ---

155ata_pccard_detach(device_t dev)
156{
157 struct ata_channel *ch = device_get_softc(dev);
158 int i;
159
160 free(ch->device[MASTER].param, M_ATA);
161 ch->device[MASTER].param = NULL;
162 ata_detach(dev);
164 bus_release_resource(dev, SYS_RES_IOPORT,
165 ATA_ALTADDR_RID, ch->r_io[ATA_ALTSTAT].res);
166 bus_release_resource(dev, SYS_RES_IOPORT,
167 ATA_IOADDR_RID, ch->r_io[ATA_DATA].res);
163 if (ch->r_io[ATA_ALTSTAT].res != ch->r_io[ATA_DATA].res)
164 bus_release_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID,
165 ch->r_io[ATA_ALTSTAT].res);
166 bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID,
167 ch->r_io[ATA_DATA].res);
168 for (i = ATA_DATA; i < ATA_MAX_RES; i++)
169 ch->r_io[i].res = NULL;
170 return 0;
171}
172
173static device_method_t ata_pccard_methods[] = {
174 /* device interface */
175 DEVMETHOD(device_probe, pccard_compat_probe),

--- 17 unchanged lines hidden ---
168 for (i = ATA_DATA; i < ATA_MAX_RES; i++)
169 ch->r_io[i].res = NULL;
170 return 0;
171}
172
173static device_method_t ata_pccard_methods[] = {
174 /* device interface */
175 DEVMETHOD(device_probe, pccard_compat_probe),

--- 17 unchanged lines hidden ---