On 15.06.22 at 20:23, Jarkko Sakkinen wrote: > On Fri, Jun 10, 2022 at 01:08:43PM +0200, LinoSanfilippo@xxxxxx wrote: >> From: Lino Sanfilippo <l.sanfilippo@xxxxxxxxxx> >> >> Implement a usage counter for the (default) locality used by the TPM TIS >> driver: >> Request the locality from the TPM if it has not been claimed yet, otherwise >> only increment the counter. Also release the locality if the counter is 0 >> otherwise only decrement the counter. Ensure thread-safety by protecting >> the counter with a mutex. >> >> This allows to request and release the locality from a thread and the >> interrupt handler at the same time without the danger to interfere with >> each other. >> >> Signed-off-by: Lino Sanfilippo <l.sanfilippo@xxxxxxxxxx> >> --- >> drivers/char/tpm/tpm_tis_core.c | 30 ++++++++++++++++++++++++++++-- >> drivers/char/tpm/tpm_tis_core.h | 2 ++ >> 2 files changed, 30 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c >> index 028bec44362d..0ef74979bc2c 100644 >> --- a/drivers/char/tpm/tpm_tis_core.c >> +++ b/drivers/char/tpm/tpm_tis_core.c >> @@ -158,16 +158,26 @@ static bool check_locality(struct tpm_chip *chip, int l) >> return false; >> } >> >> +static int release_locality_locked(struct tpm_tis_data *priv, int l) >> +{ >> + tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_ACTIVE_LOCALITY); > > nit: empty line here > > Also it would not hurt to prefix it with tpm_tis. > > This is for simple and practical reasons, like grepping. I don't > mind if you do that also for other functions (if you want to). > Ok, will do so. Regards, Lino