162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __UDF_ENDIAN_H 362306a36Sopenharmony_ci#define __UDF_ENDIAN_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <asm/byteorder.h> 662306a36Sopenharmony_ci#include <linux/string.h> 762306a36Sopenharmony_ci 862306a36Sopenharmony_cistatic inline struct kernel_lb_addr lelb_to_cpu(struct lb_addr in) 962306a36Sopenharmony_ci{ 1062306a36Sopenharmony_ci struct kernel_lb_addr out; 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum); 1362306a36Sopenharmony_ci out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum); 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci return out; 1662306a36Sopenharmony_ci} 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_cistatic inline struct lb_addr cpu_to_lelb(struct kernel_lb_addr in) 1962306a36Sopenharmony_ci{ 2062306a36Sopenharmony_ci struct lb_addr out; 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum); 2362306a36Sopenharmony_ci out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum); 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci return out; 2662306a36Sopenharmony_ci} 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_cistatic inline struct short_ad lesa_to_cpu(struct short_ad in) 2962306a36Sopenharmony_ci{ 3062306a36Sopenharmony_ci struct short_ad out; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci out.extLength = le32_to_cpu(in.extLength); 3362306a36Sopenharmony_ci out.extPosition = le32_to_cpu(in.extPosition); 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci return out; 3662306a36Sopenharmony_ci} 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_cistatic inline struct short_ad cpu_to_lesa(struct short_ad in) 3962306a36Sopenharmony_ci{ 4062306a36Sopenharmony_ci struct short_ad out; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci out.extLength = cpu_to_le32(in.extLength); 4362306a36Sopenharmony_ci out.extPosition = cpu_to_le32(in.extPosition); 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci return out; 4662306a36Sopenharmony_ci} 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_cistatic inline struct kernel_long_ad lela_to_cpu(struct long_ad in) 4962306a36Sopenharmony_ci{ 5062306a36Sopenharmony_ci struct kernel_long_ad out; 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci out.extLength = le32_to_cpu(in.extLength); 5362306a36Sopenharmony_ci out.extLocation = lelb_to_cpu(in.extLocation); 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci return out; 5662306a36Sopenharmony_ci} 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_cistatic inline struct long_ad cpu_to_lela(struct kernel_long_ad in) 5962306a36Sopenharmony_ci{ 6062306a36Sopenharmony_ci struct long_ad out; 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci out.extLength = cpu_to_le32(in.extLength); 6362306a36Sopenharmony_ci out.extLocation = cpu_to_lelb(in.extLocation); 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci return out; 6662306a36Sopenharmony_ci} 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_cistatic inline struct kernel_extent_ad leea_to_cpu(struct extent_ad in) 6962306a36Sopenharmony_ci{ 7062306a36Sopenharmony_ci struct kernel_extent_ad out; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci out.extLength = le32_to_cpu(in.extLength); 7362306a36Sopenharmony_ci out.extLocation = le32_to_cpu(in.extLocation); 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci return out; 7662306a36Sopenharmony_ci} 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci#endif /* __UDF_ENDIAN_H */ 79