tpm: tpm_tis_i2c: Drop struct tpm_vendor_specific

This function is misnamed since it only applies to a single driver. Merge
its fields into its parent.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
diff --git a/drivers/tpm/tpm_tis_i2c.c b/drivers/tpm/tpm_tis_i2c.c
index 6a3991f..3ae1a4e 100644
--- a/drivers/tpm/tpm_tis_i2c.c
+++ b/drivers/tpm/tpm_tis_i2c.c
@@ -531,7 +531,7 @@
 		return rc;
 
 	if ((buf & mask) == mask) {
-		chip->vendor.locality = loc;
+		chip->locality = loc;
 		return loc;
 	}
 
@@ -567,7 +567,7 @@
 
 	/* Wait for burstcount */
 	start = get_timer(0);
-	stop = chip->vendor.timeout_a;
+	stop = chip->timeout_a;
 	do {
 		if (check_locality(chip, loc) >= 0)
 			return loc;
@@ -582,7 +582,7 @@
 	/* NOTE: Since i2c read may fail, return 0 in this case --> time-out */
 	u8 buf;
 
-	if (iic_tpm_read(TPM_STS(chip->vendor.locality), &buf, 1) < 0)
+	if (iic_tpm_read(TPM_STS(chip->locality), &buf, 1) < 0)
 		return 0;
 	else
 		return buf;
@@ -596,7 +596,7 @@
 	u8 buf = TPM_STS_COMMAND_READY;
 
 	debug("%s\n", __func__);
-	rc = iic_tpm_write_long(TPM_STS(chip->vendor.locality), &buf, 1);
+	rc = iic_tpm_write_long(TPM_STS(chip->locality), &buf, 1);
 	if (rc)
 		debug("%s: rc=%d\n", __func__, rc);
 }
@@ -610,10 +610,10 @@
 	/* Wait for burstcount */
 	/* XXX: Which timeout value? Spec has 2 answers (c & d) */
 	start = get_timer(0);
-	stop = chip->vendor.timeout_d;
+	stop = chip->timeout_d;
 	do {
 		/* Note: STS is little endian */
-		addr = TPM_STS(chip->vendor.locality) + 1;
+		addr = TPM_STS(chip->locality) + 1;
 		if (iic_tpm_read(addr, buf, 3) < 0)
 			burstcnt = 0;
 		else
@@ -666,7 +666,7 @@
 		if (burstcnt > (count - size))
 			burstcnt = count - size;
 
-		rc = iic_tpm_read(TPM_DATA_FIFO(chip->vendor.locality),
+		rc = iic_tpm_read(TPM_DATA_FIFO(chip->locality),
 				&(buf[size]), burstcnt);
 		if (rc == 0)
 			size += burstcnt;
@@ -708,7 +708,7 @@
 		goto out;
 	}
 
-	wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, &status);
+	wait_for_stat(chip, TPM_STS_VALID, chip->timeout_c, &status);
 	if (status & TPM_STS_DATA_AVAIL) {  /* Retry? */
 		error("Error left over data\n");
 		size = -EIO;
@@ -722,7 +722,7 @@
 	 * so we sleep rather than keeping the bus busy
 	 */
 	udelay(2000);
-	release_locality(chip, chip->vendor.locality, 0);
+	release_locality(chip, chip->locality, 0);
 
 	return size;
 }
@@ -746,7 +746,7 @@
 	if ((status & TPM_STS_COMMAND_READY) == 0) {
 		tpm_tis_i2c_ready(chip);
 		if (wait_for_stat(chip, TPM_STS_COMMAND_READY,
-				  chip->vendor.timeout_b, &status) < 0) {
+				  chip->timeout_b, &status) < 0) {
 			rc = -ETIME;
 			goto out_err;
 		}
@@ -768,7 +768,7 @@
 			burstcnt = CONFIG_TPM_TIS_I2C_BURST_LIMITATION;
 #endif /* CONFIG_TPM_TIS_I2C_BURST_LIMITATION */
 
-		rc = iic_tpm_write(TPM_DATA_FIFO(chip->vendor.locality),
+		rc = iic_tpm_write(TPM_DATA_FIFO(chip->locality),
 				&(buf[count]), burstcnt);
 		if (rc == 0)
 			count += burstcnt;
@@ -779,7 +779,7 @@
 				goto out_err;
 			}
 			rc = wait_for_stat(chip, TPM_STS_VALID,
-					   chip->vendor.timeout_c, &status);
+					   chip->timeout_c, &status);
 			if (rc)
 				goto out_err;
 
@@ -791,7 +791,7 @@
 	}
 
 	/* Go and do it */
-	iic_tpm_write(TPM_STS(chip->vendor.locality), &sts, 1);
+	iic_tpm_write(TPM_STS(chip->locality), &sts, 1);
 	debug("done\n");
 
 	return len;
@@ -804,18 +804,11 @@
 	 * so we sleep rather than keeping the bus busy
 	 */
 	udelay(2000);
-	release_locality(chip, chip->vendor.locality, 0);
+	release_locality(chip, chip->locality, 0);
 
 	return rc;
 }
 
-static struct tpm_vendor_specific tpm_tis_i2c = {
-	.req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
-	.req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
-	.req_canceled = TPM_STS_COMMAND_READY,
-};
-
-
 static enum i2c_chip_type tpm_vendor_chip_type(void)
 {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
@@ -832,25 +825,25 @@
 
 int tpm_vendor_init(struct udevice *dev)
 {
-	struct tpm_chip *chip;
+	struct tpm_chip *chip = &g_chip;
 	u32 vendor;
 	u32 expected_did_vid;
 
 	tpm_dev.dev = dev;
 	tpm_dev.chip_type = tpm_vendor_chip_type();
-
-	chip = tpm_register_hardware(&tpm_tis_i2c);
-	if (chip < 0)
-		return -ENODEV;
+	chip->is_open = 1;
 
 	/* Disable interrupts (not supported) */
-	chip->vendor.irq = 0;
+	chip->irq = 0;
 
 	/* Default timeouts */
-	chip->vendor.timeout_a = TIS_SHORT_TIMEOUT;
-	chip->vendor.timeout_b = TIS_LONG_TIMEOUT;
-	chip->vendor.timeout_c = TIS_SHORT_TIMEOUT;
-	chip->vendor.timeout_d = TIS_SHORT_TIMEOUT;
+	chip->timeout_a = TIS_SHORT_TIMEOUT;
+	chip->timeout_b = TIS_LONG_TIMEOUT;
+	chip->timeout_c = TIS_SHORT_TIMEOUT;
+	chip->timeout_d = TIS_SHORT_TIMEOUT;
+	chip->req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID;
+	chip->req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID;
+	chip->req_canceled = TPM_STS_COMMAND_READY;
 
 	if (request_locality(chip, 0) < 0)
 		return  -ENODEV;
@@ -887,7 +880,7 @@
 
 void tpm_vendor_cleanup(struct tpm_chip *chip)
 {
-	release_locality(chip, chip->vendor.locality, 1);
+	release_locality(chip, chip->locality, 1);
 }
 
 /* Returns max number of milliseconds to wait */
@@ -906,7 +899,7 @@
 	}
 
 	if (duration_idx != TPM_UNDEFINED)
-		duration = chip->vendor.duration[duration_idx];
+		duration = chip->duration[duration_idx];
 
 	if (duration <= 0)
 		return 2 * 60 * HZ; /* Two minutes timeout */
@@ -943,7 +936,7 @@
 		goto out;
 	}
 
-	if (chip->vendor.irq)
+	if (chip->irq)
 		goto out_recv;
 
 	start = get_timer(0);
@@ -951,13 +944,13 @@
 	do {
 		debug("waiting for status... %ld %ld\n", start, stop);
 		u8 status = tpm_tis_i2c_status(chip);
-		if ((status & chip->vendor.req_complete_mask) ==
-		    chip->vendor.req_complete_val) {
+		if ((status & chip->req_complete_mask) ==
+		    chip->req_complete_val) {
 			debug("...got it;\n");
 			goto out_recv;
 		}
 
-		if (status == chip->vendor.req_canceled) {
+		if (status == chip->req_canceled) {
 			error("Operation Canceled\n");
 			rc = -ECANCELED;
 			goto out;
@@ -1062,18 +1055,6 @@
 	return 0;
 }
 
-struct tpm_chip *tpm_register_hardware(const struct tpm_vendor_specific *entry)
-{
-	struct tpm_chip *chip;
-
-	/* Driver specific per-device data */
-	chip = &g_chip;
-	memcpy(&chip->vendor, entry, sizeof(struct tpm_vendor_specific));
-	chip->is_open = 1;
-
-	return chip;
-}
-
 int tis_init(void)
 {
 	if (tpm.inited)
diff --git a/drivers/tpm/tpm_tis_i2c.h b/drivers/tpm/tpm_tis_i2c.h
index 426c519..2a4ad77 100644
--- a/drivers/tpm/tpm_tis_i2c.h
+++ b/drivers/tpm/tpm_tis_i2c.h
@@ -35,21 +35,17 @@
 
 struct tpm_chip;
 
-struct tpm_vendor_specific {
-	const u8 req_complete_mask;
-	const u8 req_complete_val;
-	const u8 req_canceled;
+struct tpm_chip {
+	int is_open;
+	u8 req_complete_mask;
+	u8 req_complete_val;
+	u8 req_canceled;
 	int irq;
 	int locality;
 	unsigned long timeout_a, timeout_b, timeout_c, timeout_d;  /* msec */
 	unsigned long duration[3];  /* msec */
 };
 
-struct tpm_chip {
-	int is_open;
-	struct tpm_vendor_specific vendor;
-};
-
 struct tpm_input_header {
 	__be16 tag;
 	__be32 length;
@@ -106,8 +102,6 @@
 	union tpm_cmd_params params;
 } __packed;
 
-struct tpm_chip *tpm_register_hardware(const struct tpm_vendor_specific *);
-
 struct udevice;
 int tpm_vendor_init(struct udevice *dev);