Patchwork Shutdown serial port in pony_spi

login
register
about
Submitter Carl-Daniel Hailfinger
Date 2016-03-13 16:22:38
Message ID <56E593CE.209@gmx.net>
Download mbox | patch
Permalink /patch/4426/
State Accepted
Headers show

Comments

Carl-Daniel Hailfinger - 2016-03-13 16:22:38
Implement serial port shutdown both for regular termination and error
condition in pony_spi.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Carl-Daniel Hailfinger - 2016-03-13 16:24:58
On 13.03.2016 17:22, Carl-Daniel Hailfinger wrote:
> Implement serial port shutdown both for regular termination and error
> condition in pony_spi.
>
> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>

On IRC:
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>

and committed in r1952.

Regards,
Carl-Daniel

Patch

Index: flashrom-pony_close_fd/pony_spi.c
===================================================================
--- flashrom-pony_close_fd/pony_spi.c	(Revision 1946)
+++ flashrom-pony_close_fd/pony_spi.c	(Arbeitskopie)
@@ -103,6 +103,18 @@ 
 	.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 @@ 
 			free(arg);
 			return 1;
 		}
+		if (register_shutdown(pony_spi_shutdown, NULL) != 0) {
+			free(arg);
+			serialport_shutdown(NULL);
+			return 1;
+		}
 		have_device++;
 	}
 	free(arg);