/* Register a function as FLASH transfer completion callback.  */
int32_t flash_register_callback(struct flash_descriptor *flash, const enum flash_cb_type type, flash_cb_t func)
/* Register a function as FLASH transfer completion callback.  */
int32_t flash_register_callback(struct flash_descriptor *flash, const enum flash_cb_type type, flash_cb_t func)
{
	ASSERT(flash);
	switch (type) {
	case FLASH_CB_READY:
		flash->callbacks.cb_ready = func;
		break;
	case FLASH_CB_ERROR:
		flash->callbacks.cb_error = func;
		break;
	default:
		return ERR_INVALID_ARG;
	}
	_flash_set_irq_state(&flash->dev, (enum _flash_cb_type)type, NULL != func);
	return ERR_NONE;
}