From 7478d08891b4225e56d7e0035cd78fc41b127a8e Mon Sep 17 00:00:00 2001
From: Andy <andy@bodgesoc.org>
Date: Wed, 30 Jan 2013 08:00:21 +0000
Subject: [PATCH] Avoid a bug with old smart-serial firmware versions.

Signed-off-by: Andy <andy@bodgesoc.org>
---
 src/hal/drivers/mesa-hostmot2/hostmot2.c |    2 +-
 src/hal/drivers/mesa-hostmot2/sserial.c  |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2.c b/src/hal/drivers/mesa-hostmot2/hostmot2.c
index cd50ef3..2c9708d 100644
--- a/src/hal/drivers/mesa-hostmot2/hostmot2.c
+++ b/src/hal/drivers/mesa-hostmot2/hostmot2.c
@@ -56,7 +56,7 @@ RTAPI_MP_INT(debug_modules, "Developer/debug use only!  Enable debug logging of
 int use_serial_numbers = 0;
 RTAPI_MP_INT(use_serial_numbers, "Name cards by serial number, not enumeration order (smart-serial only)");
 
-int sserial_baudrate = 2500000;
+int sserial_baudrate = -1;
 RTAPI_MP_INT(sserial_baudrate, "Over-ride the standard smart-serial baud rate. For flashing remote firmware only.");
 
 
diff --git a/src/hal/drivers/mesa-hostmot2/sserial.c b/src/hal/drivers/mesa-hostmot2/sserial.c
index b19919e..214a26a 100644
--- a/src/hal/drivers/mesa-hostmot2/sserial.c
+++ b/src/hal/drivers/mesa-hostmot2/sserial.c
@@ -1634,6 +1634,12 @@ int check_set_baudrate(hostmot2_t *hm2, hm2_sserial_instance_t *inst){
     u32 buff;
     int c;
     
+    if (hm2->sserial.baudrate < 0){ return 0;}
+    if (hm2->sserial.version < 34) {
+    HM2_ERR("Setting baudrate is not supported in the current firmware version\n"
+    "Version must be > v33 and you have version %i.", hm2->sserial.version);
+    return -1;
+    }
     lbpstride = getlocal8(hm2, inst, SSLBPCHANNELSTRIDELOC);
     HM2_PRINT("num_channels = %i\n", inst->num_channels);
     for (c = 0; c < inst->num_channels; c++){
-- 
1.7.0.4

