1
0
Fork 0

tpm: Convert tpm_find_get_ops() to use tpm_default_chip()

Convert tpm_find_get_ops() to use tpm_default_chip() in case no chip
is passed in.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
hifive-unleashed-5.1
Stefan Berger 2018-06-26 15:09:31 -04:00 committed by Jarkko Sakkinen
parent aaae815363
commit eccc9bb844
1 changed files with 13 additions and 19 deletions

View File

@ -124,29 +124,23 @@ EXPORT_SYMBOL_GPL(tpm_default_chip);
*/
struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip)
{
struct tpm_chip *res = NULL;
int chip_num = 0;
int chip_prev;
int rc;
mutex_lock(&idr_lock);
if (!chip) {
do {
chip_prev = chip_num;
chip = idr_get_next(&dev_nums_idr, &chip_num);
if (chip && !tpm_try_get_ops(chip)) {
res = chip;
break;
}
} while (chip_prev != chip_num);
} else {
if (chip) {
if (!tpm_try_get_ops(chip))
res = chip;
return chip;
return NULL;
}
mutex_unlock(&idr_lock);
return res;
chip = tpm_default_chip();
if (!chip)
return NULL;
rc = tpm_try_get_ops(chip);
/* release additional reference we got from tpm_default_chip() */
put_device(&chip->dev);
if (rc)
return NULL;
return chip;
}
/**