Commit 47a6c28b authored by Jarkko Sakkinen's avatar Jarkko Sakkinen
Browse files

tpm: remove @flags from tpm_transmit()



Remove @flags from tpm_transmit() API. It is no longer used for
anything.

Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: default avatarStefan Berger <stefanb@linux.ibm.com>
Tested-by: default avatarStefan Berger <stefanb@linux.ibm.com>
Reviewed-by: default avatarJerry Snitselaar <jsnitsel@redhat.com>
Reviewed-by: default avatarJames Bottomley <James.Bottomley@HansenPartnership.com>
Tested-by: default avatarAlexander Steffen <Alexander.Steffen@infineon.com>
parent a3fbfae8
Loading
Loading
Loading
Loading
+19 −21
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ struct class *tpm_class;
struct class *tpmrm_class;
dev_t tpm_devt;

static int tpm_request_locality(struct tpm_chip *chip, unsigned int flags)
static int tpm_request_locality(struct tpm_chip *chip)
{
	int rc;

@@ -52,7 +52,7 @@ static int tpm_request_locality(struct tpm_chip *chip, unsigned int flags)
	return 0;
}

static void tpm_relinquish_locality(struct tpm_chip *chip, unsigned int flags)
static void tpm_relinquish_locality(struct tpm_chip *chip)
{
	int rc;

@@ -66,7 +66,7 @@ static void tpm_relinquish_locality(struct tpm_chip *chip, unsigned int flags)
	chip->locality = -1;
}

static int tpm_cmd_ready(struct tpm_chip *chip, unsigned int flags)
static int tpm_cmd_ready(struct tpm_chip *chip)
{
	if (!chip->ops->cmd_ready)
		return 0;
@@ -74,7 +74,7 @@ static int tpm_cmd_ready(struct tpm_chip *chip, unsigned int flags)
	return chip->ops->cmd_ready(chip);
}

static int tpm_go_idle(struct tpm_chip *chip, unsigned int flags)
static int tpm_go_idle(struct tpm_chip *chip)
{
	if (!chip->ops->go_idle)
		return 0;
@@ -85,13 +85,12 @@ static int tpm_go_idle(struct tpm_chip *chip, unsigned int flags)
/**
 * tpm_chip_start() - power on the TPM
 * @chip:	a TPM chip to use
 * @flags:	TPM transmit flags
 *
 * Return:
 * * The response length	- OK
 * * -errno			- A system error
 */
int tpm_chip_start(struct tpm_chip *chip, unsigned int flags)
int tpm_chip_start(struct tpm_chip *chip)
{
	int ret;

@@ -99,16 +98,16 @@ int tpm_chip_start(struct tpm_chip *chip, unsigned int flags)
		chip->ops->clk_enable(chip, true);

	if (chip->locality == -1) {
		ret = tpm_request_locality(chip, flags);
		ret = tpm_request_locality(chip);
		if (ret) {
			chip->ops->clk_enable(chip, false);
			return ret;
		}
	}

	ret = tpm_cmd_ready(chip, flags);
	ret = tpm_cmd_ready(chip);
	if (ret) {
		tpm_relinquish_locality(chip, flags);
		tpm_relinquish_locality(chip);
		if (chip->ops->clk_enable)
			chip->ops->clk_enable(chip, false);
		return ret;
@@ -121,16 +120,15 @@ EXPORT_SYMBOL_GPL(tpm_chip_start);
/**
 * tpm_chip_stop() - power off the TPM
 * @chip:	a TPM chip to use
 * @flags:	TPM transmit flags
 *
 * Return:
 * * The response length	- OK
 * * -errno			- A system error
 */
void tpm_chip_stop(struct tpm_chip *chip, unsigned int flags)
void tpm_chip_stop(struct tpm_chip *chip)
{
	tpm_go_idle(chip, flags);
	tpm_relinquish_locality(chip, flags);
	tpm_go_idle(chip);
	tpm_relinquish_locality(chip);
	if (chip->ops->clk_enable)
		chip->ops->clk_enable(chip, false);
}
@@ -158,7 +156,7 @@ int tpm_try_get_ops(struct tpm_chip *chip)
		goto out_ops;

	mutex_lock(&chip->tpm_mutex);
	rc = tpm_chip_start(chip, 0);
	rc = tpm_chip_start(chip);
	if (rc)
		goto out_lock;

@@ -181,7 +179,7 @@ EXPORT_SYMBOL_GPL(tpm_try_get_ops);
 */
void tpm_put_ops(struct tpm_chip *chip)
{
	tpm_chip_stop(chip, 0);
	tpm_chip_stop(chip);
	mutex_unlock(&chip->tpm_mutex);
	up_read(&chip->ops_sem);
	put_device(&chip->dev);
@@ -297,9 +295,9 @@ static int tpm_class_shutdown(struct device *dev)

	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
		down_write(&chip->ops_sem);
		if (!tpm_chip_start(chip, 0)) {
		if (!tpm_chip_start(chip)) {
			tpm2_shutdown(chip, TPM2_SU_CLEAR);
			tpm_chip_stop(chip, 0);
			tpm_chip_stop(chip);
		}
		chip->ops = NULL;
		up_write(&chip->ops_sem);
@@ -480,9 +478,9 @@ static void tpm_del_char_device(struct tpm_chip *chip)
	/* Make the driver uncallable. */
	down_write(&chip->ops_sem);
	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
		if (!tpm_chip_start(chip, 0)) {
		if (!tpm_chip_start(chip)) {
			tpm2_shutdown(chip, TPM2_SU_CLEAR);
			tpm_chip_stop(chip, 0);
			tpm_chip_stop(chip);
		}
	}
	chip->ops = NULL;
@@ -566,11 +564,11 @@ int tpm_chip_register(struct tpm_chip *chip)
{
	int rc;

	rc = tpm_chip_start(chip, 0);
	rc = tpm_chip_start(chip);
	if (rc)
		return rc;
	rc = tpm_auto_startup(chip);
	tpm_chip_stop(chip, 0);
	tpm_chip_stop(chip);
	if (rc)
		return rc;

+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ static ssize_t tpm_dev_transmit(struct tpm_chip *chip, struct tpm_space *space,
	if (ret)
		goto out_rc;

	len = tpm_transmit(chip, buf, bufsiz, 0);
	len = tpm_transmit(chip, buf, bufsiz);
	if (len < 0)
		ret = len;

+8 −14
Original line number Diff line number Diff line
@@ -62,8 +62,7 @@ unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal)
}
EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration);

static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz,
				unsigned int flags)
static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
{
	struct tpm_header *header = buf;
	int rc;
@@ -143,7 +142,6 @@ out_recv:
 * @chip:	a TPM chip to use
 * @buf:	a TPM command buffer
 * @bufsiz:	length of the TPM command buffer
 * @flags:	TPM transmit flags
 *
 * A wrapper around tpm_try_transmit() that handles TPM2_RC_RETRY returns from
 * the TPM and retransmits the command after a delay up to a maximum wait of
@@ -156,8 +154,7 @@ out_recv:
 * * The response length	- OK
 * * -errno			- A system error
 */
ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
		     unsigned int flags)
ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz)
{
	struct tpm_header *header = (struct tpm_header *)buf;
	/* space for header and handles */
@@ -177,7 +174,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
	memcpy(save, buf, save_size);

	for (;;) {
		ret = tpm_try_transmit(chip, buf, bufsiz, flags);
		ret = tpm_try_transmit(chip, buf, bufsiz);
		if (ret < 0)
			break;
		rc = be32_to_cpu(header->return_code);
@@ -210,7 +207,6 @@ ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
 * @chip:			a TPM chip to use
 * @buf:			a TPM command buffer
 * @min_rsp_body_length:	minimum expected length of response body
 * @flags:			TPM transmit flags
 * @desc:			command description used in the error message
 *
 * Return:
@@ -219,14 +215,13 @@ ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
 * * TPM_RC	- A TPM error
 */
ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
			 size_t min_rsp_body_length, unsigned int flags,
			 const char *desc)
			 size_t min_rsp_body_length, const char *desc)
{
	const struct tpm_header *header = (struct tpm_header *)buf->data;
	int err;
	ssize_t len;

	len = tpm_transmit(chip, buf->data, PAGE_SIZE, flags);
	len = tpm_transmit(chip, buf->data, PAGE_SIZE);
	if (len <  0)
		return len;

@@ -375,8 +370,7 @@ int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
		goto out;

	memcpy(buf.data, cmd, buflen);
	rc = tpm_transmit_cmd(chip, &buf, 0, 0,
			      "attempting to a send a command");
	rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to a send a command");
	tpm_buf_destroy(&buf);
out:
	tpm_put_ops(chip);
@@ -416,9 +410,9 @@ int tpm_pm_suspend(struct device *dev)

	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
		mutex_lock(&chip->tpm_mutex);
		if (!tpm_chip_start(chip, 0)) {
		if (!tpm_chip_start(chip)) {
			tpm2_shutdown(chip, TPM2_SU_STATE);
			tpm_chip_stop(chip, 0);
			tpm_chip_stop(chip);
		}
		mutex_unlock(&chip->tpm_mutex);
	} else {
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ static ssize_t pubek_show(struct device *dev, struct device_attribute *attr,
	tpm_buf_append(&tpm_buf, anti_replay, sizeof(anti_replay));

	if (tpm_transmit_cmd(chip, &tpm_buf, READ_PUBEK_RESULT_MIN_BODY_SIZE,
			      0, "attempting to read the PUBEK"))
			     "attempting to read the PUBEK"))
		goto out_buf;

	out = (struct tpm_readpubek_out *)&tpm_buf.data[10];
+5 −8
Original line number Diff line number Diff line
@@ -485,11 +485,9 @@ extern const struct file_operations tpm_fops;
extern const struct file_operations tpmrm_fops;
extern struct idr dev_nums_idr;

ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz,
		     unsigned int flags);
ssize_t tpm_transmit(struct tpm_chip *chip, u8 *buf, size_t bufsiz);
ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_buf *buf,
			 size_t min_rsp_body_length, unsigned int flags,
			 const char *desc);
			 size_t min_rsp_body_length, const char *desc);
int tpm_get_timeouts(struct tpm_chip *);
int tpm_auto_startup(struct tpm_chip *chip);

@@ -514,8 +512,8 @@ static inline void tpm_msleep(unsigned int delay_msec)
		     delay_msec * 1000);
};

int tpm_chip_start(struct tpm_chip *chip, unsigned int flags);
void tpm_chip_stop(struct tpm_chip *chip, unsigned int flags);
int tpm_chip_start(struct tpm_chip *chip);
void tpm_chip_stop(struct tpm_chip *chip);
struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip);
__must_check int tpm_try_get_ops(struct tpm_chip *chip);
void tpm_put_ops(struct tpm_chip *chip);
@@ -548,8 +546,7 @@ int tpm2_pcr_read(struct tpm_chip *chip, u32 pcr_idx, u8 *res_buf);
int tpm2_pcr_extend(struct tpm_chip *chip, u32 pcr_idx, u32 count,
		    struct tpm2_digest *digests);
int tpm2_get_random(struct tpm_chip *chip, u8 *dest, size_t max);
void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle,
			    unsigned int flags);
void tpm2_flush_context(struct tpm_chip *chip, u32 handle);
int tpm2_seal_trusted(struct tpm_chip *chip,
		      struct trusted_key_payload *payload,
		      struct trusted_key_options *options);
Loading