update files to correct FSF address
[fw/openocd] / src / jtag / drivers / sysfsgpio.c
index 05d9a9dc0a248e3a17af34adba45dc394d1721d9..799141c6ce38705447418e78b9a9342b6a32e5ee 100644 (file)
@@ -14,7 +14,7 @@
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
  ***************************************************************************/
 /**
  * @file
@@ -199,6 +199,7 @@ static void sysfsgpio_write(int tck, int tms, int tdi)
        static int last_tdi;
 
        static int first_time;
+       size_t bytes_written;
 
        if (!first_time) {
                last_tck = !tck;
@@ -207,13 +208,24 @@ static void sysfsgpio_write(int tck, int tms, int tdi)
                first_time = 1;
        }
 
-       if (tdi != last_tdi)
-               write(tdi_fd, tdi ? &one : &zero, 1);
-       if (tms != last_tms)
-               write(tms_fd, tms ? &one : &zero, 1);
+       if (tdi != last_tdi) {
+               bytes_written = write(tdi_fd, tdi ? &one : &zero, 1);
+               if (bytes_written != 1)
+                       LOG_WARNING("writing tdi failed");
+       }
+
+       if (tms != last_tms) {
+               bytes_written = write(tms_fd, tms ? &one : &zero, 1);
+               if (bytes_written != 1)
+                       LOG_WARNING("writing tms failed");
+       }
+
        /* write clk last */
-       if (tck != last_tck)
-               write(tck_fd, tck ? &one : &zero, 1);
+       if (tck != last_tck) {
+               bytes_written = write(tck_fd, tck ? &one : &zero, 1);
+               if (bytes_written != 1)
+                       LOG_WARNING("writing tck failed");
+       }
 
        last_tdi = tdi;
        last_tms = tms;
@@ -229,36 +241,21 @@ static void sysfsgpio_reset(int trst, int srst)
 {
        const char one[] = "1";
        const char zero[] = "0";
+       size_t bytes_written;
 
        /* assume active low */
-       if (srst_fd >= 0)
-               write(srst_fd, srst ? &zero : &one, 1);
+       if (srst_fd >= 0) {
+               bytes_written = write(srst_fd, srst ? &zero : &one, 1);
+               if (bytes_written != 1)
+                       LOG_WARNING("writing srst failed");
+       }
 
        /* assume active low */
-       if (trst_fd >= 0)
-               write(trst_fd, trst ? &zero : &one, 1);
-}
-
-/* No speed control is implemented yet */
-static int sysfsgpio_speed(int speed)
-{
-       return ERROR_OK;
-}
-
-static int sysfsgpio_khz(int khz, int *jtag_speed)
-{
-       /* no adaptive clocking */
-       if (khz == 0)
-               return ERROR_FAIL;
-
-       *jtag_speed = 0;
-       return ERROR_OK;
-}
-
-static int sysfsgpio_speed_div(int speed, int *khz)
-{
-       *khz = 1;
-       return ERROR_OK;
+       if (trst_fd >= 0) {
+               bytes_written = write(trst_fd, trst ? &zero : &one, 1);
+               if (bytes_written != 1)
+                       LOG_WARNING("writing trst failed");
+       }
 }
 
 /* gpio numbers for each gpio. Negative values are invalid */
@@ -396,9 +393,6 @@ struct jtag_interface sysfsgpio_interface = {
        .supported = DEBUG_CAP_TMS_SEQ,
        .execute_queue = bitbang_execute_queue,
        .transports = jtag_only,
-       .speed = sysfsgpio_speed,
-       .khz = sysfsgpio_khz,
-       .speed_div = sysfsgpio_speed_div,
        .commands = sysfsgpio_command_handlers,
        .init = sysfsgpio_init,
        .quit = sysfsgpio_quit,
@@ -481,14 +475,18 @@ static int sysfsgpio_init(void)
                goto out_error;
 
        /* assume active low*/
-       trst_fd = setup_sysfs_gpio(trst_gpio, 1, 1);
-       if (trst_gpio > 0 && trst_fd < 0)
-               goto out_error;
+       if (trst_gpio > 0) {
+               trst_fd = setup_sysfs_gpio(trst_gpio, 1, 1);
+               if (trst_fd < 0)
+                       goto out_error;
+       }
 
        /* assume active low*/
-       srst_fd = setup_sysfs_gpio(srst_gpio, 1, 1);
-       if (srst_gpio > 0 && srst_fd < 0)
-               goto out_error;
+       if (srst_gpio > 0) {
+               srst_fd = setup_sysfs_gpio(srst_gpio, 1, 1);
+               if (srst_fd < 0)
+                       goto out_error;
+       }
 
        return ERROR_OK;