diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index c7b2d1f2aec5755aa8a50f0ee5d705e933488bd1..6bbee85680d71d9130c7da9d751b0b26711cf9e8 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.810 2009/06/21 20:08:22 dpgilbert Exp $
+$Id: CHANGELOG,v 1.811 2009/06/24 04:10:10 dpgilbert Exp $
 
 The most recent version of this file is:
 http://smartmontools.cvs.sourceforge.net/smartmontools/sm5/CHANGELOG?view=markup
@@ -41,6 +41,9 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [DG] SCSI (SAS): implement '-l sasphy,reset' (reset part was stub
+       prior to this)
+
   [DG] add 'ATA, SCSI command sets and SAT' section to smartctl.8 .
        [SCSI] add 'number of background medium scans' field
 
diff --git a/sm5/scsicmds.cpp b/sm5/scsicmds.cpp
index 5ec946bb42fb46c5c776faeccdc48943bc72afd9..ff006c6a52cdba809cf4e64ec47348e8585f70be 100644
--- a/sm5/scsicmds.cpp
+++ b/sm5/scsicmds.cpp
@@ -49,7 +49,7 @@
 #include "dev_interface.h"
 #include "utility.h"
 
-const char *scsicmds_c_cvsid="$Id: scsicmds.cpp,v 1.97 2008/07/25 21:16:00 chrfranke Exp $"
+const char *scsicmds_c_cvsid="$Id: scsicmds.cpp,v 1.98 2009/06/24 04:10:10 dpgilbert Exp $"
 CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
 
 /* for passing global control variables */
@@ -123,6 +123,7 @@ static struct scsi_opcode_name opcode_name_arr[] = {
     {RECEIVE_DIAGNOSTIC, "receive diagnostic"}, /* 0x1c */
     {SEND_DIAGNOSTIC, "send diagnostic"},       /* 0x1d */
     {READ_DEFECT_10, "read defect list(10)"},   /* 0x37 */
+    {LOG_SELECT, "log select"},                 /* 0x4c */
     {LOG_SENSE, "log sense"},                   /* 0x4d */
     {MODE_SELECT_10, "mode select(10)"},        /* 0x55 */
     {MODE_SENSE_10, "mode sense(10)"},          /* 0x5a */
@@ -338,6 +339,42 @@ int scsiLogSense(scsi_device * device, int pagenum, int subpagenum, UINT8 *pBuf,
     return 0;
 }
 
+/* Sends a LOG SELECT command. Can be used to set log page values
+ * or reset one log page (or all of them) to its defaults (typically zero).
+ * Returns 0 if ok, 1 if NOT READY, 2 if command not supported, * 3 if
+ * field in command not supported, * 4 if bad parameter to command or
+ * returns negated errno. SPC-4 sections 6.5 and 7.2 (rev 20) */
+int scsiLogSelect(scsi_device * device, int pcr, int sp, int pc, int pagenum,
+                  int subpagenum, UINT8 *pBuf, int bufLen)
+{
+    struct scsi_cmnd_io io_hdr;
+    struct scsi_sense_disect sinfo;
+    UINT8 cdb[10];
+    UINT8 sense[32];
+
+    memset(&io_hdr, 0, sizeof(io_hdr));
+    memset(cdb, 0, sizeof(cdb));
+    io_hdr.dxfer_dir = DXFER_TO_DEVICE;
+    io_hdr.dxfer_len = bufLen;
+    io_hdr.dxferp = pBuf;
+    cdb[0] = LOG_SELECT;
+    cdb[1] = (pcr ? 2 : 0) | (sp ? 1 : 0);
+    cdb[2] = ((pc << 6) & 0xc0) | (pagenum & 0x3f);
+    cdb[3] = (subpagenum & 0xff);
+    cdb[7] = ((bufLen >> 8) & 0xff);
+    cdb[8] = (bufLen & 0xff);
+    io_hdr.cmnd = cdb;
+    io_hdr.cmnd_len = sizeof(cdb);
+    io_hdr.sensep = sense;
+    io_hdr.max_sense_len = sizeof(sense);
+    io_hdr.timeout = SCSI_TIMEOUT_DEFAULT;
+
+    if (!device->scsi_pass_through(&io_hdr))
+      return -device->get_errno();
+    scsi_do_sense_disect(&io_hdr, &sinfo);
+    return scsiSimpleSenseFilter(&sinfo);
+}
+
 /* Send MODE SENSE (6 byte) command. Returns 0 if ok, 1 if NOT READY,
  * 2 if command not supported (then MODE SENSE(10) should be supported),
  * 3 if field in command not supported or returns negated errno. 
diff --git a/sm5/scsicmds.h b/sm5/scsicmds.h
index 76d347d0507148230fc26c2e134977357c936679..8a7211443d60c60b5063300ad85641222e7e2925 100644
--- a/sm5/scsicmds.h
+++ b/sm5/scsicmds.h
@@ -32,7 +32,7 @@
 #ifndef SCSICMDS_H_
 #define SCSICMDS_H_
 
-#define SCSICMDS_H_CVSID "$Id: scsicmds.h,v 1.68 2009/06/21 02:39:32 dpgilbert Exp $\n"
+#define SCSICMDS_H_CVSID "$Id: scsicmds.h,v 1.69 2009/06/24 04:10:10 dpgilbert Exp $\n"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -41,11 +41,14 @@
 
 /* #define SCSI_DEBUG 1 */ /* Comment out to disable command debugging */
 
-/* Following conditional defines bypass inclusion of scsi/scsi.h and
- * scsi/scsi_ioctl.h . Issue will be resolved later ... */
+/* Following conditional defines just in case OS already has them defined.
+ * If they are defined we hope they are defined correctly (for SCSI). */
 #ifndef TEST_UNIT_READY
 #define TEST_UNIT_READY 0x0
 #endif
+#ifndef LOG_SELECT
+#define LOG_SELECT 0x4c
+#endif
 #ifndef LOG_SENSE
 #define LOG_SENSE 0x4d
 #endif
@@ -295,7 +298,10 @@ int scsiStdInquiry(scsi_device * device, UINT8 *pBuf, int bufLen);
 int scsiInquiryVpd(scsi_device * device, int vpd_page, UINT8 *pBuf, int bufLen);
 
 int scsiLogSense(scsi_device * device, int pagenum, int subpagenum, UINT8 *pBuf,
-		 int bufLen, int known_resp_len);
+                 int bufLen, int known_resp_len);
+
+int scsiLogSelect(scsi_device * device, int pcr, int sp, int pc, int pagenum,
+                  int subpagenum, UINT8 *pBuf, int bufLen);
 
 int scsiModeSense(scsi_device * device, int pagenum, int subpagenum, int pc,
                   UINT8 *pBuf, int bufLen);
@@ -303,7 +309,7 @@ int scsiModeSense(scsi_device * device, int pagenum, int subpagenum, int pc,
 int scsiModeSelect(scsi_device * device, int sp, UINT8 *pBuf, int bufLen);
 
 int scsiModeSense10(scsi_device * device, int pagenum, int subpagenum, int pc,
-		    UINT8 *pBuf, int bufLen);
+                    UINT8 *pBuf, int bufLen);
 
 int scsiModeSelect10(scsi_device * device, int sp, UINT8 *pBuf, int bufLen);
 
diff --git a/sm5/scsiprint.cpp b/sm5/scsiprint.cpp
index 6b4e569ad77828eb2ddb772d065b0a9e170343c3..396fe7b5fa6693b28a6f8c54fddf93de48b83e89 100644
--- a/sm5/scsiprint.cpp
+++ b/sm5/scsiprint.cpp
@@ -44,7 +44,7 @@
 
 #define GBUF_SIZE 65535
 
-const char* scsiprint_c_cvsid="$Id: scsiprint.cpp,v 1.129 2009/06/21 20:08:22 dpgilbert Exp $"
+const char* scsiprint_c_cvsid="$Id: scsiprint.cpp,v 1.130 2009/06/24 04:10:10 dpgilbert Exp $"
 CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID;
 
 // control block which points to external global control variables
@@ -913,7 +913,7 @@ static int scsiPrintBackgroundResults(scsi_device * device)
                  (ucp[10] << 8) + ucp[11]);
             pout("scan progress: %.2f%%\n",
                  (double)((ucp[12] << 8) + ucp[13]) * 100.0 / 65536.0);
-            pout("    Number of background medium scans performed: %d,  ",
+            pout("    Number of background medium scans performed: %d\n",
                  (ucp[14] << 8) + ucp[15]);
             break;
         default:
@@ -1250,7 +1250,7 @@ static int scsiPrintSasPhy(scsi_device * device, int reset)
     if ((err = scsiLogSense(device, PROTOCOL_SPECIFIC_LPAGE, 0, gBuf,
                             LOG_RESP_LONG_LEN, 0))) {
         PRINT_ON(con);
-        pout("scsiPrintSasPhy Failed [%s]\n", scsiErrString(err));
+        pout("scsiPrintSasPhy Log Sense Failed [%s]\n", scsiErrString(err));
         PRINT_OFF(con);
         return FAILSMART;
     }
@@ -1269,10 +1269,14 @@ static int scsiPrintSasPhy(scsi_device * device, int reset)
         return FAILSMART;
     }
     if (reset) {
-        PRINT_ON(con);
-        pout("sasphy_reset not supported yet (need LOG SELECT)\n");
-        PRINT_OFF(con);
-        return FAILSMART;
+        if ((err = scsiLogSelect(device, 1 /* pcr */, 0 /* sp */, 0 /* pc */,
+                                 PROTOCOL_SPECIFIC_LPAGE, 0, NULL, 0))) {
+            PRINT_ON(con);
+            pout("scsiPrintSasPhy Log Select (reset) Failed [%s]\n",
+                 scsiErrString(err));
+            PRINT_OFF(con);
+            return FAILSMART;
+        }
     }
     return 0;
 }
diff --git a/sm5/smartctl.8.in b/sm5/smartctl.8.in
index 4700da0f74f9ff0cb606222d62eec5ae0bbc7517..f077403368697d0f01e8f8d1953c2dccb8b2264c 100644
--- a/sm5/smartctl.8.in
+++ b/sm5/smartctl.8.in
@@ -1,7 +1,7 @@
 .ig
  Copyright (C) 2002-9 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 
- $Id: smartctl.8.in,v 1.129 2009/06/21 20:08:22 dpgilbert Exp $
+ $Id: smartctl.8.in,v 1.130 2009/06/24 04:10:10 dpgilbert 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
@@ -955,7 +955,7 @@ are reset after reading the values.
 \- [SAS (SCSI) only] [NEW EXPERIMENTAL SMARTCTL FEATURE] prints values
 and descriptions of the SAS (SSP) Protocol Specific log page (log page
 0x18). If \'\-l sasphy,reset\' is specified, all counters
-are reset after reading the values (not yet implemented).
+are reset after reading the values.
 
 .I gplog,ADDR[,FIRST[\-LAST|+SIZE]]
 \- [ATA only] [NEW EXPERIMENTAL SMARTCTL FEATURE] prints a hex dump
@@ -1739,7 +1739,7 @@ these documents may be found in the References section of the
 
 .SH
 CVS ID OF THIS PAGE:
-$Id: smartctl.8.in,v 1.129 2009/06/21 20:08:22 dpgilbert Exp $
+$Id: smartctl.8.in,v 1.130 2009/06/24 04:10:10 dpgilbert Exp $
 .\" Local Variables:	         
 .\" mode: nroff         
 .\" End: