/* Returns zero in case of success and a negative error code in case of failure.  */
int mtd_device_parse_register(struct mtd_info *mtd, const char *const *types, struct mtd_part_parser_data *parser_data, const struct mtd_partition *parts, int nr_parts)
/* Returns zero in case of success and a negative error code in case of failure.  */
int mtd_device_parse_register(struct mtd_info *mtd, const char *const *types, struct mtd_part_parser_data *parser_data, const struct mtd_partition *parts, int nr_parts)
{
	int err;
	struct mtd_partition *real_parts;
	err = parse_mtd_partitions(mtd, types, &real_parts, parser_data);
	if (err <= 0 && nr_parts && parts) {
		real_parts = kmemdup(parts, sizeof(*parts) * nr_parts,
				     GFP_KERNEL);
		if (!real_parts)
			err = -ENOMEM;
		else
			err = nr_parts;
	}
	if (err > 0) {
		err = add_mtd_partitions(mtd, real_parts, err);
		kfree(real_parts);
	} else if (err == 0) {
		err = add_mtd_device(mtd);
		if (err == 1)
			err = -ENODEV;
	}
	return err;
}