46 lines
1.5 KiB
C
46 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* _____ _ */
|
|
/* protocol/resetflash.c |_ _|__ _ _| |__ ___ _ _ */
|
|
/* | Project: libp7 | |/ _ \| | | | '_ \ / _ \ | | | */
|
|
/* | | (_) | |_| | | | | __/ |_| | */
|
|
/* By: thomas <thomas@touhey.fr> |_|\___/ \__,_|_| |_|\___|\__, |.fr */
|
|
/* Last updated: 2016/12/17 22:06:38 |___/ */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
#include <libp7/internals.h>
|
|
|
|
/**
|
|
* p7_resetflash:
|
|
* Optimize distant flash memory.
|
|
*
|
|
* @arg handle the libp7 handle
|
|
* @arg devname the device name
|
|
* @return if it worked
|
|
*/
|
|
|
|
int p7_resetflash(p7_handle_t *handle, const char *devname)
|
|
{
|
|
int err;
|
|
|
|
/* make checks */
|
|
chk_handle(handle);
|
|
chk_active(handle);
|
|
|
|
/* send command */
|
|
log_info("sending command");
|
|
if ((err = p7_send_cmdfls_reset(handle, devname))) {
|
|
log_fatal("couldn't send command/receive its answer");
|
|
return (err);
|
|
} else if (response.type == p7_pt_error
|
|
&& response.error.code == p7_ec_overwrite_impossible) {
|
|
log_fatal("overwrite impossible");
|
|
return (p7_error_unsupported_device);
|
|
} else if (response.type != p7_pt_ack) {
|
|
log_fatal("response wasn't ack");
|
|
return (p7_error_unknown);
|
|
}
|
|
|
|
/* we're done */
|
|
return (0);
|
|
}
|