Commit 147a2746 authored by Dominik Brodowski's avatar Dominik Brodowski

pcmcia: fix up alignf issues

- pcmcia_align() used a "start" variable twice. That's obviously a bad
  idea.

- pcmcia_common_resource() needs the current "start" parameter being
  passed, instead of res->start.

- pcmcia_common_resource() doesn't use the size and align parameters,
  so get rid of those.
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 5e11611a
...@@ -596,19 +596,17 @@ struct pcmcia_align_data { ...@@ -596,19 +596,17 @@ struct pcmcia_align_data {
struct resource_map *map; struct resource_map *map;
}; };
static resource_size_t static resource_size_t pcmcia_common_align(struct pcmcia_align_data *align_data,
pcmcia_common_align(void *align_data, const struct resource *res, resource_size_t start)
resource_size_t size, resource_size_t align)
{ {
struct pcmcia_align_data *data = align_data; resource_size_t ret;
resource_size_t start;
/* /*
* Ensure that we have the correct start address * Ensure that we have the correct start address
*/ */
start = (res->start & ~data->mask) + data->offset; ret = (start & ~align_data->mask) + align_data->offset;
if (start < res->start) if (ret < start)
start += data->mask + 1; ret += align_data->mask + 1;
return start; return ret;
} }
static resource_size_t static resource_size_t
...@@ -619,29 +617,28 @@ pcmcia_align(void *align_data, const struct resource *res, ...@@ -619,29 +617,28 @@ pcmcia_align(void *align_data, const struct resource *res,
struct resource_map *m; struct resource_map *m;
resource_size_t start; resource_size_t start;
start = pcmcia_common_align(data, res, size, align); start = pcmcia_common_align(data, res->start);
for (m = data->map->next; m != data->map; m = m->next) { for (m = data->map->next; m != data->map; m = m->next) {
unsigned long start = m->base; unsigned long map_start = m->base;
unsigned long end = m->base + m->num - 1; unsigned long map_end = m->base + m->num - 1;
/* /*
* If the lower resources are not available, try aligning * If the lower resources are not available, try aligning
* to this entry of the resource database to see if it'll * to this entry of the resource database to see if it'll
* fit here. * fit here.
*/ */
if (res->start < start) { if (start < map_start)
start = pcmcia_common_align(data, res, size, align); start = pcmcia_common_align(data, map_start);
}
/* /*
* If we're above the area which was passed in, there's * If we're above the area which was passed in, there's
* no point proceeding. * no point proceeding.
*/ */
if (res->start >= res->end) if (start >= res->end)
break; break;
if ((res->start + size - 1) <= end) if ((start + size - 1) <= map_end)
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment