Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bce45a54 authored by Jarkko Sakkinen's avatar Jarkko Sakkinen Committed by Greg Kroah-Hartman
Browse files

tpm: Unify the send callback behaviour



commit f5595f5baa30e009bf54d0d7653a9a0cc465be60 upstream.

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>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent af0c1bd0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -436,7 +436,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
			goto out_err;
	}

	return len;
	return 0;
out_err:
	st33zp24_cancel(chip);
	release_locality(chip);
+10 −1
Original line number Diff line number Diff line
@@ -495,10 +495,19 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip,
	if (rc < 0) {
		if (rc != -EPIPE)
			dev_err(&chip->dev,
				"%s: tpm_send: error %d\n", __func__, rc);
				"%s: send(): error %d\n", __func__, rc);
		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)
		goto out_recv;

+1 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
		iowrite8(buf[i], priv->iobase);
	}

	return count;
	return 0;
}

static void tpm_atml_cancel(struct tpm_chip *chip)
+5 −1
Original line number Diff line number Diff line
@@ -65,7 +65,11 @@ static int i2c_atmel_send(struct tpm_chip *chip, u8 *buf, size_t len)
	dev_dbg(&chip->dev,
		"%s(buf=%*ph len=%0zx) -> sts=%d\n", __func__,
		(int)min_t(size_t, 64, len), buf, len, status);

	if (status < 0)
		return status;

	return 0;
}

static int i2c_atmel_recv(struct tpm_chip *chip, u8 *buf, size_t count)
+1 −1
Original line number Diff line number Diff line
@@ -587,7 +587,7 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
	/* go and do it */
	iic_tpm_write(TPM_STS(tpm_dev.locality), &sts, 1);

	return len;
	return 0;
out_err:
	tpm_tis_i2c_ready(chip);
	/* The TPM needs some time to clean up here,
Loading