diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-10-18 17:57:58 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-11-08 12:23:10 -0500 |
commit | 18b61b97294dad74dd00a1aa8efed0cfacb95aff (patch) | |
tree | c14ba8be136d95e725bc6f4d31073bbec8ca146d /drivers/mtd | |
parent | 37ace3d4131ae80f370eb1230fa7db2b3eedf17c (diff) |
pcmcia: convert pcmciamtd driver to use new CIS helpers
Convert the (broken) pcmciamtd driver to use the new CIS helpers.
CC: David.Woodhouse@intel.com
CC: linux-mtd@lists.infradead.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/maps/pcmciamtd.c | 177 |
1 files changed, 93 insertions, 84 deletions
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index d600c2deff73..5c3546ef29dc 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -354,101 +354,110 @@ static void pcmciamtd_release(struct pcmcia_device *link) | |||
354 | } | 354 | } |
355 | 355 | ||
356 | 356 | ||
357 | static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, int *new_name) | 357 | #ifdef CONFIG_MTD_DEBUG |
358 | static int pcmciamtd_cistpl_format(struct pcmcia_device *p_dev, | ||
359 | tuple_t *tuple, | ||
360 | void *priv_data) | ||
358 | { | 361 | { |
359 | int rc; | ||
360 | tuple_t tuple; | ||
361 | cisparse_t parse; | 362 | cisparse_t parse; |
362 | u_char buf[64]; | ||
363 | |||
364 | tuple.Attributes = 0; | ||
365 | tuple.TupleData = (cisdata_t *)buf; | ||
366 | tuple.TupleDataMax = sizeof(buf); | ||
367 | tuple.TupleOffset = 0; | ||
368 | tuple.DesiredTuple = RETURN_FIRST_TUPLE; | ||
369 | |||
370 | rc = pcmcia_get_first_tuple(link, &tuple); | ||
371 | while (rc == 0) { | ||
372 | rc = pcmcia_get_tuple_data(link, &tuple); | ||
373 | if (rc != 0) { | ||
374 | cs_error(link, GetTupleData, rc); | ||
375 | break; | ||
376 | } | ||
377 | rc = pcmcia_parse_tuple(&tuple, &parse); | ||
378 | if (rc != 0) { | ||
379 | cs_error(link, ParseTuple, rc); | ||
380 | break; | ||
381 | } | ||
382 | 363 | ||
383 | switch(tuple.TupleCode) { | 364 | if (!pcmcia_parse_tuple(tuple, &parse)) { |
384 | case CISTPL_FORMAT: { | 365 | cistpl_format_t *t = &parse.format; |
385 | cistpl_format_t *t = &parse.format; | 366 | (void)t; /* Shut up, gcc */ |
386 | (void)t; /* Shut up, gcc */ | 367 | DEBUG(2, "Format type: %u, Error Detection: %u, offset = %u, length =%u", |
387 | DEBUG(2, "Format type: %u, Error Detection: %u, offset = %u, length =%u", | 368 | t->type, t->edc, t->offset, t->length); |
388 | t->type, t->edc, t->offset, t->length); | 369 | } |
389 | break; | 370 | return -ENOSPC; |
371 | } | ||
390 | 372 | ||
391 | } | 373 | static int pcmciamtd_cistpl_jedec(struct pcmcia_device *p_dev, |
374 | tuple_t *tuple, | ||
375 | void *priv_data) | ||
376 | { | ||
377 | cisparse_t parse; | ||
378 | int i; | ||
392 | 379 | ||
393 | case CISTPL_DEVICE: { | 380 | if (!pcmcia_parse_tuple(tuple, &parse)) { |
394 | cistpl_device_t *t = &parse.device; | 381 | cistpl_jedec_t *t = &parse.jedec; |
395 | int i; | 382 | for (i = 0; i < t->nid; i++) |
396 | DEBUG(2, "Common memory:"); | 383 | DEBUG(2, "JEDEC: 0x%02x 0x%02x", t->id[i].mfr, t->id[i].info); |
397 | dev->pcmcia_map.size = t->dev[0].size; | 384 | } |
398 | for(i = 0; i < t->ndev; i++) { | 385 | return -ENOSPC; |
399 | DEBUG(2, "Region %d, type = %u", i, t->dev[i].type); | 386 | } |
400 | DEBUG(2, "Region %d, wp = %u", i, t->dev[i].wp); | 387 | #endif |
401 | DEBUG(2, "Region %d, speed = %u ns", i, t->dev[i].speed); | ||
402 | DEBUG(2, "Region %d, size = %u bytes", i, t->dev[i].size); | ||
403 | } | ||
404 | break; | ||
405 | } | ||
406 | 388 | ||
407 | case CISTPL_VERS_1: { | 389 | static int pcmciamtd_cistpl_device(struct pcmcia_device *p_dev, |
408 | cistpl_vers_1_t *t = &parse.version_1; | 390 | tuple_t *tuple, |
409 | int i; | 391 | void *priv_data) |
410 | if(t->ns) { | 392 | { |
411 | dev->mtd_name[0] = '\0'; | 393 | struct pcmciamtd_dev *dev = priv_data; |
412 | for(i = 0; i < t->ns; i++) { | 394 | cisparse_t parse; |
413 | if(i) | 395 | cistpl_device_t *t = &parse.device; |
414 | strcat(dev->mtd_name, " "); | 396 | int i; |
415 | strcat(dev->mtd_name, t->str+t->ofs[i]); | ||
416 | } | ||
417 | } | ||
418 | DEBUG(2, "Found name: %s", dev->mtd_name); | ||
419 | break; | ||
420 | } | ||
421 | 397 | ||
422 | case CISTPL_JEDEC_C: { | 398 | if (pcmcia_parse_tuple(tuple, &parse)) |
423 | cistpl_jedec_t *t = &parse.jedec; | 399 | return -EINVAL; |
424 | int i; | 400 | |
425 | for(i = 0; i < t->nid; i++) { | 401 | DEBUG(2, "Common memory:"); |
426 | DEBUG(2, "JEDEC: 0x%02x 0x%02x", t->id[i].mfr, t->id[i].info); | 402 | dev->pcmcia_map.size = t->dev[0].size; |
427 | } | 403 | /* from here on: DEBUG only */ |
428 | break; | 404 | for (i = 0; i < t->ndev; i++) { |
429 | } | 405 | DEBUG(2, "Region %d, type = %u", i, t->dev[i].type); |
406 | DEBUG(2, "Region %d, wp = %u", i, t->dev[i].wp); | ||
407 | DEBUG(2, "Region %d, speed = %u ns", i, t->dev[i].speed); | ||
408 | DEBUG(2, "Region %d, size = %u bytes", i, t->dev[i].size); | ||
409 | } | ||
410 | return 0; | ||
411 | } | ||
430 | 412 | ||
431 | case CISTPL_DEVICE_GEO: { | 413 | static int pcmciamtd_cistpl_geo(struct pcmcia_device *p_dev, |
432 | cistpl_device_geo_t *t = &parse.device_geo; | 414 | tuple_t *tuple, |
433 | int i; | 415 | void *priv_data) |
434 | dev->pcmcia_map.bankwidth = t->geo[0].buswidth; | 416 | { |
435 | for(i = 0; i < t->ngeo; i++) { | 417 | struct pcmciamtd_dev *dev = priv_data; |
436 | DEBUG(2, "region: %d bankwidth = %u", i, t->geo[i].buswidth); | 418 | cisparse_t parse; |
437 | DEBUG(2, "region: %d erase_block = %u", i, t->geo[i].erase_block); | 419 | cistpl_device_geo_t *t = &parse.device_geo; |
438 | DEBUG(2, "region: %d read_block = %u", i, t->geo[i].read_block); | 420 | int i; |
439 | DEBUG(2, "region: %d write_block = %u", i, t->geo[i].write_block); | ||
440 | DEBUG(2, "region: %d partition = %u", i, t->geo[i].partition); | ||
441 | DEBUG(2, "region: %d interleave = %u", i, t->geo[i].interleave); | ||
442 | } | ||
443 | break; | ||
444 | } | ||
445 | 421 | ||
446 | default: | 422 | if (pcmcia_parse_tuple(tuple, &parse)) |
447 | DEBUG(2, "Unknown tuple code %d", tuple.TupleCode); | 423 | return -EINVAL; |
448 | } | 424 | |
425 | dev->pcmcia_map.bankwidth = t->geo[0].buswidth; | ||
426 | /* from here on: DEBUG only */ | ||
427 | for (i = 0; i < t->ngeo; i++) { | ||
428 | DEBUG(2, "region: %d bankwidth = %u", i, t->geo[i].buswidth); | ||
429 | DEBUG(2, "region: %d erase_block = %u", i, t->geo[i].erase_block); | ||
430 | DEBUG(2, "region: %d read_block = %u", i, t->geo[i].read_block); | ||
431 | DEBUG(2, "region: %d write_block = %u", i, t->geo[i].write_block); | ||
432 | DEBUG(2, "region: %d partition = %u", i, t->geo[i].partition); | ||
433 | DEBUG(2, "region: %d interleave = %u", i, t->geo[i].interleave); | ||
434 | } | ||
435 | return 0; | ||
436 | } | ||
437 | |||
438 | |||
439 | static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, int *new_name) | ||
440 | { | ||
441 | int i; | ||
449 | 442 | ||
450 | rc = pcmcia_get_next_tuple(link, &tuple); | 443 | if (p_dev->prod_id[0]) { |
444 | dev->mtd_name[0] = '\0'; | ||
445 | for (i = 0; i < 4; i++) { | ||
446 | if (i) | ||
447 | strcat(dev->mtd_name, " "); | ||
448 | if (p_dev->prod_id[i]) | ||
449 | strcat(dev->mtd_name, p_dev->prod_id[i]); | ||
450 | } | ||
451 | DEBUG(2, "Found name: %s", dev->mtd_name); | ||
451 | } | 452 | } |
453 | |||
454 | #ifdef CONFIG_MTD_DEBUG | ||
455 | pcmcia_loop_tuple(p_dev, CISTPL_FORMAT, pcmciamtd_cistpl_format, NULL); | ||
456 | pcmcia_loop_tuple(p_dev, CISTPL_JEDEC_C, pcmciamtd_cistpl_jedec, NULL); | ||
457 | #endif | ||
458 | pcmcia_loop_tuple(p_dev, CISTPL_DEVICE, pcmciamtd_cistpl_device, dev); | ||
459 | pcmcia_loop_tuple(p_dev, CISTPL_DEVICE_GEO, pcmciamtd_cistpl_geo, dev); | ||
460 | |||
452 | if(!dev->pcmcia_map.size) | 461 | if(!dev->pcmcia_map.size) |
453 | dev->pcmcia_map.size = MAX_PCMCIA_ADDR; | 462 | dev->pcmcia_map.size = MAX_PCMCIA_ADDR; |
454 | 463 | ||