mirror of
				https://review.coreboot.org/flashrom.git
				synced 2025-11-04 07:00:39 +01:00 
			
		
		
		
	dummyflasher.c: Retype appropriate variables and attributes with bool
Use the bool type instead of an integer for appropriate variables and attributes, since this represents their purpose much better. Signed-off-by: Felix Singer <felixsinger@posteo.net> Change-Id: I712b1ef7e1ad74d3e004dcf36c82898c88072c63 Reviewed-on: https://review.coreboot.org/c/flashrom/+/66901 Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
		
				
					committed by
					
						
						Anastasia Klimchuk
					
				
			
			
				
	
			
			
			
						parent
						
							b20a55adb7
						
					
				
				
					commit
					de2052849d
				
			@@ -15,6 +15,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <assert.h>
 | 
					#include <assert.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#include <stdbool.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <ctype.h>
 | 
					#include <ctype.h>
 | 
				
			||||||
@@ -48,8 +49,8 @@ struct emu_data {
 | 
				
			|||||||
	 *       WRSR code on enabling WRSR_EXT2 for more chips. */
 | 
						 *       WRSR code on enabling WRSR_EXT2 for more chips. */
 | 
				
			||||||
	bool emu_wrsr_ext2;
 | 
						bool emu_wrsr_ext2;
 | 
				
			||||||
	bool emu_wrsr_ext3;
 | 
						bool emu_wrsr_ext3;
 | 
				
			||||||
	int erase_to_zero;
 | 
						bool erase_to_zero;
 | 
				
			||||||
	int emu_modified;	/* is the image modified since reading it? */
 | 
						bool emu_modified;	/* is the image modified since reading it? */
 | 
				
			||||||
	uint8_t emu_status[3];
 | 
						uint8_t emu_status[3];
 | 
				
			||||||
	uint8_t emu_status_len;	/* number of emulated status registers */
 | 
						uint8_t emu_status_len;	/* number of emulated status registers */
 | 
				
			||||||
	/* If "freq" parameter is passed in from command line, commands will delay
 | 
						/* If "freq" parameter is passed in from command line, commands will delay
 | 
				
			||||||
@@ -183,7 +184,7 @@ static int dummy_opaque_write(struct flashctx *flash, const uint8_t *buf, unsign
 | 
				
			|||||||
	struct emu_data *emu_data = flash->mst->opaque.data;
 | 
						struct emu_data *emu_data = flash->mst->opaque.data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memcpy(emu_data->flashchip_contents + start, buf, len);
 | 
						memcpy(emu_data->flashchip_contents + start, buf, len);
 | 
				
			||||||
	emu_data->emu_modified = 1;
 | 
						emu_data->emu_modified = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -193,7 +194,7 @@ static int dummy_opaque_erase(struct flashctx *flash, unsigned int blockaddr, un
 | 
				
			|||||||
	struct emu_data *emu_data = flash->mst->opaque.data;
 | 
						struct emu_data *emu_data = flash->mst->opaque.data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memset(emu_data->flashchip_contents + blockaddr, emu_data->erase_to_zero ? 0x00 : 0xff, blocklen);
 | 
						memset(emu_data->flashchip_contents + blockaddr, emu_data->erase_to_zero ? 0x00 : 0xff, blocklen);
 | 
				
			||||||
	emu_data->emu_modified = 1;
 | 
						emu_data->emu_modified = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -361,7 +362,7 @@ static int write_flash_data(struct emu_data *data, uint32_t start, uint32_t len,
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memcpy(data->flashchip_contents + start, buf, len);
 | 
						memcpy(data->flashchip_contents + start, buf, len);
 | 
				
			||||||
	data->emu_modified = 1;
 | 
						data->emu_modified = true;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -375,7 +376,7 @@ static int erase_flash_data(struct emu_data *data, uint32_t start, uint32_t len)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* FIXME: Maybe use ERASED_VALUE(flash) instead of 0xff ? */
 | 
						/* FIXME: Maybe use ERASED_VALUE(flash) instead of 0xff ? */
 | 
				
			||||||
	memset(data->flashchip_contents + start, 0xff, len);
 | 
						memset(data->flashchip_contents + start, 0xff, len);
 | 
				
			||||||
	data->emu_modified = 1;
 | 
						data->emu_modified = true;
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1090,20 +1091,20 @@ static int init_data(const struct programmer_cfg *cfg,
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if ((units > tmp) && (units < end)) {
 | 
							if ((units > tmp) && (units < end)) {
 | 
				
			||||||
			int units_valid = 0;
 | 
								bool units_valid = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (units < end - 3) {
 | 
								if (units < end - 3) {
 | 
				
			||||||
				;
 | 
									;
 | 
				
			||||||
			} else if (units == end - 2) {
 | 
								} else if (units == end - 2) {
 | 
				
			||||||
				if (!strcasecmp(units, "hz"))
 | 
									if (!strcasecmp(units, "hz"))
 | 
				
			||||||
					units_valid = 1;
 | 
										units_valid = true;
 | 
				
			||||||
			} else if (units == end - 3) {
 | 
								} else if (units == end - 3) {
 | 
				
			||||||
				if (!strcasecmp(units, "khz")) {
 | 
									if (!strcasecmp(units, "khz")) {
 | 
				
			||||||
					freq *= 1000;
 | 
										freq *= 1000;
 | 
				
			||||||
					units_valid = 1;
 | 
										units_valid = true;
 | 
				
			||||||
				} else if (!strcasecmp(units, "mhz")) {
 | 
									} else if (!strcasecmp(units, "mhz")) {
 | 
				
			||||||
					freq *= 1000000;
 | 
										freq *= 1000000;
 | 
				
			||||||
					units_valid = 1;
 | 
										units_valid = true;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1284,7 +1285,7 @@ static int init_data(const struct programmer_cfg *cfg,
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		if (!strcmp(tmp, "yes")) {
 | 
							if (!strcmp(tmp, "yes")) {
 | 
				
			||||||
			msg_pdbg("Emulated chip will erase to 0x00\n");
 | 
								msg_pdbg("Emulated chip will erase to 0x00\n");
 | 
				
			||||||
			data->erase_to_zero = 1;
 | 
								data->erase_to_zero = true;
 | 
				
			||||||
		} else if (!strcmp(tmp, "no")) {
 | 
							} else if (!strcmp(tmp, "no")) {
 | 
				
			||||||
			msg_pdbg("Emulated chip will erase to 0xff\n");
 | 
								msg_pdbg("Emulated chip will erase to 0xff\n");
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user