diff --git a/buspirate_spi.c b/buspirate_spi.c
index 92d7fb40ee4a12ad4b464bb9c8524836f120ddbf..55d4133bbe6f6072342595844734caf927679146 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -40,7 +40,7 @@ static int buspirate_serialport_setup(char *dev)
 {
 	/* 115200bps, 8 databits, no parity, 1 stopbit */
 	sp_fd = sp_openserport(dev, 115200);
- 	if (sp_fd < 0)
+ 	if (sp_fd == SER_INV_FD)
 		return 1;
 	return 0;
 }
diff --git a/pony_spi.c b/pony_spi.c
index 7875200de17bc0cdfe059ee5d577400d29245471..101751f2fc4783dbf0337b2fb80518d861bce0bf 100644
--- a/pony_spi.c
+++ b/pony_spi.c
@@ -116,7 +116,7 @@ int pony_spi_init(void)
 	arg = extract_programmer_param("dev");
 	if (arg && strlen(arg)) {
 		sp_fd = sp_openserport(arg, 9600);
-		if (sp_fd < 0) {
+		if (sp_fd == SER_INV_FD) {
 			free(arg);
 			return 1;
 		}
diff --git a/serprog.c b/serprog.c
index edc5a7b3ec896886403f7f08677b000f462c563f..98c839e08d741f8a0563609e63ab963d62fcc563 100644
--- a/serprog.c
+++ b/serprog.c
@@ -372,7 +372,7 @@ int serprog_init(void)
 		}
 		if (strlen(device)) {
 			sp_fd = sp_openserport(device, atoi(baudport));
-			if (sp_fd < 0) {
+			if (sp_fd == SER_INV_FD) {
 				free(device);
 				return 1;
 			}