[PATCH] pcmcia: access config_t using pointer instead of array
Access the PCMCIA config_t struct (one per device function) using
a pointer in struct pcmcia_device, instead of looking them up in
an array.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index 2b267de..f889a44 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -94,12 +94,6 @@
}
}
-#define CHECK_SOCKET(s) \
- (((s) >= sockets) || (socket_table[s]->ops == NULL))
-
-#define SOCKET(h) (h->socket)
-#define CONFIG(h) (&SOCKET(h)->config[(h)->func])
-
/* In cardbus.c */
int cb_alloc(struct pcmcia_socket *s);
void cb_free(struct pcmcia_socket *s);
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index a4333a8..5166f00 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -399,6 +399,7 @@
goto put_module;
}
}
+ p_dev->function_config = &s->config[p_dev->func];
ret = p_drv->probe(p_dev);
if (ret)
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index f588145..11a94d9 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -372,9 +372,7 @@
int pcmcia_get_status(client_handle_t handle, cs_status_t *status)
{
- struct pcmcia_socket *s;
- s = SOCKET(handle);
- return pccard_get_status(s, handle->func, status);
+ return pccard_get_status(handle->socket, handle->func, status);
}
EXPORT_SYMBOL(pcmcia_get_status);
@@ -422,7 +420,8 @@
config_t *c;
s = p_dev->socket;
- c = CONFIG(p_dev);
+ c = p_dev->function_config;
+
if (!(s->state & SOCKET_PRESENT))
return CS_NO_CARD;
if (!(c->state & CONFIG_LOCKED))
@@ -470,7 +469,7 @@
p_dev->state &= ~CLIENT_CONFIG_LOCKED;
if (!(p_dev->state & CLIENT_STALE)) {
- config_t *c = CONFIG(p_dev);
+ config_t *c = p_dev->function_config;
if (--(s->lock_count) == 0) {
s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */
s->socket.Vpp = 0;
@@ -512,7 +511,7 @@
p_dev->state &= ~CLIENT_IO_REQ;
if (!(p_dev->state & CLIENT_STALE)) {
- config_t *c = CONFIG(p_dev);
+ config_t *c = p_dev->function_config;
if (c->state & CONFIG_LOCKED)
return CS_CONFIGURATION_LOCKED;
if ((c->io.BasePort1 != req->BasePort1) ||
@@ -540,7 +539,7 @@
p_dev->state &= ~CLIENT_IRQ_REQ;
if (!(p_dev->state & CLIENT_STALE)) {
- config_t *c = CONFIG(p_dev);
+ config_t *c= p_dev->function_config;
if (c->state & CONFIG_LOCKED)
return CS_CONFIGURATION_LOCKED;
if (c->irq.Attributes != req->Attributes)
@@ -610,7 +609,7 @@
if (req->IntType & INT_CARDBUS)
return CS_UNSUPPORTED_MODE;
- c = CONFIG(p_dev);
+ c = p_dev->function_config;
if (c->state & CONFIG_LOCKED)
return CS_CONFIGURATION_LOCKED;
@@ -730,7 +729,7 @@
if (!req)
return CS_UNSUPPORTED_MODE;
- c = CONFIG(p_dev);
+ c = p_dev->function_config;
if (c->state & CONFIG_LOCKED)
return CS_CONFIGURATION_LOCKED;
if (c->state & CONFIG_IO_REQ)
@@ -786,7 +785,7 @@
if (!(s->state & SOCKET_PRESENT))
return CS_NO_CARD;
- c = CONFIG(p_dev);
+ c = p_dev->function_config;
if (c->state & CONFIG_LOCKED)
return CS_CONFIGURATION_LOCKED;
if (c->state & CONFIG_IRQ_REQ)
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index 8e2a963..ac11fb1 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -131,6 +131,7 @@
struct pcmcia_socket;
+struct config_t;
struct pcmcia_driver {
int (*probe) (struct pcmcia_device *dev);
@@ -160,6 +161,7 @@
/* the hardware "function" device; certain subdevices can
* share one hardware "function" device. */
u8 func;
+ struct config_t* function_config;
struct list_head socket_device_list;