tuple.TupleDataMax = 255;
tuple.DesiredTuple = CISTPL_MANFID;
tuple.Attributes = TUPLE_RETURN_COMMON;
- if((CardServices(GetFirstTuple,handle, &tuple) == CS_SUCCESS) &&
- (CardServices(GetTupleData,handle,&tuple) == CS_SUCCESS)){
+ if((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) &&
+ (pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS)){
prodid = le16_to_cpu(buf[1]);
}
struct bus_operations *bus;
} local_info_t;
-/*====================================================================*/
-
-static void my_cs_error(client_handle_t handle, int func, int ret)
-{
- error_info_t err = { func, ret };
- CardServices(ReportError, handle, &err);
-}
-
/*======================================================================
das16cs_pcmcia_attach() creates an "instance" of the driver, allocating
link = &local->link; link->priv = local;
/* Initialize the dev_link_t structure */
- link->release.function = &das16cs_pcmcia_release;
+#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;
client_reg.event_handler = &das16cs_pcmcia_event;
client_reg.Version = 0x0210;
client_reg.event_callback_args.client_data = link;
- ret = CardServices(RegisterClient, &link->handle, &client_reg);
+ ret = pcmcia_register_client(&link->handle, &client_reg);
if (ret != CS_SUCCESS) {
- my_cs_error(link->handle, RegisterClient, ret);
+ cs_error(link->handle, RegisterClient, ret);
das16cs_pcmcia_detach(link);
return NULL;
}
/* Break the link with Card Services */
if (link->handle)
- CardServices(DeregisterClient, link->handle);
+ pcmcia_deregister_client(link->handle);
/* Unlink device structure, and free it */
*linkp = link->next;
======================================================================*/
-#define CS_CHECK(fn, args...) \
-while ((last_ret=CardServices(last_fn=(fn),args))!=0) goto cs_failed
-
-#define CFG_CHECK(fn, args...) \
-if (CardServices(fn, args) != 0) goto next_entry
-
static void das16cs_pcmcia_config(dev_link_t *link)
{
client_handle_t handle = link->handle;
tuple.TupleData = buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
- CS_CHECK(GetFirstTuple, handle, &tuple);
- CS_CHECK(GetTupleData, handle, &tuple);
- CS_CHECK(ParseTuple, handle, &tuple, &parse);
+ last_fn = GetFirstTuple;
+ if((last_ret = pcmcia_get_first_tuple(handle, &tuple)) != 0) goto cs_failed;
+ last_fn = GetTupleData;
+ if((last_ret = pcmcia_get_tuple_data(handle, &tuple)) != 0) goto cs_failed;
+ last_fn = ParseTuple;
+ if((last_ret = pcmcia_parse_tuple(handle, &tuple, &parse)) != 0) goto cs_failed;
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
link->state |= DEV_CONFIG;
/* Look up the current Vcc */
- CS_CHECK(GetConfigurationInfo, handle, &conf);
+ last_fn = GetConfigurationInfo;
+ if((last_ret = pcmcia_get_configuration_info(handle, &conf)) != 0) goto cs_failed;
link->conf.Vcc = conf.Vcc;
/*
will only use the CIS to fill in implementation-defined details.
*/
tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
- CS_CHECK(GetFirstTuple, handle, &tuple);
+ last_fn = GetFirstTuple;
+ if((last_ret = pcmcia_get_first_tuple(handle, &tuple)) != 0) goto cs_failed;
while (1) {
cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
- CFG_CHECK(GetTupleData, handle, &tuple);
- CFG_CHECK(ParseTuple, handle, &tuple, &parse);
+ if(pcmcia_get_tuple_data(handle, &tuple)) goto next_entry;
+ if(pcmcia_parse_tuple(handle, &tuple, &parse)) goto next_entry;
if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
if (cfg->index == 0) goto next_entry;
link->io.NumPorts2 = io->win[1].len;
}
/* This reserves IO space but doesn't actually enable it */
- CFG_CHECK(RequestIO, link->handle, &link->io);
+ if(pcmcia_request_io(link->handle, &link->io)) goto next_entry;
}
/* If we got this far, we're cool! */
next_entry:
if (link->io.NumPorts1)
- CardServices(ReleaseIO, link->handle, &link->io);
- CS_CHECK(GetNextTuple, handle, &tuple);
+ pcmcia_release_io(link->handle, &link->io);
+ last_fn = GetNextTuple;
+ if((last_ret = pcmcia_get_next_tuple(handle, &tuple)) != 0) goto cs_failed;
}
/*
irq structure is initialized.
*/
if (link->conf.Attributes & CONF_ENABLE_IRQ)
- CS_CHECK(RequestIRQ, link->handle, &link->irq);
+ last_fn = RequestIRQ;
+ if((last_ret = pcmcia_request_irq(link->handle, &link->irq)) != 0) goto cs_failed;
/*
This actually configures the PCMCIA socket -- setting up
the I/O windows and the interrupt mapping, and putting the
card and host interface into "Memory and IO" mode.
*/
- CS_CHECK(RequestConfiguration, link->handle, &link->conf);
+ last_fn = RequestConfiguration;
+ if((last_ret = pcmcia_request_configuration(link->handle, &link->conf)) != 0) goto cs_failed;
/*
At this point, the dev_node_t structure(s) need to be
return;
cs_failed:
- my_cs_error(link->handle, last_fn, last_ret);
+ cs_error(link->handle, last_fn, last_ret);
das16cs_pcmcia_release((u_long)link);
} /* das16cs_pcmcia_config */
/* Don't bother checking to see if these succeed or not */
if (link->win)
- CardServices(ReleaseWindow, link->win);
- CardServices(ReleaseConfiguration, link->handle);
+ pcmcia_release_window(link->win);
+ pcmcia_release_configuration(link->handle);
if (link->io.NumPorts1)
- CardServices(ReleaseIO, link->handle, &link->io);
+ pcmcia_release_io(link->handle, &link->io);
if (link->irq.AssignedIRQ)
- CardServices(ReleaseIRQ, link->handle, &link->irq);
+ pcmcia_release_irq(link->handle, &link->irq);
link->state &= ~DEV_CONFIG;
if (link->state & DEV_STALE_LINK)
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:
/* Mark the device as stopped, to block IO until later */
dev->stop = 1;
if (link->state & DEV_CONFIG)
- CardServices(ReleaseConfiguration, link->handle);
+ 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)
- CardServices(RequestConfiguration, link->handle, &link->conf);
+ pcmcia_request_configuration(link->handle, &link->conf);
dev->stop = 0;
/*
In a normal driver, additional code may go here to restore
} /* das16cs_pcmcia_event */
/*====================================================================*/
-
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0)
+struct pcmcia_driver das16cs_driver =
+{
+ .attach = das16cs_pcmcia_attach,
+ .detach = das16cs_pcmcia_detach,
+ .owner = THIS_MODULE,
+ .drv = {
+ .name = "cb_das16_cs",
+ },
+};
+#endif
static int __init init_das16cs_pcmcia_cs(void)
{
servinfo_t serv;
DEBUG(0, "%s\n", version);
- CardServices(GetCardServicesInfo, &serv);
+ pcmcia_get_card_services_info(&serv);
if (serv.Revision != CS_RELEASE_CODE)
{
printk(KERN_NOTICE "das16cs: Card Services release "
"does not match!\n");
//return -1;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
register_pccard_driver(&dev_info, &das16cs_pcmcia_attach, &das16cs_pcmcia_detach);
+#else
+ pcmcia_register_driver(&das16cs_driver);
+#endif
return 0;
}
static void __exit exit_das16cs_pcmcia_cs(void)
{
DEBUG(0, "das16cs_pcmcia_cs: unloading\n");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
unregister_pccard_driver(&dev_info);
+#else
+ pcmcia_unregister_driver(&das16cs_driver);
+#endif
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);
das16cs_pcmcia_detach(dev_list);