[PATCH] pcmcia: remove duplicate fields in io_window_t

BasePort, NumPorts and Attributes are or can be embedded in
struct resource, so remove them.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
Dominik Brodowski 2006-01-15 08:04:43 +01:00
parent 0e0fad8f71
commit c7d006935d
2 changed files with 22 additions and 25 deletions

View File

@ -88,7 +88,7 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base,
} }
if ((s->features & SS_CAP_STATIC_MAP) && s->io_offset) { if ((s->features & SS_CAP_STATIC_MAP) && s->io_offset) {
*base = s->io_offset | (*base & 0x0fff); *base = s->io_offset | (*base & 0x0fff);
s->io[0].Attributes = attr; s->io[0].res->flags = (s->io[0].res->flags & ~IORESOURCE_BITS) | (attr & IORESOURCE_BITS);
return 0; return 0;
} }
/* Check for an already-allocated window that must conflict with /* Check for an already-allocated window that must conflict with
@ -96,38 +96,36 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base,
* potential conflicts, just the most obvious ones. * potential conflicts, just the most obvious ones.
*/ */
for (i = 0; i < MAX_IO_WIN; i++) for (i = 0; i < MAX_IO_WIN; i++)
if ((s->io[i].NumPorts != 0) && if ((s->io[i].res) &&
((s->io[i].BasePort & (align-1)) == *base)) ((s->io[i].res->start & (align-1)) == *base))
return 1; return 1;
for (i = 0; i < MAX_IO_WIN; i++) { for (i = 0; i < MAX_IO_WIN; i++) {
if (s->io[i].NumPorts == 0) { if (!s->io[i].res) {
s->io[i].res = pcmcia_find_io_region(*base, num, align, s); s->io[i].res = pcmcia_find_io_region(*base, num, align, s);
if (s->io[i].res) { if (s->io[i].res) {
s->io[i].Attributes = attr; *base = s->io[i].res->start;
s->io[i].BasePort = *base = s->io[i].res->start; s->io[i].res->flags = (s->io[i].res->flags & ~IORESOURCE_BITS) | (attr & IORESOURCE_BITS);
s->io[i].NumPorts = s->io[i].InUse = num; s->io[i].InUse = num;
break; break;
} else } else
return 1; return 1;
} else if (s->io[i].Attributes != attr) } else if ((s->io[i].res->flags & IORESOURCE_BITS) != (attr & IORESOURCE_BITS))
continue; continue;
/* Try to extend top of window */ /* Try to extend top of window */
try = s->io[i].BasePort + s->io[i].NumPorts; try = s->io[i].res->end + 1;
if ((*base == 0) || (*base == try)) if ((*base == 0) || (*base == try))
if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start, if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start,
s->io[i].res->end + num, s) == 0) { s->io[i].res->end + num, s) == 0) {
*base = try; *base = try;
s->io[i].NumPorts += num;
s->io[i].InUse += num; s->io[i].InUse += num;
break; break;
} }
/* Try to extend bottom of window */ /* Try to extend bottom of window */
try = s->io[i].BasePort - num; try = s->io[i].res->start - num;
if ((*base == 0) || (*base == try)) if ((*base == 0) || (*base == try))
if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start - num, if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start - num,
s->io[i].res->end, s) == 0) { s->io[i].res->end, s) == 0) {
s->io[i].BasePort = *base = try; *base = try;
s->io[i].NumPorts += num;
s->io[i].InUse += num; s->io[i].InUse += num;
break; break;
} }
@ -142,12 +140,13 @@ static void release_io_space(struct pcmcia_socket *s, ioaddr_t base,
int i; int i;
for (i = 0; i < MAX_IO_WIN; i++) { for (i = 0; i < MAX_IO_WIN; i++) {
if ((s->io[i].BasePort <= base) && if (!s->io[i].res)
(s->io[i].BasePort+s->io[i].NumPorts >= base+num)) { continue;
if ((s->io[i].res->start <= base) &&
(s->io[i].res->end >= base+num-1)) {
s->io[i].InUse -= num; s->io[i].InUse -= num;
/* Free the window if no one else is using it */ /* Free the window if no one else is using it */
if (s->io[i].InUse == 0) { if (s->io[i].InUse == 0) {
s->io[i].NumPorts = 0;
release_resource(s->io[i].res); release_resource(s->io[i].res);
kfree(s->io[i].res); kfree(s->io[i].res);
s->io[i].res = NULL; s->io[i].res = NULL;
@ -224,8 +223,8 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
config->AssignedIRQ = s->irq.AssignedIRQ; config->AssignedIRQ = s->irq.AssignedIRQ;
if (config->AssignedIRQ) if (config->AssignedIRQ)
config->Attributes |= CONF_ENABLE_IRQ; config->Attributes |= CONF_ENABLE_IRQ;
config->BasePort1 = s->io[0].BasePort; config->BasePort1 = s->io[0].res->start;
config->NumPorts1 = s->io[0].NumPorts; config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1;
} }
return CS_SUCCESS; return CS_SUCCESS;
} }
@ -468,7 +467,7 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
} }
if (c->state & CONFIG_IO_REQ) if (c->state & CONFIG_IO_REQ)
for (i = 0; i < MAX_IO_WIN; i++) { for (i = 0; i < MAX_IO_WIN; i++) {
if (s->io[i].NumPorts == 0) if (!s->io[i].res)
continue; continue;
s->io[i].Config--; s->io[i].Config--;
if (s->io[i].Config != 0) if (s->io[i].Config != 0)
@ -679,10 +678,10 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
if (c->state & CONFIG_IO_REQ) { if (c->state & CONFIG_IO_REQ) {
iomap.speed = io_speed; iomap.speed = io_speed;
for (i = 0; i < MAX_IO_WIN; i++) for (i = 0; i < MAX_IO_WIN; i++)
if (s->io[i].NumPorts != 0) { if (s->io[i].res) {
iomap.map = i; iomap.map = i;
iomap.flags = MAP_ACTIVE; iomap.flags = MAP_ACTIVE;
switch (s->io[i].Attributes & IO_DATA_PATH_WIDTH) { switch (s->io[i].res->flags & IO_DATA_PATH_WIDTH) {
case IO_DATA_PATH_WIDTH_16: case IO_DATA_PATH_WIDTH_16:
iomap.flags |= MAP_16BIT; break; iomap.flags |= MAP_16BIT; break;
case IO_DATA_PATH_WIDTH_AUTO: case IO_DATA_PATH_WIDTH_AUTO:
@ -690,8 +689,8 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
default: default:
break; break;
} }
iomap.start = s->io[i].BasePort; iomap.start = s->io[i].res->start;
iomap.stop = iomap.start + s->io[i].NumPorts - 1; iomap.stop = s->io[i].res->end;
s->ops->set_io_map(s, &iomap); s->ops->set_io_map(s, &iomap);
s->io[i].Config++; s->io[i].Config++;
} }

View File

@ -153,8 +153,6 @@ extern struct pccard_resource_ops pccard_nonstatic_ops;
struct pcmcia_socket; struct pcmcia_socket;
typedef struct io_window_t { typedef struct io_window_t {
u_int Attributes;
kio_addr_t BasePort, NumPorts;
kio_addr_t InUse, Config; kio_addr_t InUse, Config;
struct resource *res; struct resource *res;
} io_window_t; } io_window_t;