1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /**************************************************************** 3 4 Siano Mobile Silicon, Inc. 5 MDTV receiver kernel modules. 6 Copyright (C) 2006-2009, Uri Shkolnik 7 8 9 ****************************************************************/ 10 11 #include <linux/export.h> 12 #include <asm/byteorder.h> 13 14 #include "smsendian.h" 15 #include "smscoreapi.h" 16 smsendian_handle_tx_message(void * buffer)17void smsendian_handle_tx_message(void *buffer) 18 { 19 #ifdef __BIG_ENDIAN 20 struct sms_msg_data *msg = buffer; 21 int i; 22 int msg_words; 23 u32 *msg_data = &msg->msg_data; 24 25 switch (msg->x_msg_header.msg_type) { 26 case MSG_SMS_DATA_DOWNLOAD_REQ: 27 { 28 msg->msg_data = le32_to_cpu((__force __le32)(msg->msg_data)); 29 break; 30 } 31 32 default: 33 msg_words = (msg->x_msg_header.msg_length - 34 sizeof(struct sms_msg_hdr))/4; 35 36 for (i = 0; i < msg_words; i++) 37 msg_data[i] = le32_to_cpu((__force __le32)msg_data[i]); 38 39 break; 40 } 41 #endif /* __BIG_ENDIAN */ 42 } 43 EXPORT_SYMBOL_GPL(smsendian_handle_tx_message); 44 smsendian_handle_rx_message(void * buffer)45void smsendian_handle_rx_message(void *buffer) 46 { 47 #ifdef __BIG_ENDIAN 48 struct sms_msg_data *msg = (struct sms_msg_data *)buffer; 49 int i; 50 int msg_words; 51 52 switch (msg->x_msg_header.msg_type) { 53 case MSG_SMS_GET_VERSION_EX_RES: 54 { 55 struct sms_version_res *ver = 56 (struct sms_version_res *) msg; 57 ver->chip_model = le16_to_cpu((__force __le16)ver->chip_model); 58 break; 59 } 60 61 case MSG_SMS_DVBT_BDA_DATA: 62 case MSG_SMS_DAB_CHANNEL: 63 case MSG_SMS_DATA_MSG: 64 { 65 break; 66 } 67 68 default: 69 { 70 u32 *msg_data = &msg->msg_data; 71 msg_words = (msg->x_msg_header.msg_length - 72 sizeof(struct sms_msg_hdr))/4; 73 74 for (i = 0; i < msg_words; i++) 75 msg_data[i] = le32_to_cpu((__force __le32)msg_data[i]); 76 77 break; 78 } 79 } 80 #endif /* __BIG_ENDIAN */ 81 } 82 EXPORT_SYMBOL_GPL(smsendian_handle_rx_message); 83 smsendian_handle_message_header(void * msg)84void smsendian_handle_message_header(void *msg) 85 { 86 #ifdef __BIG_ENDIAN 87 struct sms_msg_hdr *phdr = (struct sms_msg_hdr *)msg; 88 89 phdr->msg_type = le16_to_cpu((__force __le16)phdr->msg_type); 90 phdr->msg_length = le16_to_cpu((__force __le16)phdr->msg_length); 91 phdr->msg_flags = le16_to_cpu((__force __le16)phdr->msg_flags); 92 #endif /* __BIG_ENDIAN */ 93 } 94 EXPORT_SYMBOL_GPL(smsendian_handle_message_header); 95