[PATCH] pcmcia: convert DEV_OK to pcmcia_dev_present

Instead of the DEV_OK macro, drivers should use pcmcia_dev_present().

Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
This commit is contained in:
Dominik Brodowski 2006-03-05 11:04:33 +01:00
parent e2d4096365
commit 9940ec3617
21 changed files with 59 additions and 36 deletions

View File

@ -1458,7 +1458,7 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
iminor(inode), ioctl_names[_IOC_NR(cmd)]); iminor(inode), ioctl_names[_IOC_NR(cmd)]);
link = dev_table[iminor(inode)]; link = dev_table[iminor(inode)];
if (!(DEV_OK(link))) { if (!pcmcia_dev_present(link)) {
DEBUGP(4, dev, "DEV_OK false\n"); DEBUGP(4, dev, "DEV_OK false\n");
return -ENODEV; return -ENODEV;
} }
@ -1667,7 +1667,7 @@ static int cmm_open(struct inode *inode, struct file *filp)
return -ENODEV; return -ENODEV;
link = dev_table[minor]; link = dev_table[minor];
if (link == NULL || !(DEV_OK(link))) if (link == NULL || !pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
if (link->open) if (link->open)

View File

@ -452,7 +452,7 @@ static int cm4040_open(struct inode *inode, struct file *filp)
return -ENODEV; return -ENODEV;
link = dev_table[minor]; link = dev_table[minor];
if (link == NULL || !(DEV_OK(link))) if (link == NULL || !pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
if (link->open) if (link->open)

View File

@ -728,7 +728,7 @@ static int el3_open(struct net_device *dev)
struct el3_private *lp = netdev_priv(dev); struct el3_private *lp = netdev_priv(dev);
struct pcmcia_device *link = lp->p_dev; struct pcmcia_device *link = lp->p_dev;
if (!DEV_OK(link)) if (!pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
link->open++; link->open++;
@ -1176,7 +1176,7 @@ static int el3_close(struct net_device *dev)
DEBUG(2, "%s: shutting down ethercard.\n", dev->name); DEBUG(2, "%s: shutting down ethercard.\n", dev->name);
if (DEV_OK(link)) { if (pcmcia_dev_present(link)) {
unsigned long flags; unsigned long flags;
/* Turn off statistics ASAP. We update lp->stats below. */ /* Turn off statistics ASAP. We update lp->stats below. */

View File

@ -557,7 +557,7 @@ static int el3_open(struct net_device *dev)
struct el3_private *lp = netdev_priv(dev); struct el3_private *lp = netdev_priv(dev);
struct pcmcia_device *link = lp->p_dev; struct pcmcia_device *link = lp->p_dev;
if (!DEV_OK(link)) if (!pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
link->open++; link->open++;
@ -818,7 +818,7 @@ static struct net_device_stats *el3_get_stats(struct net_device *dev)
unsigned long flags; unsigned long flags;
struct pcmcia_device *link = lp->p_dev; struct pcmcia_device *link = lp->p_dev;
if (DEV_OK(link)) { if (pcmcia_dev_present(link)) {
spin_lock_irqsave(&lp->lock, flags); spin_lock_irqsave(&lp->lock, flags);
update_stats(dev); update_stats(dev);
spin_unlock_irqrestore(&lp->lock, flags); spin_unlock_irqrestore(&lp->lock, flags);
@ -922,7 +922,7 @@ static void set_multicast_list(struct net_device *dev)
kio_addr_t ioaddr = dev->base_addr; kio_addr_t ioaddr = dev->base_addr;
u16 opts = SetRxFilter | RxStation | RxBroadcast; u16 opts = SetRxFilter | RxStation | RxBroadcast;
if (!(DEV_OK(link))) return; if (!pcmcia_dev_present(link)) return;
if (dev->flags & IFF_PROMISC) if (dev->flags & IFF_PROMISC)
opts |= RxMulticast | RxProm; opts |= RxMulticast | RxProm;
else if (dev->mc_count || (dev->flags & IFF_ALLMULTI)) else if (dev->mc_count || (dev->flags & IFF_ALLMULTI))
@ -938,7 +938,7 @@ static int el3_close(struct net_device *dev)
DEBUG(1, "%s: shutting down ethercard.\n", dev->name); DEBUG(1, "%s: shutting down ethercard.\n", dev->name);
if (DEV_OK(link)) { if (pcmcia_dev_present(link)) {
/* Turn off statistics ASAP. We update lp->stats below. */ /* Turn off statistics ASAP. We update lp->stats below. */
outw(StatsDisable, ioaddr + EL3_CMD); outw(StatsDisable, ioaddr + EL3_CMD);

View File

@ -530,7 +530,7 @@ static int axnet_open(struct net_device *dev)
DEBUG(2, "axnet_open('%s')\n", dev->name); DEBUG(2, "axnet_open('%s')\n", dev->name);
if (!DEV_OK(link)) if (!pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
link->open++; link->open++;

View File

@ -1112,7 +1112,7 @@ static int fjn_open(struct net_device *dev)
DEBUG(4, "fjn_open('%s').\n", dev->name); DEBUG(4, "fjn_open('%s').\n", dev->name);
if (!DEV_OK(link)) if (!pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
link->open++; link->open++;

View File

@ -853,7 +853,7 @@ static int mace_open(struct net_device *dev)
mace_private *lp = netdev_priv(dev); mace_private *lp = netdev_priv(dev);
struct pcmcia_device *link = lp->p_dev; struct pcmcia_device *link = lp->p_dev;
if (!DEV_OK(link)) if (!pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
link->open++; link->open++;

View File

@ -992,7 +992,7 @@ static int pcnet_open(struct net_device *dev)
DEBUG(2, "pcnet_open('%s')\n", dev->name); DEBUG(2, "pcnet_open('%s')\n", dev->name);
if (!DEV_OK(link)) if (!pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
link->open++; link->open++;

View File

@ -1259,7 +1259,7 @@ static int smc_open(struct net_device *dev)
#endif #endif
/* Check that the PCMCIA card is still here. */ /* Check that the PCMCIA card is still here. */
if (!DEV_OK(link)) if (!pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
/* Physical device present signature. */ /* Physical device present signature. */
if (check_sig(link) < 0) { if (check_sig(link) < 0) {

View File

@ -1525,7 +1525,7 @@ do_open(struct net_device *dev)
/* Check that the PCMCIA card is still here. */ /* Check that the PCMCIA card is still here. */
/* Physical device present signature. */ /* Physical device present signature. */
if (!DEV_OK(link)) if (!pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
/* okay */ /* okay */

View File

@ -216,13 +216,12 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
/* Call-back function to interrogate PCMCIA-specific information /* Call-back function to interrogate PCMCIA-specific information
about the current existance of the card */ about the current existance of the card */
static int card_present(void *arg) static int card_present(void *arg)
{ {
struct pcmcia_device *link = (struct pcmcia_device *)arg; struct pcmcia_device *link = (struct pcmcia_device *)arg;
if (link->suspended)
return 0; if (pcmcia_dev_present(link))
else if (pcmcia_dev_present(link))
return 1; return 1;
return 0; return 0;
} }

View File

@ -210,7 +210,7 @@ static int prism2_config(struct pcmcia_device *link);
static int prism2_pccard_card_present(local_info_t *local) static int prism2_pccard_card_present(local_info_t *local)
{ {
struct hostap_cs_priv *hw_priv = local->hw_priv; struct hostap_cs_priv *hw_priv = local->hw_priv;
if (hw_priv != NULL && hw_priv->link != NULL && DEV_OK(hw_priv->link)) if (hw_priv != NULL && hw_priv->link != NULL && pcmcia_dev_present(hw_priv->link))
return 1; return 1;
return 0; return 0;
} }

View File

@ -1107,7 +1107,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id, struct pt_regs *regs
status = inb(iobase + NETWAVE_REG_ASR); status = inb(iobase + NETWAVE_REG_ASR);
if (!DEV_OK(link)) { if (!pcmcia_dev_present(link)) {
DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x " DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x "
"from removed or suspended card!\n", status); "from removed or suspended card!\n", status);
break; break;
@ -1346,7 +1346,7 @@ static int netwave_open(struct net_device *dev) {
DEBUG(1, "netwave_open: starting.\n"); DEBUG(1, "netwave_open: starting.\n");
if (!DEV_OK(link)) if (!pcmcia_dev_present(link))
return -ENODEV; return -ENODEV;
link->open++; link->open++;

View File

@ -1961,7 +1961,7 @@ static irqreturn_t ray_interrupt(int irq, void *dev_id, struct pt_regs * regs)
local = (ray_dev_t *)dev->priv; local = (ray_dev_t *)dev->priv;
link = (struct pcmcia_device *)local->finder; link = (struct pcmcia_device *)local->finder;
if (!(pcmcia_dev_present(link)) || link->suspended ) { if (!pcmcia_dev_present(link)) {
DEBUG(2,"ray_cs interrupt from device not present or suspended.\n"); DEBUG(2,"ray_cs interrupt from device not present or suspended.\n");
return IRQ_NONE; return IRQ_NONE;
} }

View File

@ -1387,7 +1387,7 @@ static int wl3501_open(struct net_device *dev)
link = this->p_dev; link = this->p_dev;
spin_lock_irqsave(&this->lock, flags); spin_lock_irqsave(&this->lock, flags);
if (!DEV_OK(link)) if (!pcmcia_dev_present(link))
goto out; goto out;
netif_device_attach(dev); netif_device_attach(dev);
link->open++; link->open++;

View File

@ -469,6 +469,7 @@ static void pcmcia_card_remove(struct pcmcia_socket *s)
} }
p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list); p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list);
list_del(&p_dev->socket_device_list); list_del(&p_dev->socket_device_list);
p_dev->_removed=1;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
device_unregister(&p_dev->dev); device_unregister(&p_dev->dev);
@ -1163,6 +1164,32 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
} /* ds_event */ } /* ds_event */
struct pcmcia_device * pcmcia_dev_present(struct pcmcia_device *_p_dev)
{
struct pcmcia_device *p_dev;
struct pcmcia_device *ret = NULL;
p_dev = pcmcia_get_dev(_p_dev);
if (!p_dev)
return NULL;
if (!p_dev->socket->pcmcia_state.present)
goto out;
if (p_dev->_removed)
goto out;
if (p_dev->suspended)
goto out;
ret = p_dev;
out:
pcmcia_put_dev(p_dev);
return ret;
}
EXPORT_SYMBOL(pcmcia_dev_present);
static struct pcmcia_callback pcmcia_bus_callback = { static struct pcmcia_callback pcmcia_bus_callback = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.event = ds_event, .event = ds_event,

View File

@ -155,7 +155,7 @@ static int serial_suspend(struct pcmcia_device *link)
static int serial_resume(struct pcmcia_device *link) static int serial_resume(struct pcmcia_device *link)
{ {
if (DEV_OK(link)) { if (pcmcia_dev_present(link)) {
struct serial_info *info = link->priv; struct serial_info *info = link->priv;
int i; int i;

View File

@ -390,6 +390,7 @@ int pcmcia_eject_card(struct pcmcia_socket *skt);
int pcmcia_insert_card(struct pcmcia_socket *skt); int pcmcia_insert_card(struct pcmcia_socket *skt);
int pccard_reset_card(struct pcmcia_socket *skt); int pccard_reset_card(struct pcmcia_socket *skt);
struct pcmcia_device * pcmcia_dev_present(struct pcmcia_device *p_dev);
void pcmcia_disable_device(struct pcmcia_device *p_dev); void pcmcia_disable_device(struct pcmcia_device *p_dev);
struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt); struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt);

View File

@ -104,12 +104,6 @@ typedef struct dev_node_t {
struct dev_node_t *next; struct dev_node_t *next;
} dev_node_t; } dev_node_t;
#define pcmcia_dev_present(p_dev) \
(p_dev->socket->pcmcia_state.present)
#define DEV_OK(l) \
((l) && (!l->suspended) && pcmcia_dev_present(l))
struct pcmcia_socket; struct pcmcia_socket;
struct config_t; struct config_t;
@ -155,8 +149,10 @@ struct pcmcia_device {
config_req_t conf; config_req_t conf;
window_handle_t win; window_handle_t win;
/* Is the device suspended? */ /* Is the device suspended, or in the process of
* being removed? */
u16 suspended:1; u16 suspended:1;
u16 _removed:1;
/* Flags whether io, irq, win configurations were /* Flags whether io, irq, win configurations were
* requested, and whether the configuration is "locked" */ * requested, and whether the configuration is "locked" */
@ -174,7 +170,7 @@ struct pcmcia_device {
u16 has_card_id:1; u16 has_card_id:1;
u16 has_func_id:1; u16 has_func_id:1;
u16 reserved:4; u16 reserved:3;
u8 func_id; u8 func_id;
u16 manf_id; u16 manf_id;

View File

@ -280,7 +280,7 @@ static int pdacf_resume(struct pcmcia_device *link)
struct snd_pdacf *chip = link->priv; struct snd_pdacf *chip = link->priv;
snd_printdd(KERN_DEBUG "RESUME\n"); snd_printdd(KERN_DEBUG "RESUME\n");
if (DEV_OK(link)) { if (pcmcia_dev_present(link)) {
if (chip) { if (chip) {
snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n");
snd_pdacf_resume(chip); snd_pdacf_resume(chip);

View File

@ -291,7 +291,7 @@ static int vxp_resume(struct pcmcia_device *link)
struct vx_core *chip = link->priv; struct vx_core *chip = link->priv;
snd_printdd(KERN_DEBUG "RESUME\n"); snd_printdd(KERN_DEBUG "RESUME\n");
if (DEV_OK(link)) { if (pcmcia_dev_present(link)) {
//struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
if (chip) { if (chip) {
snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); snd_printdd(KERN_DEBUG "calling snd_vx_resume\n");