diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-03-30 12:07:50 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-05-10 04:23:23 -0400 |
commit | 059f667d9f81082e94dead14ff3fa7b3b42c98a0 (patch) | |
tree | abd97312659c44cd05dc8b1bf5bc0bb6fba832c2 /drivers/pcmcia/pcmcia_resource.c | |
parent | a60f22c4af3382b86301d64d6a9d68f30191d4c9 (diff) |
pcmcia: call pcmcia_{read,write}_cis_mem with ops_mutex held
This avoids multiple lock takings in several codepaths.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/pcmcia_resource.c')
-rw-r--r-- | drivers/pcmcia/pcmcia_resource.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index c6419c18a6c8..29f91fac1dff 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c | |||
@@ -123,6 +123,7 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, | |||
123 | config_t *c; | 123 | config_t *c; |
124 | int addr; | 124 | int addr; |
125 | u_char val; | 125 | u_char val; |
126 | int ret = 0; | ||
126 | 127 | ||
127 | if (!p_dev || !p_dev->function_config) | 128 | if (!p_dev || !p_dev->function_config) |
128 | return -EINVAL; | 129 | return -EINVAL; |
@@ -139,11 +140,10 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, | |||
139 | } | 140 | } |
140 | 141 | ||
141 | addr = (c->ConfigBase + reg->Offset) >> 1; | 142 | addr = (c->ConfigBase + reg->Offset) >> 1; |
142 | mutex_unlock(&s->ops_mutex); | ||
143 | 143 | ||
144 | switch (reg->Action) { | 144 | switch (reg->Action) { |
145 | case CS_READ: | 145 | case CS_READ: |
146 | pcmcia_read_cis_mem(s, 1, addr, 1, &val); | 146 | ret = pcmcia_read_cis_mem(s, 1, addr, 1, &val); |
147 | reg->Value = val; | 147 | reg->Value = val; |
148 | break; | 148 | break; |
149 | case CS_WRITE: | 149 | case CS_WRITE: |
@@ -152,10 +152,11 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, | |||
152 | break; | 152 | break; |
153 | default: | 153 | default: |
154 | dev_dbg(&s->dev, "Invalid conf register request\n"); | 154 | dev_dbg(&s->dev, "Invalid conf register request\n"); |
155 | return -EINVAL; | 155 | ret = -EINVAL; |
156 | break; | 156 | break; |
157 | } | 157 | } |
158 | return 0; | 158 | mutex_unlock(&s->ops_mutex); |
159 | return ret; | ||
159 | } /* pcmcia_access_configuration_register */ | 160 | } /* pcmcia_access_configuration_register */ |
160 | EXPORT_SYMBOL(pcmcia_access_configuration_register); | 161 | EXPORT_SYMBOL(pcmcia_access_configuration_register); |
161 | 162 | ||
@@ -436,7 +437,6 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, | |||
436 | s->socket.io_irq = 0; | 437 | s->socket.io_irq = 0; |
437 | s->ops->set_socket(s, &s->socket); | 438 | s->ops->set_socket(s, &s->socket); |
438 | s->lock_count++; | 439 | s->lock_count++; |
439 | mutex_unlock(&s->ops_mutex); | ||
440 | 440 | ||
441 | /* Set up CIS configuration registers */ | 441 | /* Set up CIS configuration registers */ |
442 | base = c->ConfigBase = req->ConfigBase; | 442 | base = c->ConfigBase = req->ConfigBase; |
@@ -485,7 +485,6 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, | |||
485 | 485 | ||
486 | /* Configure I/O windows */ | 486 | /* Configure I/O windows */ |
487 | if (c->state & CONFIG_IO_REQ) { | 487 | if (c->state & CONFIG_IO_REQ) { |
488 | mutex_lock(&s->ops_mutex); | ||
489 | iomap.speed = io_speed; | 488 | iomap.speed = io_speed; |
490 | for (i = 0; i < MAX_IO_WIN; i++) | 489 | for (i = 0; i < MAX_IO_WIN; i++) |
491 | if (s->io[i].res) { | 490 | if (s->io[i].res) { |
@@ -504,11 +503,11 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, | |||
504 | s->ops->set_io_map(s, &iomap); | 503 | s->ops->set_io_map(s, &iomap); |
505 | s->io[i].Config++; | 504 | s->io[i].Config++; |
506 | } | 505 | } |
507 | mutex_unlock(&s->ops_mutex); | ||
508 | } | 506 | } |
509 | 507 | ||
510 | c->state |= CONFIG_LOCKED; | 508 | c->state |= CONFIG_LOCKED; |
511 | p_dev->_locked = 1; | 509 | p_dev->_locked = 1; |
510 | mutex_unlock(&s->ops_mutex); | ||
512 | return 0; | 511 | return 0; |
513 | } /* pcmcia_request_configuration */ | 512 | } /* pcmcia_request_configuration */ |
514 | EXPORT_SYMBOL(pcmcia_request_configuration); | 513 | EXPORT_SYMBOL(pcmcia_request_configuration); |