From 6f183d427cd8dc867357acf95107bc3eaebddcfe Mon Sep 17 00:00:00 2001
From: Joerg Wunsch <j@uriah.heep.sax.de>
Date: Sat, 27 Nov 2021 15:46:10 +0000
Subject: [PATCH] patch #10029: linuxspi: Report GPIO_GET_LINEHANDLE_IOCTL
 errors Submitted by Alex Sverdlin: * linuxspi.c (linuxspi_open): Report ioctl
 error

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1493 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog  | 6 ++++++
 NEWS       | 1 +
 linuxspi.c | 2 ++
 3 files changed, 9 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 20bc88f8..1ab59c42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-11-27  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	Submitted by Alex Sverdlin:
+	patch #10029: linuxspi: Report GPIO_GET_LINEHANDLE_IOCTL errors
+	* linuxspi.c (linuxspi_open): Report ioctl error
+
 2021-11-27  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	Submitted by Alex Sverdlin:
diff --git a/NEWS b/NEWS
index 122087fa..9d6777a8 100644
--- a/NEWS
+++ b/NEWS
@@ -119,6 +119,7 @@ Current:
     patch #9328: ft245r.c: add TPI support (patches 5-7)
     patch #10027: linuxspi: Add reset pulse, according to AVR programming algorithm
     patch #10028: linuxspi: close() only when necessary
+    patch #10029: linuxspi: Report GPIO_GET_LINEHANDLE_IOCTL errors
 
   * Internals:
     - New avrdude.conf keyword "family_id", used to verify SIB attributes
diff --git a/linuxspi.c b/linuxspi.c
index 15ff97d6..6675f48a 100644
--- a/linuxspi.c
+++ b/linuxspi.c
@@ -170,6 +170,8 @@ static int linuxspi_open(PROGRAMMER *pgm, char *port)
     ret = ioctl(fd_gpiochip, GPIO_GET_LINEHANDLE_IOCTL, &req);
     if (ret == -1) {
         ret = -errno;
+        avrdude_message(MSG_INFO, "%s error: Unable to get GPIO line %d\n",
+                        progname, pgm->pinno[PIN_AVR_RESET] & ~PIN_INVERSE);
         goto close_gpiochip;
     }