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

Commit 6e599f6f authored by Christophe Ricard's avatar Christophe Ricard Committed by Jarkko Sakkinen
Browse files

tpm: drop 'read_queue' from struct tpm_vendor_specific



Dropped the field 'read_queue' from struct tpm_vendor_specific and make it
available to the various private structures in the drivers.

Signed-off-by: default avatarChristophe Ricard <christophe-h.ricard@st.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
parent 570a3609
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -338,7 +338,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
	       wait_for_stat(chip,
			     TPM_STS_DATA_AVAIL | TPM_STS_VALID,
			     chip->vendor.timeout_c,
			     &chip->vendor.read_queue, true) == 0) {
			     &tpm_dev->read_queue, true) == 0) {
		burstcnt = get_burstcount(chip);
		if (burstcnt < 0)
			return burstcnt;
@@ -367,7 +367,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
	tpm_dev = (struct st33zp24_dev *)TPM_VPRIV(chip);

	tpm_dev->intrs++;
	wake_up_interruptible(&chip->vendor.read_queue);
	wake_up_interruptible(&tpm_dev->read_queue);
	disable_irq_nosync(tpm_dev->irq);

	return IRQ_HANDLED;
@@ -407,7 +407,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
		st33zp24_cancel(chip);
		if (wait_for_stat
		    (chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b,
		     &chip->vendor.read_queue, false) < 0) {
		     &tpm_dev->read_queue, false) < 0) {
			ret = -ETIME;
			goto out_err;
		}
@@ -453,7 +453,7 @@ static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,

		ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
				tpm_calc_ordinal_duration(chip, ordinal),
				&chip->vendor.read_queue, false);
				&tpm_dev->read_queue, false);
		if (ret < 0)
			goto out_err;
	}
@@ -570,7 +570,7 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,

	if (irq) {
		/* INTERRUPT Setup */
		init_waitqueue_head(&chip->vendor.read_queue);
		init_waitqueue_head(&tpm_dev->read_queue);
		tpm_dev->intrs = 0;

		if (request_locality(chip) != LOCALITY0) {
@@ -674,7 +674,7 @@ int st33zp24_pm_resume(struct device *dev)
		gpio_set_value(tpm_dev->io_lpcpd, 1);
		ret = wait_for_stat(chip,
				TPM_STS_VALID, chip->vendor.timeout_b,
				&chip->vendor.read_queue, false);
				&tpm_dev->read_queue, false);
	} else {
		ret = tpm_pm_resume(dev);
		if (!ret)
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ struct st33zp24_dev {
	int irq;
	u32 intrs;
	int io_lpcpd;
	wait_queue_head_t read_queue;
};


+0 −2
Original line number Diff line number Diff line
@@ -137,8 +137,6 @@ struct tpm_vendor_specific {
	unsigned long duration[3]; /* jiffies */
	bool duration_adjusted;
	void *priv;

	wait_queue_head_t read_queue;
};

#define TPM_VPRIV(c)     ((c)->vendor.priv)
+9 −5
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@
struct priv_data {
	int irq;
	unsigned int intrs;
	wait_queue_head_t read_queue;
};

static s32 i2c_nuvoton_read_buf(struct i2c_client *client, u8 offset, u8 size,
@@ -232,13 +233,14 @@ static int i2c_nuvoton_wait_for_data_avail(struct tpm_chip *chip, u32 timeout,
static int i2c_nuvoton_recv_data(struct i2c_client *client,
				 struct tpm_chip *chip, u8 *buf, size_t count)
{
	struct priv_data *priv = chip->vendor.priv;
	s32 rc;
	int burst_count, bytes2read, size = 0;

	while (size < count &&
	       i2c_nuvoton_wait_for_data_avail(chip,
					       chip->vendor.timeout_c,
					       &chip->vendor.read_queue) == 0) {
					       &priv->read_queue) == 0) {
		burst_count = i2c_nuvoton_get_burstcount(client, chip);
		if (burst_count < 0) {
			dev_err(&chip->dev,
@@ -265,6 +267,7 @@ static int i2c_nuvoton_recv_data(struct i2c_client *client,
/* Read TPM command results */
static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
{
	struct priv_data *priv = chip->vendor.priv;
	struct device *dev = chip->dev.parent;
	struct i2c_client *client = to_i2c_client(dev);
	s32 rc;
@@ -286,7 +289,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
		 * tag, paramsize, and result
		 */
		status = i2c_nuvoton_wait_for_data_avail(
			chip, chip->vendor.timeout_c, &chip->vendor.read_queue);
			chip, chip->vendor.timeout_c, &priv->read_queue);
		if (status != 0) {
			dev_err(dev, "%s() timeout on dataAvail\n", __func__);
			size = -ETIMEDOUT;
@@ -348,6 +351,7 @@ static int i2c_nuvoton_recv(struct tpm_chip *chip, u8 *buf, size_t count)
 */
static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
{
	struct priv_data *priv = chip->vendor.priv;
	struct device *dev = chip->dev.parent;
	struct i2c_client *client = to_i2c_client(dev);
	u32 ordinal;
@@ -440,7 +444,7 @@ static int i2c_nuvoton_send(struct tpm_chip *chip, u8 *buf, size_t len)
	rc = i2c_nuvoton_wait_for_data_avail(chip,
					     tpm_calc_ordinal_duration(chip,
								       ordinal),
					     &chip->vendor.read_queue);
					     &priv->read_queue);
	if (rc) {
		dev_err(dev, "%s() timeout command duration\n", __func__);
		i2c_nuvoton_ready(chip);
@@ -477,7 +481,7 @@ static irqreturn_t i2c_nuvoton_int_handler(int dummy, void *dev_id)
	struct priv_data *priv = chip->vendor.priv;

	priv->intrs++;
	wake_up(&chip->vendor.read_queue);
	wake_up(&priv->read_queue);
	disable_irq_nosync(priv->irq);
	return IRQ_HANDLED;
}
@@ -541,7 +545,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
		return -ENOMEM;
	chip->vendor.priv = priv;

	init_waitqueue_head(&chip->vendor.read_queue);
	init_waitqueue_head(&priv->read_queue);

	/* Default timeouts */
	chip->vendor.timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT);
+5 −4
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ struct priv_data {
	int irq;
	bool irq_tested;
	wait_queue_head_t int_queue;
	wait_queue_head_t read_queue;
};

#if defined(CONFIG_PNP) && defined(CONFIG_ACPI)
@@ -252,7 +253,7 @@ static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
	       wait_for_tpm_stat(chip,
				 TPM_STS_DATA_AVAIL | TPM_STS_VALID,
				 chip->vendor.timeout_c,
				 &chip->vendor.read_queue, true)
				 &priv->read_queue, true)
	       == 0) {
		burstcnt = get_burstcount(chip);
		for (; burstcnt > 0 && size < count; burstcnt--)
@@ -421,7 +422,7 @@ static int tpm_tis_send_main(struct tpm_chip *chip, u8 *buf, size_t len)

		if (wait_for_tpm_stat
		    (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, dur,
		     &chip->vendor.read_queue, false) < 0) {
		     &priv->read_queue, false) < 0) {
			rc = -ETIME;
			goto out_err;
		}
@@ -575,7 +576,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)

	((struct priv_data *)chip->vendor.priv)->irq_tested = true;
	if (interrupt & TPM_INTF_DATA_AVAIL_INT)
		wake_up_interruptible(&chip->vendor.read_queue);
		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)
@@ -795,7 +796,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
	}

	/* INTERRUPT Setup */
	init_waitqueue_head(&chip->vendor.read_queue);
	init_waitqueue_head(&priv->read_queue);
	init_waitqueue_head(&priv->int_queue);
	if (interrupts && tpm_info->irq != -1) {
		if (tpm_info->irq) {
Loading