Skip to content

Commit

Permalink
[PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one …
Browse files Browse the repository at this point in the history
…probe callback

Unify the EVENT_CARD_INSERTION and "attach" callbacks to one unified
probe() callback. As all in-kernel drivers are changed to this new
callback, there will be no temporary backwards-compatibility. Inside a
probe() function, each driver _must_ set struct pcmcia_device
*p_dev->instance and instance->handle correctly.

With these patches, the basic driver interface for 16-bit PCMCIA drivers
now has the classic four callbacks known also from other buses:

        int (*probe)            (struct pcmcia_device *dev);
        void (*remove)          (struct pcmcia_device *dev);

        int (*suspend)          (struct pcmcia_device *dev);
        int (*resume)           (struct pcmcia_device *dev);

Signed-off-by: Dominik Brodowski <[email protected]>
  • Loading branch information
Dominik Brodowski committed Jan 5, 2006
1 parent b463581 commit f8cfa61
Show file tree
Hide file tree
Showing 48 changed files with 472 additions and 2,233 deletions.
6 changes: 4 additions & 2 deletions Documentation/pcmcia/driver-changes.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
This file details changes in 2.6 which affect PCMCIA card driver authors:

* Unify detach and REMOVAL event code (as of 2.6.16)
void (*remove) (struct pcmcia_device *dev);
* 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);
Expand Down
46 changes: 9 additions & 37 deletions drivers/bluetooth/bluecard_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ 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(struct pcmcia_device *p_dev);


Expand Down Expand Up @@ -860,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;
Expand All @@ -887,20 +881,13 @@ static dev_link_t *bluecard_attach(void)
link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO;

/* Register with Card Services */
link->next = NULL;
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->handle);
return NULL;
}
link->handle = p_dev;
p_dev->instance = link;

link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
bluecard_config(link);

return link;
return 0;
}


Expand Down Expand Up @@ -1046,20 +1033,6 @@ static int bluecard_resume(struct pcmcia_device *dev)
return 0;
}

static int bluecard_event(event_t event, int priority, event_callback_args_t *args)
{
dev_link_t *link = args->client_data;

switch (event) {
case CS_EVENT_CARD_INSERTION:
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
bluecard_config(link);
break;
}

return 0;
}

static struct pcmcia_device_id bluecard_ids[] = {
PCMCIA_DEVICE_PROD_ID12("BlueCard", "LSE041", 0xbaf16fbf, 0x657cc15e),
PCMCIA_DEVICE_PROD_ID12("BTCFCARD", "LSE139", 0xe3987764, 0x2524b59c),
Expand All @@ -1073,8 +1046,7 @@ static struct pcmcia_driver bluecard_driver = {
.drv = {
.name = "bluecard_cs",
},
.attach = bluecard_attach,
.event = bluecard_event,
.probe = bluecard_attach,
.remove = bluecard_detach,
.id_table = bluecard_ids,
.suspend = bluecard_suspend,
Expand Down
45 changes: 9 additions & 36 deletions drivers/bluetooth/bt3c_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ 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(struct pcmcia_device *p_dev);


Expand Down Expand Up @@ -661,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;
Expand All @@ -688,20 +682,13 @@ static dev_link_t *bt3c_attach(void)
link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO;

/* Register with Card Services */
link->next = NULL;
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->handle);
return NULL;
}
link->handle = p_dev;
p_dev->instance = link;

return link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
bt3c_config(link);

return 0;
}


Expand Down Expand Up @@ -892,19 +879,6 @@ static int bt3c_resume(struct pcmcia_device *dev)
return 0;
}

static int bt3c_event(event_t event, int priority, event_callback_args_t *args)
{
dev_link_t *link = args->client_data;

switch (event) {
case CS_EVENT_CARD_INSERTION:
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
bt3c_config(link);
break;
}

return 0;
}

static struct pcmcia_device_id bt3c_ids[] = {
PCMCIA_DEVICE_PROD_ID13("3COM", "Bluetooth PC Card", 0xefce0a31, 0xd4ce9b02),
Expand All @@ -917,8 +891,7 @@ static struct pcmcia_driver bt3c_driver = {
.drv = {
.name = "bt3c_cs",
},
.attach = bt3c_attach,
.event = bt3c_event,
.probe = bt3c_attach,
.remove = bt3c_detach,
.id_table = bt3c_ids,
.suspend = bt3c_suspend,
Expand Down
46 changes: 9 additions & 37 deletions drivers/bluetooth/btuart_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ 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(struct pcmcia_device *p_dev);


Expand Down Expand Up @@ -580,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;
Expand All @@ -607,20 +601,13 @@ static dev_link_t *btuart_attach(void)
link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO;

/* Register with Card Services */
link->next = NULL;
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->handle);
return NULL;
}
link->handle = p_dev;
p_dev->instance = link;

link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
btuart_config(link);

return link;
return 0;
}


Expand Down Expand Up @@ -813,20 +800,6 @@ static int btuart_resume(struct pcmcia_device *dev)
}


static int btuart_event(event_t event, int priority, event_callback_args_t *args)
{
dev_link_t *link = args->client_data;

switch (event) {
case CS_EVENT_CARD_INSERTION:
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
btuart_config(link);
break;
}

return 0;
}

static struct pcmcia_device_id btuart_ids[] = {
/* don't use this driver. Use serial_cs + hci_uart instead */
PCMCIA_DEVICE_NULL
Expand All @@ -838,8 +811,7 @@ static struct pcmcia_driver btuart_driver = {
.drv = {
.name = "btuart_cs",
},
.attach = btuart_attach,
.event = btuart_event,
.probe = btuart_attach,
.remove = btuart_detach,
.id_table = btuart_ids,
.suspend = btuart_suspend,
Expand Down
45 changes: 9 additions & 36 deletions drivers/bluetooth/dtl1_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ 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(struct pcmcia_device *p_dev);


Expand Down Expand Up @@ -559,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;
Expand All @@ -586,20 +580,13 @@ static dev_link_t *dtl1_attach(void)
link->conf.Vcc = 50;
link->conf.IntType = INT_MEMORY_AND_IO;

/* Register with Card Services */
link->next = NULL;
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->handle);
return NULL;
}
link->handle = p_dev;
p_dev->instance = link;

return link;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
dtl1_config(link);

return 0;
}


Expand Down Expand Up @@ -764,19 +751,6 @@ static int dtl1_resume(struct pcmcia_device *dev)
return 0;
}

static int dtl1_event(event_t event, int priority, event_callback_args_t *args)
{
dev_link_t *link = args->client_data;

switch (event) {
case CS_EVENT_CARD_INSERTION:
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
dtl1_config(link);
break;
}

return 0;
}

static struct pcmcia_device_id dtl1_ids[] = {
PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d),
Expand All @@ -790,8 +764,7 @@ static struct pcmcia_driver dtl1_driver = {
.drv = {
.name = "dtl1_cs",
},
.attach = dtl1_attach,
.event = dtl1_event,
.probe = dtl1_attach,
.remove = dtl1_detach,
.id_table = dtl1_ids,
.suspend = dtl1_suspend,
Expand Down
Loading

0 comments on commit f8cfa61

Please sign in to comment.