diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index 829bcd77747af8a85e2f99ac8ca8891d4093b576..dd7c656bf506de2a7ca7455d6b6531e44ec41bf8 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.630 2007/08/19 14:57:04 chrfranke Exp $
+$Id: CHANGELOG,v 1.631 2007/09/06 08:48:55 ballen4705 Exp $
 
 The most recent version of this file is:
 http://smartmontools.cvs.sourceforge.net/smartmontools/sm5/CHANGELOG?view=markup
@@ -33,6 +33,23 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [BA] Fixed 3ware issue with new controllers.  Documentation said
+       that one could address up to 24 disks on a single controller,
+       but in fact one was limited to 16 disks.  This is now fixed:
+       up to 32 disks can be addressed.  Thanks to Adam Radford.
+
+       NOTE1: I have patched the Linux and FreeBSD code but not
+       modified the Win32 code. Christian, please remove this
+       note if no modification is needed.
+
+       NOTE2: NOT TESTED ON LINUX.  Do not use this on a production box!
+       I will remove this NOTE2 as soon as some positive test
+       reports are recieved.
+
+       NOTE3: NOT TESTED ON FREEBSD. Do not use this on a production box!
+       I will remove this NOTE3 as soon as some positive test
+       reports are recieved.
+
   [CF] Windows installer: Added explorer drive menu, CMD window,
        UBCD4Win plugin, smartd service update and other minor
        improvements.
diff --git a/sm5/os_freebsd.cpp b/sm5/os_freebsd.cpp
index 4747168bff2b30c12ab841c20d50215bc6886e9b..9640a6a1d303d5527ea72362a5cdefadc15b9575 100644
--- a/sm5/os_freebsd.cpp
+++ b/sm5/os_freebsd.cpp
@@ -40,9 +40,9 @@
 #include "extern.h"
 #include "os_freebsd.h"
 
-static const char *filenameandversion="$Id: os_freebsd.cpp,v 1.53 2007/04/10 17:48:18 shattered Exp $";
+static const char *filenameandversion="$Id: os_freebsd.cpp,v 1.54 2007/09/06 08:48:55 ballen4705 Exp $";
 
-const char *os_XXXX_c_cvsid="$Id: os_freebsd.cpp,v 1.53 2007/04/10 17:48:18 shattered Exp $" \
+const char *os_XXXX_c_cvsid="$Id: os_freebsd.cpp,v 1.54 2007/09/06 08:48:55 ballen4705 Exp $" \
 ATACMDS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_FREEBSD_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
 
 // to hold onto exit code for atexit routine
@@ -636,8 +636,7 @@ int escalade_command_interface(int fd, int disknum, int escalade_type, smart_com
 
   // Same for (almost) all commands - but some reset below
   ata->request_id    = 0xFF;
-  ata->unit   = disknum;
-  ata->host_id = 0;
+  ata->unit          = disknum;
   ata->status        = 0;           
   ata->flags         = 0x1;
   ata->drive_head    = 0x0;
diff --git a/sm5/os_freebsd.h b/sm5/os_freebsd.h
index da50231e20c577765d2a1d2dcafaa306e7d75894..1c4cdef5a5640379264c82db8c70977b59c6ff9f 100644
--- a/sm5/os_freebsd.h
+++ b/sm5/os_freebsd.h
@@ -82,7 +82,7 @@
 #ifndef OS_FREEBSD_H_
 #define OS_FREEBSD_H_
 
-#define OS_FREEBSD_H_CVSID "$Id: os_freebsd.h,v 1.20 2006/04/12 14:54:28 ballen4705 Exp $\n"
+#define OS_FREEBSD_H_CVSID "$Id: os_freebsd.h,v 1.21 2007/09/06 08:48:55 ballen4705 Exp $\n"
 
 struct freebsd_dev_channel {
   int   channel;                // the ATA channel to work with
@@ -234,8 +234,7 @@ typedef struct
     u_int8_t	sgl_offset:3;
     u_int8_t	size;
     u_int8_t	request_id;
-    u_int8_t	unit:4;
-    u_int8_t	host_id:4;
+    u_int8_t	unit;
     u_int8_t	status;
     u_int8_t	flags;
     u_int16_t	param;
diff --git a/sm5/os_linux.cpp b/sm5/os_linux.cpp
index 722d410531d9c1dfd6c6bdfa4eb11f7d397b6fb3..a0cf122b244e816ee3a852aadcfc4457de62a5eb 100644
--- a/sm5/os_linux.cpp
+++ b/sm5/os_linux.cpp
@@ -79,9 +79,9 @@ typedef unsigned long long u8;
 
 #define ARGUSED(x) ((void)(x))
 
-static const char *filenameandversion="$Id: os_linux.cpp,v 1.96 2007/05/31 18:02:32 ballen4705 Exp $";
+static const char *filenameandversion="$Id: os_linux.cpp,v 1.97 2007/09/06 08:48:55 ballen4705 Exp $";
 
-const char *os_XXXX_c_cvsid="$Id: os_linux.cpp,v 1.96 2007/05/31 18:02:32 ballen4705 Exp $" \
+const char *os_XXXX_c_cvsid="$Id: os_linux.cpp,v 1.97 2007/09/06 08:48:55 ballen4705 Exp $" \
 ATACMDS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_LINUX_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
 
 // to hold onto exit code for atexit routine
@@ -1087,8 +1087,7 @@ int escalade_command_interface(int fd, int disknum, int escalade_type, smart_com
   // Same for (almost) all commands - but some reset below
   passthru->byte0.opcode  = TW_OP_ATA_PASSTHRU;
   passthru->request_id    = 0xFF;
-  passthru->byte3.aport   = disknum;
-  passthru->byte3.host_id = 0;
+  passthru->unit          = disknum;
   passthru->status        = 0;
   passthru->flags         = 0x1;
   passthru->drive_head    = 0x0;
diff --git a/sm5/os_linux.h b/sm5/os_linux.h
index 7ef5cb16cb936b890b19eae1d9fc6ae576310584..6c1228d3d0f1428485d3f682160a271aa909b805 100644
--- a/sm5/os_linux.h
+++ b/sm5/os_linux.h
@@ -38,7 +38,7 @@
 #ifndef OS_LINUX_H_
 #define OS_LINUX_H_
 
-#define OS_LINUX_H_CVSID "$Id: os_linux.h,v 1.25 2006/08/25 06:06:25 sxzzsf Exp $\n"
+#define OS_LINUX_H_CVSID "$Id: os_linux.h,v 1.26 2007/09/06 08:48:55 ballen4705 Exp $\n"
 
 /* 
    The following definitions/macros/prototypes are used for three
@@ -76,10 +76,7 @@ typedef struct TAG_TW_Passthru {
   } byte0;
   unsigned char size;
   unsigned char request_id;
-  struct { 
-    unsigned char aport:4;
-    unsigned char host_id:4;
-  } byte3;
+  unsigned char unit;
   unsigned char status;  // On return, contains 3ware STATUS register
   unsigned char flags;
   unsigned short param;
diff --git a/sm5/smartctl.8.in b/sm5/smartctl.8.in
index 1eaa4f128d1cf4cfea8d729d2e6298be9796a725..61e7d1c0f9359e4513a3ca85c9000daff7c9b4f8 100644
--- a/sm5/smartctl.8.in
+++ b/sm5/smartctl.8.in
@@ -1,7 +1,7 @@
 .ig
  Copyright (C) 2002-7 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 
- $Id: smartctl.8.in,v 1.102 2007/07/28 13:17:38 chrfranke Exp $
+ $Id: smartctl.8.in,v 1.103 2007/09/06 08:48:55 ballen4705 Exp $
  
  This program is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by the Free
@@ -242,7 +242,7 @@ use syntax such as:
 .fi
 where in the argument \fI3ware,N\fP, the integer N is the disk number
 (3ware \'port\') within the 3ware ATA RAID controller.  The allowed
-values of N are from 0 to 23 inclusive.  The first two forms, which
+values of N are from 0 to 31 inclusive.  The first two forms, which
 refer to devices /dev/sda\-z and /dev/twe0\-15, may be used with 3ware
 series 6000, 7000, and 8000 series controllers that use the 3x\-xxxx
 driver.  \fBNote that the /dev/sda\-z form is deprecated\fP starting
@@ -1500,7 +1500,7 @@ these documents may be found in the References section of the
 
 .SH
 CVS ID OF THIS PAGE:
-$Id: smartctl.8.in,v 1.102 2007/07/28 13:17:38 chrfranke Exp $
+$Id: smartctl.8.in,v 1.103 2007/09/06 08:48:55 ballen4705 Exp $
 .\" Local Variables:	         
 .\" mode: nroff         
 .\" End:
diff --git a/sm5/smartctl.cpp b/sm5/smartctl.cpp
index d29d26c3ec2e89c4f5f2f0ab2f54d2fbeef56e46..687cdd281775857e98566720cf1d89a8846c6644 100644
--- a/sm5/smartctl.cpp
+++ b/sm5/smartctl.cpp
@@ -50,7 +50,7 @@
 extern const char *os_solaris_ata_s_cvsid;
 #endif
 extern const char *atacmdnames_c_cvsid, *atacmds_c_cvsid, *ataprint_c_cvsid, *knowndrives_c_cvsid, *os_XXXX_c_cvsid, *scsicmds_c_cvsid, *scsiprint_c_cvsid, *utility_c_cvsid;
-const char* smartctl_c_cvsid="$Id: smartctl.cpp,v 1.166 2007/07/26 20:58:50 chrfranke Exp $"
+const char* smartctl_c_cvsid="$Id: smartctl.cpp,v 1.167 2007/09/06 08:48:55 ballen4705 Exp $"
 ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID;
 
 // This is a block containing all the "control variables".  We declare
@@ -470,8 +470,8 @@ void ParseOpts (int argc, char** argv){
             if (split_report_arg2(s, &i)) {
                  sprintf(extraerror, "Option -d 3ware,N requires N to be a non-negative integer\n");
                  badarg = TRUE;
-            } else if (i<0 || i>23) {
-                 sprintf(extraerror, "Option -d 3ware,N (N=%d) must have 0 <= N <= 23\n", i);
+            } else if (i<0 || i>31) {
+                 sprintf(extraerror, "Option -d 3ware,N (N=%d) must have 0 <= N <= 31\n", i);
                  badarg = TRUE;
             } else {
  	        // NOTE: controller_port == disk number + 1
diff --git a/sm5/smartd.8.in b/sm5/smartd.8.in
index e4de9f07acf5342219048bb3f7237dce46aaf4c1..240420d65eb844aa0b4d8eabeca4b643c96cb24b 100644
--- a/sm5/smartd.8.in
+++ b/sm5/smartd.8.in
@@ -1,7 +1,7 @@
 .ig
 Copyright (C) 2002-7 Bruce Allen <smartmontools-support@lists.sourceforge.net>
  
-$Id: smartd.8.in,v 1.117 2007/07/28 13:17:38 chrfranke Exp $
+$Id: smartd.8.in,v 1.118 2007/09/06 08:48:55 ballen4705 Exp $
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -666,10 +666,10 @@ controllers (using the Marvell rather than libata driver).
 
 .I 3ware,N
 \- the device consists of one or more ATA disks connected to a 3ware
-RAID controller. The non-negative integer N (in the range from 0 to 23
+RAID controller. The non-negative integer N (in the range from 0 to 31
 inclusive) denotes which disk on the controller is monitored.  In log
 files and email messages this disk will be identified as 3ware_disk_XX
-with XX in the range from 00 to 23 inclusive.
+with XX in the range from 00 to 31 inclusive.
 
 This Directive may at first appear confusing, because the 3ware
 controller is a SCSI device (such as /dev/sda) and should be listed as
@@ -1951,4 +1951,4 @@ smartmontools home page at \fBhttp://smartmontools.sourceforge.net/#references\f
 
 .SH
 CVS ID OF THIS PAGE:
-$Id: smartd.8.in,v 1.117 2007/07/28 13:17:38 chrfranke Exp $
+$Id: smartd.8.in,v 1.118 2007/09/06 08:48:55 ballen4705 Exp $
diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp
index fee6b9031f1b29da57263b7875a1064463c2249f..dfe986c49d641b83e3b964d6bcbd40a13887807e 100644
--- a/sm5/smartd.cpp
+++ b/sm5/smartd.cpp
@@ -119,14 +119,14 @@ extern "C" int getdomainname(char *, int); // no declaration in header files!
 extern const char *atacmdnames_c_cvsid, *atacmds_c_cvsid, *ataprint_c_cvsid, *escalade_c_cvsid, 
                   *knowndrives_c_cvsid, *os_XXXX_c_cvsid, *scsicmds_c_cvsid, *utility_c_cvsid;
 
-static const char *filenameandversion="$Id: smartd.cpp,v 1.391 2007/07/09 01:57:31 ballen4705 Exp $";
+static const char *filenameandversion="$Id: smartd.cpp,v 1.392 2007/09/06 08:48:55 ballen4705 Exp $";
 #ifdef NEED_SOLARIS_ATA_CODE
 extern const char *os_solaris_ata_s_cvsid;
 #endif
 #ifdef _WIN32
 extern const char *daemon_win32_c_cvsid, *hostname_win32_c_cvsid, *syslog_win32_c_cvsid;
 #endif
-const char *smartd_c_cvsid="$Id: smartd.cpp,v 1.391 2007/07/09 01:57:31 ballen4705 Exp $" 
+const char *smartd_c_cvsid="$Id: smartd.cpp,v 1.392 2007/09/06 08:48:55 ballen4705 Exp $" 
 ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID
 #ifdef DAEMON_WIN32_H_CVSID
 DAEMON_WIN32_H_CVSID
@@ -3047,8 +3047,8 @@ int ParseToken(char *token,cfgfile *cfg){
               PrintOut(LOG_CRIT, "File %s line %d (drive %s): Directive -d 3ware,N requires N integer\n",
                	       configfile, lineno, name);
               badarg=1;
-          } else if ( i<0 || i>23) {
-              PrintOut(LOG_CRIT, "File %s line %d (drive %s): Directive -d 3ware,N (N=%d) must have 0 <= N <= 23\n",
+          } else if ( i<0 || i>31) {
+              PrintOut(LOG_CRIT, "File %s line %d (drive %s): Directive -d 3ware,N (N=%d) must have 0 <= N <= 31\n",
                        configfile, lineno, name, i);
               badarg=1;
           } else {