Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

fsl_shw_return_t sah_validate_uco ( fsl_shw_uco_t uco  ) 

Verify the user context object.

Verify that supplied User Context Object is valid

Sanity checks the user context object fields to ensure that they make some sense before passing the uco as a parameter

Parameters:
uco user context object
Returns:
A return code of type fsl_shw_return_t.

Definition at line 1300 of file sf_util.c.

References fsl_shw_uco_t::callback, fsl_shw_uco_t::flags, FSL_RETURN_BAD_FLAG_S, FSL_RETURN_ERROR_S, FSL_RETURN_INTERNAL_ERROR_S, FSL_RETURN_MEMORY_ERROR_S, FSL_RETURN_NO_RESOURCE_S, FSL_RETURN_OK_S, FSL_UCO_BLOCKING_MODE, FSL_UCO_CALLBACK_MODE, fsl_shw_uco_t::mem_util, fsl_shw_uco_t::pool_size, and fsl_shw_uco_t::sahara_openfd.

Referenced by fsl_shw_add_entropy(), fsl_shw_get_random(), fsl_shw_get_results(), and sah_register().

{
    fsl_shw_return_t status = FSL_RETURN_OK_S;


    /* check if file is opened */
    if (uco->sahara_openfd < 0) {
        status = FSL_RETURN_NO_RESOURCE_S;
    } else {
        /* check flag combination: the only invalid setting of the
         * blocking and callback flags is blocking with callback. So check
         * for that
         */
        if ((uco->flags & (FSL_UCO_BLOCKING_MODE | FSL_UCO_CALLBACK_MODE)) ==
                         (FSL_UCO_BLOCKING_MODE | FSL_UCO_CALLBACK_MODE)) {
            status = FSL_RETURN_BAD_FLAG_S;
        } else {
            /* check that memory utilities have been attached */
            if (uco->mem_util == NULL) {
                status = FSL_RETURN_MEMORY_ERROR_S;
            } else {
                /* must have pool of at least 1, even for blocking mode */
                if (uco->pool_size == 0) {
                    status = FSL_RETURN_ERROR_S;
                } else {
                    /* if callback flag is set, it better have a callback
                     * routine */
                    if (uco->flags & FSL_UCO_CALLBACK_MODE) {
                        if (uco->callback == NULL) {
                            status = FSL_RETURN_INTERNAL_ERROR_S;
                        }
                    }
                }
            }
        }
    }

    return status;
}


Generated by  Doxygen 1.6.0   Back to index