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 17 void smsendian_handle_tx_message(void *buffer) 18 { 19 #ifdef __BIG_ENDIAN 20 struct sms_msg_data *msg = (struct sms_msg_data *)buffer; 21 int i; 22 int msg_words; 23 24 switch (msg->x_msg_header.msg_type) { 25 case MSG_SMS_DATA_DOWNLOAD_REQ: 26 { 27 msg->msg_data[0] = le32_to_cpu((__force __le32)(msg->msg_data[0])); 28 break; 29 } 30 31 default: 32 msg_words = (msg->x_msg_header.msg_length - 33 sizeof(struct sms_msg_hdr))/4; 34 35 for (i = 0; i < msg_words; i++) 36 msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]); 37 38 break; 39 } 40 #endif /* __BIG_ENDIAN */ 41 } 42 EXPORT_SYMBOL_GPL(smsendian_handle_tx_message); 43 44 void smsendian_handle_rx_message(void *buffer) 45 { 46 #ifdef __BIG_ENDIAN 47 struct sms_msg_data *msg = (struct sms_msg_data *)buffer; 48 int i; 49 int msg_words; 50 51 switch (msg->x_msg_header.msg_type) { 52 case MSG_SMS_GET_VERSION_EX_RES: 53 { 54 struct sms_version_res *ver = 55 (struct sms_version_res *) msg; 56 ver->chip_model = le16_to_cpu((__force __le16)ver->chip_model); 57 break; 58 } 59 60 case MSG_SMS_DVBT_BDA_DATA: 61 case MSG_SMS_DAB_CHANNEL: 62 case MSG_SMS_DATA_MSG: 63 { 64 break; 65 } 66 67 default: 68 { 69 msg_words = (msg->x_msg_header.msg_length - 70 sizeof(struct sms_msg_hdr))/4; 71 72 for (i = 0; i < msg_words; i++) 73 msg->msg_data[i] = le32_to_cpu((__force __le32)msg->msg_data[i]); 74 75 break; 76 } 77 } 78 #endif /* __BIG_ENDIAN */ 79 } 80 EXPORT_SYMBOL_GPL(smsendian_handle_rx_message); 81 82 void smsendian_handle_message_header(void *msg) 83 { 84 #ifdef __BIG_ENDIAN 85 struct sms_msg_hdr *phdr = (struct sms_msg_hdr *)msg; 86 87 phdr->msg_type = le16_to_cpu((__force __le16)phdr->msg_type); 88 phdr->msg_length = le16_to_cpu((__force __le16)phdr->msg_length); 89 phdr->msg_flags = le16_to_cpu((__force __le16)phdr->msg_flags); 90 #endif /* __BIG_ENDIAN */ 91 } 92 EXPORT_SYMBOL_GPL(smsendian_handle_message_header); 93