@@ -129,7 +129,7 @@ static bool ke04_flash_write(target_flash_s *flash, target_addr_t dest, const vo
129129static bool ke04_flash_done (target_flash_s * flash );
130130static bool ke04_mass_erase (target_s * target , platform_timeout_s * print_progess );
131131
132- bool ke04_probe (target_s * target )
132+ bool ke04_probe (target_s * const target )
133133{
134134 /* Read the higher 16bits of System Reset Status and ID Register */
135135 const uint16_t srsid = target_mem32_read32 (target , SIM_SRSID ) >> 16U ;
@@ -186,7 +186,7 @@ bool ke04_probe(target_s *target)
186186 target_add_ram32 (target , RAM_BASE_ADDR , ramsize ); /* Higher RAM */
187187
188188 /* Add flash, all KE04 have same write and erase size */
189- target_flash_s * flash = calloc (1 , sizeof (* flash ));
189+ target_flash_s * const flash = calloc (1 , sizeof (* flash ));
190190 if (!flash ) { /* calloc failed: heap exhaustion */
191191 DEBUG_ERROR ("calloc: failed in %s\n" , __func__ );
192192 return false;
@@ -206,7 +206,7 @@ bool ke04_probe(target_s *target)
206206 return true;
207207}
208208
209- static bool ke04_wait_complete (target_s * target )
209+ static bool ke04_wait_complete (target_s * const target )
210210{
211211 uint8_t fstat = 0 ;
212212 /* Wait for CCIF to be high */
@@ -218,10 +218,10 @@ static bool ke04_wait_complete(target_s *target)
218218 return true;
219219}
220220
221- static bool ke04_command (target_s * target , uint8_t cmd , uint32_t addr , const void * const data )
221+ static bool ke04_command (target_s * const target , uint8_t cmd , uint32_t addr , const void * const data )
222222{
223223 /* Set FCLKDIV to 0x17 for 24MHz (default at reset) */
224- uint8_t fclkdiv = target_mem32_read8 (target , FTMRE_FCLKDIV );
224+ const uint8_t fclkdiv = target_mem32_read8 (target , FTMRE_FCLKDIV );
225225 if ((fclkdiv & 0x1fU ) != 0x17U ) {
226226 if (!ke04_wait_complete (target ))
227227 return false;
@@ -279,7 +279,7 @@ static bool ke04_command(target_s *target, uint8_t cmd, uint32_t addr, const voi
279279 return true;
280280}
281281
282- static bool ke04_flash_done (target_flash_s * flash )
282+ static bool ke04_flash_done (target_flash_s * const flash )
283283{
284284 target_s * target = flash -> t ;
285285 if (target -> unsafe_enabled ||
@@ -302,11 +302,12 @@ static bool ke04_flash_erase(target_flash_s *const flash, const target_addr_t ad
302302 return true;
303303}
304304
305- static bool ke04_flash_write (target_flash_s * flash , target_addr_t dest , const void * src , size_t len )
305+ static bool ke04_flash_write (
306+ target_flash_s * const flash , const target_addr_t dest , const void * const src , const size_t len )
306307{
307308 /* Ensure we don't write something horrible over the security byte */
308309 target_s * target = flash -> t ;
309- const uint8_t * data = src ;
310+ const uint8_t * const data = src ;
310311#pragma GCC diagnostic push
311312#pragma GCC diagnostic ignored "-Wcast-qual"
312313 if (!target -> unsafe_enabled && dest <= FLASH_SECURITY_BYTE_ADDRESS && dest + len > FLASH_SECURITY_BYTE_ADDRESS )
@@ -332,14 +333,14 @@ static bool ke04_mass_erase(target_s *const target, platform_timeout_s *const pr
332333 return true;
333334}
334335
335- static bool ke04_cmd_sector_erase (target_s * target , int argc , const char * * argv )
336+ static bool ke04_cmd_sector_erase (target_s * const target , const int argc , const char * * const argv )
336337{
337338 if (argc < 2 )
338339 tc_printf (target , "usage: monitor sector_erase <addr>\n" );
339340
340- target_flash_s * flash = target -> flash ;
341+ target_flash_s * const flash = target -> flash ;
341342 char * eos = NULL ;
342- uint32_t addr = strtoul (argv [1 ], & eos , 0 );
343+ const uint32_t addr = strtoul (argv [1 ], & eos , 0 );
343344
344345 /* Check that addr is a valid number and inside the flash range */
345346 if ((eos && eos [0 ] != '\0' ) || addr < flash -> start || addr >= flash -> start + flash -> length ) {
@@ -355,7 +356,7 @@ static bool ke04_cmd_sector_erase(target_s *target, int argc, const char **argv)
355356 return true;
356357}
357358
358- static bool kinetis_cmd_unsafe (target_s * target , int argc , const char * * argv )
359+ static bool kinetis_cmd_unsafe (target_s * const target , const int argc , const char * * const argv )
359360{
360361 if (argc == 1 )
361362 tc_printf (target , "Allow programming security byte: %s\n" , target -> unsafe_enabled ? "enabled" : "disabled" );
0 commit comments