diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-03-01 18:09:29 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-03-31 10:26:33 -0500 |
commit | e2d4096365e06b9a3799afbadc28b4519c0b3526 (patch) | |
tree | 90ec691d71f9c0309048714e359b8ba351b533f7 /drivers/mtd/maps | |
parent | f6fbe01ac976f3ec618cd5fb71ad9ce2cfa7ab2b (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/mtd/maps')
-rw-r--r-- | drivers/mtd/maps/pcmciamtd.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index 466f558aa7ed..a01e04bf484a 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -111,8 +111,8 @@ static caddr_t remap_window(struct map_info *map, unsigned long to) | |||
111 | memreq_t mrq; | 111 | memreq_t mrq; |
112 | int ret; | 112 | int ret; |
113 | 113 | ||
114 | if(!(dev->p_dev->state & DEV_PRESENT)) { | 114 | if (!pcmcia_dev_present(dev->p_dev)) { |
115 | DEBUG(1, "device removed state = 0x%4.4X", dev->p_dev->state); | 115 | DEBUG(1, "device removed"); |
116 | return 0; | 116 | return 0; |
117 | } | 117 | } |
118 | 118 | ||
@@ -238,7 +238,7 @@ static void pcmcia_copy_to_remap(struct map_info *map, unsigned long to, const v | |||
238 | 238 | ||
239 | /* read/write{8,16} copy_{from,to} routines with direct access */ | 239 | /* read/write{8,16} copy_{from,to} routines with direct access */ |
240 | 240 | ||
241 | #define DEV_REMOVED(x) (!(*(u_int *)x->map_priv_1 & DEV_PRESENT)) | 241 | #define DEV_REMOVED(x) (!(pcmcia_dev_present(((struct pcmciamtd_dev *)map->map_priv_1)->p_dev))) |
242 | 242 | ||
243 | static map_word pcmcia_read8(struct map_info *map, unsigned long ofs) | 243 | static map_word pcmcia_read8(struct map_info *map, unsigned long ofs) |
244 | { | 244 | { |
@@ -503,9 +503,6 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
503 | 503 | ||
504 | DEBUG(3, "link=0x%p", link); | 504 | DEBUG(3, "link=0x%p", link); |
505 | 505 | ||
506 | /* Configure card */ | ||
507 | link->state |= DEV_CONFIG; | ||
508 | |||
509 | DEBUG(2, "Validating CIS"); | 506 | DEBUG(2, "Validating CIS"); |
510 | ret = pcmcia_validate_cis(link, &cisinfo); | 507 | ret = pcmcia_validate_cis(link, &cisinfo); |
511 | if(ret != CS_SUCCESS) { | 508 | if(ret != CS_SUCCESS) { |
@@ -651,7 +648,6 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
651 | use the faster non-remapping read/write functions */ | 648 | use the faster non-remapping read/write functions */ |
652 | if(mtd->size <= dev->win_size) { | 649 | if(mtd->size <= dev->win_size) { |
653 | DEBUG(1, "Using non remapping memory functions"); | 650 | DEBUG(1, "Using non remapping memory functions"); |
654 | dev->pcmcia_map.map_priv_1 = (unsigned long)&(dev->p_dev->state); | ||
655 | dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base; | 651 | dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base; |
656 | if (dev->pcmcia_map.bankwidth == 1) { | 652 | if (dev->pcmcia_map.bankwidth == 1) { |
657 | dev->pcmcia_map.read = pcmcia_read8; | 653 | dev->pcmcia_map.read = pcmcia_read8; |
@@ -673,7 +669,6 @@ static int pcmciamtd_config(struct pcmcia_device *link) | |||
673 | } | 669 | } |
674 | snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index); | 670 | snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index); |
675 | info("mtd%d: %s", mtd->index, mtd->name); | 671 | info("mtd%d: %s", mtd->index, mtd->name); |
676 | link->state &= ~DEV_CONFIG_PENDING; | ||
677 | link->dev_node = &dev->node; | 672 | link->dev_node = &dev->node; |
678 | return 0; | 673 | return 0; |
679 | 674 | ||
@@ -712,17 +707,16 @@ static int pcmciamtd_resume(struct pcmcia_device *dev) | |||
712 | 707 | ||
713 | static void pcmciamtd_detach(struct pcmcia_device *link) | 708 | static void pcmciamtd_detach(struct pcmcia_device *link) |
714 | { | 709 | { |
715 | DEBUG(3, "link=0x%p", link); | 710 | struct pcmciamtd_dev *dev = link->priv; |
716 | 711 | ||
717 | if(link->state & DEV_CONFIG) { | 712 | DEBUG(3, "link=0x%p", link); |
718 | struct pcmciamtd_dev *dev = link->priv; | ||
719 | if(dev->mtd_info) { | ||
720 | del_mtd_device(dev->mtd_info); | ||
721 | info("mtd%d: Removed", dev->mtd_info->index); | ||
722 | } | ||
723 | 713 | ||
724 | pcmciamtd_release(link); | 714 | if(dev->mtd_info) { |
715 | del_mtd_device(dev->mtd_info); | ||
716 | info("mtd%d: Removed", dev->mtd_info->index); | ||
725 | } | 717 | } |
718 | |||
719 | pcmciamtd_release(link); | ||
726 | } | 720 | } |
727 | 721 | ||
728 | 722 | ||
@@ -747,7 +741,6 @@ static int pcmciamtd_probe(struct pcmcia_device *link) | |||
747 | link->conf.Attributes = 0; | 741 | link->conf.Attributes = 0; |
748 | link->conf.IntType = INT_MEMORY; | 742 | link->conf.IntType = INT_MEMORY; |
749 | 743 | ||
750 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
751 | return pcmciamtd_config(link); | 744 | return pcmciamtd_config(link); |
752 | } | 745 | } |
753 | 746 | ||