/* This function is similar to 'ubi_get_device()', but it searches the device by its major number.  */
struct ubi_device* ubi_get_by_major(int major)
/* This function is similar to 'ubi_get_device()', but it searches the device by its major number.  */
struct ubi_device* ubi_get_by_major(int major)
{
	int i;
	struct ubi_device *ubi;
	spin_lock(&ubi_devices_lock);
	for (i = 0; i < UBI_MAX_DEVICES; i++) {
		ubi = ubi_devices[i];
		if (ubi && MAJOR(ubi->cdev.dev) == major) {
			ubi_assert(ubi->ref_count >= 0);
			ubi->ref_count += 1;
			get_device(&ubi->dev);
			spin_unlock(&ubi_devices_lock);
			return ubi;
		}
	}
	spin_unlock(&ubi_devices_lock);
	return NULL;
}