Merge tag 'v3.3.7' into 3.3/master
[zen-stable.git] / drivers / media / dvb / siano / smsendian.c
blobe2657c2f0109afc8b5a47524f0aec617a5984f85
1 /****************************************************************
3 Siano Mobile Silicon, Inc.
4 MDTV receiver kernel modules.
5 Copyright (C) 2006-2009, Uri Shkolnik
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ****************************************************************/
22 #include <linux/export.h>
23 #include <asm/byteorder.h>
25 #include "smsendian.h"
26 #include "smscoreapi.h"
28 void smsendian_handle_tx_message(void *buffer)
30 #ifdef __BIG_ENDIAN
31 struct SmsMsgData_ST *msg = (struct SmsMsgData_ST *)buffer;
32 int i;
33 int msgWords;
35 switch (msg->xMsgHeader.msgType) {
36 case MSG_SMS_DATA_DOWNLOAD_REQ:
38 msg->msgData[0] = le32_to_cpu(msg->msgData[0]);
39 break;
42 default:
43 msgWords = (msg->xMsgHeader.msgLength -
44 sizeof(struct SmsMsgHdr_ST))/4;
46 for (i = 0; i < msgWords; i++)
47 msg->msgData[i] = le32_to_cpu(msg->msgData[i]);
49 break;
51 #endif /* __BIG_ENDIAN */
53 EXPORT_SYMBOL_GPL(smsendian_handle_tx_message);
55 void smsendian_handle_rx_message(void *buffer)
57 #ifdef __BIG_ENDIAN
58 struct SmsMsgData_ST *msg = (struct SmsMsgData_ST *)buffer;
59 int i;
60 int msgWords;
62 switch (msg->xMsgHeader.msgType) {
63 case MSG_SMS_GET_VERSION_EX_RES:
65 struct SmsVersionRes_ST *ver =
66 (struct SmsVersionRes_ST *) msg;
67 ver->ChipModel = le16_to_cpu(ver->ChipModel);
68 break;
71 case MSG_SMS_DVBT_BDA_DATA:
72 case MSG_SMS_DAB_CHANNEL:
73 case MSG_SMS_DATA_MSG:
75 break;
78 default:
80 msgWords = (msg->xMsgHeader.msgLength -
81 sizeof(struct SmsMsgHdr_ST))/4;
83 for (i = 0; i < msgWords; i++)
84 msg->msgData[i] = le32_to_cpu(msg->msgData[i]);
86 break;
89 #endif /* __BIG_ENDIAN */
91 EXPORT_SYMBOL_GPL(smsendian_handle_rx_message);
93 void smsendian_handle_message_header(void *msg)
95 #ifdef __BIG_ENDIAN
96 struct SmsMsgHdr_ST *phdr = (struct SmsMsgHdr_ST *)msg;
98 phdr->msgType = le16_to_cpu(phdr->msgType);
99 phdr->msgLength = le16_to_cpu(phdr->msgLength);
100 phdr->msgFlags = le16_to_cpu(phdr->msgFlags);
101 #endif /* __BIG_ENDIAN */
103 EXPORT_SYMBOL_GPL(smsendian_handle_message_header);