[PATCH] hciattach: Big endian support for various TI chips.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The firmware files from TI and the loading of firmware are designed to
work on little endian machines. This patch adds support to load the
firmware on big endian hosts as well as on little endian hosts.
---
tools/hciattach_ti.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/hciattach_ti.c b/tools/hciattach_ti.c
index 8322b45..555fe5e 100644
--- a/tools/hciattach_ti.c
+++ b/tools/hciattach_ti.c
@@ -124,6 +124,8 @@ static FILE *bts_load_script(const char
*file_name, uint32_t *version)
         perror("can't read firmware file");
         goto errclose;
     }
+    header.magic = htobl(header.magic);
+    header.version = htobl(header.version);

     if (header.magic != FILE_HEADER_MAGIC) {
         fprintf(stderr, "%s not a legal TI firmware file\n", file_name);
@@ -153,6 +155,9 @@ static unsigned long bts_fetch_action(FILE *fp,
unsigned char *action_buf,
     if (1 != fread(&action_hdr, sizeof(struct bts_action), 1, fp))
         return 0;

+    action_hdr.type = htobs(action_hdr.type);
+    action_hdr.size = htobs(action_hdr.size);
+
     if (action_hdr.size > buf_size) {
         fprintf(stderr, "bts_next_action: not enough space to read
next action\n");
         return 0;
@@ -241,6 +246,7 @@ static int brf_send_command_socket(int fd, struct
bts_action_send *send_action)
 {
     char response[1024] = {0};
     hci_command_hdr *cmd = (hci_command_hdr *) send_action->data;
+    cmd->opcode = htobs(cmd->opcode);
     uint16_t opcode = cmd->opcode;

     struct hci_request rq;
@@ -331,10 +337,13 @@ static int brf_do_action(uint16_t brf_type,
uint8_t *brf_action, long brf_size,
         break;
     case ACTION_SERIAL:
         DPRINTF("S");
+        ((struct bts_action_serial *) brf_action)->baud =
htobl(((struct bts_action_serial *) brf_action)->baud);
+        ((struct bts_action_serial *) brf_action)->flow_control =
htobl(((struct bts_action_serial *) brf_action)->flow_control);
         ret = brf_set_serial_params((struct bts_action_serial *)
brf_action, fd, speed, ti);
         break;
     case ACTION_DELAY:
         DPRINTF("D");
+        ((struct bts_action_delay *) brf_action)->msec =
htobl(((struct bts_action_delay *) brf_action)->msec);
         brf_delay((struct bts_action_delay *) brf_action);
         break;
     case ACTION_REMARKS:
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux