mirror of
				https://review.coreboot.org/flashrom.git
				synced 2025-10-31 13:20:42 +01:00 
			
		
		
		
	Use a common parameter variable for all programmers
This allows us to reduce #ifdef clauses a lot if we compile out some programmers completely. Corresponding to flashrom svn r679. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Reinauer <stepan@coresystems.de>
This commit is contained in:
		| @@ -24,45 +24,43 @@ | |||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
| #include "flash.h" | #include "flash.h" | ||||||
|  |  | ||||||
| char *dummytype = NULL; |  | ||||||
|  |  | ||||||
| int dummy_init(void) | int dummy_init(void) | ||||||
| { | { | ||||||
| 	int i; | 	int i; | ||||||
| 	printf_debug("%s\n", __func__); | 	printf_debug("%s\n", __func__); | ||||||
|  |  | ||||||
| 	/* "all" is equivalent to specifying no type. */ | 	/* "all" is equivalent to specifying no type. */ | ||||||
| 	if (dummytype && (!strcmp(dummytype, "all"))) { | 	if (programmer_param && (!strcmp(programmer_param, "all"))) { | ||||||
| 		free(dummytype); | 		free(programmer_param); | ||||||
| 		dummytype = NULL; | 		programmer_param = NULL; | ||||||
| 	} | 	} | ||||||
| 	if (!dummytype) | 	if (!programmer_param) | ||||||
| 		dummytype = strdup("parallel,lpc,fwh,spi"); | 		programmer_param = strdup("parallel,lpc,fwh,spi"); | ||||||
| 	/* Convert the parameters to lowercase. */ | 	/* Convert the parameters to lowercase. */ | ||||||
| 	for (i = 0; dummytype[i] != '\0'; i++) | 	for (i = 0; programmer_param[i] != '\0'; i++) | ||||||
| 		dummytype[i] = (char)tolower(dummytype[i]); | 		programmer_param[i] = (char)tolower(programmer_param[i]); | ||||||
|  |  | ||||||
| 	buses_supported = CHIP_BUSTYPE_NONE; | 	buses_supported = CHIP_BUSTYPE_NONE; | ||||||
| 	if (strstr(dummytype, "parallel")) { | 	if (strstr(programmer_param, "parallel")) { | ||||||
| 		buses_supported |= CHIP_BUSTYPE_PARALLEL; | 		buses_supported |= CHIP_BUSTYPE_PARALLEL; | ||||||
| 		printf_debug("Enabling support for %s flash.\n", "parallel"); | 		printf_debug("Enabling support for %s flash.\n", "parallel"); | ||||||
| 	} | 	} | ||||||
| 	if (strstr(dummytype, "lpc")) { | 	if (strstr(programmer_param, "lpc")) { | ||||||
| 		buses_supported |= CHIP_BUSTYPE_LPC; | 		buses_supported |= CHIP_BUSTYPE_LPC; | ||||||
| 		printf_debug("Enabling support for %s flash.\n", "LPC"); | 		printf_debug("Enabling support for %s flash.\n", "LPC"); | ||||||
| 	} | 	} | ||||||
| 	if (strstr(dummytype, "fwh")) { | 	if (strstr(programmer_param, "fwh")) { | ||||||
| 		buses_supported |= CHIP_BUSTYPE_FWH; | 		buses_supported |= CHIP_BUSTYPE_FWH; | ||||||
| 		printf_debug("Enabling support for %s flash.\n", "FWH"); | 		printf_debug("Enabling support for %s flash.\n", "FWH"); | ||||||
| 	} | 	} | ||||||
| 	if (strstr(dummytype, "spi")) { | 	if (strstr(programmer_param, "spi")) { | ||||||
| 		buses_supported |= CHIP_BUSTYPE_SPI; | 		buses_supported |= CHIP_BUSTYPE_SPI; | ||||||
| 		spi_controller = SPI_CONTROLLER_DUMMY; | 		spi_controller = SPI_CONTROLLER_DUMMY; | ||||||
| 		printf_debug("Enabling support for %s flash.\n", "SPI"); | 		printf_debug("Enabling support for %s flash.\n", "SPI"); | ||||||
| 	} | 	} | ||||||
| 	if (buses_supported == CHIP_BUSTYPE_NONE) | 	if (buses_supported == CHIP_BUSTYPE_NONE) | ||||||
| 		printf_debug("Support for all flash bus types disabled.\n"); | 		printf_debug("Support for all flash bus types disabled.\n"); | ||||||
| 	free(dummytype); | 	free(programmer_param); | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								flash.h
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								flash.h
									
									
									
									
									
								
							| @@ -277,7 +277,7 @@ struct pcidev_status { | |||||||
| 	const char *device_name; | 	const char *device_name; | ||||||
| }; | }; | ||||||
| uint32_t pcidev_validate(struct pci_dev *dev, struct pcidev_status *devs); | uint32_t pcidev_validate(struct pci_dev *dev, struct pcidev_status *devs); | ||||||
| uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status *devs); | uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status *devs, char *pcidev_bdf); | ||||||
|  |  | ||||||
| /* print.c */ | /* print.c */ | ||||||
| char *flashbuses_to_text(enum chipbustype bustype); | char *flashbuses_to_text(enum chipbustype bustype); | ||||||
| @@ -350,7 +350,6 @@ extern int io_fd; | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| /* dummyflasher.c */ | /* dummyflasher.c */ | ||||||
| extern char *dummytype; |  | ||||||
| int dummy_init(void); | int dummy_init(void); | ||||||
| int dummy_shutdown(void); | int dummy_shutdown(void); | ||||||
| void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); | void *dummy_map(const char *descr, unsigned long phys_addr, size_t len); | ||||||
| @@ -383,13 +382,13 @@ extern struct pcidev_status satas_sii[]; | |||||||
| /* ft2232_spi.c */ | /* ft2232_spi.c */ | ||||||
| #define FTDI_FT2232H 0x6010 | #define FTDI_FT2232H 0x6010 | ||||||
| #define FTDI_FT4232H 0x6011 | #define FTDI_FT4232H 0x6011 | ||||||
| extern char *ft2232spi_param; |  | ||||||
| int ft2232_spi_init(void); | int ft2232_spi_init(void); | ||||||
| int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); | int ft2232_spi_send_command(unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr); | ||||||
| int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); | int ft2232_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len); | ||||||
| int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf); | int ft2232_spi_write_256(struct flashchip *flash, uint8_t *buf); | ||||||
|  |  | ||||||
| /* flashrom.c */ | /* flashrom.c */ | ||||||
|  | extern char *programmer_param; | ||||||
| extern int verbose; | extern int verbose; | ||||||
| extern const char *flashrom_version; | extern const char *flashrom_version; | ||||||
| #define printf_debug(x...) { if (verbose) printf(x); } | #define printf_debug(x...) { if (verbose) printf(x); } | ||||||
| @@ -399,7 +398,6 @@ int min(int a, int b); | |||||||
| int max(int a, int b); | int max(int a, int b); | ||||||
| int check_erased_range(struct flashchip *flash, int start, int len); | int check_erased_range(struct flashchip *flash, int start, int len); | ||||||
| int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message); | int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message); | ||||||
| extern char *pcidev_bdf; |  | ||||||
| char *strcat_realloc(char *dest, const char *src); | char *strcat_realloc(char *dest, const char *src); | ||||||
|  |  | ||||||
| #define OK 0 | #define OK 0 | ||||||
| @@ -507,7 +505,6 @@ int ich_spi_write_256(struct flashchip *flash, uint8_t * buf); | |||||||
| int ich_spi_send_multicommand(struct spi_command *spicommands); | int ich_spi_send_multicommand(struct spi_command *spicommands); | ||||||
|  |  | ||||||
| /* it87spi.c */ | /* it87spi.c */ | ||||||
| extern char *it87opts; |  | ||||||
| extern uint16_t it8716f_flashport; | extern uint16_t it8716f_flashport; | ||||||
| void enter_conf_mode_ite(uint16_t port); | void enter_conf_mode_ite(uint16_t port); | ||||||
| void exit_conf_mode_ite(uint16_t port); | void exit_conf_mode_ite(uint16_t port); | ||||||
| @@ -628,7 +625,6 @@ int erase_stm50flw0x0x(struct flashchip *flash); | |||||||
| int write_stm50flw0x0x(struct flashchip *flash, uint8_t *buf); | int write_stm50flw0x0x(struct flashchip *flash, uint8_t *buf); | ||||||
|  |  | ||||||
| /* serprog.c */ | /* serprog.c */ | ||||||
| extern char *serprog_param; |  | ||||||
| int serprog_init(void); | int serprog_init(void); | ||||||
| int serprog_shutdown(void); | int serprog_shutdown(void); | ||||||
| void serprog_chip_writeb(uint8_t val, chipaddr addr); | void serprog_chip_writeb(uint8_t val, chipaddr addr); | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								flashrom.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								flashrom.c
									
									
									
									
									
								
							| @@ -34,6 +34,7 @@ const char *flashrom_version = FLASHROM_VERSION; | |||||||
| char *chip_to_probe = NULL; | char *chip_to_probe = NULL; | ||||||
| int verbose = 0; | int verbose = 0; | ||||||
| enum programmer programmer = PROGRAMMER_INTERNAL; | enum programmer programmer = PROGRAMMER_INTERNAL; | ||||||
|  | char *programmer_param = NULL; | ||||||
|  |  | ||||||
| const struct programmer_entry programmer_table[] = { | const struct programmer_entry programmer_table[] = { | ||||||
| 	{ | 	{ | ||||||
| @@ -642,30 +643,32 @@ int main(int argc, char *argv[]) | |||||||
| 		case 'p': | 		case 'p': | ||||||
| 			if (strncmp(optarg, "internal", 8) == 0) { | 			if (strncmp(optarg, "internal", 8) == 0) { | ||||||
| 				programmer = PROGRAMMER_INTERNAL; | 				programmer = PROGRAMMER_INTERNAL; | ||||||
|  | 				if (optarg[8] == '=') | ||||||
|  | 					programmer_param = strdup(optarg + 9); | ||||||
| 			} else if (strncmp(optarg, "dummy", 5) == 0) { | 			} else if (strncmp(optarg, "dummy", 5) == 0) { | ||||||
| 				programmer = PROGRAMMER_DUMMY; | 				programmer = PROGRAMMER_DUMMY; | ||||||
| 				if (optarg[5] == '=') | 				if (optarg[5] == '=') | ||||||
| 					dummytype = strdup(optarg + 6); | 					programmer_param = strdup(optarg + 6); | ||||||
| 			} else if (strncmp(optarg, "nic3com", 7) == 0) { | 			} else if (strncmp(optarg, "nic3com", 7) == 0) { | ||||||
| 				programmer = PROGRAMMER_NIC3COM; | 				programmer = PROGRAMMER_NIC3COM; | ||||||
| 				if (optarg[7] == '=') | 				if (optarg[7] == '=') | ||||||
| 					pcidev_bdf = strdup(optarg + 8); | 					programmer_param = strdup(optarg + 8); | ||||||
| 			} else if (strncmp(optarg, "satasii", 7) == 0) { | 			} else if (strncmp(optarg, "satasii", 7) == 0) { | ||||||
| 				programmer = PROGRAMMER_SATASII; | 				programmer = PROGRAMMER_SATASII; | ||||||
| 				if (optarg[7] == '=') | 				if (optarg[7] == '=') | ||||||
| 					pcidev_bdf = strdup(optarg + 8); | 					programmer_param = strdup(optarg + 8); | ||||||
| 			} else if (strncmp(optarg, "it87spi", 7) == 0) { | 			} else if (strncmp(optarg, "it87spi", 7) == 0) { | ||||||
| 				programmer = PROGRAMMER_IT87SPI; | 				programmer = PROGRAMMER_IT87SPI; | ||||||
| 				if (optarg[7] == '=') | 				if (optarg[7] == '=') | ||||||
| 					it87opts = strdup(optarg + 8); | 					programmer_param = strdup(optarg + 8); | ||||||
| 			} else if (strncmp(optarg, "ft2232spi", 9) == 0) { | 			} else if (strncmp(optarg, "ft2232spi", 9) == 0) { | ||||||
| 				programmer = PROGRAMMER_FT2232SPI; | 				programmer = PROGRAMMER_FT2232SPI; | ||||||
| 				if (optarg[9] == '=') | 				if (optarg[9] == '=') | ||||||
| 					ft2232spi_param = strdup(optarg + 10); | 					programmer_param = strdup(optarg + 10); | ||||||
| 			} else if (strncmp(optarg, "serprog", 7) == 0) { | 			} else if (strncmp(optarg, "serprog", 7) == 0) { | ||||||
| 				programmer = PROGRAMMER_SERPROG; | 				programmer = PROGRAMMER_SERPROG; | ||||||
| 				if (optarg[7] == '=') | 				if (optarg[7] == '=') | ||||||
| 					serprog_param = strdup(optarg + 8); | 					programmer_param = strdup(optarg + 8); | ||||||
| 			} else { | 			} else { | ||||||
| 				printf("Error: Unknown programmer.\n"); | 				printf("Error: Unknown programmer.\n"); | ||||||
| 				exit(1); | 				exit(1); | ||||||
|   | |||||||
							
								
								
									
										18
									
								
								ft2232_spi.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								ft2232_spi.c
									
									
									
									
									
								
							| @@ -26,8 +26,6 @@ | |||||||
| #include "flash.h" | #include "flash.h" | ||||||
| #include "spi.h" | #include "spi.h" | ||||||
|  |  | ||||||
| char *ft2232spi_param = NULL; |  | ||||||
|  |  | ||||||
| #if FT2232_SPI_SUPPORT == 1 | #if FT2232_SPI_SUPPORT == 1 | ||||||
|  |  | ||||||
| #include <ftdi.h> | #include <ftdi.h> | ||||||
| @@ -83,16 +81,16 @@ int ft2232_spi_init(void) | |||||||
| 		return EXIT_FAILURE; | 		return EXIT_FAILURE; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (ft2232spi_param && !strlen(ft2232spi_param)) { | 	if (programmer_param && !strlen(programmer_param)) { | ||||||
| 		free(ft2232spi_param); | 		free(programmer_param); | ||||||
| 		ft2232spi_param = NULL; | 		programmer_param = NULL; | ||||||
| 	} | 	} | ||||||
| 	if (ft2232spi_param) { | 	if (programmer_param) { | ||||||
| 		if (strstr(ft2232spi_param, "2232")) | 		if (strstr(programmer_param, "2232")) | ||||||
| 			ft2232_type = FTDI_FT2232H; | 			ft2232_type = FTDI_FT2232H; | ||||||
| 		if (strstr(ft2232spi_param, "4232")) | 		if (strstr(programmer_param, "4232")) | ||||||
| 			ft2232_type = FTDI_FT4232H; | 			ft2232_type = FTDI_FT4232H; | ||||||
| 		portpos = strstr(ft2232spi_param, "port="); | 		portpos = strstr(programmer_param, "port="); | ||||||
| 		if (portpos) { | 		if (portpos) { | ||||||
| 			portpos += 5; | 			portpos += 5; | ||||||
| 			switch (toupper(*portpos)) { | 			switch (toupper(*portpos)) { | ||||||
| @@ -107,7 +105,7 @@ int ft2232_spi_init(void) | |||||||
| 					"using default.\n"); | 					"using default.\n"); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		free(ft2232spi_param); | 		free(programmer_param); | ||||||
| 	} | 	} | ||||||
| 	printf_debug("Using device type %s ", | 	printf_debug("Using device type %s ", | ||||||
| 		     (ft2232_type == FTDI_FT2232H) ? "2232H" : "4232H"); | 		     (ft2232_type == FTDI_FT2232H) ? "2232H" : "4232H"); | ||||||
|   | |||||||
| @@ -31,7 +31,6 @@ | |||||||
| #define ITE_SUPERIO_PORT1	0x2e | #define ITE_SUPERIO_PORT1	0x2e | ||||||
| #define ITE_SUPERIO_PORT2	0x4e | #define ITE_SUPERIO_PORT2	0x4e | ||||||
|  |  | ||||||
| char *it87opts = NULL; |  | ||||||
| uint16_t it8716f_flashport = 0; | uint16_t it8716f_flashport = 0; | ||||||
| /* use fast 33MHz SPI (<>0) or slow 16MHz (0) */ | /* use fast 33MHz SPI (<>0) or slow 16MHz (0) */ | ||||||
| int fast_spi = 1; | int fast_spi = 1; | ||||||
| @@ -95,11 +94,11 @@ static uint16_t find_ite_spi_flash_port(uint16_t port) | |||||||
| 		flashport = sio_read(port, 0x64) << 8; | 		flashport = sio_read(port, 0x64) << 8; | ||||||
| 		flashport |= sio_read(port, 0x65); | 		flashport |= sio_read(port, 0x65); | ||||||
| 		printf("Serial flash port 0x%04x\n", flashport); | 		printf("Serial flash port 0x%04x\n", flashport); | ||||||
| 		if (it87opts && !strlen(it87opts)) { | 		if (programmer_param && !strlen(programmer_param)) { | ||||||
| 			free(it87opts); | 			free(programmer_param); | ||||||
| 			it87opts = NULL; | 			programmer_param = NULL; | ||||||
| 		} | 		} | ||||||
| 		if (it87opts && (portpos = strstr(it87opts, "port="))) { | 		if (programmer_param && (portpos = strstr(programmer_param, "port="))) { | ||||||
| 			portpos += 5; | 			portpos += 5; | ||||||
| 			flashport = strtol(portpos, (char **)NULL, 0); | 			flashport = strtol(portpos, (char **)NULL, 0); | ||||||
| 			printf("Forcing serial flash port 0x%04x\n", flashport); | 			printf("Forcing serial flash port 0x%04x\n", flashport); | ||||||
|   | |||||||
| @@ -58,7 +58,7 @@ int nic3com_init(void) | |||||||
| { | { | ||||||
| 	get_io_perms(); | 	get_io_perms(); | ||||||
|  |  | ||||||
| 	io_base_addr = pcidev_init(PCI_VENDOR_ID_3COM, nics_3com); | 	io_base_addr = pcidev_init(PCI_VENDOR_ID_3COM, nics_3com, programmer_param); | ||||||
| 	id = pcidev_dev->device_id; | 	id = pcidev_dev->device_id; | ||||||
|  |  | ||||||
| 	/* 3COM 3C90xB cards need a special fixup. */ | 	/* 3COM 3C90xB cards need a special fixup. */ | ||||||
| @@ -94,7 +94,7 @@ int nic3com_shutdown(void) | |||||||
| 		OUTL(internal_conf, io_base_addr + INTERNAL_CONFIG); | 		OUTL(internal_conf, io_base_addr + INTERNAL_CONFIG); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	free(pcidev_bdf); | 	free(programmer_param); | ||||||
| 	pci_cleanup(pacc); | 	pci_cleanup(pacc); | ||||||
| 	release_io_perms(); | 	release_io_perms(); | ||||||
| 	return 0; | 	return 0; | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								pcidev.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								pcidev.c
									
									
									
									
									
								
							| @@ -26,7 +26,6 @@ | |||||||
| uint32_t io_base_addr; | uint32_t io_base_addr; | ||||||
| struct pci_access *pacc; | struct pci_access *pacc; | ||||||
| struct pci_filter filter; | struct pci_filter filter; | ||||||
| char *pcidev_bdf = NULL; |  | ||||||
| struct pci_dev *pcidev_dev = NULL; | struct pci_dev *pcidev_dev = NULL; | ||||||
|  |  | ||||||
| uint32_t pcidev_validate(struct pci_dev *dev, struct pcidev_status *devs) | uint32_t pcidev_validate(struct pci_dev *dev, struct pcidev_status *devs) | ||||||
| @@ -58,7 +57,7 @@ uint32_t pcidev_validate(struct pci_dev *dev, struct pcidev_status *devs) | |||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status *devs) | uint32_t pcidev_init(uint16_t vendor_id, struct pcidev_status *devs, char *pcidev_bdf) | ||||||
| { | { | ||||||
| 	struct pci_dev *dev; | 	struct pci_dev *dev; | ||||||
| 	char *msg = NULL; | 	char *msg = NULL; | ||||||
|   | |||||||
| @@ -47,7 +47,7 @@ int satasii_init(void) | |||||||
|  |  | ||||||
| 	get_io_perms(); | 	get_io_perms(); | ||||||
|  |  | ||||||
| 	pcidev_init(PCI_VENDOR_ID_SII, satas_sii); | 	pcidev_init(PCI_VENDOR_ID_SII, satas_sii, programmer_param); | ||||||
| 	id = pcidev_dev->device_id; | 	id = pcidev_dev->device_id; | ||||||
|  |  | ||||||
| 	if ((id == 0x3132) || (id == 0x3124)) { | 	if ((id == 0x3132) || (id == 0x3124)) { | ||||||
| @@ -71,7 +71,7 @@ int satasii_init(void) | |||||||
|  |  | ||||||
| int satasii_shutdown(void) | int satasii_shutdown(void) | ||||||
| { | { | ||||||
| 	free(pcidev_bdf); | 	free(programmer_param); | ||||||
| 	pci_cleanup(pacc); | 	pci_cleanup(pacc); | ||||||
| 	release_io_perms(); | 	release_io_perms(); | ||||||
| 	return 0; | 	return 0; | ||||||
|   | |||||||
							
								
								
									
										29
									
								
								serprog.c
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								serprog.c
									
									
									
									
									
								
							| @@ -19,8 +19,14 @@ | |||||||
|  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA |  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <string.h> | #include <stdio.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
|  | #include <unistd.h> | ||||||
|  | #include "flash.h" | ||||||
|  |  | ||||||
|  | #if SERPROG_SUPPORT == 1 | ||||||
|  |  | ||||||
|  | #include <string.h> | ||||||
| #include <ctype.h> | #include <ctype.h> | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
| @@ -31,15 +37,8 @@ | |||||||
| #include <netdb.h> | #include <netdb.h> | ||||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||||
| #include <errno.h> | #include <errno.h> | ||||||
| #include <stdio.h> |  | ||||||
| #include <unistd.h> |  | ||||||
| #include <inttypes.h> | #include <inttypes.h> | ||||||
| #include <termios.h> | #include <termios.h> | ||||||
| #include "flash.h" |  | ||||||
|  |  | ||||||
| char *serprog_param = NULL; |  | ||||||
|  |  | ||||||
| #if SERPROG_SUPPORT == 1 |  | ||||||
|  |  | ||||||
| #define MSGHEADER "serprog:" | #define MSGHEADER "serprog:" | ||||||
|  |  | ||||||
| @@ -431,15 +430,15 @@ int serprog_init(void) | |||||||
| 	char *dev; | 	char *dev; | ||||||
| 	printf_debug("%s\n", __func__); | 	printf_debug("%s\n", __func__); | ||||||
| 	/* the parameter is either of format "/dev/device:baud" or "ip:port" */ | 	/* the parameter is either of format "/dev/device:baud" or "ip:port" */ | ||||||
| 	if ((!serprog_param) || (!strlen(serprog_param))) { | 	if ((!programmer_param) || (!strlen(programmer_param))) { | ||||||
| 		nodevice: | 		nodevice: | ||||||
| 		fprintf(stderr, | 		fprintf(stderr, | ||||||
| 			"Error: No device/host given for the serial programmer driver.\n" | 			"Error: No device/host given for the serial programmer driver.\n" | ||||||
| 			"Use flashrom -p serprog=/dev/device:baud or flashrom -p serprog=ip:port\n"); | 			"Use flashrom -p serprog=/dev/device:baud or flashrom -p serprog=ip:port\n"); | ||||||
| 		exit(1); | 		exit(1); | ||||||
| 	} | 	} | ||||||
| 	num = strstr(serprog_param, ":"); | 	num = strstr(programmer_param, ":"); | ||||||
| 	len = num - serprog_param; | 	len = num - programmer_param; | ||||||
| 	if (!len) goto nodevice; | 	if (!len) goto nodevice; | ||||||
| 	if (!num) { | 	if (!num) { | ||||||
| 		fprintf(stderr, | 		fprintf(stderr, | ||||||
| @@ -447,15 +446,15 @@ int serprog_init(void) | |||||||
| 			"Use flashrom -p serprog=/dev/device:baud or flashrom -p serprog=ip:port\n"); | 			"Use flashrom -p serprog=/dev/device:baud or flashrom -p serprog=ip:port\n"); | ||||||
| 		exit(1); | 		exit(1); | ||||||
| 	} | 	} | ||||||
| 	len = num - serprog_param; | 	len = num - programmer_param; | ||||||
| 	dev = malloc(len + 1); | 	dev = malloc(len + 1); | ||||||
| 	if (!dev) sp_die("Error: memory allocation failure"); | 	if (!dev) sp_die("Error: memory allocation failure"); | ||||||
| 	memcpy(dev, serprog_param, len); | 	memcpy(dev, programmer_param, len); | ||||||
| 	dev[len] = 0; | 	dev[len] = 0; | ||||||
| 	num = strdup(num + 1); | 	num = strdup(num + 1); | ||||||
| 	if (!num) sp_die("Error: memory allocation failure"); | 	if (!num) sp_die("Error: memory allocation failure"); | ||||||
| 	free(serprog_param); | 	free(programmer_param); | ||||||
| 	serprog_param = NULL; | 	programmer_param = NULL; | ||||||
|  |  | ||||||
| 	if (dev[0] == '/') sp_fd = sp_openserport(dev, atoi(num)); | 	if (dev[0] == '/') sp_fd = sp_openserport(dev, atoi(num)); | ||||||
| 	else sp_fd = sp_opensocket(dev, atoi(num)); | 	else sp_fd = sp_opensocket(dev, atoi(num)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Carl-Daniel Hailfinger
					Carl-Daniel Hailfinger