Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tpm: make check_locality return bool

Since check_locality is checking to see if a certain
locality is active, return true if active otherwise
return false.

Cc: Christophe Ricard <christophe.ricard@gmail.com>
Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Cc: Marcel Selhorst <tpmdd@selhorst.net>
Cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.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>

authored by

Jerry Snitselaar and committed by
Jarkko Sakkinen
84d25940 67c2f3d3

+23 -21
+6 -6
drivers/char/tpm/st33zp24/st33zp24.c
··· 117 117 /* 118 118 * check_locality if the locality is active 119 119 * @param: chip, the tpm chip description 120 - * @return: the active locality or -EACCESS. 120 + * @return: true if LOCALITY0 is active, otherwise false 121 121 */ 122 - static int check_locality(struct tpm_chip *chip) 122 + static bool check_locality(struct tpm_chip *chip) 123 123 { 124 124 struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); 125 125 u8 data; ··· 129 129 if (status && (data & 130 130 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) == 131 131 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) 132 - return tpm_dev->locality; 132 + return true; 133 133 134 - return -EACCES; 134 + return false; 135 135 } /* check_locality() */ 136 136 137 137 /* ··· 146 146 long ret; 147 147 u8 data; 148 148 149 - if (check_locality(chip) == tpm_dev->locality) 149 + if (check_locality(chip)) 150 150 return tpm_dev->locality; 151 151 152 152 data = TPM_ACCESS_REQUEST_USE; ··· 158 158 159 159 /* Request locality is usually effective after the request */ 160 160 do { 161 - if (check_locality(chip) >= 0) 161 + if (check_locality(chip)) 162 162 return tpm_dev->locality; 163 163 msleep(TPM_TIMEOUT); 164 164 } while (time_before(jiffies, stop));
+6 -6
drivers/char/tpm/tpm_i2c_infineon.c
··· 278 278 #define TPM_DATA_FIFO(l) (0x0005 | ((l) << 4)) 279 279 #define TPM_DID_VID(l) (0x0006 | ((l) << 4)) 280 280 281 - static int check_locality(struct tpm_chip *chip, int loc) 281 + static bool check_locality(struct tpm_chip *chip, int loc) 282 282 { 283 283 u8 buf; 284 284 int rc; 285 285 286 286 rc = iic_tpm_read(TPM_ACCESS(loc), &buf, 1); 287 287 if (rc < 0) 288 - return rc; 288 + return false; 289 289 290 290 if ((buf & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) == 291 291 (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) { 292 292 tpm_dev.locality = loc; 293 - return loc; 293 + return true; 294 294 } 295 295 296 - return -EIO; 296 + return false; 297 297 } 298 298 299 299 /* implementation similar to tpm_tis */ ··· 315 315 unsigned long stop; 316 316 u8 buf = TPM_ACCESS_REQUEST_USE; 317 317 318 - if (check_locality(chip, loc) >= 0) 318 + if (check_locality(chip, loc)) 319 319 return loc; 320 320 321 321 iic_tpm_write(TPM_ACCESS(loc), &buf, 1); ··· 323 323 /* wait for burstcount */ 324 324 stop = jiffies + chip->timeout_a; 325 325 do { 326 - if (check_locality(chip, loc) >= 0) 326 + if (check_locality(chip, loc)) 327 327 return loc; 328 328 usleep_range(TPM_TIMEOUT_US_LOW, TPM_TIMEOUT_US_HI); 329 329 } while (time_before(jiffies, stop));
+11 -9
drivers/char/tpm/tpm_tis_core.c
··· 56 56 return -1; 57 57 } 58 58 59 - static int check_locality(struct tpm_chip *chip, int l) 59 + static bool check_locality(struct tpm_chip *chip, int l) 60 60 { 61 61 struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); 62 62 int rc; ··· 64 64 65 65 rc = tpm_tis_read8(priv, TPM_ACCESS(l), &access); 66 66 if (rc < 0) 67 - return rc; 67 + return false; 68 68 69 69 if ((access & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) == 70 - (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) 71 - return priv->locality = l; 70 + (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) { 71 + priv->locality = l; 72 + return true; 73 + } 72 74 73 - return -1; 75 + return false; 74 76 } 75 77 76 78 static void release_locality(struct tpm_chip *chip, int l, int force) ··· 98 96 unsigned long stop, timeout; 99 97 long rc; 100 98 101 - if (check_locality(chip, l) >= 0) 99 + if (check_locality(chip, l)) 102 100 return l; 103 101 104 102 rc = tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_REQUEST_USE); ··· 114 112 return -1; 115 113 rc = wait_event_interruptible_timeout(priv->int_queue, 116 114 (check_locality 117 - (chip, l) >= 0), 115 + (chip, l)), 118 116 timeout); 119 117 if (rc > 0) 120 118 return l; ··· 125 123 } else { 126 124 /* wait for burstcount */ 127 125 do { 128 - if (check_locality(chip, l) >= 0) 126 + if (check_locality(chip, l)) 129 127 return l; 130 128 msleep(TPM_TIMEOUT); 131 129 } while (time_before(jiffies, stop)); ··· 537 535 wake_up_interruptible(&priv->read_queue); 538 536 if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT) 539 537 for (i = 0; i < 5; i++) 540 - if (check_locality(chip, i) >= 0) 538 + if (check_locality(chip, i)) 541 539 break; 542 540 if (interrupt & 543 541 (TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_STS_VALID_INT |