Commit f5595f5b authored by Jarkko Sakkinen's avatar Jarkko Sakkinen

tpm: Unify the send callback behaviour

The send() callback should never return length as it does not in every
driver except tpm_crb in the success case. The reason is that the main
transmit functionality only cares about whether the transmit was
successful or not and ignores the count completely.
Suggested-by: default avatarStefan Berger <stefanb@linux.ibm.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: default avatarStefan Berger <stefanb@linux.ibm.com>
Reviewed-by: default avatarJerry Snitselaar <jsnitsel@redhat.com>
Tested-by: default avatarAlexander Steffen <Alexander.Steffen@infineon.com>
parent 6ea3dfe1
...@@ -436,7 +436,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf, ...@@ -436,7 +436,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
goto out_err; goto out_err;
} }
return len; return 0;
out_err: out_err:
st33zp24_cancel(chip); st33zp24_cancel(chip);
release_locality(chip); release_locality(chip);
......
...@@ -230,10 +230,19 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, ...@@ -230,10 +230,19 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip,
if (rc < 0) { if (rc < 0) {
if (rc != -EPIPE) if (rc != -EPIPE)
dev_err(&chip->dev, dev_err(&chip->dev,
"%s: tpm_send: error %d\n", __func__, rc); "%s: send(): error %d\n", __func__, rc);
goto out; goto out;
} }
/* A sanity check. send() should just return zero on success e.g.
* not the command length.
*/
if (rc > 0) {
dev_warn(&chip->dev,
"%s: send(): invalid value %d\n", __func__, rc);
rc = 0;
}
if (chip->flags & TPM_CHIP_FLAG_IRQ) if (chip->flags & TPM_CHIP_FLAG_IRQ)
goto out_recv; goto out_recv;
......
...@@ -105,7 +105,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -105,7 +105,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
iowrite8(buf[i], priv->iobase); iowrite8(buf[i], priv->iobase);
} }
return count; return 0;
} }
static void tpm_atml_cancel(struct tpm_chip *chip) static void tpm_atml_cancel(struct tpm_chip *chip)
......
...@@ -65,7 +65,11 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -65,7 +65,11 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)
dev_dbg(&chip->dev, dev_dbg(&chip->dev,
"%s(buf=%*ph len=%0zx) -> sts=%d\n", __func__, "%s(buf=%*ph len=%0zx) -> sts=%d\n", __func__,
(int)min_t(size_t, 64, len), buf, len, status); (int)min_t(size_t, 64, len), buf, len, status);
if (status < 0)
return status; return status;
return 0;
} }
static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count) static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count)
......
...@@ -588,7 +588,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -588,7 +588,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
/* go and do it */ /* go and do it */
iic_tpm_write(TPM_STS(tpm_dev.locality), &sts, 1); iic_tpm_write(TPM_STS(tpm_dev.locality), &sts, 1);
return len; return 0;
out_err: out_err:
tpm_tis_i2c_ready(chip); tpm_tis_i2c_ready(chip);
/* The TPM needs some time to clean up here, /* The TPM needs some time to clean up here,
......
...@@ -465,7 +465,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -465,7 +465,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
} }
dev_dbg(dev, "%s() -> %zd\n", __func__, len); dev_dbg(dev, "%s() -> %zd\n", __func__, len);
return len; return 0;
} }
static bool i2c_nuvoton_req_canceled(struct tpm_chip *chip, u8 status) static bool i2c_nuvoton_req_canceled(struct tpm_chip *chip, u8 status)
......
...@@ -139,14 +139,14 @@ static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -139,14 +139,14 @@ static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
} }
/** /**
* tpm_ibmvtpm_send - Send tpm request * tpm_ibmvtpm_send() - Send a TPM command
*
* @chip: tpm chip struct * @chip: tpm chip struct
* @buf: buffer contains data to send * @buf: buffer contains data to send
* @count: size of buffer * @count: size of buffer
* *
* Return: * Return:
* Number of bytes sent or < 0 on error. * 0 on success,
* -errno on error
*/ */
static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
{ {
...@@ -192,7 +192,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -192,7 +192,7 @@ static int tpm_ibmvtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
rc = 0; rc = 0;
ibmvtpm->tpm_processing_cmd = false; ibmvtpm->tpm_processing_cmd = false;
} else } else
rc = count; rc = 0;
spin_unlock(&ibmvtpm->rtce_lock); spin_unlock(&ibmvtpm->rtce_lock);
return rc; return rc;
......
...@@ -354,7 +354,7 @@ static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count) ...@@ -354,7 +354,7 @@ static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count)
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
wait_and_send(chip, buf[i]); wait_and_send(chip, buf[i]);
} }
return count; return 0;
} }
static void tpm_inf_cancel(struct tpm_chip *chip) static void tpm_inf_cancel(struct tpm_chip *chip)
......
...@@ -226,7 +226,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count) ...@@ -226,7 +226,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count)
} }
outb(NSC_COMMAND_EOC, priv->base + NSC_COMMAND); outb(NSC_COMMAND_EOC, priv->base + NSC_COMMAND);
return count; return 0;
} }
static void tpm_nsc_cancel(struct tpm_chip *chip) static void tpm_nsc_cancel(struct tpm_chip *chip)
......
...@@ -481,7 +481,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len) ...@@ -481,7 +481,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len)
goto out_err; goto out_err;
} }
} }
return len; return 0;
out_err: out_err:
tpm_tis_ready(chip); tpm_tis_ready(chip);
return rc; return rc;
......
...@@ -335,7 +335,6 @@ static int vtpm_proxy_is_driver_command(struct tpm_chip *chip, ...@@ -335,7 +335,6 @@ static int vtpm_proxy_is_driver_command(struct tpm_chip *chip,
static int vtpm_proxy_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t count) static int vtpm_proxy_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t count)
{ {
struct proxy_dev *proxy_dev = dev_get_drvdata(&chip->dev); struct proxy_dev *proxy_dev = dev_get_drvdata(&chip->dev);
int rc = 0;
if (count > sizeof(proxy_dev->buffer)) { if (count > sizeof(proxy_dev->buffer)) {
dev_err(&chip->dev, dev_err(&chip->dev,
...@@ -366,7 +365,7 @@ static int vtpm_proxy_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -366,7 +365,7 @@ static int vtpm_proxy_tpm_op_send(struct tpm_chip *chip, u8 *buf, size_t count)
wake_up_interruptible(&proxy_dev->wq); wake_up_interruptible(&proxy_dev->wq);
return rc; return 0;
} }
static void vtpm_proxy_tpm_op_cancel(struct tpm_chip *chip) static void vtpm_proxy_tpm_op_cancel(struct tpm_chip *chip)
......
...@@ -173,7 +173,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) ...@@ -173,7 +173,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count)
return -ETIME; return -ETIME;
} }
return count; return 0;
} }
static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count) static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment