smsendian.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /****************************************************************
  2. Siano Mobile Silicon, Inc.
  3. MDTV receiver kernel modules.
  4. Copyright (C) 2006-2009, Uri Shkolnik
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ****************************************************************/
  16. #include <linux/export.h>
  17. #include <asm/byteorder.h>
  18. #include "smsendian.h"
  19. #include "smscoreapi.h"
  20. void smsendian_handle_tx_message(void *buffer)
  21. {
  22. #ifdef __BIG_ENDIAN
  23. struct sms_msg_data *msg = (struct sms_msg_data *)buffer;
  24. int i;
  25. int msg_words;
  26. switch (msg->x_msg_header.msg_type) {
  27. case MSG_SMS_DATA_DOWNLOAD_REQ:
  28. {
  29. msg->msg_data[0] = le32_to_cpu((__force __le32)(msg->msg_data[0]));
  30. break;
  31. }
  32. default:
  33. msg_words = (msg->x_msg_header.msg_length -
  34. sizeof(struct sms_msg_hdr))/4;
  35. for (i = 0; i < msg_words; i++)
  36. msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
  37. break;
  38. }
  39. #endif /* __BIG_ENDIAN */
  40. }
  41. EXPORT_SYMBOL_GPL(smsendian_handle_tx_message);
  42. void smsendian_handle_rx_message(void *buffer)
  43. {
  44. #ifdef __BIG_ENDIAN
  45. struct sms_msg_data *msg = (struct sms_msg_data *)buffer;
  46. int i;
  47. int msg_words;
  48. switch (msg->x_msg_header.msg_type) {
  49. case MSG_SMS_GET_VERSION_EX_RES:
  50. {
  51. struct sms_version_res *ver =
  52. (struct sms_version_res *) msg;
  53. ver->chip_model = le16_to_cpu((__force __le16)ver->chip_model);
  54. break;
  55. }
  56. case MSG_SMS_DVBT_BDA_DATA:
  57. case MSG_SMS_DAB_CHANNEL:
  58. case MSG_SMS_DATA_MSG:
  59. {
  60. break;
  61. }
  62. default:
  63. {
  64. msg_words = (msg->x_msg_header.msg_length -
  65. sizeof(struct sms_msg_hdr))/4;
  66. for (i = 0; i < msg_words; i++)
  67. msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]);
  68. break;
  69. }
  70. }
  71. #endif /* __BIG_ENDIAN */
  72. }
  73. EXPORT_SYMBOL_GPL(smsendian_handle_rx_message);
  74. void smsendian_handle_message_header(void *msg)
  75. {
  76. #ifdef __BIG_ENDIAN
  77. struct sms_msg_hdr *phdr = (struct sms_msg_hdr *)msg;
  78. phdr->msg_type = le16_to_cpu((__force __le16)phdr->msg_type);
  79. phdr->msg_length = le16_to_cpu((__force __le16)phdr->msg_length);
  80. phdr->msg_flags = le16_to_cpu((__force __le16)phdr->msg_flags);
  81. #endif /* __BIG_ENDIAN */
  82. }
  83. EXPORT_SYMBOL_GPL(smsendian_handle_message_header);