Skip to content

Commit

Permalink
[PATCH] pcmcia: use bitfield instead of p_state and state
Browse files Browse the repository at this point in the history
Instead of the two status values struct pcmcia_device->p_state and state,
use descriptive bitfields. Most value-checking in drivers was invalid, as
the core now only calls the ->remove() (a.k.a. detach) function in case the
attachement _and_ configuration was successful.

Signed-off-by: Dominik Brodowski <[email protected]>
  • Loading branch information
Dominik Brodowski committed Mar 31, 2006
1 parent f6fbe01 commit e2d4096
Show file tree
Hide file tree
Showing 49 changed files with 335 additions and 682 deletions.
14 changes: 3 additions & 11 deletions drivers/bluetooth/bluecard_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ static void bluecard_write_wakeup(bluecard_info_t *info)

clear_bit(XMIT_WAKEUP, &(info->tx_state));

if (!(info->p_dev->state & DEV_PRESENT))
if (!pcmcia_dev_present(info->p_dev))
return;

if (test_bit(XMIT_BUFFER_NUMBER, &(info->tx_state))) {
Expand Down Expand Up @@ -879,7 +879,6 @@ static int bluecard_probe(struct pcmcia_device *link)
link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.IntType = INT_MEMORY_AND_IO;

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

Expand All @@ -888,9 +887,7 @@ static void bluecard_detach(struct pcmcia_device *link)
{
bluecard_info_t *info = link->priv;

if (link->state & DEV_CONFIG)
bluecard_release(link);

bluecard_release(link);
kfree(info);
}

Expand Down Expand Up @@ -933,9 +930,6 @@ static int bluecard_config(struct pcmcia_device *link)
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

/* Configure card */
link->state |= DEV_CONFIG;

link->conf.ConfigIndex = 0x20;
link->io.NumPorts1 = 64;
link->io.IOAddrLines = 6;
Expand Down Expand Up @@ -969,7 +963,6 @@ static int bluecard_config(struct pcmcia_device *link)

strcpy(info->node.dev_name, info->hdev->name);
link->dev_node = &info->node;
link->state &= ~DEV_CONFIG_PENDING;

return 0;

Expand All @@ -986,8 +979,7 @@ static void bluecard_release(struct pcmcia_device *link)
{
bluecard_info_t *info = link->priv;

if (link->state & DEV_PRESENT)
bluecard_close(info);
bluecard_close(info);

del_timer(&(info->timer));

Expand Down
14 changes: 3 additions & 11 deletions drivers/bluetooth/bt3c_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ static void bt3c_write_wakeup(bt3c_info_t *info)
register struct sk_buff *skb;
register int len;

if (!(info->p_dev->state & DEV_PRESENT))
if (!pcmcia_dev_present(info->p_dev))
break;


Expand Down Expand Up @@ -668,7 +668,6 @@ static int bt3c_probe(struct pcmcia_device *link)
link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.IntType = INT_MEMORY_AND_IO;

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

Expand All @@ -677,9 +676,7 @@ static void bt3c_detach(struct pcmcia_device *link)
{
bt3c_info_t *info = link->priv;

if (link->state & DEV_CONFIG)
bt3c_release(link);

bt3c_release(link);
kfree(info);
}

Expand Down Expand Up @@ -733,9 +730,6 @@ static int bt3c_config(struct pcmcia_device *link)
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

/* Configure card */
link->state |= DEV_CONFIG;

/* First pass: look for a config entry that looks normal. */
tuple.TupleData = (cisdata_t *)buf;
tuple.TupleOffset = 0;
Expand Down Expand Up @@ -805,7 +799,6 @@ static int bt3c_config(struct pcmcia_device *link)

strcpy(info->node.dev_name, info->hdev->name);
link->dev_node = &info->node;
link->state &= ~DEV_CONFIG_PENDING;

return 0;

Expand All @@ -822,8 +815,7 @@ static void bt3c_release(struct pcmcia_device *link)
{
bt3c_info_t *info = link->priv;

if (link->state & DEV_PRESENT)
bt3c_close(info);
bt3c_close(info);

pcmcia_disable_device(link);
}
Expand Down
14 changes: 3 additions & 11 deletions drivers/bluetooth/btuart_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static void btuart_write_wakeup(btuart_info_t *info)

clear_bit(XMIT_WAKEUP, &(info->tx_state));

if (!(info->p_dev->state & DEV_PRESENT))
if (!pcmcia_dev_present(info->p_dev))
return;

if (!(skb = skb_dequeue(&(info->txq))))
Expand Down Expand Up @@ -599,7 +599,6 @@ static int btuart_probe(struct pcmcia_device *link)
link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.IntType = INT_MEMORY_AND_IO;

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

Expand All @@ -608,9 +607,7 @@ static void btuart_detach(struct pcmcia_device *link)
{
btuart_info_t *info = link->priv;

if (link->state & DEV_CONFIG)
btuart_release(link);

btuart_release(link);
kfree(info);
}

Expand Down Expand Up @@ -664,9 +661,6 @@ static int btuart_config(struct pcmcia_device *link)
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

/* Configure card */
link->state |= DEV_CONFIG;

/* First pass: look for a config entry that looks normal. */
tuple.TupleData = (cisdata_t *) buf;
tuple.TupleOffset = 0;
Expand Down Expand Up @@ -737,7 +731,6 @@ static int btuart_config(struct pcmcia_device *link)

strcpy(info->node.dev_name, info->hdev->name);
link->dev_node = &info->node;
link->state &= ~DEV_CONFIG_PENDING;

return 0;

Expand All @@ -754,8 +747,7 @@ static void btuart_release(struct pcmcia_device *link)
{
btuart_info_t *info = link->priv;

if (link->state & DEV_PRESENT)
btuart_close(info);
btuart_close(info);

pcmcia_disable_device(link);
}
Expand Down
13 changes: 3 additions & 10 deletions drivers/bluetooth/dtl1_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static void dtl1_write_wakeup(dtl1_info_t *info)

clear_bit(XMIT_WAKEUP, &(info->tx_state));

if (!(info->p_dev->state & DEV_PRESENT))
if (!pcmcia_dev_present(info->p_dev))
return;

if (!(skb = skb_dequeue(&(info->txq))))
Expand Down Expand Up @@ -578,7 +578,6 @@ static int dtl1_probe(struct pcmcia_device *link)
link->conf.Attributes = CONF_ENABLE_IRQ;
link->conf.IntType = INT_MEMORY_AND_IO;

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

Expand All @@ -587,8 +586,7 @@ static void dtl1_detach(struct pcmcia_device *link)
{
dtl1_info_t *info = link->priv;

if (link->state & DEV_CONFIG)
dtl1_release(link);
dtl1_release(link);

kfree(info);
}
Expand Down Expand Up @@ -642,9 +640,6 @@ static int dtl1_config(struct pcmcia_device *link)
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

/* Configure card */
link->state |= DEV_CONFIG;

tuple.TupleData = (cisdata_t *)buf;
tuple.TupleOffset = 0;
tuple.TupleDataMax = 255;
Expand Down Expand Up @@ -689,7 +684,6 @@ static int dtl1_config(struct pcmcia_device *link)

strcpy(info->node.dev_name, info->hdev->name);
link->dev_node = &info->node;
link->state &= ~DEV_CONFIG_PENDING;

return 0;

Expand All @@ -706,8 +700,7 @@ static void dtl1_release(struct pcmcia_device *link)
{
dtl1_info_t *info = link->priv;

if (link->state & DEV_PRESENT)
dtl1_close(info);
dtl1_close(info);

pcmcia_disable_device(link);
}
Expand Down
13 changes: 3 additions & 10 deletions drivers/char/pcmcia/cm4000_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
if (count == 0) /* according to manpage */
return 0;

if ((dev->p_dev->state & DEV_PRESENT) == 0 || /* socket removed */
if (!pcmcia_dev_present(dev->p_dev) || /* device removed */
test_bit(IS_CMM_ABSENT, &dev->flags))
return -ENODEV;

Expand Down Expand Up @@ -1108,7 +1108,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf,

sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0;

if ((dev->p_dev->state & DEV_PRESENT) == 0 || /* socket removed */
if (!pcmcia_dev_present(dev->p_dev) || /* device removed */
test_bit(IS_CMM_ABSENT, &dev->flags))
return -ENODEV;

Expand Down Expand Up @@ -1789,7 +1789,6 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
goto cs_failed;
}

link->state |= DEV_CONFIG;
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

Expand Down Expand Up @@ -1844,16 +1843,13 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
dev->node.minor = devno;
dev->node.next = NULL;
link->dev_node = &dev->node;
link->state &= ~DEV_CONFIG_PENDING;

return 0;

cs_failed:
cs_error(link, fail_fn, fail_rc);
cs_release:
cm4000_release(link);

link->state &= ~DEV_CONFIG_PENDING;
return -ENODEV;
}

Expand Down Expand Up @@ -1913,7 +1909,6 @@ static int cm4000_probe(struct pcmcia_device *link)
init_waitqueue_head(&dev->atrq);
init_waitqueue_head(&dev->readq);

link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
ret = cm4000_config(link, i);
if (ret)
return ret;
Expand All @@ -1936,11 +1931,9 @@ static void cm4000_detach(struct pcmcia_device *link)
if (devno == CM4000_MAX_DEV)
return;

link->state &= ~DEV_PRESENT;
stop_monitor(dev);

if (link->state & DEV_CONFIG)
cm4000_release(link);
cm4000_release(link);

dev_table[devno] = NULL;
kfree(dev);
Expand Down
16 changes: 4 additions & 12 deletions drivers/char/pcmcia/cm4040_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
return -EAGAIN;
}

if ((dev->p_dev->state & DEV_PRESENT)==0)
if (!pcmcia_dev_present(dev->p_dev))
return -ENODEV;

for (i = 0; i < 5; i++) {
Expand Down Expand Up @@ -351,7 +351,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
return -EAGAIN;
}

if ((dev->p_dev->state & DEV_PRESENT) == 0)
if (!pcmcia_dev_present(dev->p_dev))
return -ENODEV;

bytes_to_write = count;
Expand Down Expand Up @@ -543,7 +543,6 @@ static int reader_config(struct pcmcia_device *link, int devno)
goto cs_failed;
}

link->state |= DEV_CONFIG;
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];

Expand Down Expand Up @@ -602,9 +601,7 @@ static int reader_config(struct pcmcia_device *link, int devno)
sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno);
dev->node.major = major;
dev->node.minor = devno;
dev->node.next = NULL;
link->dev_node = &dev->node;
link->state &= ~DEV_CONFIG_PENDING;
dev->node.next = &dev->node;

DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno,
link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1);
Expand All @@ -616,7 +613,6 @@ static int reader_config(struct pcmcia_device *link, int devno)
cs_error(link, fail_fn, fail_rc);
cs_release:
reader_release(link);
link->state &= ~DEV_CONFIG_PENDING;
return -ENODEV;
}

Expand Down Expand Up @@ -659,7 +655,6 @@ static int reader_probe(struct pcmcia_device *link)
init_timer(&dev->poll_timer);
dev->poll_timer.function = &cm4040_do_poll;

link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
ret = reader_config(link, i);
if (ret)
return ret;
Expand All @@ -683,10 +678,7 @@ static void reader_detach(struct pcmcia_device *link)
if (devno == CM_MAX_DEV)
return;

link->state &= ~DEV_PRESENT;

if (link->state & DEV_CONFIG)
reader_release(link);
reader_release(link);

dev_table[devno] = NULL;
kfree(dev);
Expand Down
Loading

0 comments on commit e2d4096

Please sign in to comment.