/* Delete selected partition from the partion list of the specified device. */
static int part_del(struct mtd_device *dev, struct part_info *part)
/* Delete selected partition from the partion list of the specified device. */
static int part_del(struct mtd_device *dev, struct part_info *part)
{
	u8 current_save_needed = 0;
	if (dev->num_parts == 1)
		return device_del(dev);
	if (dev == current_mtd_dev) {
		struct part_info *curr_pi;
		curr_pi = mtd_part_info(current_mtd_dev, current_mtd_partnum);
		if (curr_pi) {
			if (curr_pi == part) {
				printf("current partition deleted, resetting current to 0\n");
				current_mtd_partnum = 0;
			} else if (part->offset <= curr_pi->offset) {
				current_mtd_partnum--;
			}
			current_save_needed = 1;
		}
	}
	list_del(&part->link);
	free(part);
	dev->num_parts--;
	if (current_save_needed > 0)
		current_save();
	else
		index_partitions();
	return 0;
}