Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * lowlevel.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * PURPOSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *  Low Level Device Routines for the UDF filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  *	This file is distributed under the terms of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  *	License (GPL). Copies of the GPL can be obtained from:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  *		ftp://prep.ai.mit.edu/pub/gnu/GPL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  *	Each contributing author retains all rights to their own work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  *  (C) 1999-2001 Ben Fennema
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  * HISTORY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  *  03/26/99 blf  Created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "udfdecl.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/cdrom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include "udf_sb.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) unsigned int udf_get_last_session(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	struct cdrom_device_info *cdi = disk_to_cdi(sb->s_bdev->bd_disk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	struct cdrom_multisession ms_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	if (!cdi) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		udf_debug("CDROMMULTISESSION not supported.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	ms_info.addr_format = CDROM_LBA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	if (cdrom_multisession(cdi, &ms_info) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		udf_debug("XA disk: %s, vol_desc_start=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 			  ms_info.xa_flag ? "yes" : "no", ms_info.addr.lba);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 			return ms_info.addr.lba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) unsigned long udf_get_last_block(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	struct block_device *bdev = sb->s_bdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	struct cdrom_device_info *cdi = disk_to_cdi(bdev->bd_disk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	unsigned long lblock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	 * The cdrom layer call failed or returned obviously bogus value?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	 * Try using the device size...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	if (!cdi || cdrom_get_last_written(cdi, &lblock) || lblock == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 		lblock = i_size_read(bdev->bd_inode) >> sb->s_blocksize_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	if (lblock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 		return lblock - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) }