diff options
Diffstat (limited to 'drivers/mtd/maps')
-rw-r--r-- | drivers/mtd/maps/alchemy-flash.c | 4 | ||||
-rw-r--r-- | drivers/mtd/maps/cfi_flagadm.c | 2 | ||||
-rw-r--r-- | drivers/mtd/maps/dbox2-flash.c | 2 | ||||
-rw-r--r-- | drivers/mtd/maps/dilnetpc.c | 4 | ||||
-rw-r--r-- | drivers/mtd/maps/dmv182.c | 2 | ||||
-rw-r--r-- | drivers/mtd/maps/h720x-flash.c | 2 | ||||
-rw-r--r-- | drivers/mtd/maps/netsc520.c | 4 | ||||
-rw-r--r-- | drivers/mtd/maps/nettel.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/ocotea.c | 6 | ||||
-rw-r--r-- | drivers/mtd/maps/pci.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/pcmciamtd.c | 117 | ||||
-rw-r--r-- | drivers/mtd/maps/redwood.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/sbc8240.c | 8 | ||||
-rw-r--r-- | drivers/mtd/maps/sc520cdp.c | 2 | ||||
-rw-r--r-- | drivers/mtd/maps/scx200_docflash.c | 2 | ||||
-rw-r--r-- | drivers/mtd/maps/sharpsl-flash.c | 4 | ||||
-rw-r--r-- | drivers/mtd/maps/ts5500_flash.c | 2 | ||||
-rw-r--r-- | drivers/mtd/maps/uclinux.c | 2 | ||||
-rw-r--r-- | drivers/mtd/maps/vmax301.c | 2 |
19 files changed, 71 insertions, 103 deletions
diff --git a/drivers/mtd/maps/alchemy-flash.c b/drivers/mtd/maps/alchemy-flash.c index a57791a6ce40..b933a2a27b18 100644 --- a/drivers/mtd/maps/alchemy-flash.c +++ b/drivers/mtd/maps/alchemy-flash.c | |||
@@ -126,8 +126,6 @@ static struct mtd_partition alchemy_partitions[] = { | |||
126 | } | 126 | } |
127 | }; | 127 | }; |
128 | 128 | ||
129 | #define NB_OF(x) (sizeof(x)/sizeof(x[0])) | ||
130 | |||
131 | static struct mtd_info *mymtd; | 129 | static struct mtd_info *mymtd; |
132 | 130 | ||
133 | int __init alchemy_mtd_init(void) | 131 | int __init alchemy_mtd_init(void) |
@@ -154,7 +152,7 @@ int __init alchemy_mtd_init(void) | |||
154 | * Static partition definition selection | 152 | * Static partition definition selection |
155 | */ | 153 | */ |
156 | parts = alchemy_partitions; | 154 | parts = alchemy_partitions; |
157 | nb_parts = NB_OF(alchemy_partitions); | 155 | nb_parts = ARRAY_SIZE(alchemy_partitions); |
158 | alchemy_map.size = window_size; | 156 | alchemy_map.size = window_size; |
159 | 157 | ||
160 | /* | 158 | /* |
diff --git a/drivers/mtd/maps/cfi_flagadm.c b/drivers/mtd/maps/cfi_flagadm.c index 6a8c0415bde8..fd0f0d3187de 100644 --- a/drivers/mtd/maps/cfi_flagadm.c +++ b/drivers/mtd/maps/cfi_flagadm.c | |||
@@ -86,7 +86,7 @@ struct mtd_partition flagadm_parts[] = { | |||
86 | } | 86 | } |
87 | }; | 87 | }; |
88 | 88 | ||
89 | #define PARTITION_COUNT (sizeof(flagadm_parts)/sizeof(struct mtd_partition)) | 89 | #define PARTITION_COUNT ARRAY_SIZE(flagadm_parts) |
90 | 90 | ||
91 | static struct mtd_info *mymtd; | 91 | static struct mtd_info *mymtd; |
92 | 92 | ||
diff --git a/drivers/mtd/maps/dbox2-flash.c b/drivers/mtd/maps/dbox2-flash.c index 49d90542fc75..652813cd6c2d 100644 --- a/drivers/mtd/maps/dbox2-flash.c +++ b/drivers/mtd/maps/dbox2-flash.c | |||
@@ -57,7 +57,7 @@ static struct mtd_partition partition_info[]= { | |||
57 | } | 57 | } |
58 | }; | 58 | }; |
59 | 59 | ||
60 | #define NUM_PARTITIONS (sizeof(partition_info) / sizeof(partition_info[0])) | 60 | #define NUM_PARTITIONS ARRAY_SIZE(partition_info) |
61 | 61 | ||
62 | #define WINDOW_ADDR 0x10000000 | 62 | #define WINDOW_ADDR 0x10000000 |
63 | #define WINDOW_SIZE 0x800000 | 63 | #define WINDOW_SIZE 0x800000 |
diff --git a/drivers/mtd/maps/dilnetpc.c b/drivers/mtd/maps/dilnetpc.c index efb221692641..c299d10b33e6 100644 --- a/drivers/mtd/maps/dilnetpc.c +++ b/drivers/mtd/maps/dilnetpc.c | |||
@@ -300,7 +300,7 @@ static struct mtd_partition partition_info[]= | |||
300 | }, | 300 | }, |
301 | }; | 301 | }; |
302 | 302 | ||
303 | #define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) | 303 | #define NUM_PARTITIONS ARRAY_SIZE(partition_info) |
304 | 304 | ||
305 | static struct mtd_info *mymtd; | 305 | static struct mtd_info *mymtd; |
306 | static struct mtd_info *lowlvl_parts[NUM_PARTITIONS]; | 306 | static struct mtd_info *lowlvl_parts[NUM_PARTITIONS]; |
@@ -345,7 +345,7 @@ static struct mtd_partition higlvl_partition_info[]= | |||
345 | }, | 345 | }, |
346 | }; | 346 | }; |
347 | 347 | ||
348 | #define NUM_HIGHLVL_PARTITIONS (sizeof(higlvl_partition_info)/sizeof(partition_info[0])) | 348 | #define NUM_HIGHLVL_PARTITIONS ARRAY_SIZE(higlvl_partition_info) |
349 | 349 | ||
350 | 350 | ||
351 | static int dnp_adnp_probe(void) | 351 | static int dnp_adnp_probe(void) |
diff --git a/drivers/mtd/maps/dmv182.c b/drivers/mtd/maps/dmv182.c index b993ac01a9a5..2bb3c0f0f970 100644 --- a/drivers/mtd/maps/dmv182.c +++ b/drivers/mtd/maps/dmv182.c | |||
@@ -99,7 +99,7 @@ static struct mtd_info *this_mtd; | |||
99 | static int __init init_svme182(void) | 99 | static int __init init_svme182(void) |
100 | { | 100 | { |
101 | struct mtd_partition *partitions; | 101 | struct mtd_partition *partitions; |
102 | int num_parts = sizeof(svme182_partitions) / sizeof(struct mtd_partition); | 102 | int num_parts = ARRAY_SIZE(svme182_partitions); |
103 | 103 | ||
104 | partitions = svme182_partitions; | 104 | partitions = svme182_partitions; |
105 | 105 | ||
diff --git a/drivers/mtd/maps/h720x-flash.c b/drivers/mtd/maps/h720x-flash.c index 319094821101..0667101ccbe1 100644 --- a/drivers/mtd/maps/h720x-flash.c +++ b/drivers/mtd/maps/h720x-flash.c | |||
@@ -59,7 +59,7 @@ static struct mtd_partition h720x_partitions[] = { | |||
59 | } | 59 | } |
60 | }; | 60 | }; |
61 | 61 | ||
62 | #define NUM_PARTITIONS (sizeof(h720x_partitions)/sizeof(h720x_partitions[0])) | 62 | #define NUM_PARTITIONS ARRAY_SIZE(h720x_partitions) |
63 | 63 | ||
64 | static int nr_mtd_parts; | 64 | static int nr_mtd_parts; |
65 | static struct mtd_partition *mtd_parts; | 65 | static struct mtd_partition *mtd_parts; |
diff --git a/drivers/mtd/maps/netsc520.c b/drivers/mtd/maps/netsc520.c index 33060a315722..ed215470158b 100644 --- a/drivers/mtd/maps/netsc520.c +++ b/drivers/mtd/maps/netsc520.c | |||
@@ -76,7 +76,7 @@ static struct mtd_partition partition_info[]={ | |||
76 | .size = 0x80000 | 76 | .size = 0x80000 |
77 | }, | 77 | }, |
78 | }; | 78 | }; |
79 | #define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) | 79 | #define NUM_PARTITIONS ARRAY_SIZE(partition_info) |
80 | 80 | ||
81 | #define WINDOW_SIZE 0x00100000 | 81 | #define WINDOW_SIZE 0x00100000 |
82 | #define WINDOW_ADDR 0x00200000 | 82 | #define WINDOW_ADDR 0x00200000 |
@@ -88,7 +88,7 @@ static struct map_info netsc520_map = { | |||
88 | .phys = WINDOW_ADDR, | 88 | .phys = WINDOW_ADDR, |
89 | }; | 89 | }; |
90 | 90 | ||
91 | #define NUM_FLASH_BANKS (sizeof(netsc520_map)/sizeof(struct map_info)) | 91 | #define NUM_FLASH_BANKS ARRAY_SIZE(netsc520_map) |
92 | 92 | ||
93 | static struct mtd_info *mymtd; | 93 | static struct mtd_info *mymtd; |
94 | 94 | ||
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c index 632eb2aa968f..54a3102ab19a 100644 --- a/drivers/mtd/maps/nettel.c +++ b/drivers/mtd/maps/nettel.c | |||
@@ -128,8 +128,7 @@ static struct mtd_partition nettel_amd_partitions[] = { | |||
128 | } | 128 | } |
129 | }; | 129 | }; |
130 | 130 | ||
131 | #define NUM_AMD_PARTITIONS \ | 131 | #define NUM_AMD_PARTITIONS ARRAY_SIZE(nettel_amd_partitions) |
132 | (sizeof(nettel_amd_partitions)/sizeof(nettel_amd_partitions[0])) | ||
133 | 132 | ||
134 | /****************************************************************************/ | 133 | /****************************************************************************/ |
135 | 134 | ||
diff --git a/drivers/mtd/maps/ocotea.c b/drivers/mtd/maps/ocotea.c index c223514ca2eb..a21fcd195ab4 100644 --- a/drivers/mtd/maps/ocotea.c +++ b/drivers/mtd/maps/ocotea.c | |||
@@ -58,8 +58,6 @@ static struct mtd_partition ocotea_large_partitions[] = { | |||
58 | } | 58 | } |
59 | }; | 59 | }; |
60 | 60 | ||
61 | #define NB_OF(x) (sizeof(x)/sizeof(x[0])) | ||
62 | |||
63 | int __init init_ocotea(void) | 61 | int __init init_ocotea(void) |
64 | { | 62 | { |
65 | u8 fpga0_reg; | 63 | u8 fpga0_reg; |
@@ -97,7 +95,7 @@ int __init init_ocotea(void) | |||
97 | if (flash) { | 95 | if (flash) { |
98 | flash->owner = THIS_MODULE; | 96 | flash->owner = THIS_MODULE; |
99 | add_mtd_partitions(flash, ocotea_small_partitions, | 97 | add_mtd_partitions(flash, ocotea_small_partitions, |
100 | NB_OF(ocotea_small_partitions)); | 98 | ARRAY_SIZE(ocotea_small_partitions)); |
101 | } else { | 99 | } else { |
102 | printk("map probe failed for flash\n"); | 100 | printk("map probe failed for flash\n"); |
103 | return -ENXIO; | 101 | return -ENXIO; |
@@ -118,7 +116,7 @@ int __init init_ocotea(void) | |||
118 | if (flash) { | 116 | if (flash) { |
119 | flash->owner = THIS_MODULE; | 117 | flash->owner = THIS_MODULE; |
120 | add_mtd_partitions(flash, ocotea_large_partitions, | 118 | add_mtd_partitions(flash, ocotea_large_partitions, |
121 | NB_OF(ocotea_large_partitions)); | 119 | ARRAY_SIZE(ocotea_large_partitions)); |
122 | } else { | 120 | } else { |
123 | printk("map probe failed for flash\n"); | 121 | printk("map probe failed for flash\n"); |
124 | return -ENXIO; | 122 | return -ENXIO; |
diff --git a/drivers/mtd/maps/pci.c b/drivers/mtd/maps/pci.c index 21822c2edbe4..d2ab1bae9c34 100644 --- a/drivers/mtd/maps/pci.c +++ b/drivers/mtd/maps/pci.c | |||
@@ -334,9 +334,6 @@ mtd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
334 | return 0; | 334 | return 0; |
335 | 335 | ||
336 | release: | 336 | release: |
337 | if (mtd) | ||
338 | map_destroy(mtd); | ||
339 | |||
340 | if (map) { | 337 | if (map) { |
341 | map->exit(dev, map); | 338 | map->exit(dev, map); |
342 | kfree(map); | 339 | kfree(map); |
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index f988c817e196..d27f4129afd3 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -54,7 +54,7 @@ static const int debug = 0; | |||
54 | #define MAX_PCMCIA_ADDR 0x4000000 | 54 | #define MAX_PCMCIA_ADDR 0x4000000 |
55 | 55 | ||
56 | struct pcmciamtd_dev { | 56 | struct pcmciamtd_dev { |
57 | dev_link_t link; /* PCMCIA link */ | 57 | struct pcmcia_device *p_dev; |
58 | dev_node_t node; /* device node */ | 58 | dev_node_t node; /* device node */ |
59 | caddr_t win_base; /* ioremapped address of PCMCIA window */ | 59 | caddr_t win_base; /* ioremapped address of PCMCIA window */ |
60 | unsigned int win_size; /* size of window */ | 60 | unsigned int win_size; /* size of window */ |
@@ -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->link.state & DEV_PRESENT)) { | 114 | if (!pcmcia_dev_present(dev->p_dev)) { |
115 | DEBUG(1, "device removed state = 0x%4.4X", dev->link.state); | 115 | DEBUG(1, "device removed"); |
116 | return 0; | 116 | return 0; |
117 | } | 117 | } |
118 | 118 | ||
@@ -122,7 +122,7 @@ static caddr_t remap_window(struct map_info *map, unsigned long to) | |||
122 | dev->offset, mrq.CardOffset); | 122 | dev->offset, mrq.CardOffset); |
123 | mrq.Page = 0; | 123 | mrq.Page = 0; |
124 | if( (ret = pcmcia_map_mem_page(win, &mrq)) != CS_SUCCESS) { | 124 | if( (ret = pcmcia_map_mem_page(win, &mrq)) != CS_SUCCESS) { |
125 | cs_error(dev->link.handle, MapMemPage, ret); | 125 | cs_error(dev->p_dev, MapMemPage, ret); |
126 | return NULL; | 126 | return NULL; |
127 | } | 127 | } |
128 | dev->offset = mrq.CardOffset; | 128 | dev->offset = mrq.CardOffset; |
@@ -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 | { |
@@ -319,7 +319,7 @@ static void pcmcia_copy_to(struct map_info *map, unsigned long to, const void *f | |||
319 | static void pcmciamtd_set_vpp(struct map_info *map, int on) | 319 | static void pcmciamtd_set_vpp(struct map_info *map, int on) |
320 | { | 320 | { |
321 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; | 321 | struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; |
322 | dev_link_t *link = &dev->link; | 322 | struct pcmcia_device *link = dev->p_dev; |
323 | modconf_t mod; | 323 | modconf_t mod; |
324 | int ret; | 324 | int ret; |
325 | 325 | ||
@@ -328,9 +328,9 @@ static void pcmciamtd_set_vpp(struct map_info *map, int on) | |||
328 | mod.Vpp1 = mod.Vpp2 = on ? dev->vpp : 0; | 328 | mod.Vpp1 = mod.Vpp2 = on ? dev->vpp : 0; |
329 | 329 | ||
330 | DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp); | 330 | DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp); |
331 | ret = pcmcia_modify_configuration(link->handle, &mod); | 331 | ret = pcmcia_modify_configuration(link, &mod); |
332 | if(ret != CS_SUCCESS) { | 332 | if(ret != CS_SUCCESS) { |
333 | cs_error(link->handle, ModifyConfiguration, ret); | 333 | cs_error(link, ModifyConfiguration, ret); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | 336 | ||
@@ -340,7 +340,7 @@ static void pcmciamtd_set_vpp(struct map_info *map, int on) | |||
340 | * still open, this will be postponed until it is closed. | 340 | * still open, this will be postponed until it is closed. |
341 | */ | 341 | */ |
342 | 342 | ||
343 | static void pcmciamtd_release(dev_link_t *link) | 343 | static void pcmciamtd_release(struct pcmcia_device *link) |
344 | { | 344 | { |
345 | struct pcmciamtd_dev *dev = link->priv; | 345 | struct pcmciamtd_dev *dev = link->priv; |
346 | 346 | ||
@@ -353,12 +353,11 @@ static void pcmciamtd_release(dev_link_t *link) | |||
353 | } | 353 | } |
354 | pcmcia_release_window(link->win); | 354 | pcmcia_release_window(link->win); |
355 | } | 355 | } |
356 | pcmcia_release_configuration(link->handle); | 356 | pcmcia_disable_device(link); |
357 | link->state &= ~DEV_CONFIG; | ||
358 | } | 357 | } |
359 | 358 | ||
360 | 359 | ||
361 | static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_name) | 360 | static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, int *new_name) |
362 | { | 361 | { |
363 | int rc; | 362 | int rc; |
364 | tuple_t tuple; | 363 | tuple_t tuple; |
@@ -371,16 +370,16 @@ static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_ | |||
371 | tuple.TupleOffset = 0; | 370 | tuple.TupleOffset = 0; |
372 | tuple.DesiredTuple = RETURN_FIRST_TUPLE; | 371 | tuple.DesiredTuple = RETURN_FIRST_TUPLE; |
373 | 372 | ||
374 | rc = pcmcia_get_first_tuple(link->handle, &tuple); | 373 | rc = pcmcia_get_first_tuple(link, &tuple); |
375 | while(rc == CS_SUCCESS) { | 374 | while(rc == CS_SUCCESS) { |
376 | rc = pcmcia_get_tuple_data(link->handle, &tuple); | 375 | rc = pcmcia_get_tuple_data(link, &tuple); |
377 | if(rc != CS_SUCCESS) { | 376 | if(rc != CS_SUCCESS) { |
378 | cs_error(link->handle, GetTupleData, rc); | 377 | cs_error(link, GetTupleData, rc); |
379 | break; | 378 | break; |
380 | } | 379 | } |
381 | rc = pcmcia_parse_tuple(link->handle, &tuple, &parse); | 380 | rc = pcmcia_parse_tuple(link, &tuple, &parse); |
382 | if(rc != CS_SUCCESS) { | 381 | if(rc != CS_SUCCESS) { |
383 | cs_error(link->handle, ParseTuple, rc); | 382 | cs_error(link, ParseTuple, rc); |
384 | break; | 383 | break; |
385 | } | 384 | } |
386 | 385 | ||
@@ -451,7 +450,7 @@ static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_ | |||
451 | DEBUG(2, "Unknown tuple code %d", tuple.TupleCode); | 450 | DEBUG(2, "Unknown tuple code %d", tuple.TupleCode); |
452 | } | 451 | } |
453 | 452 | ||
454 | rc = pcmcia_get_next_tuple(link->handle, &tuple); | 453 | rc = pcmcia_get_next_tuple(link, &tuple); |
455 | } | 454 | } |
456 | if(!dev->pcmcia_map.size) | 455 | if(!dev->pcmcia_map.size) |
457 | dev->pcmcia_map.size = MAX_PCMCIA_ADDR; | 456 | dev->pcmcia_map.size = MAX_PCMCIA_ADDR; |
@@ -488,7 +487,7 @@ static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_ | |||
488 | #define CS_CHECK(fn, ret) \ | 487 | #define CS_CHECK(fn, ret) \ |
489 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 488 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
490 | 489 | ||
491 | static void pcmciamtd_config(dev_link_t *link) | 490 | static int pcmciamtd_config(struct pcmcia_device *link) |
492 | { | 491 | { |
493 | struct pcmciamtd_dev *dev = link->priv; | 492 | struct pcmciamtd_dev *dev = link->priv; |
494 | struct mtd_info *mtd = NULL; | 493 | struct mtd_info *mtd = NULL; |
@@ -504,13 +503,10 @@ static void pcmciamtd_config(dev_link_t *link) | |||
504 | 503 | ||
505 | DEBUG(3, "link=0x%p", link); | 504 | DEBUG(3, "link=0x%p", link); |
506 | 505 | ||
507 | /* Configure card */ | ||
508 | link->state |= DEV_CONFIG; | ||
509 | |||
510 | DEBUG(2, "Validating CIS"); | 506 | DEBUG(2, "Validating CIS"); |
511 | ret = pcmcia_validate_cis(link->handle, &cisinfo); | 507 | ret = pcmcia_validate_cis(link, &cisinfo); |
512 | if(ret != CS_SUCCESS) { | 508 | if(ret != CS_SUCCESS) { |
513 | cs_error(link->handle, GetTupleData, ret); | 509 | cs_error(link, GetTupleData, ret); |
514 | } else { | 510 | } else { |
515 | DEBUG(2, "ValidateCIS found %d chains", cisinfo.Chains); | 511 | DEBUG(2, "ValidateCIS found %d chains", cisinfo.Chains); |
516 | } | 512 | } |
@@ -538,7 +534,7 @@ static void pcmciamtd_config(dev_link_t *link) | |||
538 | req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; | 534 | req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; |
539 | req.Base = 0; | 535 | req.Base = 0; |
540 | req.AccessSpeed = mem_speed; | 536 | req.AccessSpeed = mem_speed; |
541 | link->win = (window_handle_t)link->handle; | 537 | link->win = (window_handle_t)link; |
542 | req.Size = (force_size) ? force_size << 20 : MAX_PCMCIA_ADDR; | 538 | req.Size = (force_size) ? force_size << 20 : MAX_PCMCIA_ADDR; |
543 | dev->win_size = 0; | 539 | dev->win_size = 0; |
544 | 540 | ||
@@ -546,7 +542,7 @@ static void pcmciamtd_config(dev_link_t *link) | |||
546 | int ret; | 542 | int ret; |
547 | DEBUG(2, "requesting window with size = %dKiB memspeed = %d", | 543 | DEBUG(2, "requesting window with size = %dKiB memspeed = %d", |
548 | req.Size >> 10, req.AccessSpeed); | 544 | req.Size >> 10, req.AccessSpeed); |
549 | ret = pcmcia_request_window(&link->handle, &req, &link->win); | 545 | ret = pcmcia_request_window(&link, &req, &link->win); |
550 | DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size); | 546 | DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size); |
551 | if(ret) { | 547 | if(ret) { |
552 | req.Size >>= 1; | 548 | req.Size >>= 1; |
@@ -562,19 +558,19 @@ static void pcmciamtd_config(dev_link_t *link) | |||
562 | if(!dev->win_size) { | 558 | if(!dev->win_size) { |
563 | err("Cant allocate memory window"); | 559 | err("Cant allocate memory window"); |
564 | pcmciamtd_release(link); | 560 | pcmciamtd_release(link); |
565 | return; | 561 | return -ENODEV; |
566 | } | 562 | } |
567 | DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10); | 563 | DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10); |
568 | 564 | ||
569 | /* Get write protect status */ | 565 | /* Get write protect status */ |
570 | CS_CHECK(GetStatus, pcmcia_get_status(link->handle, &status)); | 566 | CS_CHECK(GetStatus, pcmcia_get_status(link, &status)); |
571 | DEBUG(2, "status value: 0x%x window handle = 0x%8.8lx", | 567 | DEBUG(2, "status value: 0x%x window handle = 0x%8.8lx", |
572 | status.CardState, (unsigned long)link->win); | 568 | status.CardState, (unsigned long)link->win); |
573 | dev->win_base = ioremap(req.Base, req.Size); | 569 | dev->win_base = ioremap(req.Base, req.Size); |
574 | if(!dev->win_base) { | 570 | if(!dev->win_base) { |
575 | err("ioremap(%lu, %u) failed", req.Base, req.Size); | 571 | err("ioremap(%lu, %u) failed", req.Base, req.Size); |
576 | pcmciamtd_release(link); | 572 | pcmciamtd_release(link); |
577 | return; | 573 | return -ENODEV; |
578 | } | 574 | } |
579 | DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x", | 575 | DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x", |
580 | dev, req.Base, dev->win_base, req.Size); | 576 | dev, req.Base, dev->win_base, req.Size); |
@@ -584,17 +580,14 @@ static void pcmciamtd_config(dev_link_t *link) | |||
584 | dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; | 580 | dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; |
585 | 581 | ||
586 | DEBUG(2, "Getting configuration"); | 582 | DEBUG(2, "Getting configuration"); |
587 | CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link->handle, &t)); | 583 | CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &t)); |
588 | DEBUG(2, "Vcc = %d Vpp1 = %d Vpp2 = %d", t.Vcc, t.Vpp1, t.Vpp2); | 584 | DEBUG(2, "Vcc = %d Vpp1 = %d Vpp2 = %d", t.Vcc, t.Vpp1, t.Vpp2); |
589 | dev->vpp = (vpp) ? vpp : t.Vpp1; | 585 | dev->vpp = (vpp) ? vpp : t.Vpp1; |
590 | link->conf.Attributes = 0; | 586 | link->conf.Attributes = 0; |
591 | link->conf.Vcc = t.Vcc; | ||
592 | if(setvpp == 2) { | 587 | if(setvpp == 2) { |
593 | link->conf.Vpp1 = dev->vpp; | 588 | link->conf.Vpp = dev->vpp; |
594 | link->conf.Vpp2 = dev->vpp; | ||
595 | } else { | 589 | } else { |
596 | link->conf.Vpp1 = 0; | 590 | link->conf.Vpp = 0; |
597 | link->conf.Vpp2 = 0; | ||
598 | } | 591 | } |
599 | 592 | ||
600 | link->conf.IntType = INT_MEMORY; | 593 | link->conf.IntType = INT_MEMORY; |
@@ -606,9 +599,10 @@ static void pcmciamtd_config(dev_link_t *link) | |||
606 | link->conf.ConfigIndex = 0; | 599 | link->conf.ConfigIndex = 0; |
607 | link->conf.Present = t.Present; | 600 | link->conf.Present = t.Present; |
608 | DEBUG(2, "Setting Configuration"); | 601 | DEBUG(2, "Setting Configuration"); |
609 | ret = pcmcia_request_configuration(link->handle, &link->conf); | 602 | ret = pcmcia_request_configuration(link, &link->conf); |
610 | if(ret != CS_SUCCESS) { | 603 | if(ret != CS_SUCCESS) { |
611 | cs_error(link->handle, RequestConfiguration, ret); | 604 | cs_error(link, RequestConfiguration, ret); |
605 | return -ENODEV; | ||
612 | } | 606 | } |
613 | 607 | ||
614 | if(mem_type == 1) { | 608 | if(mem_type == 1) { |
@@ -616,7 +610,7 @@ static void pcmciamtd_config(dev_link_t *link) | |||
616 | } else if(mem_type == 2) { | 610 | } else if(mem_type == 2) { |
617 | mtd = do_map_probe("map_rom", &dev->pcmcia_map); | 611 | mtd = do_map_probe("map_rom", &dev->pcmcia_map); |
618 | } else { | 612 | } else { |
619 | for(i = 0; i < sizeof(probes) / sizeof(char *); i++) { | 613 | for(i = 0; i < ARRAY_SIZE(probes); i++) { |
620 | DEBUG(1, "Trying %s", probes[i]); | 614 | DEBUG(1, "Trying %s", probes[i]); |
621 | mtd = do_map_probe(probes[i], &dev->pcmcia_map); | 615 | mtd = do_map_probe(probes[i], &dev->pcmcia_map); |
622 | if(mtd) | 616 | if(mtd) |
@@ -629,7 +623,7 @@ static void pcmciamtd_config(dev_link_t *link) | |||
629 | if(!mtd) { | 623 | if(!mtd) { |
630 | DEBUG(1, "Cant find an MTD"); | 624 | DEBUG(1, "Cant find an MTD"); |
631 | pcmciamtd_release(link); | 625 | pcmciamtd_release(link); |
632 | return; | 626 | return -ENODEV; |
633 | } | 627 | } |
634 | 628 | ||
635 | dev->mtd_info = mtd; | 629 | dev->mtd_info = mtd; |
@@ -654,7 +648,6 @@ static void pcmciamtd_config(dev_link_t *link) | |||
654 | use the faster non-remapping read/write functions */ | 648 | use the faster non-remapping read/write functions */ |
655 | if(mtd->size <= dev->win_size) { | 649 | if(mtd->size <= dev->win_size) { |
656 | DEBUG(1, "Using non remapping memory functions"); | 650 | DEBUG(1, "Using non remapping memory functions"); |
657 | dev->pcmcia_map.map_priv_1 = (unsigned long)&(dev->link.state); | ||
658 | dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base; | 651 | dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base; |
659 | if (dev->pcmcia_map.bankwidth == 1) { | 652 | if (dev->pcmcia_map.bankwidth == 1) { |
660 | dev->pcmcia_map.read = pcmcia_read8; | 653 | dev->pcmcia_map.read = pcmcia_read8; |
@@ -672,19 +665,18 @@ static void pcmciamtd_config(dev_link_t *link) | |||
672 | dev->mtd_info = NULL; | 665 | dev->mtd_info = NULL; |
673 | err("Couldnt register MTD device"); | 666 | err("Couldnt register MTD device"); |
674 | pcmciamtd_release(link); | 667 | pcmciamtd_release(link); |
675 | return; | 668 | return -ENODEV; |
676 | } | 669 | } |
677 | 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); |
678 | info("mtd%d: %s", mtd->index, mtd->name); | 671 | info("mtd%d: %s", mtd->index, mtd->name); |
679 | link->state &= ~DEV_CONFIG_PENDING; | 672 | link->dev_node = &dev->node; |
680 | link->dev = &dev->node; | 673 | return 0; |
681 | return; | ||
682 | 674 | ||
683 | cs_failed: | 675 | cs_failed: |
684 | cs_error(link->handle, last_fn, last_ret); | 676 | cs_error(link, last_fn, last_ret); |
685 | err("CS Error, exiting"); | 677 | err("CS Error, exiting"); |
686 | pcmciamtd_release(link); | 678 | pcmciamtd_release(link); |
687 | return; | 679 | return -ENODEV; |
688 | } | 680 | } |
689 | 681 | ||
690 | 682 | ||
@@ -713,21 +705,18 @@ static int pcmciamtd_resume(struct pcmcia_device *dev) | |||
713 | * when the device is released. | 705 | * when the device is released. |
714 | */ | 706 | */ |
715 | 707 | ||
716 | static void pcmciamtd_detach(struct pcmcia_device *p_dev) | 708 | static void pcmciamtd_detach(struct pcmcia_device *link) |
717 | { | 709 | { |
718 | dev_link_t *link = dev_to_instance(p_dev); | 710 | struct pcmciamtd_dev *dev = link->priv; |
719 | 711 | ||
720 | DEBUG(3, "link=0x%p", link); | 712 | DEBUG(3, "link=0x%p", link); |
721 | 713 | ||
722 | if(link->state & DEV_CONFIG) { | 714 | if(dev->mtd_info) { |
723 | struct pcmciamtd_dev *dev = link->priv; | 715 | del_mtd_device(dev->mtd_info); |
724 | if(dev->mtd_info) { | 716 | info("mtd%d: Removed", dev->mtd_info->index); |
725 | del_mtd_device(dev->mtd_info); | ||
726 | info("mtd%d: Removed", dev->mtd_info->index); | ||
727 | } | ||
728 | |||
729 | pcmciamtd_release(link); | ||
730 | } | 717 | } |
718 | |||
719 | pcmciamtd_release(link); | ||
731 | } | 720 | } |
732 | 721 | ||
733 | 722 | ||
@@ -736,10 +725,9 @@ static void pcmciamtd_detach(struct pcmcia_device *p_dev) | |||
736 | * with Card Services. | 725 | * with Card Services. |
737 | */ | 726 | */ |
738 | 727 | ||
739 | static int pcmciamtd_attach(struct pcmcia_device *p_dev) | 728 | static int pcmciamtd_probe(struct pcmcia_device *link) |
740 | { | 729 | { |
741 | struct pcmciamtd_dev *dev; | 730 | struct pcmciamtd_dev *dev; |
742 | dev_link_t *link; | ||
743 | 731 | ||
744 | /* Create new memory card device */ | 732 | /* Create new memory card device */ |
745 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); | 733 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); |
@@ -747,20 +735,13 @@ static int pcmciamtd_attach(struct pcmcia_device *p_dev) | |||
747 | DEBUG(1, "dev=0x%p", dev); | 735 | DEBUG(1, "dev=0x%p", dev); |
748 | 736 | ||
749 | memset(dev, 0, sizeof(*dev)); | 737 | memset(dev, 0, sizeof(*dev)); |
750 | link = &dev->link; | 738 | dev->p_dev = link; |
751 | link->priv = dev; | 739 | link->priv = dev; |
752 | 740 | ||
753 | link->conf.Attributes = 0; | 741 | link->conf.Attributes = 0; |
754 | link->conf.IntType = INT_MEMORY; | 742 | link->conf.IntType = INT_MEMORY; |
755 | 743 | ||
756 | link->next = NULL; | 744 | return pcmciamtd_config(link); |
757 | link->handle = p_dev; | ||
758 | p_dev->instance = link; | ||
759 | |||
760 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
761 | pcmciamtd_config(link); | ||
762 | |||
763 | return 0; | ||
764 | } | 745 | } |
765 | 746 | ||
766 | static struct pcmcia_device_id pcmciamtd_ids[] = { | 747 | static struct pcmcia_device_id pcmciamtd_ids[] = { |
@@ -794,7 +775,7 @@ static struct pcmcia_driver pcmciamtd_driver = { | |||
794 | .drv = { | 775 | .drv = { |
795 | .name = "pcmciamtd" | 776 | .name = "pcmciamtd" |
796 | }, | 777 | }, |
797 | .probe = pcmciamtd_attach, | 778 | .probe = pcmciamtd_probe, |
798 | .remove = pcmciamtd_detach, | 779 | .remove = pcmciamtd_detach, |
799 | .owner = THIS_MODULE, | 780 | .owner = THIS_MODULE, |
800 | .id_table = pcmciamtd_ids, | 781 | .id_table = pcmciamtd_ids, |
diff --git a/drivers/mtd/maps/redwood.c b/drivers/mtd/maps/redwood.c index 5b76ed886185..50b14033613f 100644 --- a/drivers/mtd/maps/redwood.c +++ b/drivers/mtd/maps/redwood.c | |||
@@ -121,8 +121,7 @@ struct map_info redwood_flash_map = { | |||
121 | }; | 121 | }; |
122 | 122 | ||
123 | 123 | ||
124 | #define NUM_REDWOOD_FLASH_PARTITIONS \ | 124 | #define NUM_REDWOOD_FLASH_PARTITIONS ARRAY_SIZE(redwood_flash_partitions) |
125 | (sizeof(redwood_flash_partitions)/sizeof(redwood_flash_partitions[0])) | ||
126 | 125 | ||
127 | static struct mtd_info *redwood_mtd; | 126 | static struct mtd_info *redwood_mtd; |
128 | 127 | ||
diff --git a/drivers/mtd/maps/sbc8240.c b/drivers/mtd/maps/sbc8240.c index 225cdd9ba5b2..350286dc1d2e 100644 --- a/drivers/mtd/maps/sbc8240.c +++ b/drivers/mtd/maps/sbc8240.c | |||
@@ -66,7 +66,7 @@ static struct map_info sbc8240_map[2] = { | |||
66 | } | 66 | } |
67 | }; | 67 | }; |
68 | 68 | ||
69 | #define NUM_FLASH_BANKS (sizeof(sbc8240_map) / sizeof(struct map_info)) | 69 | #define NUM_FLASH_BANKS ARRAY_SIZE(sbc8240_map) |
70 | 70 | ||
71 | /* | 71 | /* |
72 | * The following defines the partition layout of SBC8240 boards. | 72 | * The following defines the partition layout of SBC8240 boards. |
@@ -125,8 +125,6 @@ static struct mtd_partition sbc8240_fs_partitions [] = { | |||
125 | } | 125 | } |
126 | }; | 126 | }; |
127 | 127 | ||
128 | #define NB_OF(x) (sizeof (x) / sizeof (x[0])) | ||
129 | |||
130 | /* trivial struct to describe partition information */ | 128 | /* trivial struct to describe partition information */ |
131 | struct mtd_part_def | 129 | struct mtd_part_def |
132 | { | 130 | { |
@@ -190,10 +188,10 @@ int __init init_sbc8240_mtd (void) | |||
190 | #ifdef CONFIG_MTD_PARTITIONS | 188 | #ifdef CONFIG_MTD_PARTITIONS |
191 | sbc8240_part_banks[0].mtd_part = sbc8240_uboot_partitions; | 189 | sbc8240_part_banks[0].mtd_part = sbc8240_uboot_partitions; |
192 | sbc8240_part_banks[0].type = "static image"; | 190 | sbc8240_part_banks[0].type = "static image"; |
193 | sbc8240_part_banks[0].nums = NB_OF(sbc8240_uboot_partitions); | 191 | sbc8240_part_banks[0].nums = ARRAY_SIZE(sbc8240_uboot_partitions); |
194 | sbc8240_part_banks[1].mtd_part = sbc8240_fs_partitions; | 192 | sbc8240_part_banks[1].mtd_part = sbc8240_fs_partitions; |
195 | sbc8240_part_banks[1].type = "static file system"; | 193 | sbc8240_part_banks[1].type = "static file system"; |
196 | sbc8240_part_banks[1].nums = NB_OF(sbc8240_fs_partitions); | 194 | sbc8240_part_banks[1].nums = ARRAY_SIZE(sbc8240_fs_partitions); |
197 | 195 | ||
198 | for (i = 0; i < NUM_FLASH_BANKS; i++) { | 196 | for (i = 0; i < NUM_FLASH_BANKS; i++) { |
199 | 197 | ||
diff --git a/drivers/mtd/maps/sc520cdp.c b/drivers/mtd/maps/sc520cdp.c index ed92afadd8a9..e8c130e1efd3 100644 --- a/drivers/mtd/maps/sc520cdp.c +++ b/drivers/mtd/maps/sc520cdp.c | |||
@@ -107,7 +107,7 @@ static struct map_info sc520cdp_map[] = { | |||
107 | }, | 107 | }, |
108 | }; | 108 | }; |
109 | 109 | ||
110 | #define NUM_FLASH_BANKS (sizeof(sc520cdp_map)/sizeof(struct map_info)) | 110 | #define NUM_FLASH_BANKS ARRAY_SIZE(sc520cdp_map) |
111 | 111 | ||
112 | static struct mtd_info *mymtd[NUM_FLASH_BANKS]; | 112 | static struct mtd_info *mymtd[NUM_FLASH_BANKS]; |
113 | static struct mtd_info *merged_mtd; | 113 | static struct mtd_info *merged_mtd; |
diff --git a/drivers/mtd/maps/scx200_docflash.c b/drivers/mtd/maps/scx200_docflash.c index 2c91dff8bb60..28b8a571a91a 100644 --- a/drivers/mtd/maps/scx200_docflash.c +++ b/drivers/mtd/maps/scx200_docflash.c | |||
@@ -70,7 +70,7 @@ static struct mtd_partition partition_info[] = { | |||
70 | .size = 0x80000 | 70 | .size = 0x80000 |
71 | }, | 71 | }, |
72 | }; | 72 | }; |
73 | #define NUM_PARTITIONS (sizeof(partition_info)/sizeof(partition_info[0])) | 73 | #define NUM_PARTITIONS ARRAY_SIZE(partition_info) |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | 76 | ||
diff --git a/drivers/mtd/maps/sharpsl-flash.c b/drivers/mtd/maps/sharpsl-flash.c index 999f4bb3d845..12fe53c0d2fc 100644 --- a/drivers/mtd/maps/sharpsl-flash.c +++ b/drivers/mtd/maps/sharpsl-flash.c | |||
@@ -49,8 +49,6 @@ static struct mtd_partition sharpsl_partitions[1] = { | |||
49 | } | 49 | } |
50 | }; | 50 | }; |
51 | 51 | ||
52 | #define NB_OF(x) (sizeof(x)/sizeof(x[0])) | ||
53 | |||
54 | int __init init_sharpsl(void) | 52 | int __init init_sharpsl(void) |
55 | { | 53 | { |
56 | struct mtd_partition *parts; | 54 | struct mtd_partition *parts; |
@@ -92,7 +90,7 @@ int __init init_sharpsl(void) | |||
92 | } | 90 | } |
93 | 91 | ||
94 | parts = sharpsl_partitions; | 92 | parts = sharpsl_partitions; |
95 | nb_parts = NB_OF(sharpsl_partitions); | 93 | nb_parts = ARRAY_SIZE(sharpsl_partitions); |
96 | 94 | ||
97 | printk(KERN_NOTICE "Using %s partision definition\n", part_type); | 95 | printk(KERN_NOTICE "Using %s partision definition\n", part_type); |
98 | add_mtd_partitions(mymtd, parts, nb_parts); | 96 | add_mtd_partitions(mymtd, parts, nb_parts); |
diff --git a/drivers/mtd/maps/ts5500_flash.c b/drivers/mtd/maps/ts5500_flash.c index 4b372bcb17f1..a7422c200567 100644 --- a/drivers/mtd/maps/ts5500_flash.c +++ b/drivers/mtd/maps/ts5500_flash.c | |||
@@ -64,7 +64,7 @@ static struct mtd_partition ts5500_partitions[] = { | |||
64 | } | 64 | } |
65 | }; | 65 | }; |
66 | 66 | ||
67 | #define NUM_PARTITIONS (sizeof(ts5500_partitions)/sizeof(struct mtd_partition)) | 67 | #define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions) |
68 | 68 | ||
69 | static struct mtd_info *mymtd; | 69 | static struct mtd_info *mymtd; |
70 | 70 | ||
diff --git a/drivers/mtd/maps/uclinux.c b/drivers/mtd/maps/uclinux.c index 79d92808b766..f7264dc2ac9b 100644 --- a/drivers/mtd/maps/uclinux.c +++ b/drivers/mtd/maps/uclinux.c | |||
@@ -37,7 +37,7 @@ struct mtd_partition uclinux_romfs[] = { | |||
37 | { .name = "ROMfs" } | 37 | { .name = "ROMfs" } |
38 | }; | 38 | }; |
39 | 39 | ||
40 | #define NUM_PARTITIONS (sizeof(uclinux_romfs) / sizeof(uclinux_romfs[0])) | 40 | #define NUM_PARTITIONS ARRAY_SIZE(uclinux_romfs) |
41 | 41 | ||
42 | /****************************************************************************/ | 42 | /****************************************************************************/ |
43 | 43 | ||
diff --git a/drivers/mtd/maps/vmax301.c b/drivers/mtd/maps/vmax301.c index e0063941c0df..b3e487395435 100644 --- a/drivers/mtd/maps/vmax301.c +++ b/drivers/mtd/maps/vmax301.c | |||
@@ -182,7 +182,7 @@ int __init init_vmax301(void) | |||
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | if (!vmax_mtd[1] && !vmax_mtd[2]) { | 185 | if (!vmax_mtd[0] && !vmax_mtd[1]) { |
186 | iounmap((void *)iomapadr); | 186 | iounmap((void *)iomapadr); |
187 | return -ENXIO; | 187 | return -ENXIO; |
188 | } | 188 | } |