/* This function returns UBI device description object for UBI device number @ubi_num, or NULL if the device does not exist. This function increases the device reference count to prevent removal of the device. In other words, the device cannot be removed if its reference count is not zero.  */
struct ubi_device* ubi_get_device(int ubi_num)
/* This function returns UBI device description object for UBI device number @ubi_num, or NULL if the device does not exist. This function increases the device reference count to prevent removal of the device. In other words, the device cannot be removed if its reference count is not zero.  */
struct ubi_device* ubi_get_device(int ubi_num)
{
	struct ubi_device *ubi;
	spin_lock(&ubi_devices_lock);
	ubi = ubi_devices[ubi_num];
	if (ubi) {
		ubi_assert(ubi->ref_count >= 0);
		ubi->ref_count += 1;
		get_device(&ubi->dev);
	}
	spin_unlock(&ubi_devices_lock);
	return ubi;
}