Implement serial port shutdown both for regular termination and error
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>
Sun, 13 Mar 2016 16:24:09 +0000 (16:24 +0000)
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>
Sun, 13 Mar 2016 16:24:09 +0000 (16:24 +0000)
condition in pony_spi.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
git-svn-id: svn://flashrom.org/flashrom/trunk@1952 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

pony_spi.c

index 8a0f340..f8faeb3 100644 (file)
@@ -103,6 +103,18 @@ static const struct bitbang_spi_master bitbang_spi_master_pony = {
        .half_period = 0,
 };
 
+static int pony_spi_shutdown(void *data)
+{
+       /* Shut down serial port communication */
+       int ret = serialport_shutdown(NULL);
+       if (ret)
+               msg_pdbg("Pony SPI shutdown failed.\n");
+       else
+               msg_pdbg("Pony SPI shutdown completed.\n");
+
+       return ret;
+}
+
 int pony_spi_init(void)
 {
        int i, data_out;
@@ -120,6 +132,11 @@ int pony_spi_init(void)
                        free(arg);
                        return 1;
                }
+               if (register_shutdown(pony_spi_shutdown, NULL) != 0) {
+                       free(arg);
+                       serialport_shutdown(NULL);
+                       return 1;
+               }
                have_device++;
        }
        free(arg);