mirror of
				https://review.coreboot.org/flashrom.git
				synced 2025-10-31 13:20:42 +01:00 
			
		
		
		
	ch341a_spi: drop validation of handle in routines
Since the handle is no longer a global variable and only exists during the lifetime of the driver, we can stop checking if the handle equals NULL. Change-Id: I1872495b83a522ceced331fef35d9d9d3b43fce5 Signed-off-by: Alexander Goncharov <chat@joursoir.net> Reviewed-on: https://review.coreboot.org/c/flashrom/+/72808 Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
		 Alexander Goncharov
					Alexander Goncharov
				
			
				
					committed by
					
						 Anastasia Klimchuk
						Anastasia Klimchuk
					
				
			
			
				
	
			
			
			 Anastasia Klimchuk
						Anastasia Klimchuk
					
				
			
						parent
						
							abbf988ecb
						
					
				
				
					commit
					5b2716d99c
				
			
							
								
								
									
										10
									
								
								ch341a_spi.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								ch341a_spi.c
									
									
									
									
									
								
							| @@ -137,9 +137,6 @@ static void LIBUSB_CALL cb_in(struct libusb_transfer *transfer) | |||||||
| static int32_t usb_transfer(const struct ch341a_spi_data *data, const char *func, | static int32_t usb_transfer(const struct ch341a_spi_data *data, const char *func, | ||||||
| 			    unsigned int writecnt, unsigned int readcnt, const uint8_t *writearr, uint8_t *readarr) | 			    unsigned int writecnt, unsigned int readcnt, const uint8_t *writearr, uint8_t *readarr) | ||||||
| { | { | ||||||
| 	if (data->handle == NULL) |  | ||||||
| 		return -1; |  | ||||||
|  |  | ||||||
| 	int state_out = TRANS_IDLE; | 	int state_out = TRANS_IDLE; | ||||||
| 	data->transfer_out->buffer = (uint8_t*)writearr; | 	data->transfer_out->buffer = (uint8_t*)writearr; | ||||||
| 	data->transfer_out->length = writecnt; | 	data->transfer_out->length = writecnt; | ||||||
| @@ -262,9 +259,6 @@ err: | |||||||
|  *   Set the SPI bus data width (speed(b2): 0 = Single, 1 = Double).  */ |  *   Set the SPI bus data width (speed(b2): 0 = Single, 1 = Double).  */ | ||||||
| static int32_t config_stream(const struct ch341a_spi_data *data, uint32_t speed) | static int32_t config_stream(const struct ch341a_spi_data *data, uint32_t speed) | ||||||
| { | { | ||||||
| 	if (data->handle == NULL) |  | ||||||
| 		return -1; |  | ||||||
|  |  | ||||||
| 	uint8_t buf[] = { | 	uint8_t buf[] = { | ||||||
| 		CH341A_CMD_I2C_STREAM, | 		CH341A_CMD_I2C_STREAM, | ||||||
| 		CH341A_CMD_I2C_STM_SET | (speed & 0x7), | 		CH341A_CMD_I2C_STM_SET | (speed & 0x7), | ||||||
| @@ -344,8 +338,6 @@ static void ch341a_spi_delay(const struct flashctx *flash, unsigned int usecs) | |||||||
| static int ch341a_spi_spi_send_command(const struct flashctx *flash, unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr) | static int ch341a_spi_spi_send_command(const struct flashctx *flash, unsigned int writecnt, unsigned int readcnt, const unsigned char *writearr, unsigned char *readarr) | ||||||
| { | { | ||||||
| 	struct ch341a_spi_data *data = flash->mst->spi.data; | 	struct ch341a_spi_data *data = flash->mst->spi.data; | ||||||
| 	if (data->handle == NULL) |  | ||||||
| 		return -1; |  | ||||||
|  |  | ||||||
| 	/* How many packets ... */ | 	/* How many packets ... */ | ||||||
| 	const size_t packets = (writecnt + readcnt + CH341_PACKET_LENGTH - 2) / (CH341_PACKET_LENGTH - 1); | 	const size_t packets = (writecnt + readcnt + CH341_PACKET_LENGTH - 2) / (CH341_PACKET_LENGTH - 1); | ||||||
| @@ -394,8 +386,6 @@ static int ch341a_spi_spi_send_command(const struct flashctx *flash, unsigned in | |||||||
| static int ch341a_spi_shutdown(void *data) | static int ch341a_spi_shutdown(void *data) | ||||||
| { | { | ||||||
| 	struct ch341a_spi_data *ch341a_data = data; | 	struct ch341a_spi_data *ch341a_data = data; | ||||||
| 	if (ch341a_data->handle == NULL) |  | ||||||
| 		return -1; |  | ||||||
|  |  | ||||||
| 	enable_pins(ch341a_data, false); | 	enable_pins(ch341a_data, false); | ||||||
| 	libusb_free_transfer(ch341a_data->transfer_out); | 	libusb_free_transfer(ch341a_data->transfer_out); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user