udfend.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef __UDF_ENDIAN_H
  2. #define __UDF_ENDIAN_H
  3. #include <asm/byteorder.h>
  4. #include <linux/string.h>
  5. static inline struct kernel_lb_addr lelb_to_cpu(struct lb_addr in)
  6. {
  7. struct kernel_lb_addr out;
  8. out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum);
  9. out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum);
  10. return out;
  11. }
  12. static inline struct lb_addr cpu_to_lelb(struct kernel_lb_addr in)
  13. {
  14. struct lb_addr out;
  15. out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum);
  16. out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum);
  17. return out;
  18. }
  19. static inline struct short_ad lesa_to_cpu(struct short_ad in)
  20. {
  21. struct short_ad out;
  22. out.extLength = le32_to_cpu(in.extLength);
  23. out.extPosition = le32_to_cpu(in.extPosition);
  24. return out;
  25. }
  26. static inline struct short_ad cpu_to_lesa(struct short_ad in)
  27. {
  28. struct short_ad out;
  29. out.extLength = cpu_to_le32(in.extLength);
  30. out.extPosition = cpu_to_le32(in.extPosition);
  31. return out;
  32. }
  33. static inline struct kernel_long_ad lela_to_cpu(struct long_ad in)
  34. {
  35. struct kernel_long_ad out;
  36. out.extLength = le32_to_cpu(in.extLength);
  37. out.extLocation = lelb_to_cpu(in.extLocation);
  38. return out;
  39. }
  40. static inline struct long_ad cpu_to_lela(struct kernel_long_ad in)
  41. {
  42. struct long_ad out;
  43. out.extLength = cpu_to_le32(in.extLength);
  44. out.extLocation = cpu_to_lelb(in.extLocation);
  45. return out;
  46. }
  47. static inline struct kernel_extent_ad leea_to_cpu(struct extent_ad in)
  48. {
  49. struct kernel_extent_ad out;
  50. out.extLength = le32_to_cpu(in.extLength);
  51. out.extLocation = le32_to_cpu(in.extLocation);
  52. return out;
  53. }
  54. #endif /* __UDF_ENDIAN_H */