aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2006-03-01 18:09:29 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 10:26:33 -0500
commite2d4096365e06b9a3799afbadc28b4519c0b3526 (patch)
tree90ec691d71f9c0309048714e359b8ba351b533f7 /drivers/pcmcia
parentf6fbe01ac976f3ec618cd5fb71ad9ce2cfa7ab2b (diff)
[PATCH] pcmcia: use bitfield instead of p_state and state
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 <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r--drivers/pcmcia/cs_internal.h2
-rw-r--r--drivers/pcmcia/ds.c41
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c4
-rw-r--r--drivers/pcmcia/pcmcia_resource.c24
4 files changed, 35 insertions, 36 deletions
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index ecc579bbaeba..d6164cd583fd 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -23,7 +23,7 @@
23#define CLIENT_IO_REQ 0x0004 23#define CLIENT_IO_REQ 0x0004
24#define CLIENT_UNBOUND 0x0008 24#define CLIENT_UNBOUND 0x0008
25#define CLIENT_STALE 0x0010 25#define CLIENT_STALE 0x0010
26#define CLIENT_WIN_REQ(i) (0x20<<(i)) 26#define CLIENT_WIN_REQ(i) (0x1<<(i))
27#define CLIENT_CARDBUS 0x8000 27#define CLIENT_CARDBUS 0x8000
28 28
29#define REGION_MAGIC 0xE3C9 29#define REGION_MAGIC 0xE3C9
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 34e634aa48e4..8c87343707cf 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -390,8 +390,6 @@ static int pcmcia_device_probe(struct device * dev)
390 goto put_dev; 390 goto put_dev;
391 } 391 }
392 392
393 p_dev->p_state &= ~CLIENT_UNBOUND;
394
395 ret = p_drv->probe(p_dev); 393 ret = p_drv->probe(p_dev);
396 if (ret) 394 if (ret)
397 goto put_module; 395 goto put_module;
@@ -433,17 +431,16 @@ static int pcmcia_device_remove(struct device * dev)
433 p_drv->remove(p_dev); 431 p_drv->remove(p_dev);
434 432
435 /* check for proper unloading */ 433 /* check for proper unloading */
436 if (p_dev->p_state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED)) 434 if (p_dev->_irq || p_dev->_io || p_dev->_locked)
437 printk(KERN_INFO "pcmcia: driver %s did not release config properly\n", 435 printk(KERN_INFO "pcmcia: driver %s did not release config properly\n",
438 p_drv->drv.name); 436 p_drv->drv.name);
439 437
440 for (i = 0; i < MAX_WIN; i++) 438 for (i = 0; i < MAX_WIN; i++)
441 if (p_dev->p_state & CLIENT_WIN_REQ(i)) 439 if (p_dev->_win & CLIENT_WIN_REQ(i))
442 printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n", 440 printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n",
443 p_drv->drv.name); 441 p_drv->drv.name);
444 442
445 /* references from pcmcia_probe_device */ 443 /* references from pcmcia_probe_device */
446 p_dev->p_state = CLIENT_UNBOUND;
447 pcmcia_put_dev(p_dev); 444 pcmcia_put_dev(p_dev);
448 module_put(p_drv->owner); 445 module_put(p_drv->owner);
449 446
@@ -472,7 +469,6 @@ static void pcmcia_card_remove(struct pcmcia_socket *s)
472 } 469 }
473 p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list); 470 p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list);
474 list_del(&p_dev->socket_device_list); 471 list_del(&p_dev->socket_device_list);
475 p_dev->p_state |= CLIENT_STALE;
476 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 472 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
477 473
478 device_unregister(&p_dev->dev); 474 device_unregister(&p_dev->dev);
@@ -602,9 +598,6 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
602 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); 598 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id);
603 599
604 /* compat */ 600 /* compat */
605 p_dev->p_state = CLIENT_UNBOUND;
606
607
608 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 601 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
609 602
610 /* 603 /*
@@ -1033,15 +1026,18 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1033 if (dev->driver) 1026 if (dev->driver)
1034 p_drv = to_pcmcia_drv(dev->driver); 1027 p_drv = to_pcmcia_drv(dev->driver);
1035 1028
1036 if (p_drv && p_drv->suspend) { 1029 if (!p_drv)
1030 goto out;
1031
1032 if (p_drv->suspend) {
1037 ret = p_drv->suspend(p_dev); 1033 ret = p_drv->suspend(p_dev);
1038 if (ret) 1034 if (ret)
1039 goto out; 1035 goto out;
1040 if ((p_dev->state & DEV_CONFIG) &&
1041 !(p_dev->state & DEV_SUSPEND_NORELEASE))
1042 pcmcia_release_configuration(p_dev);
1043 } 1036 }
1044 1037
1038 if (p_dev->device_no == p_dev->func)
1039 pcmcia_release_configuration(p_dev);
1040
1045 out: 1041 out:
1046 if (!ret) 1042 if (!ret)
1047 p_dev->suspended = 1; 1043 p_dev->suspended = 1;
@@ -1058,17 +1054,18 @@ static int pcmcia_dev_resume(struct device * dev)
1058 if (dev->driver) 1054 if (dev->driver)
1059 p_drv = to_pcmcia_drv(dev->driver); 1055 p_drv = to_pcmcia_drv(dev->driver);
1060 1056
1061 if (p_drv && p_drv->resume) { 1057 if (!p_drv)
1062 if ((p_dev->state & DEV_CONFIG) && 1058 goto out;
1063 !(p_dev->state & DEV_SUSPEND_NORELEASE)){ 1059
1064 ret = pcmcia_request_configuration(p_dev, 1060 if (p_dev->device_no == p_dev->func) {
1065 &p_dev->conf); 1061 ret = pcmcia_request_configuration(p_dev, &p_dev->conf);
1066 if (ret) 1062 if (ret)
1067 goto out; 1063 goto out;
1068 }
1069 ret = p_drv->resume(p_dev);
1070 } 1064 }
1071 1065
1066 if (p_drv->resume)
1067 ret = p_drv->resume(p_dev);
1068
1072 out: 1069 out:
1073 if (!ret) 1070 if (!ret)
1074 p_dev->suspended = 0; 1071 p_dev->suspended = 0;
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 2b11a332175e..c53db7ceda5e 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -304,6 +304,7 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int
304{ 304{
305 dev_node_t *node; 305 dev_node_t *node;
306 struct pcmcia_device *p_dev; 306 struct pcmcia_device *p_dev;
307 struct pcmcia_driver *p_drv;
307 unsigned long flags; 308 unsigned long flags;
308 int ret = 0; 309 int ret = 0;
309 310
@@ -358,7 +359,8 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int
358 found: 359 found:
359 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 360 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
360 361
361 if (p_dev->state & DEV_CONFIG_PENDING) { 362 p_drv = to_pcmcia_drv(p_dev->dev.driver);
363 if (p_drv && !p_dev->_locked) {
362 ret = -EAGAIN; 364 ret = -EAGAIN;
363 goto err_put; 365 goto err_put;
364 } 366 }
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index dbf167c979f6..45063b4e5b78 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -476,8 +476,8 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
476 config_t *c = p_dev->function_config; 476 config_t *c = p_dev->function_config;
477 int i; 477 int i;
478 478
479 if (p_dev->p_state & CLIENT_CONFIG_LOCKED) { 479 if (p_dev->_locked) {
480 p_dev->p_state &= ~CLIENT_CONFIG_LOCKED; 480 p_dev->_locked = 0;
481 if (--(s->lock_count) == 0) { 481 if (--(s->lock_count) == 0) {
482 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */ 482 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */
483 s->socket.Vpp = 0; 483 s->socket.Vpp = 0;
@@ -516,10 +516,10 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
516 struct pcmcia_socket *s = p_dev->socket; 516 struct pcmcia_socket *s = p_dev->socket;
517 config_t *c = p_dev->function_config; 517 config_t *c = p_dev->function_config;
518 518
519 if (!(p_dev->p_state & CLIENT_IO_REQ)) 519 if (!p_dev->_io )
520 return CS_BAD_HANDLE; 520 return CS_BAD_HANDLE;
521 521
522 p_dev->p_state &= ~CLIENT_IO_REQ; 522 p_dev->_io = 0;
523 523
524 if ((c->io.BasePort1 != req->BasePort1) || 524 if ((c->io.BasePort1 != req->BasePort1) ||
525 (c->io.NumPorts1 != req->NumPorts1) || 525 (c->io.NumPorts1 != req->NumPorts1) ||
@@ -542,9 +542,9 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
542 struct pcmcia_socket *s = p_dev->socket; 542 struct pcmcia_socket *s = p_dev->socket;
543 config_t *c= p_dev->function_config; 543 config_t *c= p_dev->function_config;
544 544
545 if (!(p_dev->p_state & CLIENT_IRQ_REQ)) 545 if (!p_dev->_irq)
546 return CS_BAD_HANDLE; 546 return CS_BAD_HANDLE;
547 p_dev->p_state &= ~CLIENT_IRQ_REQ; 547 p_dev->_irq = 0;
548 548
549 if (c->state & CONFIG_LOCKED) 549 if (c->state & CONFIG_LOCKED)
550 return CS_CONFIGURATION_LOCKED; 550 return CS_CONFIGURATION_LOCKED;
@@ -576,7 +576,7 @@ int pcmcia_release_window(window_handle_t win)
576 if ((win == NULL) || (win->magic != WINDOW_MAGIC)) 576 if ((win == NULL) || (win->magic != WINDOW_MAGIC))
577 return CS_BAD_HANDLE; 577 return CS_BAD_HANDLE;
578 s = win->sock; 578 s = win->sock;
579 if (!(win->handle->p_state & CLIENT_WIN_REQ(win->index))) 579 if (!(win->handle->_win & CLIENT_WIN_REQ(win->index)))
580 return CS_BAD_HANDLE; 580 return CS_BAD_HANDLE;
581 581
582 /* Shut down memory window */ 582 /* Shut down memory window */
@@ -590,7 +590,7 @@ int pcmcia_release_window(window_handle_t win)
590 kfree(win->ctl.res); 590 kfree(win->ctl.res);
591 win->ctl.res = NULL; 591 win->ctl.res = NULL;
592 } 592 }
593 win->handle->p_state &= ~CLIENT_WIN_REQ(win->index); 593 win->handle->_win &= ~CLIENT_WIN_REQ(win->index);
594 594
595 win->magic = 0; 595 win->magic = 0;
596 596
@@ -708,7 +708,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
708 } 708 }
709 709
710 c->state |= CONFIG_LOCKED; 710 c->state |= CONFIG_LOCKED;
711 p_dev->p_state |= CLIENT_CONFIG_LOCKED; 711 p_dev->_locked = 1;
712 return CS_SUCCESS; 712 return CS_SUCCESS;
713} /* pcmcia_request_configuration */ 713} /* pcmcia_request_configuration */
714EXPORT_SYMBOL(pcmcia_request_configuration); 714EXPORT_SYMBOL(pcmcia_request_configuration);
@@ -754,7 +754,7 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req)
754 754
755 c->io = *req; 755 c->io = *req;
756 c->state |= CONFIG_IO_REQ; 756 c->state |= CONFIG_IO_REQ;
757 p_dev->p_state |= CLIENT_IO_REQ; 757 p_dev->_io = 1;
758 return CS_SUCCESS; 758 return CS_SUCCESS;
759} /* pcmcia_request_io */ 759} /* pcmcia_request_io */
760EXPORT_SYMBOL(pcmcia_request_io); 760EXPORT_SYMBOL(pcmcia_request_io);
@@ -850,7 +850,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
850 s->irq.Config++; 850 s->irq.Config++;
851 851
852 c->state |= CONFIG_IRQ_REQ; 852 c->state |= CONFIG_IRQ_REQ;
853 p_dev->p_state |= CLIENT_IRQ_REQ; 853 p_dev->_irq = 1;
854 854
855#ifdef CONFIG_PCMCIA_PROBE 855#ifdef CONFIG_PCMCIA_PROBE
856 pcmcia_used_irq[irq]++; 856 pcmcia_used_irq[irq]++;
@@ -910,7 +910,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
910 if (!win->ctl.res) 910 if (!win->ctl.res)
911 return CS_IN_USE; 911 return CS_IN_USE;
912 } 912 }
913 (*p_dev)->p_state |= CLIENT_WIN_REQ(w); 913 (*p_dev)->_win |= CLIENT_WIN_REQ(w);
914 914
915 /* Configure the socket controller */ 915 /* Configure the socket controller */
916 win->ctl.map = w+1; 916 win->ctl.map = w+1;