Commit 2941bfd0 authored by Russell King's avatar Russell King

[PCMCIA] Allow socket drivers call pcmcia_parse_events directly.

Remove register_callback methods.  Instead, allow socket drivers
pass their events directly into cs.c via pcmcia_parse_events().
parent 67c72fb5
......@@ -231,11 +231,6 @@ static const lookup_t service_table[] = {
======================================================================*/
static int register_callback(struct pcmcia_socket *s, void (*handler)(void *, unsigned int), void * info)
{
return s->ss_entry->register_callback(s, handler, info);
}
static int get_socket_status(struct pcmcia_socket *s, int *val)
{
return s->ss_entry->get_status(s, val);
......@@ -356,6 +351,7 @@ static int pcmcia_add_socket(struct class_device *class_dev)
wait_for_completion(&socket->thread_done);
BUG_ON(!socket->thread);
pcmcia_parse_events(socket, SS_DETECT);
return 0;
}
......@@ -872,16 +868,14 @@ static int pccardd(void *__skt)
complete_and_exit(&skt->thread_done, 0);
}
static void parse_events(void *info, u_int events)
void pcmcia_parse_events(struct pcmcia_socket *s, u_int events)
{
struct pcmcia_socket *s = info;
spin_lock(&s->thread_lock);
s->thread_events |= events;
spin_unlock(&s->thread_lock);
wake_up(&s->thread_wait);
} /* parse_events */
} /* pcmcia_parse_events */
/*======================================================================
......@@ -1142,9 +1136,6 @@ int pcmcia_deregister_client(client_handle_t handle)
handle->event_handler = NULL;
}
if (--s->real_clients == 0)
register_callback(s, NULL, NULL);
return CS_SUCCESS;
} /* deregister_client */
......@@ -1559,11 +1550,6 @@ int pcmcia_register_client(client_handle_t *handle, client_reg_t *req)
if (client == NULL)
return CS_OUT_OF_RESOURCE;
if (++s->real_clients == 1) {
register_callback(s, &parse_events, s);
parse_events(s, SS_DETECT);
}
*handle = client;
client->state &= ~CLIENT_UNBOUND;
client->Socket = s;
......@@ -2532,6 +2518,7 @@ EXPORT_SYMBOL(pcmcia_write_memory);
EXPORT_SYMBOL(dead_socket);
EXPORT_SYMBOL(CardServices);
EXPORT_SYMBOL(MTDHelperEntry);
EXPORT_SYMBOL(pcmcia_parse_events);
struct class pcmcia_socket_class = {
.name = "pcmcia_socket",
......
......@@ -66,7 +66,6 @@ static struct pci_driver i82092aa_pci_drv = {
static struct pccard_operations i82092aa_operations = {
.init = i82092aa_init,
.suspend = i82092aa_suspend,
.register_callback = i82092aa_register_callback,
.get_status = i82092aa_get_status,
.get_socket = i82092aa_get_socket,
.set_socket = i82092aa_set_socket,
......@@ -86,10 +85,6 @@ struct socket_info {
unsigned int pending_events; /* Pending events on this interface */
void (*handler)(void *info, u_int events);
/* callback to the driver of the card */
void *info; /* to be passed to the handler */
struct pcmcia_socket socket;
struct pci_dev *dev; /* The PCI device for the socket */
};
......@@ -332,8 +327,8 @@ static void i82092aa_bh(void *dummy)
for (i=0; i < socket_count; i++) {
events = xchg(&(sockets[i].pending_events),0);
printk("events = %x \n",events);
if (sockets[i].handler)
sockets[i].handler(sockets[i].info, events);
if (events)
pcmcia_parse_events(&sockets[i].socket, events);
}
}
......@@ -367,8 +362,7 @@ static irqreturn_t i82092aa_interrupt(int irq, void *dev, struct pt_regs *regs)
csc = indirect_read(i,I365_CSC); /* card status change register */
if ((csc==0) || /* no events on this socket */
(sockets[i].handler==NULL)) /* no way to handle events */
if (csc==0) /* no events on this socket */
continue;
handled = 1;
events = 0;
......@@ -475,16 +469,6 @@ static int i82092aa_suspend(struct pcmcia_socket *sock)
return retval;
}
static int i82092aa_register_callback(struct pcmcia_socket *socket, void (*handler)(void *, unsigned int), void * info)
{
unsigned int sock = container_of(socket, struct socket_info, socket)->number;
enter("i82092aa_register_callback");
sockets[sock].handler = handler;
sockets[sock].info = info;
leave("i82092aa_register_callback");
return 0;
} /* i82092aa_register_callback */
static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value)
{
unsigned int sock = container_of(socket, struct socket_info, socket)->number;
......
......@@ -35,7 +35,6 @@ static int i82092aa_set_io_map(struct pcmcia_socket *socket, struct pccard_io_ma
static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_map *mem);
static int i82092aa_init(struct pcmcia_socket *socket);
static int i82092aa_suspend(struct pcmcia_socket *socket);
static int i82092aa_register_callback(struct pcmcia_socket *socket, void (*handler)(void *, unsigned int), void * info);
#endif
......@@ -164,8 +164,6 @@ struct i82365_socket {
ioaddr_t ioaddr;
u_short psock;
u_char cs_irq, intr;
void (*handler)(void *info, u_int events);
void *info;
union {
cirrus_state_t cirrus;
vg46x_state_t vg46x;
......@@ -883,8 +881,8 @@ static void pcic_bh(void *dummy)
*/
if (events & SS_DETECT)
mdelay(4);
if (socket[i].handler)
socket[i].handler(socket[i].info, events);
if (events)
pcmcia_parse_events(&socket[i].socket, events);
}
}
......@@ -911,8 +909,7 @@ static irqreturn_t pcic_interrupt(int irq, void *dev,
handled = 1;
ISA_LOCK(i, flags);
csc = i365_get(i, I365_CSC);
if ((csc == 0) || (!socket[i].handler) ||
(i365_get(i, I365_IDENT) & 0x70)) {
if ((csc == 0) || (i365_get(i, I365_IDENT) & 0x70)) {
ISA_UNLOCK(i, flags);
continue;
}
......@@ -968,16 +965,6 @@ static void pcic_interrupt_wrapper(u_long data)
/*====================================================================*/
static int pcic_register_callback(struct pcmcia_socket *s, void (*handler)(void *, unsigned int), void * info)
{
unsigned int sock = container_of(s, struct i82365_socket, socket)->number;
socket[sock].handler = handler;
socket[sock].info = info;
return 0;
} /* pcic_register_callback */
/*====================================================================*/
static int i365_get_status(u_short sock, u_int *value)
{
u_int status;
......@@ -1402,7 +1389,6 @@ static int pcic_suspend(struct pcmcia_socket *sock)
static struct pccard_operations pcic_operations = {
.init = pcic_init,
.suspend = pcic_suspend,
.register_callback = pcic_register_callback,
.get_status = pcic_get_status,
.get_socket = pcic_get_socket,
.set_socket = pcic_set_socket,
......
......@@ -295,8 +295,8 @@ static void sa1100_pcmcia_task_handler(void *data)
events & SS_BATWARN ? "BATWARN " : "",
events & SS_STSCHG ? "STSCHG " : "");
if (events && skt->handler != NULL)
skt->handler(skt->handler_info, events);
if (events)
pcmcia_parse_events(&skt->socket, events);
} while (events);
}
......@@ -335,36 +335,6 @@ static irqreturn_t sa1100_pcmcia_interrupt(int irq, void *dev, struct pt_regs *r
return IRQ_HANDLED;
}
/* sa1100_pcmcia_register_callback()
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* Implements the register_callback() operation for the in-kernel
* PCMCIA service (formerly SS_RegisterCallback in Card Services). If
* the function pointer `handler' is not NULL, remember the callback
* location in the state for `sock', and increment the usage counter
* for the driver module. (The callback is invoked from the interrupt
* service routine, sa1100_pcmcia_interrupt(), to notify Card Services
* of interesting events.) Otherwise, clear the callback pointer in the
* socket state and decrement the module usage count.
*
* Returns: 0
*/
static int
sa1100_pcmcia_register_callback(struct pcmcia_socket *sock,
void (*handler)(void *, unsigned int),
void *info)
{
struct sa1100_pcmcia_socket *skt = to_sa1100_socket(sock);
if (handler) {
skt->handler_info = info;
skt->handler = handler;
} else {
skt->handler = NULL;
}
return 0;
}
/* sa1100_pcmcia_get_status()
* ^^^^^^^^^^^^^^^^^^^^^^^^^^
......@@ -654,7 +624,6 @@ static CLASS_DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
static struct pccard_operations sa11xx_pcmcia_operations = {
.init = sa1100_pcmcia_sock_init,
.suspend = sa1100_pcmcia_suspend,
.register_callback = sa1100_pcmcia_register_callback,
.get_status = sa1100_pcmcia_get_status,
.get_socket = sa1100_pcmcia_get_socket,
.set_socket = sa1100_pcmcia_set_socket,
......
......@@ -59,8 +59,6 @@ struct sa1100_pcmcia_socket {
unsigned int status;
socket_state_t cs_state;
void (*handler)(void *, unsigned int);
void *handler_info;
unsigned short spd_io[MAX_IO_WIN];
unsigned short spd_mem[MAX_WIN];
......
......@@ -116,8 +116,6 @@ static struct pccard_operations tcic_operations;
struct tcic_socket {
u_short psock;
void (*handler)(void *info, u_int events);
void *info;
u_char last_sstat;
u_char id;
struct pcmcia_socket socket;
......@@ -433,8 +431,6 @@ static int __init init_tcic(void)
for (i = 0; i < sock; i++) {
if ((i == ignore) || is_active(i)) continue;
socket_table[sockets].psock = i;
socket_table[sockets].handler = NULL;
socket_table[sockets].info = NULL;
socket_table[sockets].id = get_tcic_id();
socket_table[sockets].socket.owner = THIS_MODULE;
......@@ -572,8 +568,8 @@ static void tcic_bh(void *dummy)
events = pending_events[i];
pending_events[i] = 0;
spin_unlock_irq(&pending_event_lock);
if (socket_table[i].handler)
socket_table[i].handler(socket_table[i].info, events);
if (events)
pcmcia_parse_events(&socket_table[i].socket, events);
}
}
......@@ -606,7 +602,7 @@ static irqreturn_t tcic_interrupt(int irq, void *dev, struct pt_regs *regs)
tcic_setb(TCIC_ICSR, TCIC_ICSR_CLEAR);
quick = 1;
}
if ((latch == 0) || (socket_table[psock].handler == NULL))
if (latch == 0)
continue;
events = (latch & TCIC_SSTAT_CD) ? SS_DETECT : 0;
events |= (latch & TCIC_SSTAT_WP) ? SS_WRPROT : 0;
......@@ -646,16 +642,6 @@ static void tcic_timer(u_long data)
/*====================================================================*/
static int tcic_register_callback(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info)
{
u_short psock = container_of(sock, struct tcic_socket, socket)->psock;
socket_table[psock].handler = handler;
socket_table[psock].info = info;
return 0;
} /* tcic_register_callback */
/*====================================================================*/
static int tcic_get_status(struct pcmcia_socket *sock, u_int *value)
{
u_short psock = container_of(sock, struct tcic_socket, socket)->psock;
......@@ -918,7 +904,6 @@ static int tcic_suspend(struct pcmcia_socket *sock)
static struct pccard_operations tcic_operations = {
.init = tcic_init,
.suspend = tcic_suspend,
.register_callback = tcic_register_callback,
.get_status = tcic_get_status,
.get_socket = tcic_get_socket,
.set_socket = tcic_set_socket,
......
......@@ -429,8 +429,8 @@ static void yenta_bh(void *data)
events = socket->events;
socket->events = 0;
spin_unlock_irq(&socket->event_lock);
if (socket->handler)
socket->handler(socket->info, events);
if (events)
pcmcia_parse_events(&socket->socket, events);
}
static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
......@@ -771,20 +771,9 @@ static void yenta_close(struct pci_dev *dev)
}
static int yenta_register_callback(struct pcmcia_socket *sock, void (*handler)(void *, unsigned int), void * info)
{
struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
socket->handler = handler;
socket->info = info;
return 0;
}
static struct pccard_operations yenta_socket_operations = {
.init = yenta_init,
.suspend = yenta_suspend,
.register_callback = yenta_register_callback,
.get_status = yenta_get_status,
.get_socket = yenta_get_socket,
.set_socket = yenta_set_socket,
......
......@@ -99,8 +99,6 @@ struct yenta_socket {
struct pci_dev *dev;
int cb_irq, io_irq;
void *base;
void (*handler)(void *, unsigned int);
void *info;
spinlock_t event_lock;
unsigned int events;
struct work_struct tq_task;
......
......@@ -235,6 +235,7 @@ struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr);
extern void pcmcia_parse_events(struct pcmcia_socket *socket, unsigned int events);
extern int pcmcia_register_socket(struct pcmcia_socket *socket);
extern void pcmcia_unregister_socket(struct pcmcia_socket *socket);
......
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