Commit 2a1ed77f authored by Stefan Tauner's avatar Stefan Tauner
Browse files

Introduce generic shutdown_free() and remove redundant internal_shutdown()


The former will be useful in cases where cleanup equals a simple call to free().

Corresponding to flashrom svn r1848.
Signed-off-by: default avatarStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: default avatarStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
parent 4e32ec19
...@@ -54,6 +54,7 @@ typedef uint32_t chipsize_t; /* Able to store the number of bytes of any support ...@@ -54,6 +54,7 @@ typedef uint32_t chipsize_t; /* Able to store the number of bytes of any support
#define PRIuCHIPSIZE PRIu32 #define PRIuCHIPSIZE PRIu32
int register_shutdown(int (*function) (void *data), void *data); int register_shutdown(int (*function) (void *data), void *data);
int shutdown_free(void *data);
void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len); void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len);
void programmer_unmap_flash_region(void *virt_addr, size_t len); void programmer_unmap_flash_region(void *virt_addr, size_t len);
void programmer_delay(unsigned int usecs); void programmer_delay(unsigned int usecs);
......
...@@ -373,6 +373,12 @@ static bool all_skipped = true; ...@@ -373,6 +373,12 @@ static bool all_skipped = true;
static int check_block_eraser(const struct flashctx *flash, int k, int log); static int check_block_eraser(const struct flashctx *flash, int k, int log);
int shutdown_free(void *data)
{
free(data);
return 0;
}
/* Register a function to be executed on programmer shutdown. /* Register a function to be executed on programmer shutdown.
* The advantage over atexit() is that you can supply a void pointer which will * The advantage over atexit() is that you can supply a void pointer which will
* be used as parameter to the registered function upon programmer shutdown. * be used as parameter to the registered function upon programmer shutdown.
......
...@@ -158,11 +158,6 @@ static const struct par_master par_master_internal = { ...@@ -158,11 +158,6 @@ static const struct par_master par_master_internal = {
enum chipbustype internal_buses_supported = BUS_NONE; enum chipbustype internal_buses_supported = BUS_NONE;
static int internal_shutdown(void *data)
{
return 0;
}
int internal_init(void) int internal_init(void)
{ {
#if __FLASHROM_LITTLE_ENDIAN__ #if __FLASHROM_LITTLE_ENDIAN__
...@@ -237,8 +232,6 @@ int internal_init(void) ...@@ -237,8 +232,6 @@ int internal_init(void)
if (rget_io_perms()) if (rget_io_perms())
return 1; return 1;
if (register_shutdown(internal_shutdown, NULL))
return 1;
/* Default to Parallel/LPC/FWH flash devices. If a known host controller /* Default to Parallel/LPC/FWH flash devices. If a known host controller
* is found, the host controller init routine sets the * is found, the host controller init routine sets the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment