mtdpart.c (c42c2710d64381fd48d36b278e0744aa683d93fe) | mtdpart.c (07fd2f871c5e3dfb8ff5eb9c4b44fdb4cf1aeff5) |
---|---|
1/* 2 * Simple MTD partitioning layer 3 * 4 * Copyright © 2000 Nicolas Pitre <nico@fluxnic.net> 5 * Copyright © 2002 Thomas Gleixner <gleixner@linutronix.de> 6 * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 729 unchanged lines hidden (view full) --- 738 "ofpart", 739 NULL 740}; 741 742/** 743 * parse_mtd_partitions - parse MTD partitions 744 * @master: the master partition (describes whole MTD device) 745 * @types: names of partition parsers to try or %NULL | 1/* 2 * Simple MTD partitioning layer 3 * 4 * Copyright © 2000 Nicolas Pitre <nico@fluxnic.net> 5 * Copyright © 2002 Thomas Gleixner <gleixner@linutronix.de> 6 * Copyright © 2000-2010 David Woodhouse <dwmw2@infradead.org> 7 * 8 * This program is free software; you can redistribute it and/or modify --- 729 unchanged lines hidden (view full) --- 738 "ofpart", 739 NULL 740}; 741 742/** 743 * parse_mtd_partitions - parse MTD partitions 744 * @master: the master partition (describes whole MTD device) 745 * @types: names of partition parsers to try or %NULL |
746 * @pparts: array of partitions found is returned here | 746 * @pparts: info about partitions found is returned here |
747 * @data: MTD partition parser-specific data 748 * 749 * This function tries to find partition on MTD device @master. It uses MTD 750 * partition parsers, specified in @types. However, if @types is %NULL, then 751 * the default list of parsers is used. The default list contains only the 752 * "cmdlinepart" and "ofpart" parsers ATM. 753 * Note: If there are more then one parser in @types, the kernel only takes the 754 * partitions parsed out by the first parser. 755 * 756 * This function may return: 757 * o a negative error code in case of failure | 747 * @data: MTD partition parser-specific data 748 * 749 * This function tries to find partition on MTD device @master. It uses MTD 750 * partition parsers, specified in @types. However, if @types is %NULL, then 751 * the default list of parsers is used. The default list contains only the 752 * "cmdlinepart" and "ofpart" parsers ATM. 753 * Note: If there are more then one parser in @types, the kernel only takes the 754 * partitions parsed out by the first parser. 755 * 756 * This function may return: 757 * o a negative error code in case of failure |
758 * o zero if no partitions were found 759 * o a positive number of found partitions, in which case on exit @pparts will 760 * point to an array containing this number of &struct mtd_info objects. | 758 * o zero otherwise, and @pparts will describe the partitions, number of 759 * partitions, and the parser which parsed them |
761 */ 762int parse_mtd_partitions(struct mtd_info *master, const char *const *types, | 760 */ 761int parse_mtd_partitions(struct mtd_info *master, const char *const *types, |
763 const struct mtd_partition **pparts, | 762 struct mtd_partitions *pparts, |
764 struct mtd_part_parser_data *data) 765{ 766 struct mtd_part_parser *parser; 767 int ret, err = 0; 768 769 if (!types) 770 types = default_mtd_part_types; 771 772 for ( ; *types; types++) { 773 pr_debug("%s: parsing partitions %s\n", master->name, *types); 774 parser = mtd_part_parser_get(*types); 775 if (!parser && !request_module("%s", *types)) 776 parser = mtd_part_parser_get(*types); 777 pr_debug("%s: got parser %s\n", master->name, 778 parser ? parser->name : NULL); 779 if (!parser) 780 continue; | 763 struct mtd_part_parser_data *data) 764{ 765 struct mtd_part_parser *parser; 766 int ret, err = 0; 767 768 if (!types) 769 types = default_mtd_part_types; 770 771 for ( ; *types; types++) { 772 pr_debug("%s: parsing partitions %s\n", master->name, *types); 773 parser = mtd_part_parser_get(*types); 774 if (!parser && !request_module("%s", *types)) 775 parser = mtd_part_parser_get(*types); 776 pr_debug("%s: got parser %s\n", master->name, 777 parser ? parser->name : NULL); 778 if (!parser) 779 continue; |
781 ret = (*parser->parse_fn)(master, pparts, data); | 780 ret = (*parser->parse_fn)(master, &pparts->parts, data); |
782 pr_debug("%s: parser %s: %i\n", 783 master->name, parser->name, ret); 784 mtd_part_parser_put(parser); 785 if (ret > 0) { 786 printk(KERN_NOTICE "%d %s partitions found on MTD device %s\n", 787 ret, parser->name, master->name); | 781 pr_debug("%s: parser %s: %i\n", 782 master->name, parser->name, ret); 783 mtd_part_parser_put(parser); 784 if (ret > 0) { 785 printk(KERN_NOTICE "%d %s partitions found on MTD device %s\n", 786 ret, parser->name, master->name); |
788 return ret; | 787 pparts->nr_parts = ret; 788 pparts->parser = parser; 789 return 0; |
789 } 790 /* 791 * Stash the first error we see; only report it if no parser 792 * succeeds 793 */ 794 if (ret < 0 && !err) 795 err = ret; 796 } --- 29 unchanged lines hidden --- | 790 } 791 /* 792 * Stash the first error we see; only report it if no parser 793 * succeeds 794 */ 795 if (ret < 0 && !err) 796 err = ret; 797 } --- 29 unchanged lines hidden --- |