Skip to content

Commit

Permalink
[PATCH] pcmcia: remove duplicate fields in io_window_t
Browse files Browse the repository at this point in the history
BasePort, NumPorts and Attributes are or can be embedded in
struct resource, so remove them.

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
  • Loading branch information
Dominik Brodowski committed Mar 31, 2006
1 parent 0e0fad8 commit c7d0069
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
45 changes: 22 additions & 23 deletions drivers/pcmcia/pcmcia_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,46 +88,44 @@ 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) {
*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;
}
/* Check for an already-allocated window that must conflict with
* what was asked for. It is a hack because it does not catch all
* potential conflicts, just the most obvious ones.
*/
for (i = 0; i < MAX_IO_WIN; i++)
if ((s->io[i].NumPorts != 0) &&
((s->io[i].BasePort & (align-1)) == *base))
if ((s->io[i].res) &&
((s->io[i].res->start & (align-1)) == *base))
return 1;
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);
if (s->io[i].res) {
s->io[i].Attributes = attr;
s->io[i].BasePort = *base = s->io[i].res->start;
s->io[i].NumPorts = s->io[i].InUse = num;
*base = s->io[i].res->start;
s->io[i].res->flags = (s->io[i].res->flags & ~IORESOURCE_BITS) | (attr & IORESOURCE_BITS);
s->io[i].InUse = num;
break;
} else
return 1;
} else if (s->io[i].Attributes != attr)
} else if ((s->io[i].res->flags & IORESOURCE_BITS) != (attr & IORESOURCE_BITS))
continue;
/* 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 (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start,
s->io[i].res->end + num, s) == 0) {
*base = try;
s->io[i].NumPorts += num;
s->io[i].InUse += num;
break;
}
/* 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 (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start - num,
s->io[i].res->end, s) == 0) {
s->io[i].BasePort = *base = try;
s->io[i].NumPorts += num;
*base = try;
s->io[i].InUse += num;
break;
}
Expand All @@ -142,12 +140,13 @@ static void release_io_space(struct pcmcia_socket *s, ioaddr_t base,
int i;

for (i = 0; i < MAX_IO_WIN; i++) {
if ((s->io[i].BasePort <= base) &&
(s->io[i].BasePort+s->io[i].NumPorts >= base+num)) {
if (!s->io[i].res)
continue;
if ((s->io[i].res->start <= base) &&
(s->io[i].res->end >= base+num-1)) {
s->io[i].InUse -= num;
/* Free the window if no one else is using it */
if (s->io[i].InUse == 0) {
s->io[i].NumPorts = 0;
release_resource(s->io[i].res);
kfree(s->io[i].res);
s->io[i].res = NULL;
Expand Down Expand Up @@ -224,8 +223,8 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
config->AssignedIRQ = s->irq.AssignedIRQ;
if (config->AssignedIRQ)
config->Attributes |= CONF_ENABLE_IRQ;
config->BasePort1 = s->io[0].BasePort;
config->NumPorts1 = s->io[0].NumPorts;
config->BasePort1 = s->io[0].res->start;
config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1;
}
return CS_SUCCESS;
}
Expand Down Expand Up @@ -468,7 +467,7 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
}
if (c->state & CONFIG_IO_REQ)
for (i = 0; i < MAX_IO_WIN; i++) {
if (s->io[i].NumPorts == 0)
if (!s->io[i].res)
continue;
s->io[i].Config--;
if (s->io[i].Config != 0)
Expand Down Expand Up @@ -679,19 +678,19 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
if (c->state & CONFIG_IO_REQ) {
iomap.speed = io_speed;
for (i = 0; i < MAX_IO_WIN; i++)
if (s->io[i].NumPorts != 0) {
if (s->io[i].res) {
iomap.map = i;
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:
iomap.flags |= MAP_16BIT; break;
case IO_DATA_PATH_WIDTH_AUTO:
iomap.flags |= MAP_AUTOSZ; break;
default:
break;
}
iomap.start = s->io[i].BasePort;
iomap.stop = iomap.start + s->io[i].NumPorts - 1;
iomap.start = s->io[i].res->start;
iomap.stop = s->io[i].res->end;
s->ops->set_io_map(s, &iomap);
s->io[i].Config++;
}
Expand Down
2 changes: 0 additions & 2 deletions include/pcmcia/ss.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ extern struct pccard_resource_ops pccard_nonstatic_ops;
struct pcmcia_socket;

typedef struct io_window_t {
u_int Attributes;
kio_addr_t BasePort, NumPorts;
kio_addr_t InUse, Config;
struct resource *res;
} io_window_t;
Expand Down

0 comments on commit c7d0069

Please sign in to comment.