Commit d7906de1 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
parents fbd91ac2 725a6abf
This file details changes in 2.6 which affect PCMCIA card driver authors:
* Unify detach and REMOVAL event code, as well as attach and INSERTION
code (as of 2.6.16)
void (*remove) (struct pcmcia_device *dev);
int (*probe) (struct pcmcia_device *dev);
* Move suspend, resume and reset out of event handler (as of 2.6.16)
int (*suspend) (struct pcmcia_device *dev);
int (*resume) (struct pcmcia_device *dev);
should be initialized in struct pcmcia_driver, and handle
(SUSPEND == RESET_PHYSICAL) and (RESUME == CARD_RESET) events
* event handler initialization in struct pcmcia_driver (as of 2.6.13)
The event handler is notified of all events, and must be initialized
as the event() callback in the driver's struct pcmcia_driver.
......
......@@ -62,6 +62,7 @@ int dpm_runtime_suspend(struct device * dev, pm_message_t state)
up(&dpm_sem);
return error;
}
EXPORT_SYMBOL(dpm_runtime_suspend);
#if 0
......
......@@ -87,14 +87,8 @@ typedef struct bluecard_info_t {
static void bluecard_config(dev_link_t *link);
static void bluecard_release(dev_link_t *link);
static int bluecard_event(event_t event, int priority, event_callback_args_t *args);
static dev_info_t dev_info = "bluecard_cs";
static dev_link_t *bluecard_attach(void);
static void bluecard_detach(dev_link_t *);
static dev_link_t *dev_list = NULL;
static void bluecard_detach(struct pcmcia_device *p_dev);
/* Default baud rate: 57600, 115200, 230400 or 460800 */
......@@ -862,17 +856,15 @@ static int bluecard_close(bluecard_info_t *info)
return 0;
}
static dev_link_t *bluecard_attach(void)
static int bluecard_attach(struct pcmcia_device *p_dev)
{
bluecard_info_t *info;
client_reg_t client_reg;
dev_link_t *link;
int ret;
/* Create new info device */
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return NULL;
return -ENOMEM;
link = &info->link;
link->priv = info;
......@@ -889,50 +881,24 @@ static dev_link_t *bluecard_attach(void)
link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO;
/* Register with Card Services */
link->next = dev_list;
dev_list = link;
client_reg.dev_info = &dev_info;
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);
bluecard_detach(link);
return NULL;
}
link->handle = p_dev;
p_dev->instance = link;
return link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
bluecard_config(link);
return 0;
}
static void bluecard_detach(dev_link_t *link)
static void bluecard_detach(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
bluecard_info_t *info = link->priv;
dev_link_t **linkp;
int ret;
/* Locate device structure */
for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
if (*linkp == link)
break;
if (*linkp == NULL)
return;
if (link->state & DEV_CONFIG)
bluecard_release(link);
if (link->handle) {
ret = pcmcia_deregister_client(link->handle);
if (ret != CS_SUCCESS)
cs_error(link->handle, DeregisterClient, ret);
}
/* Unlink device structure, free bits */
*linkp = link->next;
kfree(info);
}
......@@ -1045,39 +1011,24 @@ static void bluecard_release(dev_link_t *link)
link->state &= ~DEV_CONFIG;
}
static int bluecard_suspend(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);
link->state |= DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);
static int bluecard_event(event_t event, int priority, event_callback_args_t *args)
return 0;
}
static int bluecard_resume(struct pcmcia_device *dev)
{
dev_link_t *link = args->client_data;
bluecard_info_t *info = link->priv;
dev_link_t *link = dev_to_instance(dev);
switch (event) {
case CS_EVENT_CARD_REMOVAL:
link->state &= ~DEV_PRESENT;
if (link->state & DEV_CONFIG) {
bluecard_close(info);
bluecard_release(link);
}
break;
case CS_EVENT_CARD_INSERTION:
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
bluecard_config(link);
break;
case CS_EVENT_PM_SUSPEND:
link->state |= DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_RESET_PHYSICAL:
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 (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);
break;
}
link->state &= ~DEV_SUSPEND;
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);
return 0;
}
......@@ -1095,10 +1046,11 @@ static struct pcmcia_driver bluecard_driver = {
.drv = {
.name = "bluecard_cs",
},
.attach = bluecard_attach,
.event = bluecard_event,
.detach = bluecard_detach,
.probe = bluecard_attach,
.remove = bluecard_detach,
.id_table = bluecard_ids,
.suspend = bluecard_suspend,
.resume = bluecard_resume,
};
static int __init init_bluecard_cs(void)
......@@ -1110,7 +1062,6 @@ static int __init init_bluecard_cs(void)
static void __exit exit_bluecard_cs(void)
{
pcmcia_unregister_driver(&bluecard_driver);
BUG_ON(dev_list != NULL);
}
module_init(init_bluecard_cs);
......
......@@ -90,14 +90,8 @@ typedef struct bt3c_info_t {
static void bt3c_config(dev_link_t *link);
static void bt3c_release(dev_link_t *link);
static int bt3c_event(event_t event, int priority, event_callback_args_t *args);
static dev_info_t dev_info = "bt3c_cs";
static dev_link_t *bt3c_attach(void);
static void bt3c_detach(dev_link_t *);
static dev_link_t *dev_list = NULL;
static void bt3c_detach(struct pcmcia_device *p_dev);
/* Transmit states */
......@@ -663,17 +657,15 @@ static int bt3c_close(bt3c_info_t *info)
return 0;
}
static dev_link_t *bt3c_attach(void)
static int bt3c_attach(struct pcmcia_device *p_dev)
{
bt3c_info_t *info;
client_reg_t client_reg;
dev_link_t *link;
int ret;
/* Create new info device */
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return NULL;
return -ENOMEM;
link = &info->link;
link->priv = info;
......@@ -690,50 +682,24 @@ static dev_link_t *bt3c_attach(void)
link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO;
/* Register with Card Services */
link->next = dev_list;
dev_list = link;
client_reg.dev_info = &dev_info;
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);
bt3c_detach(link);
return NULL;
}
link->handle = p_dev;
p_dev->instance = link;
return link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
bt3c_config(link);
return 0;
}
static void bt3c_detach(dev_link_t *link)
static void bt3c_detach(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
bt3c_info_t *info = link->priv;
dev_link_t **linkp;
int ret;
/* Locate device structure */
for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
if (*linkp == link)
break;
if (*linkp == NULL)
return;
if (link->state & DEV_CONFIG)
bt3c_release(link);
if (link->handle) {
ret = pcmcia_deregister_client(link->handle);
if (ret != CS_SUCCESS)
cs_error(link->handle, DeregisterClient, ret);
}
/* Unlink device structure, free bits */
*linkp = link->next;
kfree(info);
}
......@@ -891,43 +857,29 @@ static void bt3c_release(dev_link_t *link)
link->state &= ~DEV_CONFIG;
}
static int bt3c_suspend(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);
static int bt3c_event(event_t event, int priority, event_callback_args_t *args)
link->state |= DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);
return 0;
}
static int bt3c_resume(struct pcmcia_device *dev)
{
dev_link_t *link = args->client_data;
bt3c_info_t *info = link->priv;
dev_link_t *link = dev_to_instance(dev);
switch (event) {
case CS_EVENT_CARD_REMOVAL:
link->state &= ~DEV_PRESENT;
if (link->state & DEV_CONFIG) {
bt3c_close(info);
bt3c_release(link);
}
break;
case CS_EVENT_CARD_INSERTION:
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
bt3c_config(link);
break;
case CS_EVENT_PM_SUSPEND:
link->state |= DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_RESET_PHYSICAL:
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 (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);
break;
}
link->state &= ~DEV_SUSPEND;
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);
return 0;
}
static struct pcmcia_device_id bt3c_ids[] = {
PCMCIA_DEVICE_PROD_ID13("3COM", "Bluetooth PC Card", 0xefce0a31, 0xd4ce9b02),
PCMCIA_DEVICE_NULL
......@@ -939,10 +891,11 @@ static struct pcmcia_driver bt3c_driver = {
.drv = {
.name = "bt3c_cs",
},
.attach = bt3c_attach,
.event = bt3c_event,
.detach = bt3c_detach,
.probe = bt3c_attach,
.remove = bt3c_detach,
.id_table = bt3c_ids,
.suspend = bt3c_suspend,
.resume = bt3c_resume,
};
static int __init init_bt3c_cs(void)
......@@ -954,7 +907,6 @@ static int __init init_bt3c_cs(void)
static void __exit exit_bt3c_cs(void)
{
pcmcia_unregister_driver(&bt3c_driver);
BUG_ON(dev_list != NULL);
}
module_init(init_bt3c_cs);
......
......@@ -86,14 +86,8 @@ typedef struct btuart_info_t {
static void btuart_config(dev_link_t *link);
static void btuart_release(dev_link_t *link);
static int btuart_event(event_t event, int priority, event_callback_args_t *args);
static dev_info_t dev_info = "btuart_cs";
static dev_link_t *btuart_attach(void);
static void btuart_detach(dev_link_t *);
static dev_link_t *dev_list = NULL;
static void btuart_detach(struct pcmcia_device *p_dev);
/* Maximum baud rate */
......@@ -582,17 +576,15 @@ static int btuart_close(btuart_info_t *info)
return 0;
}
static dev_link_t *btuart_attach(void)
static int btuart_attach(struct pcmcia_device *p_dev)
{
btuart_info_t *info;
client_reg_t client_reg;
dev_link_t *link;
int ret;
/* Create new info device */
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return NULL;
return -ENOMEM;
link = &info->link;
link->priv = info;
......@@ -609,50 +601,24 @@ static dev_link_t *btuart_attach(void)
link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO;
/* Register with Card Services */
link->next = dev_list;
dev_list = link;
client_reg.dev_info = &dev_info;
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);
btuart_detach(link);
return NULL;
}
link->handle = p_dev;
p_dev->instance = link;
return link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
btuart_config(link);
return 0;
}
static void btuart_detach(dev_link_t *link)
static void btuart_detach(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);
btuart_info_t *info = link->priv;
dev_link_t **linkp;
int ret;
/* Locate device structure */
for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
if (*linkp == link)
break;
if (*linkp == NULL)
return;
if (link->state & DEV_CONFIG)
btuart_release(link);
if (link->handle) {
ret = pcmcia_deregister_client(link->handle);
if (ret != CS_SUCCESS)
cs_error(link->handle, DeregisterClient, ret);
}
/* Unlink device structure, free bits */
*linkp = link->next;
kfree(info);
}
......@@ -811,43 +777,29 @@ static void btuart_release(dev_link_t *link)
link->state &= ~DEV_CONFIG;
}
static int btuart_suspend(struct pcmcia_device *dev)
{
dev_link_t *link = dev_to_instance(dev);
static int btuart_event(event_t event, int priority, event_callback_args_t *args)
link->state |= DEV_SUSPEND;
if (link->state & DEV_CONFIG)
pcmcia_release_configuration(link->handle);
return 0;
}
static int btuart_resume(struct pcmcia_device *dev)
{
dev_link_t *link = args->client_data;
btuart_info_t *info = link->priv;
dev_link_t *link = dev_to_instance(dev);
switch (event) {
case CS_EVENT_CARD_REMOVAL:
link->state &= ~DEV_PRESENT;
if (link->state & DEV_CONFIG) {
btuart_close(info);
btuart_release(link);
}
break;
case CS_EVENT_CARD_INSERTION:
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
btuart_config(link);
break;
case CS_EVENT_PM_SUSPEND:
link->state |= DEV_SUSPEND;
/* Fall through... */
case CS_EVENT_RESET_PHYSICAL:
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 (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);
break;
}
link->state &= ~DEV_SUSPEND;
if (DEV_OK(link))
pcmcia_request_configuration(link->handle, &link->conf);
return 0;
}
static struct pcmcia_device_id btuart_ids[] = {
/* don't use this driver. Use serial_cs + hci_uart instead */
PCMCIA_DEVICE_NULL
......@@ -859,10 +811,11 @@ static struct pcmcia_driver btuart_driver = {
.drv = {
.name = "btuart_cs",
},
.attach = btuart_attach,
.event = btuart_event,
.detach = btuart_detach,
.probe = btuart_attach,
.remove = btuart_detach,
.id_table = btuart_ids,
.suspend = btuart_suspend,
.resume = btuart_resume,
};
static int __init init_btuart_cs(void)
......@@ -874,7 +827,6 @@ static int __init init_btuart_cs(void)
static void __exit exit_btuart_cs(void)
{
pcmcia_unregister_driver(&btuart_driver);
BUG_ON(dev_list != NULL);
}
module_init(init_btuart_cs);
......
......@@ -89,14 +89,8 @@ typedef struct dtl1_info_t {
static void dtl1_config(dev_link_t *link);
static void dtl1_release(dev_link_t *link);
static int dtl1_event(event_t event, int priority, event_callback_args_t *args);
static dev_info_t dev_info = "dtl1_cs";
static dev_link_t *dtl1_attach(void);
static void dtl1_detach(dev_link_t *);
static dev_link_t *dev_list = NULL;
static void dtl1_detach(struct pcmcia_device *p_dev);
/* Transmit states */
......@@ -561,17 +555,15 @@ static int dtl1_close(dtl1_info_t *info)
return 0;
}
static dev_link_t *dtl1_attach(void)
static int dtl1_attach(struct pcmcia_device *p_dev)
{
dtl1_info_t *info;
client_reg_t client_reg;
dev_link_t *link;
int ret;
/* Create new info device */
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return NULL;
return -ENOMEM;
link = &info->link;
link->priv = info;
......@@ -588,50 +580,24 @@ static dev_link_t *dtl1_attach(void)
link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO;
/* Register with Card Services */
link->next = dev_list;
dev_list = link;
client_reg.dev_info = &dev_info;
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);
dtl1_detach(link);
return NULL;
}
link->handle = p_dev;
p_dev->instance = link;
return link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
dtl1_config(link);
return 0;
}
static void dtl1_detach(dev_link_t *link)
static void dtl1_detach(struct pcmcia_device *p_dev)
{
dev_link_t *link = dev_to_instance(p_dev);