Commit 153fef7f authored by Russell King's avatar Russell King

[PCMCIA] 02-validatemem

Move validate_mem() so we don't recurse.  We call this function from
the DS_GET_FIRST_TUPLE and DS_VALIDATE_CIS calls, which are the the
first two functions which may be called by cardmgr or cardctl which
require CIS access.
parent 90f346a7
......@@ -107,7 +107,6 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag
pccard_mem_map *mem = &s->cis_mem;
if (!(s->features & SS_CAP_STATIC_MAP) &&
mem->sys_start == 0) {
validate_mem(s);
mem->sys_start = 0;
if (find_mem_region(&mem->sys_start, s->map_size,
s->map_size, 0, "card services", s)) {
......
......@@ -180,7 +180,7 @@ int write_memory(memory_handle_t handle, mem_op_t *req, caddr_t buf);
int copy_memory(memory_handle_t handle, copy_op_t *req);
/* In rsrc_mgr */
void validate_mem(struct pcmcia_socket *s);
void pcmcia_validate_mem(struct pcmcia_socket *s);
struct resource *find_io_region(unsigned long base, int num, unsigned long align,
char *name, struct pcmcia_socket *s);
int adjust_io_region(struct resource *res, unsigned long r_start,
......
......@@ -941,6 +941,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
ret = pcmcia_get_configuration_info(s->handle, &buf.config);
break;
case DS_GET_FIRST_TUPLE:
pcmcia_validate_mem(s->parent);
ret = pcmcia_get_first_tuple(s->handle, &buf.tuple);
break;
case DS_GET_NEXT_TUPLE:
......@@ -962,6 +963,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
ret = pcmcia_get_status(s->handle, &buf.status);
break;
case DS_VALIDATE_CIS:
pcmcia_validate_mem(s->parent);
ret = pcmcia_validate_cis(s->handle, &buf.cisinfo);
break;
case DS_SUSPEND_CARD:
......
......@@ -454,7 +454,7 @@ static u_long inv_probe(resource_map_t *m, struct pcmcia_socket *s)
return do_mem_probe(m->base, m->num, s);
}
void validate_mem(struct pcmcia_socket *s)
static void validate_mem(struct pcmcia_socket *s)
{
resource_map_t *m, mm;
static u_char order[] = { 0xd0, 0xe0, 0xc0, 0xf0 };
......@@ -462,9 +462,6 @@ void validate_mem(struct pcmcia_socket *s)
u_long b, i, ok = 0;
int force_low = !(s->features & SS_CAP_PAGE_REGS);
if (!probe_mem)
return;
down(&rsrc_sem);
/* We do up to four passes through the list */
if (!force_low) {
......@@ -500,12 +497,12 @@ void validate_mem(struct pcmcia_socket *s)
#else /* CONFIG_PCMCIA_PROBE */
void validate_mem(struct pcmcia_socket *s)
static void validate_mem(struct pcmcia_socket *s)
{
resource_map_t *m, mm;
static int done = 0;
if (probe_mem && done++ == 0) {
if (done++ == 0) {
down(&rsrc_sem);
for (m = mem_db.next; m != &mem_db; m = mm.next) {
mm = *m;
......@@ -518,6 +515,18 @@ void validate_mem(struct pcmcia_socket *s)
#endif /* CONFIG_PCMCIA_PROBE */
void pcmcia_validate_mem(struct pcmcia_socket *s)
{
down(&s->skt_sem);
if (probe_mem && s->state & SOCKET_PRESENT)
validate_mem(s);
up(&s->skt_sem);
}
EXPORT_SYMBOL(pcmcia_validate_mem);
struct pcmcia_align_data {
unsigned long mask;
unsigned long offset;
......
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