#define mtd_device_register(master, parts, nr_parts)?? ?\ ?? ?mtd_device_parse_register(master, NULL, NULL, parts, nr_parts)
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) { ?? ?struct mtd_partitions parsed; ?? ?int ret;
?? ?mtd_set_dev_defaults(mtd);
?? ?memset(&parsed, 0, sizeof(parsed));
?? ?ret = parse_mtd_partitions(mtd, types, &parsed, parser_data); ?? ?if ((ret < 0 || parsed.nr_parts == 0) && parts && nr_parts) { ?? ??? ?/* Fall back to driver-provided partitions */ ?? ??? ?parsed = (struct mtd_partitions){ ?? ??? ??? ?.parts?? ??? ?= parts, ?? ??? ??? ?.nr_parts?? ?= nr_parts, ?? ??? ?}; ?? ?} else if (ret < 0) { ?? ??? ?/* Didn't come up with parsed OR fallback partitions */ ?? ??? ?pr_info("mtd: failed to find partitions; one or more parsers reports errors (%d)\n", ?? ??? ??? ?ret); ?? ??? ?/* Don't abort on errors; we can still use unpartitioned MTD */ ?? ??? ?memset(&parsed, 0, sizeof(parsed)); ?? ?}
?? ?ret = mtd_add_device_partitions(mtd, &parsed); ?? ?if (ret) ?? ??? ?goto out;
?? ?/* ?? ? * FIXME: some drivers unfortunately call this function more than once. ?? ? * So we have to check if we've already assigned the reboot notifier. ?? ? * ?? ? * Generally, we can make multiple calls work for most cases, but it ?? ? * does cause problems with parse_mtd_partitions() above (e.g., ?? ? * cmdlineparts will register partitions more than once). ?? ? */ ?? ?WARN_ONCE(mtd->_reboot && mtd->reboot_notifier.notifier_call, ?? ??? ?? "MTD already registered\n"); ?? ?if (mtd->_reboot && !mtd->reboot_notifier.notifier_call) { ?? ??? ?mtd->reboot_notifier.notifier_call = mtd_reboot_notifier; ?? ??? ?register_reboot_notifier(&mtd->reboot_notifier); ?? ?}
out: ?? ?/* Cleanup any parsed partitions */ ?? ?mtd_part_parser_cleanup(&parsed); ?? ?return ret; }
|