/*
* check_locality if the locality is active
* @param: chip, the tpm chip description
- * @return: the active locality or -EACCESS.
+ * @return: true if LOCALITY0 is active, otherwise false
*/
-static int check_locality(struct tpm_chip *chip)
+static bool check_locality(struct tpm_chip *chip)
{
struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
u8 data;
if (status && (data &
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
- return tpm_dev->locality;
+ return true;
- return -EACCES;
+ return false;
} /* check_locality() */
/*
long ret;
u8 data;
- if (check_locality(chip) == tpm_dev->locality)
+ if (check_locality(chip))
return tpm_dev->locality;
data = TPM_ACCESS_REQUEST_USE;
/* Request locality is usually effective after the request */
do {
- if (check_locality(chip) >= 0)
+ if (check_locality(chip))
return tpm_dev->locality;
msleep(TPM_TIMEOUT);
} while (time_before(jiffies, stop));
#define TPM_DATA_FIFO(l) (0x0005 | ((l) << 4))
#define TPM_DID_VID(l) (0x0006 | ((l) << 4))
-static int check_locality(struct tpm_chip *chip, int loc)
+static bool check_locality(struct tpm_chip *chip, int loc)
{
u8 buf;
int rc;
rc = iic_tpm_read(TPM_ACCESS(loc), &buf, 1);
if (rc < 0)
- return rc;
+ return false;
if ((buf & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) {
tpm_dev.locality = loc;
- return loc;
+ return true;
}
- return -EIO;
+ return false;
}
/* implementation similar to tpm_tis */
unsigned long stop;
u8 buf = TPM_ACCESS_REQUEST_USE;
- if (check_locality(chip, loc) >= 0)
+ if (check_locality(chip, loc))
return loc;
iic_tpm_write(TPM_ACCESS(loc), &buf, 1);
/* wait for burstcount */
stop = jiffies + chip->timeout_a;
do {
- if (check_locality(chip, loc) >= 0)
+ if (check_locality(chip, loc))
return loc;
usleep_range(TPM_TIMEOUT_US_LOW, TPM_TIMEOUT_US_HI);
} while (time_before(jiffies, stop));
return -1;
}
-static int check_locality(struct tpm_chip *chip, int l)
+static bool check_locality(struct tpm_chip *chip, int l)
{
struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
int rc;
rc = tpm_tis_read8(priv, TPM_ACCESS(l), &access);
if (rc < 0)
- return rc;
+ return false;
if ((access & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
- (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
- return priv->locality = l;
+ (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) {
+ priv->locality = l;
+ return true;
+ }
- return -1;
+ return false;
}
static void release_locality(struct tpm_chip *chip, int l, int force)
unsigned long stop, timeout;
long rc;
- if (check_locality(chip, l) >= 0)
+ if (check_locality(chip, l))
return l;
rc = tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_REQUEST_USE);
return -1;
rc = wait_event_interruptible_timeout(priv->int_queue,
(check_locality
- (chip, l) >= 0),
+ (chip, l)),
timeout);
if (rc > 0)
return l;
} else {
/* wait for burstcount */
do {
- if (check_locality(chip, l) >= 0)
+ if (check_locality(chip, l))
return l;
msleep(TPM_TIMEOUT);
} while (time_before(jiffies, stop));
wake_up_interruptible(&priv->read_queue);
if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT)
for (i = 0; i < 5; i++)
- if (check_locality(chip, i) >= 0)
+ if (check_locality(chip, i))
break;
if (interrupt &
(TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_STS_VALID_INT |