/*====================================================================*/
-/* Parameters that can be set with 'insmod' */
-
-/* The old way: bit map of interrupts to choose from */
-/* This means pick from 15, 14, 12, 11, 10, 9, 7, 5, 4, and 3 */
-static u_int irq_mask = 0xdeb8;
-/* Newer, simpler way of listing specific interrupts */
-static int irq_list[4] = { -1 };
-
-MODULE_PARM(irq_mask, "i");
-MODULE_PARM(irq_list, "1-4i");
-
-/*====================================================================*/
-
-/*
- The event() function is this driver's Card Services event handler.
- It will be called by Card Services when an appropriate card status
- event is received. The config() and release() entry points are
- used to configure or release a socket, in response to card
- insertion and ejection events. They are invoked from the das08_pcmcia
- event handler.
-
- Kernel version 2.6.16 upwards uses suspend() and resume() functions
- instead of an event() function.
-*/
-
static void das16cs_pcmcia_config(dev_link_t *link);
static void das16cs_pcmcia_release(u_long arg);
-#ifdef COMEDI_PCMCIA_2_6_16
static int das16cs_pcmcia_suspend(struct pcmcia_device *p_dev);
static int das16cs_pcmcia_resume(struct pcmcia_device *p_dev);
-#else
-static int das16cs_pcmcia_event(event_t event, int priority,
- event_callback_args_t *args);
-#endif
/*
The attach() and detach() entry points are used to create and destroy
needed to manage one actual PCMCIA card.
*/
-#ifdef COMEDI_PCMCIA_2_6_16
static int das16cs_pcmcia_attach(struct pcmcia_device *);
static void das16cs_pcmcia_detach(struct pcmcia_device *);
-#else
-static dev_link_t *das16cs_pcmcia_attach(void);
-static void das16cs_pcmcia_detach(dev_link_t *);
-#endif
/*
You'll also need to prototype all the functions that will actually
======================================================================*/
-#ifdef COMEDI_PCMCIA_2_6_16
static int das16cs_pcmcia_attach(struct pcmcia_device *p_dev)
-#else
-static dev_link_t *das16cs_pcmcia_attach(void)
-#endif
{
local_info_t *local;
dev_link_t *link;
-#ifndef COMEDI_PCMCIA_2_6_16
- client_reg_t client_reg;
- int ret;
-#endif
- int i;
DEBUG(0, "das16cs_pcmcia_attach()\n");
/* Allocate space for private device-specific data */
local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
-#ifdef COMEDI_PCMCIA_2_6_16
if (!local) return -ENOMEM;
-#else
- if (!local) return NULL;
-#endif
memset(local, 0, sizeof(local_info_t));
link = &local->link; link->priv = local;
/* Initialize the dev_link_t structure */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- link->release.function = &das16cs_pcmcia_release;
- link->release.data = (u_long)link;
-#endif
/* Interrupt setup */
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
link->irq.IRQInfo1 = IRQ_INFO2_VALID|IRQ_LEVEL_ID;
- if (irq_list[0] == -1)
- link->irq.IRQInfo2 = irq_mask;
- else
- for (i = 0; i < 4; i++)
- link->irq.IRQInfo2 |= 1 << irq_list[i];
link->irq.Handler = NULL;
/*
link->next = dev_list;
dev_list = link;
-#ifdef COMEDI_PCMCIA_2_6_16
link->handle = p_dev;
p_dev->instance = link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
das16cs_pcmcia_config(link);
return 0;
-#else
- /* Register with Card Services */
- client_reg.dev_info = &dev_info;
- client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
- client_reg.EventMask =
- CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
- CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
- CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
- client_reg.event_handler = &das16cs_pcmcia_event;
-#endif
- client_reg.Version = 0x0210;
- client_reg.event_callback_args.client_data = link;
- ret = pcmcia_register_client(&link->handle, &client_reg);
- if (ret != CS_SUCCESS) {
- cs_error(link->handle, RegisterClient, ret);
- das16cs_pcmcia_detach(link);
- return NULL;
- }
-
- return link;
-#endif
} /* das16cs_pcmcia_attach */
/*======================================================================
======================================================================*/
-#ifdef COMEDI_PCMCIA_2_6_16
static void das16cs_pcmcia_detach(struct pcmcia_device *p_dev)
-#else
-static void das16cs_pcmcia_detach(dev_link_t *link)
-#endif
{
-#ifdef COMEDI_PCMCIA_2_6_16
dev_link_t *link = dev_to_instance(p_dev);
-#endif
dev_link_t **linkp;
DEBUG(0, "das16cs_pcmcia_detach(0x%p)\n", link);
*/
if (link->state & DEV_CONFIG)
{
-#ifdef COMEDI_PCMCIA_2_6_16
((local_info_t *)link->priv)->stop = 1;
das16cs_pcmcia_release((u_long)link);
-#else
-#ifdef PCMCIA_DEBUG
- printk(KERN_DEBUG "das16cs: detach postponed, '%s' "
- "still locked\n", link->dev->dev_name);
-#endif
- link->state |= DEV_STALE_LINK;
- return;
-#endif
}
-
-#ifndef COMEDI_PCMCIA_2_6_16
- /* Break the link with Card Services */
- if (link->handle)
- pcmcia_deregister_client(link->handle);
-#endif
-
/* Unlink device structure, and free it */
*linkp = link->next;
/* This points to the parent local_info_t struct */
kfree(link->priv);
-
} /* das16cs_pcmcia_detach */
/*======================================================================
DEBUG(0, "das16cs_pcmcia_release(0x%p)\n", link);
-#ifndef COMEDI_PCMCIA_2_6_16
- /*
- If the device is currently in use, we won't release until it
- is actually closed, because until then, we can't be sure that
- no one will try to access the device or its data structures.
- */
- if (link->open)
- {
- DEBUG(1, "das16cs: release postponed, '%s' still open\n",
- link->dev->dev_name);
- link->state |= DEV_STALE_CONFIG;
- return;
- }
-#endif
-
/* Unlink the device chain */
link->dev = NULL;
if (link->irq.AssignedIRQ)
pcmcia_release_irq(link->handle, &link->irq);
link->state &= ~DEV_CONFIG;
-
-#ifndef COMEDI_PCMCIA_2_6_16
- if (link->state & DEV_STALE_LINK)
- das16cs_pcmcia_detach(link);
-#endif
-
} /* das16cs_pcmcia_release */
-/*======================================================================
-
- The card status event handler. Mostly, this schedules other
- stuff to run after an event is received.
-
- When a CARD_REMOVAL event is received, we immediately set a
- private flag to block future accesses to this device. All the
- functions that actually access the device should check this flag
- to make sure the card is still present.
-
-======================================================================*/
-
-#ifndef COMEDI_PCMCIA_2_6_16
-static int das16cs_pcmcia_event(event_t event, int priority,
- event_callback_args_t *args)
-{
- dev_link_t *link = args->client_data;
- local_info_t *dev = link->priv;
-
- DEBUG(1, "das16cs_pcmcia_event(0x%06x)\n", event);
-
- switch (event)
- {
- case CS_EVENT_CARD_REMOVAL:
- link->state &= ~DEV_PRESENT;
- if (link->state & DEV_CONFIG)
- {
- ((local_info_t *)link->priv)->stop = 1;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- mod_timer(&link->release, jiffies + HZ/20);
-#else
- das16cs_pcmcia_release((u_long)link);
-#endif
- }
- break;
- case CS_EVENT_CARD_INSERTION:
- link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- dev->bus = args->bus;
-#endif
- das16cs_pcmcia_config(link);
- break;
- case CS_EVENT_PM_SUSPEND:
- link->state |= DEV_SUSPEND;
- /* Fall through... */
- case CS_EVENT_RESET_PHYSICAL:
- /* Mark the device as stopped, to block IO until later */
- dev->stop = 1;
- if (link->state & DEV_CONFIG)
- pcmcia_release_configuration(link->handle);
- break;
- case CS_EVENT_PM_RESUME:
- link->state &= ~DEV_SUSPEND;
- /* Fall through... */
- case CS_EVENT_CARD_RESET:
- if (link->state & DEV_CONFIG)
- pcmcia_request_configuration(link->handle, &link->conf);
- dev->stop = 0;
-/*
-In a normal driver, additional code may go here to restore
-the device state and restart IO.
-*/
- break;
- }
-
- return 0;
-} /* das16cs_pcmcia_event */
-#endif
-
-#ifdef COMEDI_PCMCIA_2_6_16
static int das16cs_pcmcia_suspend(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
local->stop = 0;
return 0;
} /* das16cs_pcmcia_resume */
-#endif
/*====================================================================*/
struct pcmcia_driver das16cs_driver =
{
-#ifdef COMEDI_PCMCIA_2_6_16
.probe = das16cs_pcmcia_attach,
.remove = das16cs_pcmcia_detach,
.suspend = das16cs_pcmcia_suspend,
.resume = das16cs_pcmcia_resume,
-#else
- .attach = das16cs_pcmcia_attach,
- .detach = das16cs_pcmcia_detach,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
- .event = das16cs_pcmcia_event,
-#endif
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
.id_table = NULL, /* FIXME */
-#endif
.owner = THIS_MODULE,
.drv = {
.name = dev_info,
pcmcia_unregister_driver(&das16cs_driver);
while (dev_list != NULL)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- del_timer(&dev_list->release);
-#endif
if (dev_list->state & DEV_CONFIG)
das16cs_pcmcia_release((u_long)dev_list);
-#ifndef COMEDI_PCMCIA_2_6_16
- das16cs_pcmcia_detach(dev_list);
-#else
das16cs_pcmcia_detach(dev_list->handle);
-#endif
}
}
-int init_module(void)
+int __init init_module(void)
{
int ret;
return comedi_driver_register(&driver_das16cs);
}
-void cleanup_module(void)
+void __exit cleanup_module(void)
{
exit_das16cs_pcmcia_cs();
comedi_driver_unregister(&driver_das16cs);
#endif
/*====================================================================*/
-
-/* Parameters that can be set with 'insmod' */
-
-/* The old way: bit map of interrupts to choose from */
-/* This means pick from 15, 14, 12, 11, 10, 9, 7, 5, 4, and 3 */
-static u_int irq_mask = 0xdeb8;
-/* Newer, simpler way of listing specific interrupts */
-static int irq_list[4] = { -1 };
-
-MODULE_PARM(irq_mask, "i");
-MODULE_PARM(irq_list, "1-4i");
-
-/*====================================================================*/
-
-/*
- The event() function is this driver's Card Services event handler.
- It will be called by Card Services when an appropriate card status
- event is received. The config() and release() entry points are
- used to configure or release a socket, in response to card
- insertion and ejection events. They are invoked from the das08_pcmcia
- event handler.
-
- Kernel version 2.6.16 upwards uses suspend() and resume() functions
- instead of an event() function.
-*/
-
static void das08_pcmcia_config(dev_link_t *link);
static void das08_pcmcia_release(u_long arg);
-#ifdef COMEDI_PCMCIA_2_6_16
static int das08_pcmcia_suspend(struct pcmcia_device *p_dev);
static int das08_pcmcia_resume(struct pcmcia_device *p_dev);
-#else
-static int das08_pcmcia_event(event_t event, int priority,
- event_callback_args_t *args);
-#endif
/*
The attach() and detach() entry points are used to create and destroy
needed to manage one actual PCMCIA card.
*/
-#ifdef COMEDI_PCMCIA_2_6_16
static int das08_pcmcia_attach(struct pcmcia_device *);
static void das08_pcmcia_detach(struct pcmcia_device *);
-#else
-static dev_link_t *das08_pcmcia_attach(void);
-static void das08_pcmcia_detach(dev_link_t *);
-#endif
/*
You'll also need to prototype all the functions that will actually
======================================================================*/
-#ifdef COMEDI_PCMCIA_2_6_16
static int das08_pcmcia_attach(struct pcmcia_device *p_dev)
-#else
-static dev_link_t *das08_pcmcia_attach(void)
-#endif
{
local_info_t *local;
dev_link_t *link;
-#ifndef COMEDI_PCMCIA_2_6_16
- client_reg_t client_reg;
- int ret;
-#endif
- int i;
DEBUG(0, "das08_pcmcia_attach()\n");
/* Allocate space for private device-specific data */
local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
-#ifdef COMEDI_PCMCIA_2_6_16
if (!local) return -ENOMEM;
-#else
- if (!local) return NULL;
-#endif
memset(local, 0, sizeof(local_info_t));
link = &local->link; link->priv = local;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- /* Initialize the dev_link_t structure */
- link->release.function = &das08_pcmcia_release;
- link->release.data = (u_long)link;
-#endif
/* Interrupt setup */
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
link->irq.IRQInfo1 = IRQ_INFO2_VALID|IRQ_LEVEL_ID;
- if (irq_list[0] == -1)
- link->irq.IRQInfo2 = irq_mask;
- else
- for (i = 0; i < 4; i++)
- link->irq.IRQInfo2 |= 1 << irq_list[i];
link->irq.Handler = NULL;
/*
link->next = dev_list;
dev_list = link;
-#ifdef COMEDI_PCMCIA_2_6_16
link->handle = p_dev;
p_dev->instance = link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
das08_pcmcia_config(link);
return 0;
-#else
- /* Register with Card Services */
- client_reg.dev_info = &dev_info;
- client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
- client_reg.EventMask =
- CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
- CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
- CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
- client_reg.event_handler = &das08_pcmcia_event;
-#endif
- client_reg.Version = 0x0210;
- client_reg.event_callback_args.client_data = link;
- ret = pcmcia_register_client(&link->handle, &client_reg);
- if (ret != CS_SUCCESS) {
- cs_error(link->handle, RegisterClient, ret);
- das08_pcmcia_detach(link);
- return NULL;
- }
-
- return link;
-#endif
} /* das08_pcmcia_attach */
/*======================================================================
======================================================================*/
-#ifdef COMEDI_PCMCIA_2_6_16
static void das08_pcmcia_detach(struct pcmcia_device *p_dev)
-#else
-static void das08_pcmcia_detach(dev_link_t *link)
-#endif
{
-#ifdef COMEDI_PCMCIA_2_6_16
dev_link_t *link = dev_to_instance(p_dev);
-#endif
dev_link_t **linkp;
DEBUG(0, "das08_pcmcia_detach(0x%p)\n", link);
*/
if (link->state & DEV_CONFIG)
{
-#ifdef COMEDI_PCMCIA_2_6_16
((local_info_t *)link->priv)->stop = 1;
das08_pcmcia_release((u_long)link);
-#else
-#ifdef PCMCIA_DEBUG
- printk(KERN_DEBUG "das08: detach postponed, '%s' "
- "still locked\n", link->dev->dev_name);
-#endif
- link->state |= DEV_STALE_LINK;
- return;
-#endif
}
-#ifndef COMEDI_PCMCIA_2_6_16
- /* Break the link with Card Services */
- if (link->handle)
- pcmcia_deregister_client(link->handle);
-#endif
-
/* Unlink device structure, and free it */
*linkp = link->next;
/* This points to the parent local_info_t struct */
DEBUG(0, "das08_pcmcia_release(0x%p)\n", link);
-#ifndef COMEDI_PCMCIA_2_6_16
- /*
- If the device is currently in use, we won't release until it
- is actually closed, because until then, we can't be sure that
- no one will try to access the device or its data structures.
- */
- if (link->open)
- {
- DEBUG(1, "das08: release postponed, '%s' still open\n",
- link->dev->dev_name);
- link->state |= DEV_STALE_CONFIG;
- return;
- }
-#endif
-
/* Unlink the device chain */
link->dev = NULL;
pcmcia_release_irq(link->handle, &link->irq);
link->state &= ~DEV_CONFIG;
-#ifndef COMEDI_PCMCIA_2_6_16
- if (link->state & DEV_STALE_LINK)
- das08_pcmcia_detach(link);
-#endif
-
} /* das08_pcmcia_release */
/*======================================================================
======================================================================*/
-#ifndef COMEDI_PCMCIA_2_6_16
-static int das08_pcmcia_event(event_t event, int priority,
- event_callback_args_t *args)
-{
- dev_link_t *link = args->client_data;
- local_info_t *dev = link->priv;
-
- DEBUG(1, "das08_pcmcia_event(0x%06x)\n", event);
-
- switch (event)
- {
- case CS_EVENT_CARD_REMOVAL:
- link->state &= ~DEV_PRESENT;
- if (link->state & DEV_CONFIG)
- {
- ((local_info_t *)link->priv)->stop = 1;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- mod_timer(&link->release, jiffies + HZ/20);
-#else
- das08_pcmcia_release((ulong)link);
-#endif
- }
- break;
- case CS_EVENT_CARD_INSERTION:
- link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- dev->bus = args->bus;
-#endif
- das08_pcmcia_config(link);
- break;
- case CS_EVENT_PM_SUSPEND:
- link->state |= DEV_SUSPEND;
- /* Fall through... */
- case CS_EVENT_RESET_PHYSICAL:
- /* Mark the device as stopped, to block IO until later */
- dev->stop = 1;
- if (link->state & DEV_CONFIG)
- pcmcia_release_configuration(link->handle);
- break;
- case CS_EVENT_PM_RESUME:
- link->state &= ~DEV_SUSPEND;
- /* Fall through... */
- case CS_EVENT_CARD_RESET:
- if (link->state & DEV_CONFIG)
- pcmcia_request_configuration(link->handle, &link->conf);
- dev->stop = 0;
-/*
-In a normal driver, additional code may go here to restore
-the device state and restart IO.
-*/
- break;
- }
-
- return 0;
-} /* das08_pcmcia_event */
-#endif
-
-#ifdef COMEDI_PCMCIA_2_6_16
static int das08_pcmcia_suspend(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
local->stop = 0;
return 0;
} /* das08_pcmcia_resume */
-#endif
/*====================================================================*/
struct pcmcia_driver das08_cs_driver =
{
-#ifdef COMEDI_PCMCIA_2_6_16
.probe = das08_pcmcia_attach,
.remove = das08_pcmcia_detach,
.suspend = das08_pcmcia_suspend,
.resume = das08_pcmcia_resume,
-#else
- .attach = &das08_pcmcia_attach,
- .detach = &das08_pcmcia_detach,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
- .event = &das08_pcmcia_event,
-#endif
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
.id_table = NULL, /* FIXME */
-#endif
.owner = THIS_MODULE,
.drv = {
.name = dev_info,
pcmcia_unregister_driver(&das08_cs_driver);
while (dev_list != NULL)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- del_timer(&dev_list->release);
-#endif
if (dev_list->state & DEV_CONFIG)
das08_pcmcia_release((u_long)dev_list);
-#ifndef COMEDI_PCMCIA_2_6_16
- das08_pcmcia_detach(dev_list);
-#else
das08_pcmcia_detach(dev_list->handle);
-#endif
}
}
/*====================================================================*/
-/* Parameters that can be set with 'insmod' */
-
-/* The old way: bit map of interrupts to choose from */
-/* This means pick from 15, 14, 12, 11, 10, 9, 7, 5, 4, and 3 */
-static u_int irq_mask = 0xdeb8;
-/* Newer, simpler way of listing specific interrupts */
-static int irq_list[4] = { -1 };
-
-MODULE_PARM(irq_mask, "i");
-MODULE_PARM(irq_list, "1-4i");
-
-/*====================================================================*/
-
-/*
- The event() function is this driver's Card Services event handler.
- It will be called by Card Services when an appropriate card status
- event is received. The config() and release() entry points are
- used to configure or release a socket, in response to card
- insertion and ejection events. They are invoked from the dummy
- event handler.
-
- Kernel version 2.6.16 upwards uses suspend() and resume() functions
- instead of an event() function.
-*/
-
static void dio24_config(dev_link_t *link);
static void dio24_release(u_long arg);
-#ifdef COMEDI_PCMCIA_2_6_16
static int dio24_cs_suspend(struct pcmcia_device *p_dev);
static int dio24_cs_resume(struct pcmcia_device *p_dev);
-#else
-static int dio24_event(event_t event, int priority,
- event_callback_args_t *args);
-#endif
/*
The attach() and detach() entry points are used to create and destroy
needed to manage one actual PCMCIA card.
*/
-#ifdef COMEDI_PCMCIA_2_6_16
static int dio24_cs_attach(struct pcmcia_device *);
static void dio24_cs_detach(struct pcmcia_device *);
-#else
-static dev_link_t *dio24_cs_attach(void);
-static void dio24_cs_detach(dev_link_t *);
-#endif
/*
You'll also need to prototype all the functions that will actually
======================================================================*/
-#ifdef COMEDI_PCMCIA_2_6_16
static int dio24_cs_attach(struct pcmcia_device *p_dev)
-#else
-static dev_link_t *dio24_cs_attach(void)
-#endif
{
local_info_t *local;
dev_link_t *link;
-#ifndef COMEDI_PCMCIA_2_6_16
- client_reg_t client_reg;
- int ret;
-#endif
- int i;
printk(KERN_INFO "ni_daq_dio24: HOLA SOY YO - CS-attach!\n");
/* Allocate space for private device-specific data */
local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
-#ifdef COMEDI_PCMCIA_2_6_16
if (!local) return -ENOMEM;
-#else
- if (!local) return NULL;
-#endif
memset(local, 0, sizeof(local_info_t));
link = &local->link; link->priv = local;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- /* Initialize the dev_link_t structure */
- link->release.function = &dio24_release;
- link->release.data = (u_long)link;
-#endif
/* Interrupt setup */
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
link->irq.IRQInfo1 = IRQ_INFO2_VALID|IRQ_LEVEL_ID;
- if (irq_list[0] == -1)
- link->irq.IRQInfo2 = irq_mask;
- else
- for (i = 0; i < 4; i++)
- link->irq.IRQInfo2 |= 1 << irq_list[i];
link->irq.Handler = NULL;
/*
link->next = pcmcia_dev_list;
pcmcia_dev_list = link;
-#ifdef COMEDI_PCMCIA_2_6_16
link->handle = p_dev;
p_dev->instance = link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
dio24_config(link);
return 0;
-#else
- /* Register with Card Services */
- client_reg.dev_info = &dev_info;
- client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
- client_reg.EventMask =
- CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
- CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
- CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
- client_reg.event_handler = &dio24_event;
-#endif
- client_reg.Version = 0x0210;
- client_reg.event_callback_args.client_data = link;
- ret = pcmcia_register_client(&link->handle, &client_reg);
- if (ret != CS_SUCCESS) {
- cs_error(link->handle, RegisterClient, ret);
- dio24_cs_detach(link);
- return NULL;
- }
-
- return link;
-#endif
} /* dio24_cs_attach */
/*======================================================================
======================================================================*/
-#ifdef COMEDI_PCMCIA_2_6_16
static void dio24_cs_detach(struct pcmcia_device *p_dev)
-#else
-static void dio24_cs_detach(dev_link_t *link)
-#endif
{
-#ifdef COMEDI_PCMCIA_2_6_16
dev_link_t *link = dev_to_instance(p_dev);
-#endif
dev_link_t **linkp;
printk(KERN_INFO "ni_daq_dio24: HOLA SOY YO - cs-detach!\n");
detach().
*/
if (link->state & DEV_CONFIG) {
-#ifdef COMEDI_PCMCIA_2_6_16
((local_info_t *)link->priv)->stop = 1;
dio24_release((u_long)link);
-#else
-#ifdef PCMCIA_DEBUG
- printk(KERN_DEBUG "ni_daq_dio24: detach postponed, '%s' "
- "still locked\n", link->dev->dev_name);
-#endif
- link->state |= DEV_STALE_LINK;
- return;
-#endif
}
-#ifndef COMEDI_PCMCIA_2_6_16
- /* Break the link with Card Services */
- if (link->handle)
- pcmcia_deregister_client(link->handle);
-#endif
-
/* Unlink device structure, and free it */
*linkp = link->next;
/* This points to the parent local_info_t struct */
DEBUG(0, "dio24_release(0x%p)\n", link);
-#ifndef COMEDI_PCMCIA_2_6_16
- /*
- If the device is currently in use, we won't release until it
- is actually closed, because until then, we can't be sure that
- no one will try to access the device or its data structures.
- */
- if (link->open) {
- DEBUG(1, "ni_dio24: release postponed, '%s' still open\n",
- link->dev->dev_name);
- link->state |= DEV_STALE_CONFIG;
- return;
- }
-#endif
-
/* Unlink the device chain */
link->dev = NULL;
pcmcia_release_irq(link->handle, &link->irq);
link->state &= ~DEV_CONFIG;
-#ifndef COMEDI_PCMCIA_2_6_16
- if (link->state & DEV_STALE_LINK)
- dio24_cs_detach(link);
-#endif
-
} /* dio24_release */
/*======================================================================
======================================================================*/
-#ifndef COMEDI_PCMCIA_2_6_16
-static int dio24_event(event_t event, int priority,
- event_callback_args_t *args)
-{
- dev_link_t *link = args->client_data;
- local_info_t *dev = link->priv;
- DEBUG(1, "dio24_event(0x%06x)\n", event);
-
- switch (event) {
- case CS_EVENT_CARD_REMOVAL:
- link->state &= ~DEV_PRESENT;
- if (link->state & DEV_CONFIG) {
- ((local_info_t *)link->priv)->stop = 1;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- mod_timer(&link->release, jiffies + HZ/20);
-#else
- dio24_release((u_long)pcmcia_dev_list);
-#endif
- }
- break;
- case CS_EVENT_CARD_INSERTION:
- link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-// dev->bus = args->bus;
- dio24_config(link);
- break;
- case CS_EVENT_PM_SUSPEND:
- link->state |= DEV_SUSPEND;
- /* Fall through... */
- case CS_EVENT_RESET_PHYSICAL:
- /* Mark the device as stopped, to block IO until later */
- dev->stop = 1;
- if (link->state & DEV_CONFIG)
- pcmcia_release_configuration(link->handle);
- break;
- case CS_EVENT_PM_RESUME:
- link->state &= ~DEV_SUSPEND;
- /* Fall through... */
- case CS_EVENT_CARD_RESET:
- if (link->state & DEV_CONFIG)
- pcmcia_request_configuration(link->handle, &link->conf);
- dev->stop = 0;
- /*
- In a normal driver, additional code may go here to restore
- the device state and restart IO.
- */
- break;
- }
- return 0;
-} /* dio24_event */
-#endif
-
-#ifdef COMEDI_PCMCIA_2_6_16
static int dio24_cs_suspend(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
local->stop = 0;
return 0;
} /* dio24_cs_resume */
-#endif
/*====================================================================*/
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
static struct pcmcia_device_id dio24_cs_ids[] =
{
/* N.B. These IDs should match those in dio24_boards */
};
MODULE_DEVICE_TABLE(pcmcia, dio24_cs_ids);
-#endif
struct pcmcia_driver dio24_cs_driver =
{
-#ifdef COMEDI_PCMCIA_2_6_16
.probe = dio24_cs_attach,
.remove = dio24_cs_detach,
.suspend = dio24_cs_suspend,
.resume = dio24_cs_resume,
-#else
- .attach = &dio24_cs_attach,
- .detach = &dio24_cs_detach,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
- .event = &dio24_event,
-#endif
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
.id_table = dio24_cs_ids,
-#endif
.owner = THIS_MODULE,
.drv = {
.name = dev_info,
DEBUG(0, "ni_dio24: unloading\n");
pcmcia_unregister_driver(&dio24_cs_driver);
while (pcmcia_dev_list != NULL) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- del_timer(&pcmcia_dev_list->release);
-#endif
if (pcmcia_dev_list->state & DEV_CONFIG)
dio24_release((u_long)pcmcia_dev_list);
-#ifndef COMEDI_PCMCIA_2_6_16
- dio24_cs_detach(pcmcia_dev_list);
-#else
dio24_cs_detach(pcmcia_dev_list->handle);
-#endif
}
}
/*====================================================================*/
-/* Parameters that can be set with 'insmod' */
-
-/* The old way: bit map of interrupts to choose from */
-/* This means pick from 15, 14, 12, 11, 10, 9, 7, 5, 4, and 3 */
-static u_int irq_mask = 0xdeb8;
-/* Newer, simpler way of listing specific interrupts */
-static int irq_list[4] = { -1 };
-
-MODULE_PARM(irq_mask, "i");
-MODULE_PARM(irq_list, "1-4i");
-
-/*====================================================================*/
-
/*
The event() function is this driver's Card Services event handler.
It will be called by Card Services when an appropriate card status
static void labpc_config(dev_link_t *link);
static void labpc_release(u_long arg);
-#ifdef COMEDI_PCMCIA_2_6_16
static int labpc_cs_suspend(struct pcmcia_device *p_dev);
static int labpc_cs_resume(struct pcmcia_device *p_dev);
-#else
-static int labpc_event(event_t event, int priority,
- event_callback_args_t *args);
-#endif
/*
The attach() and detach() entry points are used to create and destroy
needed to manage one actual PCMCIA card.
*/
-#ifdef COMEDI_PCMCIA_2_6_16
static int labpc_cs_attach(struct pcmcia_device *);
static void labpc_cs_detach(struct pcmcia_device *);
-#else
-static dev_link_t *labpc_cs_attach(void);
-static void labpc_cs_detach(dev_link_t *);
-#endif
/*
You'll also need to prototype all the functions that will actually
======================================================================*/
-#ifdef COMEDI_PCMCIA_2_6_16
static int labpc_cs_attach(struct pcmcia_device *p_dev)
-#else
-static dev_link_t *labpc_cs_attach(void)
-#endif
{
local_info_t *local;
dev_link_t *link;
-#ifndef COMEDI_PCMCIA_2_6_16
- client_reg_t client_reg;
- int ret;
-#endif
- int i;
DEBUG(0, "labpc_cs_attach()\n");
/* Allocate space for private device-specific data */
local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
-#ifdef COMEDI_PCMCIA_2_6_16
if (!local) return -ENOMEM;
-#else
- if (!local) return NULL;
-#endif
memset(local, 0, sizeof(local_info_t));
link = &local->link; link->priv = local;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- /* Initialize the dev_link_t structure */
- link->release.function = &labpc_release;
- link->release.data = (u_long)link;
-#endif
/* Interrupt setup */
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_FORCED_PULSE;
link->irq.IRQInfo1 = IRQ_INFO2_VALID | IRQ_PULSE_ID;
- if (irq_list[0] == -1)
- link->irq.IRQInfo2 = irq_mask;
- else for (i = 0; i < 4; i++)
- link->irq.IRQInfo2 |= 1 << irq_list[i];
link->irq.Handler = NULL;
/*
link->next = pcmcia_dev_list;
pcmcia_dev_list = link;
-#ifdef COMEDI_PCMCIA_2_6_16
link->handle = p_dev;
p_dev->instance = link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
labpc_config(link);
return 0;
-#else
- /* Register with Card Services */
- client_reg.dev_info = &dev_info;
- client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
- client_reg.EventMask =
- CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
- CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
- CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
- client_reg.event_handler = &labpc_event;
-#endif
- client_reg.Version = 0x0210;
- client_reg.event_callback_args.client_data = link;
- ret = pcmcia_register_client(&link->handle, &client_reg);
- if (ret != CS_SUCCESS) {
- cs_error(link->handle, RegisterClient, ret);
- labpc_cs_detach(link);
- return NULL;
- }
-
- return link;
-#endif
} /* labpc_cs_attach */
/*======================================================================
======================================================================*/
-#ifdef COMEDI_PCMCIA_2_6_16
static void labpc_cs_detach(struct pcmcia_device *p_dev)
-#else
-static void labpc_cs_detach(dev_link_t *link)
-#endif
{
-#ifdef COMEDI_PCMCIA_2_6_16
dev_link_t *link = dev_to_instance(p_dev);
-#endif
dev_link_t **linkp;
DEBUG(0, "labpc_cs_detach(0x%p)\n", link);
detach().
*/
if (link->state & DEV_CONFIG) {
-#ifdef COMEDI_PCMCIA_2_6_16
((local_info_t *)link->priv)->stop = 1;
labpc_release((u_long)link);
-#else
-#ifdef PCMCIA_DEBUG
- printk(KERN_DEBUG "ni_labpc: detach postponed, '%s' "
- "still locked\n", link->dev->dev_name);
-#endif
- link->state |= DEV_STALE_LINK;
- return;
-#endif
}
-#ifndef COMEDI_PCMCIA_2_6_16
- /* Break the link with Card Services */
- if (link->handle)
- pcmcia_deregister_client(link->handle);
-#endif
-
/* Unlink device structure, and free it */
*linkp = link->next;
/* This points to the parent local_info_t struct */
DEBUG(0, "labpc_release(0x%p)\n", link);
-#ifndef COMEDI_PCMCIA_2_6_16
- /*
- If the device is currently in use, we won't release until it
- is actually closed, because until then, we can't be sure that
- no one will try to access the device or its data structures.
- */
- if (link->open) {
- DEBUG(1, "ni_labpc: release postponed, '%s' still open\n",
- link->dev->dev_name);
- link->state |= DEV_STALE_CONFIG;
- return;
- }
-#endif
-
/* Unlink the device chain */
link->dev = NULL;
pcmcia_release_irq(link->handle, &link->irq);
link->state &= ~DEV_CONFIG;
-#ifndef COMEDI_PCMCIA_2_6_16
- if (link->state & DEV_STALE_LINK)
- labpc_cs_detach(link);
-#endif
-
} /* labpc_release */
/*======================================================================
======================================================================*/
-#ifndef COMEDI_PCMCIA_2_6_16
-static int labpc_event(event_t event, int priority,
- event_callback_args_t *args)
-{
- dev_link_t *link = args->client_data;
- local_info_t *dev = link->priv;
-
- DEBUG(1, "labpc_event(0x%06x)\n", event);
-
- switch (event) {
- case CS_EVENT_CARD_REMOVAL:
- link->state &= ~DEV_PRESENT;
- if (link->state & DEV_CONFIG) {
- ((local_info_t *)link->priv)->stop = 1;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- mod_timer(&link->release, jiffies + HZ/20);
-#else
- labpc_release((ulong)link);
-#endif
- }
- break;
- case CS_EVENT_CARD_INSERTION:
- link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-// dev->bus = args->bus;
- labpc_config(link);
- break;
- case CS_EVENT_PM_SUSPEND:
- link->state |= DEV_SUSPEND;
- /* Fall through... */
- case CS_EVENT_RESET_PHYSICAL:
- /* Mark the device as stopped, to block IO until later */
- dev->stop = 1;
- if (link->state & DEV_CONFIG)
- pcmcia_release_configuration(link->handle);
- break;
- case CS_EVENT_PM_RESUME:
- link->state &= ~DEV_SUSPEND;
- /* Fall through... */
- case CS_EVENT_CARD_RESET:
- if (link->state & DEV_CONFIG)
- pcmcia_request_configuration(link->handle, &link->conf);
- dev->stop = 0;
- /*
- In a normal driver, additional code may go here to restore
- the device state and restart IO.
- */
- break;
- }
- return 0;
-} /* labpc_event */
-#endif
-
-#ifdef COMEDI_PCMCIA_2_6_16
static int labpc_cs_suspend(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
local->stop = 0;
return 0;
} /* labpc_cs_resume */
-#endif
/*====================================================================*/
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
static struct pcmcia_device_id labpc_cs_ids[] =
{
/* N.B. These IDs should match those in labpc_cs_boards (ni_labpc.c) */
};
MODULE_DEVICE_TABLE(pcmcia, labpc_cs_ids);
-#endif
struct pcmcia_driver labpc_cs_driver =
{
-#ifdef COMEDI_PCMCIA_2_6_16
.probe = labpc_cs_attach,
.remove = labpc_cs_detach,
.suspend = labpc_cs_suspend,
.resume = labpc_cs_resume,
-#else
- .attach = labpc_cs_attach,
- .detach = labpc_cs_detach,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
- .event = &labpc_event,
-#endif
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
.id_table = labpc_cs_ids,
-#endif
.owner = THIS_MODULE,
.drv = {
.name = dev_info,
DEBUG(0, "ni_labpc: unloading\n");
pcmcia_unregister_driver(&labpc_cs_driver);
while (pcmcia_dev_list != NULL) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- del_timer(&pcmcia_dev_list->release);
-#endif
if (pcmcia_dev_list->state & DEV_CONFIG)
labpc_release((u_long)pcmcia_dev_list);
-#ifndef COMEDI_PCMCIA_2_6_16
- labpc_cs_detach(pcmcia_dev_list);
-#else
labpc_cs_detach(pcmcia_dev_list->handle);
-#endif
}
}
static void mio_cs_config(dev_link_t *link);
static void cs_release(u_long arg);
-#ifdef COMEDI_PCMCIA_2_6_16
static void cs_detach(struct pcmcia_device *);
-#else
-static void cs_detach(dev_link_t *);
-#endif
static int irq_mask;
static dev_link_t *dev_list = NULL;
COMEDI_MAJOR,0,
NULL
};
-#ifndef COMEDI_PCMCIA_2_6_16
-static int mio_cs_event(event_t event, int priority, event_callback_args_t *args);
-#endif
-
-#ifdef COMEDI_PCMCIA_2_6_16
static int cs_attach(struct pcmcia_device *p_dev)
-#else
-static dev_link_t *cs_attach(void)
-#endif
{
dev_link_t *link;
-#ifndef COMEDI_PCMCIA_2_6_16
- client_reg_t client_reg;
- int ret;
-#endif
link=kmalloc(sizeof(*link),GFP_KERNEL);
-#ifdef COMEDI_PCMCIA_2_6_16
if(!link)return -ENOMEM;
-#else
- if(!link)return NULL;
-#endif
memset(link,0,sizeof(*link));
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- link->release.function = &cs_release;
- link->release.data = (u_long)link;
-#endif
link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
link->io.NumPorts1 = 16;
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
link->next = dev_list;
dev_list = link;
-#ifdef COMEDI_PCMCIA_2_6_16
link->handle = p_dev;
p_dev->instance = link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
mio_cs_config(link);
return 0;
-#else
- client_reg.dev_info = &dev_info;
- client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
- client_reg.EventMask =
- CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
- CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
- CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
- client_reg.event_handler = &mio_cs_event;
-#endif
- client_reg.Version = 0x0210;
- client_reg.event_callback_args.client_data = link;
- ret = pcmcia_register_client(&link->handle, &client_reg);
- if (ret != CS_SUCCESS) {
- cs_error(link->handle, RegisterClient, ret);
- printk("detaching...\n");
- cs_detach(link);
- return NULL;
- }
-
- return link;
-#endif
}
static void cs_release(u_long arg)
link->state &= ~DEV_CONFIG;
}
-#ifdef COMEDI_PCMCIA_2_6_16
static void cs_detach(struct pcmcia_device *p_dev)
-#else
-static void cs_detach(dev_link_t *link)
-#endif
{
-#ifdef COMEDI_PCMCIA_2_6_16
dev_link_t *link = dev_to_instance(p_dev);
-#endif
dev_link_t **linkp;
DPRINTK("cs_detach(link=%p)\n",link);
//cli
if (link->state & DEV_RELEASE_PENDING){
printk("dev release pending bug\n");
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- del_timer(&link->release);
-#endif
link->state &= ~DEV_RELEASE_PENDING;
}
//restore_flags
if(link->state & DEV_CONFIG) {
cs_release((u_long)link);
-#ifndef COMEDI_PCMCIA_2_6_16
- if(link->state & DEV_STALE_CONFIG) {
- link->state |= DEV_STALE_LINK;
- return;
- }
-#endif
}
-#ifndef COMEDI_PCMCIA_2_6_16
- if(link->handle){
- pcmcia_deregister_client(link->handle);
- }
-#endif
-
/* Unlink device structure, and free it */
*linkp = link->next;
kfree(link);
}
-#ifndef COMEDI_PCMCIA_2_6_16
-static int mio_cs_event(event_t event, int priority, event_callback_args_t *args)
-{
- dev_link_t *link = args->client_data;
-
- DPRINTK("mio_cs_event(event=%x,priority=%d,args=%p)\n",event,priority,args);
-
- switch(event){
- case CS_EVENT_CARD_REMOVAL:
- DPRINTK("removal event\n");
- link->state &= ~DEV_PRESENT;
- if(link->state & DEV_CONFIG) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- link->release.expires = jiffies+HZ/20;
- link->state |= DEV_RELEASE_PENDING;
- add_timer(&link->release);
-#else
- cs_release((ulong)link);
-#endif
- }
- /* XXX disable irq here, to get rid of spurious interrupts */
- break;
- case CS_EVENT_CARD_INSERTION:
- DPRINTK("card insertion event\n");
- link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
- mio_cs_config(link);
- break;
- case CS_EVENT_PM_SUSPEND:
- DPRINTK("pm suspend event\n");
- link->state |= DEV_SUSPEND;
- /* fall through */
- case CS_EVENT_RESET_PHYSICAL:
- DPRINTK("reset physical event\n");
- if(link->state & DEV_CONFIG)
- pcmcia_release_configuration(link->handle);
- break;
- case CS_EVENT_PM_RESUME:
- DPRINTK("pm resume event\n");
- link->state &= ~DEV_SUSPEND;
- /* fall through */
- case CS_EVENT_CARD_RESET:
- DPRINTK("card reset event\n");
- if(DEV_OK(link))
- pcmcia_request_configuration(link->handle, &link->conf);
- break;
- default:
- DPRINTK("unknown event (ignored)\n");
- }
- return 0;
-}
-#endif
-
-
-#ifdef COMEDI_PCMCIA_2_6_16
static int mio_cs_suspend(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
return 0;
}
-#endif
-
-
static void mio_cs_config(dev_link_t *link)
{
MODULE_LICENSE("GPL");
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
static struct pcmcia_device_id ni_mio_cs_ids[] =
{
PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010d), /* DAQCard-ai-16xe-50 */
};
MODULE_DEVICE_TABLE(pcmcia, ni_mio_cs_ids);
-#endif
struct pcmcia_driver ni_mio_cs_driver =
{
-#ifdef COMEDI_PCMCIA_2_6_16
.probe = &cs_attach,
.remove = &cs_detach,
.suspend = &mio_cs_suspend,
.resume = &mio_cs_resume,
-#else
- .attach = &cs_attach,
- .detach = &cs_detach,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
- .event = &mio_cs_event,
-#endif
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
.id_table = ni_mio_cs_ids,
-#endif
.owner = THIS_MODULE,
.drv = {
.name = dev_info,
pcmcia_unregister_driver(&ni_mio_cs_driver);
#if 0
while(dev_list != NULL)
-#ifndef COMEDI_PCMCIA_2_6_16
- cs_detach(dev_list);
-#else
cs_detach(dev_list->handle);
-#endif
#endif
comedi_driver_unregister(&driver_ni_mio_cs);
}
static void daqp_cs_config(dev_link_t *link);
static void daqp_cs_release(u_long arg);
-#ifdef COMEDI_PCMCIA_2_6_16
static int daqp_cs_suspend(struct pcmcia_device *p_dev);
static int daqp_cs_resume(struct pcmcia_device *p_dev);
-#else
-static int daqp_cs_event(event_t event, int priority,
- event_callback_args_t *args);
-#endif
/*
The attach() and detach() entry points are used to create and destroy
needed to manage one actual PCMCIA card.
*/
-#ifdef COMEDI_PCMCIA_2_6_16
static int daqp_cs_attach(struct pcmcia_device *);
static void daqp_cs_detach(struct pcmcia_device *);
-#else
-static dev_link_t *daqp_cs_attach(void);
-static void daqp_cs_detach(dev_link_t *);
-#endif
/*
The dev_info variable is the "key" that is used to match up this
======================================================================*/
-#ifdef COMEDI_PCMCIA_2_6_16
static int daqp_cs_attach(struct pcmcia_device *p_dev)
-#else
-static dev_link_t *daqp_cs_attach(void)
-#endif
{
local_info_t *local;
dev_link_t *link;
-#ifndef COMEDI_PCMCIA_2_6_16
- client_reg_t client_reg;
- int ret;
-#endif
int i;
DEBUG(0, "daqp_cs_attach()\n");
if (dev_table[i] == NULL) break;
if (i == MAX_DEV) {
printk(KERN_NOTICE "daqp_cs: no devices available\n");
-#ifdef COMEDI_PCMCIA_2_6_16
return -ENODEV;
-#else
- return NULL;
-#endif
}
/* Allocate space for private device-specific data */
local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
-#ifdef COMEDI_PCMCIA_2_6_16
if (!local) return -ENOMEM;
-#else
- if (!local) return NULL;
-#endif
memset(local, 0, sizeof(local_info_t));
local->table_index = i;
dev_table[i] = local;
link = &local->link;
link->priv = local;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- /* Initialize the dev_link_t structure */
- link->release.function = &daqp_cs_release;
- link->release.data = (u_long)link;
-#endif
- /* Interrupt setup */
+
+ /* Interrupt setup */
link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
link->irq.IRQInfo1 = IRQ_INFO2_VALID|IRQ_LEVEL_ID;
if (irq_list[0] == -1)
link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO;
-#ifdef COMEDI_PCMCIA_2_6_16
link->handle = p_dev;
p_dev->instance = link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
daqp_cs_config(link);
return 0;
-#else
- /* Register with Card Services */
- client_reg.dev_info = &dev_info;
- client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
- client_reg.EventMask =
- CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
- CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
- CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
- client_reg.event_handler = &daqp_cs_event;
-#endif
- client_reg.Version = 0x0210;
- client_reg.event_callback_args.client_data = link;
- ret = pcmcia_register_client(&link->handle, &client_reg);
- if (ret != CS_SUCCESS) {
- cs_error(link->handle, RegisterClient, ret);
- daqp_cs_detach(link);
- return NULL;
- }
-
- return link;
-#endif
} /* daqp_cs_attach */
/*======================================================================
======================================================================*/
-#ifdef COMEDI_PCMCIA_2_6_16
static void daqp_cs_detach(struct pcmcia_device *p_dev)
-#else
-static void daqp_cs_detach(dev_link_t *link)
-#endif
{
-#ifdef COMEDI_PCMCIA_2_6_16
dev_link_t *link = dev_to_instance(p_dev);
-#endif
local_info_t *dev = link->priv;
DEBUG(0, "daqp_cs_detach(0x%p)\n", link);
detach().
*/
if (link->state & DEV_CONFIG) {
-#ifdef COMEDI_PCMCIA_2_6_16
dev->stop = 1;
daqp_cs_release((u_long)link);
-#else
-#ifdef PCMCIA_DEBUG
- printk(KERN_DEBUG "daqp_cs: detach postponed, '%s' "
- "still locked\n", link->dev->dev_name);
-#endif
- link->state |= DEV_STALE_LINK;
- return;
-#endif
}
-#ifndef COMEDI_PCMCIA_2_6_16
- /* Break the link with Card Services */
- if (link->handle)
- pcmcia_deregister_client(link->handle);
-#endif
-
/* Unlink device structure, and free it */
dev_table[dev->table_index] = NULL;
kfree(dev);
DEBUG(0, "daqp_cs_release(0x%p)\n", link);
-#ifndef COMEDI_PCMCIA_2_6_16
- /*
- If the device is currently in use, we won't release until it
- is actually closed, because until then, we can't be sure that
- no one will try to access the device or its data structures.
- */
- if (link->open) {
- DEBUG(1, "daqp_cs: release postponed, '%s' still open\n",
- link->dev->dev_name);
- link->state |= DEV_STALE_CONFIG;
- return;
- }
-#endif
-
/* Unlink the device chain */
link->dev = NULL;
pcmcia_release_irq(link->handle, &link->irq);
link->state &= ~DEV_CONFIG;
-#ifndef COMEDI_PCMCIA_2_6_16
- if (link->state & DEV_STALE_LINK)
- daqp_cs_detach(link);
-#endif
-
} /* daqp_cs_release */
/*======================================================================
======================================================================*/
-#ifndef COMEDI_PCMCIA_2_6_16
-static int daqp_cs_event(event_t event, int priority,
- event_callback_args_t *args)
-{
- dev_link_t *link = args->client_data;
- local_info_t *dev = link->priv;
-
- DEBUG(1, "daqp_cs_event(0x%06x)\n", event);
-
- switch (event) {
- case CS_EVENT_CARD_REMOVAL:
- link->state &= ~DEV_PRESENT;
- if (link->state & DEV_CONFIG) {
- dev->stop = 1;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
- link->release.expires = jiffies + HZ/20;
- add_timer(&link->release);
-#else
- daqp_cs_release((ulong)link);
-#endif
- }
- break;
- case CS_EVENT_CARD_INSERTION:
- link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
- daqp_cs_config(link);
- break;
- case CS_EVENT_PM_SUSPEND:
- link->state |= DEV_SUSPEND;
- /* Fall through... */
- case CS_EVENT_RESET_PHYSICAL:
- /* Mark the device as stopped, to block IO until later */
- dev->stop = 1;
- if (link->state & DEV_CONFIG)
- pcmcia_release_configuration(link->handle);
- break;
- case CS_EVENT_PM_RESUME:
- link->state &= ~DEV_SUSPEND;
- /* Fall through... */
- case CS_EVENT_CARD_RESET:
- if (link->state & DEV_CONFIG)
- pcmcia_request_configuration(link->handle, &link->conf);
- dev->stop = 0;
- break;
- }
- return 0;
-} /* daqp_cs_event */
-#endif
-
-#ifdef COMEDI_PCMCIA_2_6_16
static int daqp_cs_suspend(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
return 0;
}
-#endif
/*====================================================================*/
struct pcmcia_driver daqp_cs_driver =
{
-#ifdef COMEDI_PCMCIA_2_6_16
.probe = daqp_cs_attach,
.remove = daqp_cs_detach,
.suspend = daqp_cs_suspend,
.resume = daqp_cs_resume,
-#else
- .attach = daqp_cs_attach,
- .detach = daqp_cs_detach,
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
- .event = daqp_cs_event,
-#endif
-#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
.id_table = NULL, /* FIXME */
-#endif
.owner = THIS_MODULE,
.drv = {
.name = dev_info,
* do it again or oops()... that's why this test is here
*/
if (dev_table[i]) {
-#ifndef COMEDI_PCMCIA_2_6_16
- daqp_cs_detach(&dev_table[i]->link);
-#else
daqp_cs_detach(dev_table[i]->link.handle);
-#endif
}
}
}