Commit e1d2950d0f5aaa7ab6609ffa96dde2e163fc2902
1 parent
2697eff1af
Exists in
master
and in
54 other branches
mtdparts: get rid of custom DEBUG macro, use debug()
Signed-off-by: Wolfgang Denk <wd@denx.de>
Showing 1 changed file with 40 additions and 50 deletions Side-by-side Diff
common/cmd_mtdparts.c
... | ... | @@ -103,16 +103,6 @@ |
103 | 103 | #include <onenand_uboot.h> |
104 | 104 | #endif |
105 | 105 | |
106 | -/* enable/disable debugging messages */ | |
107 | -#define DEBUG_MTDPARTS | |
108 | -#undef DEBUG_MTDPARTS | |
109 | - | |
110 | -#ifdef DEBUG_MTDPARTS | |
111 | -# define DEBUGF(fmt, args...) printf(fmt ,##args) | |
112 | -#else | |
113 | -# define DEBUGF(fmt, args...) | |
114 | -#endif | |
115 | - | |
116 | 106 | /* special size referring to all the remaining space in a partition */ |
117 | 107 | #define SIZE_REMAINING 0xFFFFFFFF |
118 | 108 | |
... | ... | @@ -243,7 +233,7 @@ |
243 | 233 | struct list_head *dentry; |
244 | 234 | struct mtd_device *dev; |
245 | 235 | |
246 | - DEBUGF("--- index partitions ---\n"); | |
236 | + debug("--- index partitions ---\n"); | |
247 | 237 | |
248 | 238 | if (current_mtd_dev) { |
249 | 239 | mtddevnum = 0; |
250 | 240 | |
... | ... | @@ -261,12 +251,12 @@ |
261 | 251 | part = mtd_part_info(current_mtd_dev, current_mtd_partnum); |
262 | 252 | setenv("mtddevname", part->name); |
263 | 253 | |
264 | - DEBUGF("=> mtddevnum %d,\n=> mtddevname %s\n", mtddevnum, part->name); | |
254 | + debug("=> mtddevnum %d,\n=> mtddevname %s\n", mtddevnum, part->name); | |
265 | 255 | } else { |
266 | 256 | setenv("mtddevnum", NULL); |
267 | 257 | setenv("mtddevname", NULL); |
268 | 258 | |
269 | - DEBUGF("=> mtddevnum NULL\n=> mtddevname NULL\n"); | |
259 | + debug("=> mtddevnum NULL\n=> mtddevname NULL\n"); | |
270 | 260 | } |
271 | 261 | } |
272 | 262 | |
... | ... | @@ -277,7 +267,7 @@ |
277 | 267 | { |
278 | 268 | char buf[16]; |
279 | 269 | |
280 | - DEBUGF("--- current_save ---\n"); | |
270 | + debug("--- current_save ---\n"); | |
281 | 271 | |
282 | 272 | if (current_mtd_dev) { |
283 | 273 | sprintf(buf, "%s%d,%d", MTD_DEV_TYPE(current_mtd_dev->id->type), |
284 | 274 | |
... | ... | @@ -286,12 +276,12 @@ |
286 | 276 | setenv("partition", buf); |
287 | 277 | strncpy(last_partition, buf, 16); |
288 | 278 | |
289 | - DEBUGF("=> partition %s\n", buf); | |
279 | + debug("=> partition %s\n", buf); | |
290 | 280 | } else { |
291 | 281 | setenv("partition", NULL); |
292 | 282 | last_partition[0] = '\0'; |
293 | 283 | |
294 | - DEBUGF("=> partition NULL\n"); | |
284 | + debug("=> partition NULL\n"); | |
295 | 285 | } |
296 | 286 | index_partitions(); |
297 | 287 | } |
... | ... | @@ -505,7 +495,7 @@ |
505 | 495 | part->dev = dev; |
506 | 496 | |
507 | 497 | if (list_empty(&dev->parts)) { |
508 | - DEBUGF("part_sort_add: list empty\n"); | |
498 | + debug("part_sort_add: list empty\n"); | |
509 | 499 | list_add(&part->link, &dev->parts); |
510 | 500 | dev->num_parts++; |
511 | 501 | index_partitions(); |
... | ... | @@ -598,7 +588,7 @@ |
598 | 588 | /* fetch the partition size */ |
599 | 589 | if (*p == '-') { |
600 | 590 | /* assign all remaining space to this partition */ |
601 | - DEBUGF("'-': remaining size assigned\n"); | |
591 | + debug("'-': remaining size assigned\n"); | |
602 | 592 | size = SIZE_REMAINING; |
603 | 593 | p++; |
604 | 594 | } else { |
... | ... | @@ -683,7 +673,7 @@ |
683 | 673 | part->name[name_len - 1] = '\0'; |
684 | 674 | INIT_LIST_HEAD(&part->link); |
685 | 675 | |
686 | - DEBUGF("+ partition: name %-22s size 0x%08x offset 0x%08x mask flags %d\n", | |
676 | + debug("+ partition: name %-22s size 0x%08x offset 0x%08x mask flags %d\n", | |
687 | 677 | part->name, part->size, |
688 | 678 | part->offset, part->mask_flags); |
689 | 679 | |
... | ... | @@ -837,7 +827,7 @@ |
837 | 827 | u32 offset; |
838 | 828 | int err = 1; |
839 | 829 | |
840 | - DEBUGF("===device_parse===\n"); | |
830 | + debug("===device_parse===\n"); | |
841 | 831 | |
842 | 832 | assert(retdev); |
843 | 833 | *retdev = NULL; |
844 | 834 | |
... | ... | @@ -860,11 +850,11 @@ |
860 | 850 | return 1; |
861 | 851 | } |
862 | 852 | |
863 | - DEBUGF("dev type = %d (%s), dev num = %d, mtd-id = %s\n", | |
853 | + debug("dev type = %d (%s), dev num = %d, mtd-id = %s\n", | |
864 | 854 | id->type, MTD_DEV_TYPE(id->type), |
865 | 855 | id->num, id->mtd_id); |
866 | 856 | pend = strchr(p, ';'); |
867 | - DEBUGF("parsing partitions %.*s\n", (pend ? pend - p : strlen(p)), p); | |
857 | + debug("parsing partitions %.*s\n", (pend ? pend - p : strlen(p)), p); | |
868 | 858 | |
869 | 859 | |
870 | 860 | /* parse partitions */ |
... | ... | @@ -910,7 +900,7 @@ |
910 | 900 | return 1; |
911 | 901 | } |
912 | 902 | |
913 | - DEBUGF("\ntotal partitions: %d\n", num_parts); | |
903 | + debug("\ntotal partitions: %d\n", num_parts); | |
914 | 904 | |
915 | 905 | /* check for next device presence */ |
916 | 906 | if (p) { |
... | ... | @@ -951,7 +941,7 @@ |
951 | 941 | |
952 | 942 | *retdev = dev; |
953 | 943 | |
954 | - DEBUGF("===\n\n"); | |
944 | + debug("===\n\n"); | |
955 | 945 | return 0; |
956 | 946 | } |
957 | 947 | |
958 | 948 | |
... | ... | @@ -1003,13 +993,13 @@ |
1003 | 993 | struct list_head *entry; |
1004 | 994 | struct mtdids *id; |
1005 | 995 | |
1006 | - DEBUGF("--- id_find_by_mtd_id: '%.*s' (len = %d)\n", | |
996 | + debug("--- id_find_by_mtd_id: '%.*s' (len = %d)\n", | |
1007 | 997 | mtd_id_len, mtd_id, mtd_id_len); |
1008 | 998 | |
1009 | 999 | list_for_each(entry, &mtdids) { |
1010 | 1000 | id = list_entry(entry, struct mtdids, link); |
1011 | 1001 | |
1012 | - DEBUGF("entry: '%s' (len = %d)\n", | |
1002 | + debug("entry: '%s' (len = %d)\n", | |
1013 | 1003 | id->mtd_id, strlen(id->mtd_id)); |
1014 | 1004 | |
1015 | 1005 | if (mtd_id_len != strlen(id->mtd_id)) |
... | ... | @@ -1079,7 +1069,7 @@ |
1079 | 1069 | u32 size, offset, len, part_cnt; |
1080 | 1070 | u32 maxlen = buflen - 1; |
1081 | 1071 | |
1082 | - DEBUGF("--- generate_mtdparts ---\n"); | |
1072 | + debug("--- generate_mtdparts ---\n"); | |
1083 | 1073 | |
1084 | 1074 | if (list_empty(&devices)) { |
1085 | 1075 | buf[0] = '\0'; |
... | ... | @@ -1221,7 +1211,7 @@ |
1221 | 1211 | struct mtd_device *dev; |
1222 | 1212 | int part_num; |
1223 | 1213 | |
1224 | - DEBUGF("\n---list_partitions---\n"); | |
1214 | + debug("\n---list_partitions---\n"); | |
1225 | 1215 | list_for_each(dentry, &devices) { |
1226 | 1216 | dev = list_entry(dentry, struct mtd_device, link); |
1227 | 1217 | printf("\ndevice %s%d <%s>, # parts = %d\n", |
... | ... | @@ -1286,7 +1276,7 @@ |
1286 | 1276 | u8 type, dnum, pnum; |
1287 | 1277 | const char *p; |
1288 | 1278 | |
1289 | - DEBUGF("--- find_dev_and_part ---\nid = %s\n", id); | |
1279 | + debug("--- find_dev_and_part ---\nid = %s\n", id); | |
1290 | 1280 | |
1291 | 1281 | list_for_each(dentry, &devices) { |
1292 | 1282 | *part_num = 0; |
... | ... | @@ -1347,7 +1337,7 @@ |
1347 | 1337 | |
1348 | 1338 | if (find_dev_and_part(id, &dev, &pnum, &part) == 0) { |
1349 | 1339 | |
1350 | - DEBUGF("delete_partition: device = %s%d, partition %d = (%s) 0x%08x@0x%08x\n", | |
1340 | + debug("delete_partition: device = %s%d, partition %d = (%s) 0x%08x@0x%08x\n", | |
1351 | 1341 | MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum, |
1352 | 1342 | part->name, part->size, part->offset); |
1353 | 1343 | |
... | ... | @@ -1378,7 +1368,7 @@ |
1378 | 1368 | struct mtd_device *dev; |
1379 | 1369 | int err = 1; |
1380 | 1370 | |
1381 | - DEBUGF("\n---parse_mtdparts---\nmtdparts = %s\n\n", p); | |
1371 | + debug("\n---parse_mtdparts---\nmtdparts = %s\n\n", p); | |
1382 | 1372 | |
1383 | 1373 | /* delete all devices and partitions */ |
1384 | 1374 | if (mtd_devices_init() != 0) { |
... | ... | @@ -1400,7 +1390,7 @@ |
1400 | 1390 | if ((device_parse(p, &p, &dev) != 0) || (!dev)) |
1401 | 1391 | break; |
1402 | 1392 | |
1403 | - DEBUGF("+ device: %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type), | |
1393 | + debug("+ device: %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type), | |
1404 | 1394 | dev->id->num, dev->id->mtd_id); |
1405 | 1395 | |
1406 | 1396 | /* check if parsed device is already on the list */ |
1407 | 1397 | |
... | ... | @@ -1441,12 +1431,12 @@ |
1441 | 1431 | u32 size; |
1442 | 1432 | int ret = 1; |
1443 | 1433 | |
1444 | - DEBUGF("\n---parse_mtdids---\nmtdids = %s\n\n", ids); | |
1434 | + debug("\n---parse_mtdids---\nmtdids = %s\n\n", ids); | |
1445 | 1435 | |
1446 | 1436 | /* clean global mtdids list */ |
1447 | 1437 | list_for_each_safe(entry, n, &mtdids) { |
1448 | 1438 | id_tmp = list_entry(entry, struct mtdids, link); |
1449 | - DEBUGF("mtdids del: %d %d\n", id_tmp->type, id_tmp->num); | |
1439 | + debug("mtdids del: %d %d\n", id_tmp->type, id_tmp->num); | |
1450 | 1440 | list_del(entry); |
1451 | 1441 | free(id_tmp); |
1452 | 1442 | } |
... | ... | @@ -1512,7 +1502,7 @@ |
1512 | 1502 | id->mtd_id[mtd_id_len - 1] = '\0'; |
1513 | 1503 | INIT_LIST_HEAD(&id->link); |
1514 | 1504 | |
1515 | - DEBUGF("+ id %s%d\t%16d bytes\t%s\n", | |
1505 | + debug("+ id %s%d\t%16d bytes\t%s\n", | |
1516 | 1506 | MTD_DEV_TYPE(id->type), id->num, |
1517 | 1507 | id->size, id->mtd_id); |
1518 | 1508 | |
... | ... | @@ -1546,7 +1536,7 @@ |
1546 | 1536 | int ids_changed; |
1547 | 1537 | char tmp_ep[PARTITION_MAXLEN]; |
1548 | 1538 | |
1549 | - DEBUGF("\n---mtdparts_init---\n"); | |
1539 | + debug("\n---mtdparts_init---\n"); | |
1550 | 1540 | if (!initialized) { |
1551 | 1541 | INIT_LIST_HEAD(&mtdids); |
1552 | 1542 | INIT_LIST_HEAD(&devices); |
1553 | 1543 | |
1554 | 1544 | |
... | ... | @@ -1567,18 +1557,18 @@ |
1567 | 1557 | if (current_partition) |
1568 | 1558 | strncpy(tmp_ep, current_partition, PARTITION_MAXLEN); |
1569 | 1559 | |
1570 | - DEBUGF("last_ids : %s\n", last_ids); | |
1571 | - DEBUGF("env_ids : %s\n", ids); | |
1572 | - DEBUGF("last_parts: %s\n", last_parts); | |
1573 | - DEBUGF("env_parts : %s\n\n", parts); | |
1560 | + debug("last_ids : %s\n", last_ids); | |
1561 | + debug("env_ids : %s\n", ids); | |
1562 | + debug("last_parts: %s\n", last_parts); | |
1563 | + debug("env_parts : %s\n\n", parts); | |
1574 | 1564 | |
1575 | - DEBUGF("last_partition : %s\n", last_partition); | |
1576 | - DEBUGF("env_partition : %s\n", current_partition); | |
1565 | + debug("last_partition : %s\n", last_partition); | |
1566 | + debug("env_partition : %s\n", current_partition); | |
1577 | 1567 | |
1578 | 1568 | /* if mtdids varible is empty try to use defaults */ |
1579 | 1569 | if (!ids) { |
1580 | 1570 | if (mtdids_default) { |
1581 | - DEBUGF("mtdids variable not defined, using default\n"); | |
1571 | + debug("mtdids variable not defined, using default\n"); | |
1582 | 1572 | ids = mtdids_default; |
1583 | 1573 | setenv("mtdids", (char *)ids); |
1584 | 1574 | } else { |
... | ... | @@ -1634,7 +1624,7 @@ |
1634 | 1624 | current_mtd_partnum = 0; |
1635 | 1625 | current_save(); |
1636 | 1626 | |
1637 | - DEBUGF("mtdparts_init: current_mtd_dev = %s%d, current_mtd_partnum = %d\n", | |
1627 | + debug("mtdparts_init: current_mtd_dev = %s%d, current_mtd_partnum = %d\n", | |
1638 | 1628 | MTD_DEV_TYPE(current_mtd_dev->id->type), |
1639 | 1629 | current_mtd_dev->id->num, current_mtd_partnum); |
1640 | 1630 | } |
... | ... | @@ -1653,7 +1643,7 @@ |
1653 | 1643 | struct mtd_device *cdev; |
1654 | 1644 | u8 pnum; |
1655 | 1645 | |
1656 | - DEBUGF("--- getting current partition: %s\n", tmp_ep); | |
1646 | + debug("--- getting current partition: %s\n", tmp_ep); | |
1657 | 1647 | |
1658 | 1648 | if (find_dev_and_part(tmp_ep, &cdev, &pnum, &p) == 0) { |
1659 | 1649 | current_mtd_dev = cdev; |
... | ... | @@ -1661,7 +1651,7 @@ |
1661 | 1651 | current_save(); |
1662 | 1652 | } |
1663 | 1653 | } else if (getenv("partition") == NULL) { |
1664 | - DEBUGF("no partition variable set, setting...\n"); | |
1654 | + debug("no partition variable set, setting...\n"); | |
1665 | 1655 | current_save(); |
1666 | 1656 | } |
1667 | 1657 | |
... | ... | @@ -1685,7 +1675,7 @@ |
1685 | 1675 | if (!dev) |
1686 | 1676 | return NULL; |
1687 | 1677 | |
1688 | - DEBUGF("\n--- mtd_part_info: partition number %d for device %s%d (%s)\n", | |
1678 | + debug("\n--- mtd_part_info: partition number %d for device %s%d (%s)\n", | |
1689 | 1679 | part_num, MTD_DEV_TYPE(dev->id->type), |
1690 | 1680 | dev->id->num, dev->id->mtd_id); |
1691 | 1681 | |
1692 | 1682 | |
... | ... | @@ -1821,12 +1811,12 @@ |
1821 | 1811 | } |
1822 | 1812 | sprintf(tmpbuf, "%s:%s(%s)%s", |
1823 | 1813 | id->mtd_id, argv[3], argv[4], argv[5] ? argv[5] : ""); |
1824 | - DEBUGF("add tmpbuf: %s\n", tmpbuf); | |
1814 | + debug("add tmpbuf: %s\n", tmpbuf); | |
1825 | 1815 | |
1826 | 1816 | if ((device_parse(tmpbuf, NULL, &dev) != 0) || (!dev)) |
1827 | 1817 | return 1; |
1828 | 1818 | |
1829 | - DEBUGF("+ %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type), | |
1819 | + debug("+ %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type), | |
1830 | 1820 | dev->id->num, dev->id->mtd_id); |
1831 | 1821 | |
1832 | 1822 | if ((dev_tmp = device_find(dev->id->type, dev->id->num)) == NULL) { |
... | ... | @@ -1850,7 +1840,7 @@ |
1850 | 1840 | |
1851 | 1841 | /* mtdparts del part-id */ |
1852 | 1842 | if ((argc == 3) && (strcmp(argv[1], "del") == 0)) { |
1853 | - DEBUGF("del: part-id = %s\n", argv[2]); | |
1843 | + debug("del: part-id = %s\n", argv[2]); | |
1854 | 1844 | |
1855 | 1845 | return delete_partition(argv[2]); |
1856 | 1846 | } |