If FT2232H SPI is not enabled, it should be compiled out completely. We can't remove ft2232_spi.o from unconditional OBJS yet due to our makefile structure (make features), but this patch adds #ifdefs around all FT2232H code, so the net effect is the same.
This is 0.9.1 material.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-ft2232_compileout/flash.h =================================================================== --- flashrom-ft2232_compileout/flash.h (Revision 684) +++ flashrom-ft2232_compileout/flash.h (Arbeitskopie) @@ -86,7 +86,9 @@ PROGRAMMER_NIC3COM, PROGRAMMER_SATASII, PROGRAMMER_IT87SPI, +#if FT2232_SPI_SUPPORT == 1 PROGRAMMER_FT2232SPI, +#endif #if SERPROG_SUPPORT == 1 PROGRAMMER_SERPROG, #endif @@ -426,9 +428,13 @@ SPI_CONTROLLER_SB600, SPI_CONTROLLER_VIA, SPI_CONTROLLER_WBSIO, +#if FT2232_SPI_SUPPORT == 1 SPI_CONTROLLER_FT2232, +#endif SPI_CONTROLLER_DUMMY, + SPI_CONTROLLER_INVALID /* This must always be the last entry. */ }; +extern const int spi_programmer_count; struct spi_command { unsigned int writecnt; unsigned int readcnt; Index: flashrom-ft2232_compileout/spi.c =================================================================== --- flashrom-ft2232_compileout/spi.c (Revision 684) +++ flashrom-ft2232_compileout/spi.c (Arbeitskopie) @@ -82,12 +82,14 @@ .write_256 = wbsio_spi_write_1, },
+#if FT2232_SPI_SUPPORT == 1 { /* SPI_CONTROLLER_FT2232 */ .command = ft2232_spi_send_command, .multicommand = default_spi_send_multicommand, .read = ft2232_spi_read, .write_256 = ft2232_spi_write_256, }, +#endif
{ /* SPI_CONTROLLER_DUMMY */ .command = dummy_spi_send_command, @@ -95,8 +97,11 @@ .read = NULL, .write_256 = NULL, }, + + {}, /* This entry corresponds to SPI_CONTROLLER_INVALID. */ };
+const int spi_programmer_count = ARRAY_SIZE(spi_programmer);
int spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr) @@ -293,7 +298,9 @@ case SPI_CONTROLLER_VIA: case SPI_CONTROLLER_SB600: case SPI_CONTROLLER_WBSIO: +#if FT2232_SPI_SUPPORT == 1 case SPI_CONTROLLER_FT2232: +#endif case SPI_CONTROLLER_DUMMY: return probe_spi_rdid_generic(flash, 4); default: Index: flashrom-ft2232_compileout/ft2232_spi.c =================================================================== --- flashrom-ft2232_compileout/ft2232_spi.c (Revision 684) +++ flashrom-ft2232_compileout/ft2232_spi.c (Arbeitskopie) @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+#if FT2232_SPI_SUPPORT == 1 + #include <stdio.h> #include <stdint.h> #include <string.h> @@ -25,9 +27,6 @@ #include <ctype.h> #include "flash.h" #include "spi.h" - -#if FT2232_SPI_SUPPORT == 1 - #include <ftdi.h>
/* the 'H' chips can run internally at either 12Mhz or 60Mhz. @@ -297,29 +296,4 @@ return 0; }
-#else -int ft2232_spi_init(void) -{ - fprintf(stderr, "FT2232 SPI support was not compiled in\n"); - exit(1); -} - -int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, - const unsigned char *writearr, unsigned char *readarr) -{ - fprintf(stderr, "FT2232 SPI support was not compiled in\n"); - exit(1); -} - -int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len) -{ - fprintf(stderr, "FT2232 SPI support was not compiled in\n"); - exit(1); -} - -int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf) -{ - fprintf(stderr, "FT2232 SPI support was not compiled in\n"); - exit(1); -} #endif Index: flashrom-ft2232_compileout/flashrom.c =================================================================== --- flashrom-ft2232_compileout/flashrom.c (Revision 684) +++ flashrom-ft2232_compileout/flashrom.c (Arbeitskopie) @@ -122,6 +122,7 @@ .delay = internal_delay, },
+#if FT2232_SPI_SUPPORT == 1 { .name = "ft2232spi", .init = ft2232_spi_init, @@ -138,6 +139,7 @@ .chip_writen = fallback_chip_writen, .delay = internal_delay, }, +#endif
#if SERPROG_SUPPORT == 1 { @@ -610,6 +612,10 @@ fprintf(stderr, "Programmer table miscompilation!\n"); exit(1); } + if (spi_programmer_count - 1 != SPI_CONTROLLER_INVALID) { + fprintf(stderr, "SPI programmer table miscompilation!\n"); + exit(1); + }
setbuf(stdout, NULL); while ((opt = getopt_long(argc, argv, "rRwvnVEfc:m:l:i:p:Lzh",
On 8/17/09 5:57 PM, Carl-Daniel Hailfinger wrote:
If FT2232H SPI is not enabled, it should be compiled out completely. We can't remove ft2232_spi.o from unconditional OBJS yet due to our makefile structure (make features), but this patch adds #ifdefs around all FT2232H code, so the net effect is the same.
This is 0.9.1 material.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Please address the one issue below.
Acked-by: Stefan Reinauer stepan@coresystems.de
Index: flashrom-ft2232_compileout/ft2232_spi.c
--- flashrom-ft2232_compileout/ft2232_spi.c (Revision 684) +++ flashrom-ft2232_compileout/ft2232_spi.c (Arbeitskopie) @@ -18,6 +18,8 @@
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#if FT2232_SPI_SUPPORT == 1
#include <stdio.h> #include <stdint.h> #include <string.h> @@ -25,9 +27,6 @@ #include <ctype.h> #include "flash.h" #include "spi.h"
-#if FT2232_SPI_SUPPORT == 1
#include <ftdi.h>
/* the 'H' chips can run internally at either 12Mhz or 60Mhz. @@ -297,29 +296,4 @@ return 0; }
-#else -int ft2232_spi_init(void) -{
- fprintf(stderr, "FT2232 SPI support was not compiled in\n");
- exit(1);
-}
-int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr)
-{
- fprintf(stderr, "FT2232 SPI support was not compiled in\n");
- exit(1);
-}
-int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len) -{
- fprintf(stderr, "FT2232 SPI support was not compiled in\n");
- exit(1);
-}
-int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf) -{
- fprintf(stderr, "FT2232 SPI support was not compiled in\n");
- exit(1);
-} #endif
For serprog.c the mechanism is moved to the Makefile
ifeq ($(CONFIG_SERPROG), yes) FEATURE_CFLAGS += -D'SERPROG_SUPPORT=1' OBJS += serprog.o endif
Maybe the two cases should be unified?
Stefan
On 19.08.2009 13:52, Stefan Reinauer wrote:
On 8/17/09 5:57 PM, Carl-Daniel Hailfinger wrote:
If FT2232H SPI is not enabled, it should be compiled out completely. We can't remove ft2232_spi.o from unconditional OBJS yet due to our makefile structure (make features), but this patch adds #ifdefs around all FT2232H code, so the net effect is the same.
This is 0.9.1 material.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Please address the one issue below.
I worked on that thing for hours and didn't get it to work reliably. Detailed explanation below.
Acked-by: Stefan Reinauer stepan@coresystems.de
Thanks, r691.
Once I know how to solve the makefile issue, I'll send a followup patch addressing your comments.
For serprog.c the mechanism is moved to the Makefile
ifeq ($(CONFIG_SERPROG), yes) FEATURE_CFLAGS += -D'SERPROG_SUPPORT=1' OBJS += serprog.o endif
Maybe the two cases should be unified?
CONFIG_SERPROG is not determined during make features, so we can use it in ifeq easily. FT2232_SPI support is determined during make features which is after any ifeq statements have been parsed, and thus the ifeq solution will always give the same result regardless of whether FT2232_SPI was actually selected or not.
There are two ways out: - Run make twice automatically (which also means running make features and make compiler and make pciutils twice). I once had such a patch in flashrom, but I was asked to convert this back to the run-once model so I did that. - Move make config to a separate configure.sh
Neither of these ways sounds great.
Any advice is appreciated.
Regards, Carl-Daniel