From 93df07866a6eb92e126e7bd4e55f10f50e286008 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Thu, 22 Sep 2022 10:31:59 +0100 Subject: [PATCH] Inform user of -x disable_no_spi when needed (without -v) --- src/linuxspi.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/linuxspi.c b/src/linuxspi.c index 2b708ae5..8ba2a918 100644 --- a/src/linuxspi.c +++ b/src/linuxspi.c @@ -65,8 +65,7 @@ /* * Private data for this programmer. */ -struct pdata -{ +struct pdata { int disable_no_cs; }; @@ -99,12 +98,7 @@ static int linuxspi_spi_duplex(const PROGRAMMER *pgm, const unsigned char *tx, u } static void linuxspi_setup(PROGRAMMER *pgm) { - if ((pgm->cookie = malloc(sizeof(struct pdata))) == 0) { - avrdude_message(MSG_INFO, "%s: linuxspi_setup(): Out of memory allocating private data\n", - progname); - exit(1); - } - memset(pgm->cookie, 0, sizeof(struct pdata)); + pgm->cookie = cfg_malloc("linuxspi_setup()", sizeof(struct pdata)); } static void linuxspi_teardown(PROGRAMMER* pgm) { @@ -180,18 +174,16 @@ static int linuxspi_open(PROGRAMMER *pgm, const char *pt) { } uint32_t mode = SPI_MODE_0; - if (!PDATA(pgm)->disable_no_cs) { + if (!PDATA(pgm)->disable_no_cs) mode |= SPI_NO_CS; - } + ret = ioctl(fd_spidev, SPI_IOC_WR_MODE32, &mode); if (ret == -1) { int ioctl_errno = errno; avrdude_message(MSG_INFO, "%s: error: Unable to set SPI mode %0X on %s\n", progname, mode, spidev); - if(ioctl_errno == EINVAL || !PDATA(pgm)->disable_no_cs) { - avrdude_message(MSG_NOTICE, "%s: Try \"-x disable_no_cs\" option\n", - progname); - } + if(ioctl_errno == EINVAL || !PDATA(pgm)->disable_no_cs) + avrdude_message(MSG_INFO, "%s: try -x disable_no_cs\n", progname); goto close_spidev; } fd_gpiochip = open(gpiochip, 0);