18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __UDF_ENDIAN_H 38c2ecf20Sopenharmony_ci#define __UDF_ENDIAN_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <asm/byteorder.h> 68c2ecf20Sopenharmony_ci#include <linux/string.h> 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_cistatic inline struct kernel_lb_addr lelb_to_cpu(struct lb_addr in) 98c2ecf20Sopenharmony_ci{ 108c2ecf20Sopenharmony_ci struct kernel_lb_addr out; 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum); 138c2ecf20Sopenharmony_ci out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum); 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci return out; 168c2ecf20Sopenharmony_ci} 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistatic inline struct lb_addr cpu_to_lelb(struct kernel_lb_addr in) 198c2ecf20Sopenharmony_ci{ 208c2ecf20Sopenharmony_ci struct lb_addr out; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum); 238c2ecf20Sopenharmony_ci out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum); 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci return out; 268c2ecf20Sopenharmony_ci} 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistatic inline struct short_ad lesa_to_cpu(struct short_ad in) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci struct short_ad out; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci out.extLength = le32_to_cpu(in.extLength); 338c2ecf20Sopenharmony_ci out.extPosition = le32_to_cpu(in.extPosition); 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci return out; 368c2ecf20Sopenharmony_ci} 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_cistatic inline struct short_ad cpu_to_lesa(struct short_ad in) 398c2ecf20Sopenharmony_ci{ 408c2ecf20Sopenharmony_ci struct short_ad out; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci out.extLength = cpu_to_le32(in.extLength); 438c2ecf20Sopenharmony_ci out.extPosition = cpu_to_le32(in.extPosition); 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci return out; 468c2ecf20Sopenharmony_ci} 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic inline struct kernel_long_ad lela_to_cpu(struct long_ad in) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci struct kernel_long_ad out; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci out.extLength = le32_to_cpu(in.extLength); 538c2ecf20Sopenharmony_ci out.extLocation = lelb_to_cpu(in.extLocation); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci return out; 568c2ecf20Sopenharmony_ci} 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistatic inline struct long_ad cpu_to_lela(struct kernel_long_ad in) 598c2ecf20Sopenharmony_ci{ 608c2ecf20Sopenharmony_ci struct long_ad out; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci out.extLength = cpu_to_le32(in.extLength); 638c2ecf20Sopenharmony_ci out.extLocation = cpu_to_lelb(in.extLocation); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci return out; 668c2ecf20Sopenharmony_ci} 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistatic inline struct kernel_extent_ad leea_to_cpu(struct extent_ad in) 698c2ecf20Sopenharmony_ci{ 708c2ecf20Sopenharmony_ci struct kernel_extent_ad out; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci out.extLength = le32_to_cpu(in.extLength); 738c2ecf20Sopenharmony_ci out.extLocation = le32_to_cpu(in.extLocation); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci return out; 768c2ecf20Sopenharmony_ci} 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#endif /* __UDF_ENDIAN_H */ 79