Message ID | 20220224180552.26901-4-sughosh.ganu@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | tpm: rng: Move TPM RNG functionality to driver model | expand |
On 2/24/22 19:05, Sughosh Ganu wrote: > The tpm_startup function returns negative values for error > conditions. Fix the return type of the function to a signed int > instead of a u32. > > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> > --- > include/tpm_api.h | 2 +- > lib/tpm_api.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/tpm_api.h b/include/tpm_api.h > index b9e3e8b5e6..fb6ee14e23 100644 > --- a/include/tpm_api.h > +++ b/include/tpm_api.h > @@ -18,7 +18,7 @@ > * @param mode TPM startup mode > * Return: return code of the operation Should this become: Return: 0 for success, -ve in case of error ? If we would stop at after this patch, TPM errors would be returned as -EPERM (= TPM_LIB_ERROR). So maybe this patch should be merged with a later patch. Best regards Heinrich > */ > -u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode); > +int tpm_startup(struct udevice *dev, enum tpm_startup_type mode); > > /** > * Issue a TPM_SelfTestFull command. > diff --git a/lib/tpm_api.c b/lib/tpm_api.c > index 1bbe33a3fc..b762202866 100644 > --- a/lib/tpm_api.c > +++ b/lib/tpm_api.c > @@ -21,7 +21,7 @@ static bool is_tpm2(struct udevice *dev) > return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2; > } > > -u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode) > +int tpm_startup(struct udevice *dev, enum tpm_startup_type mode) > { > if (is_tpm1(dev)) { > return tpm1_startup(dev, mode);
hello Heinrich, On Fri, 25 Feb 2022 at 00:25, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote: > > On 2/24/22 19:05, Sughosh Ganu wrote: > > The tpm_startup function returns negative values for error > > conditions. Fix the return type of the function to a signed int > > instead of a u32. > > > > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> > > --- > > include/tpm_api.h | 2 +- > > lib/tpm_api.c | 2 +- > > 2 files changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/include/tpm_api.h b/include/tpm_api.h > > index b9e3e8b5e6..fb6ee14e23 100644 > > --- a/include/tpm_api.h > > +++ b/include/tpm_api.h > > @@ -18,7 +18,7 @@ > > * @param mode TPM startup mode > > * Return: return code of the operation > > Should this become: > > Return: 0 for success, -ve in case of error ? I think there are two types of return codes coming from tpm_startup. One is the negative values which are primarily for handling error conditions like invalid parameters, unsupported tpm chip version etc. The other error codes are the response from the tpm chip for the requested operation. These are non-negative values. For a successful response though, both tpmv1 and tpmv2 response is a 0x0. Should this be Return: 0 for success, -EINVAL for invalid parameters, -ENOSYS for unsupported TPM version, TPM error codes > > If we would stop at after this patch, TPM errors would be returned as > -EPERM (= TPM_LIB_ERROR). So maybe this patch should be merged with a > later patch. Sorry, but I don't get this. The patch is changing the return type for tpm_startup. I think this function is not returning TPM_LIB_ERROR -- that is returned by the RNG functions of the TPM device. -sughosh > > Best regards > > Heinrich > > > */ > > -u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode); > > +int tpm_startup(struct udevice *dev, enum tpm_startup_type mode); > > > > /** > > * Issue a TPM_SelfTestFull command. > > diff --git a/lib/tpm_api.c b/lib/tpm_api.c > > index 1bbe33a3fc..b762202866 100644 > > --- a/lib/tpm_api.c > > +++ b/lib/tpm_api.c > > @@ -21,7 +21,7 @@ static bool is_tpm2(struct udevice *dev) > > return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2; > > } > > > > -u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode) > > +int tpm_startup(struct udevice *dev, enum tpm_startup_type mode) > > { > > if (is_tpm1(dev)) { > > return tpm1_startup(dev, mode); >
diff --git a/include/tpm_api.h b/include/tpm_api.h index b9e3e8b5e6..fb6ee14e23 100644 --- a/include/tpm_api.h +++ b/include/tpm_api.h @@ -18,7 +18,7 @@ * @param mode TPM startup mode * Return: return code of the operation */ -u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode); +int tpm_startup(struct udevice *dev, enum tpm_startup_type mode); /** * Issue a TPM_SelfTestFull command. diff --git a/lib/tpm_api.c b/lib/tpm_api.c index 1bbe33a3fc..b762202866 100644 --- a/lib/tpm_api.c +++ b/lib/tpm_api.c @@ -21,7 +21,7 @@ static bool is_tpm2(struct udevice *dev) return IS_ENABLED(CONFIG_TPM_V2) && tpm_get_version(dev) == TPM_V2; } -u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode) +int tpm_startup(struct udevice *dev, enum tpm_startup_type mode) { if (is_tpm1(dev)) { return tpm1_startup(dev, mode);
The tpm_startup function returns negative values for error conditions. Fix the return type of the function to a signed int instead of a u32. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> --- include/tpm_api.h | 2 +- lib/tpm_api.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)