/* This function searches UBI device number object by its major number. If UBI device was not found, this function returns -ENODEV, otherwise the UBI device number is returned.  */
int ubi_major2num(int major)
/* This function searches UBI device number object by its major number. If UBI device was not found, this function returns -ENODEV, otherwise the UBI device number is returned.  */
int ubi_major2num(int major)
{
	int i, ubi_num = -ENODEV;
	spin_lock(&ubi_devices_lock);
	for (i = 0; i < UBI_MAX_DEVICES; i++) {
		struct ubi_device *ubi = ubi_devices[i];
		if (ubi && MAJOR(ubi->cdev.dev) == major) {
			ubi_num = ubi->ubi_num;
			break;
		}
	}
	spin_unlock(&ubi_devices_lock);
	return ubi_num;
}