From patchwork Sat Mar 26 07:00:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Ricard X-Patchwork-Id: 8674261 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 42EB99F44D for ; Sat, 26 Mar 2016 07:00:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C051B20260 for ; Sat, 26 Mar 2016 07:00:44 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4CD8920259 for ; Sat, 26 Mar 2016 07:00:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ajiD9-0001nf-VT; Sat, 26 Mar 2016 07:00:39 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1ajiD8-0001nT-At for tpmdd-devel@lists.sourceforge.net; Sat, 26 Mar 2016 07:00:38 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.67 as permitted sender) client-ip=74.125.82.67; envelope-from=christophe.ricard@gmail.com; helo=mail-wm0-f67.google.com; Received: from mail-wm0-f67.google.com ([74.125.82.67]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1ajiD6-0001j4-VN for tpmdd-devel@lists.sourceforge.net; Sat, 26 Mar 2016 07:00:38 +0000 Received: by mail-wm0-f67.google.com with SMTP id u125so8179740wmg.0 for ; Sat, 26 Mar 2016 00:00:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2TfCoO5m5Yvt+auHfEOoZ3ED4lHgKaKXcj6u9nr9OY4=; b=F40rMWW99mvsBd8qtSIGb4AlKodbOerxI0omVxQpNP5FTaaWBfOWJYzpDa5Xzdunw3 2wCY9l+7drfcWxWPak341uJ+PWqLs7Gq6pqk+ubSSH0vAEIfRJ2as8k2PS75ECnvYHUP KSifAmRUXghJKPYDNt13eqNHW0dMdDoZ76D7hOuXUM4/sHu+JKpA9ExIsNP4J1j7cTCD N5MCl5PjITr11CPnXbRd7cN367u/hjZbBqcYhwu7fzhMilDp314k181yvX3d94/bD9D3 M9ZAlaVtdWVsypM8VLeP2NvSIJdpxRh7nAlHMsr53JRFejcaCqwIM3bidTbSY/idyAU/ w4AA== X-Gm-Message-State: AD7BkJIIXYi+bgS7tyJt7J+evRpCkEHecKhOoTmJ+nDvOLbSuhmZt3+36dg4HV0sGAbgWg== X-Received: by 10.28.95.131 with SMTP id t125mr497338wmb.80.1458975630984; Sat, 26 Mar 2016 00:00:30 -0700 (PDT) Received: from localhost.localdomain (ax113-6-78-236-204-66.fbx.proxad.net. [78.236.204.66]) by smtp.gmail.com with ESMTPSA id lz5sm14978102wjb.5.2016.03.26.00.00.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 26 Mar 2016 00:00:30 -0700 (PDT) From: Christophe Ricard X-Google-Original-From: Christophe Ricard To: jarkko.sakkinen@linux.intel.com Date: Sat, 26 Mar 2016 08:00:15 +0100 Message-Id: <1458975615-8095-8-git-send-email-christophe-h.ricard@st.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458975615-8095-1-git-send-email-christophe-h.ricard@st.com> References: <1458975615-8095-1-git-send-email-christophe-h.ricard@st.com> X-Spam-Score: -1.6 (-) X-Headers-End: 1ajiD6-0001j4-VN Cc: jean-luc.blanc@st.com, ashley@ashleylai.com, tpmdd-devel@lists.sourceforge.net, christophe-h.ricard@st.com, benoit.houyere@st.com Subject: [tpmdd-devel] [PATCH v2 7/7] tpm: drop 'read_queue' from struct tpm_vendor_specific X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Christophe Ricard --- drivers/char/tpm/st33zp24/st33zp24.c | 12 ++++++------ drivers/char/tpm/st33zp24/st33zp24.h | 1 + drivers/char/tpm/tpm.h | 6 ------ drivers/char/tpm/tpm_i2c_nuvoton.c | 14 +++++++++----- drivers/char/tpm/tpm_tis.c | 9 +++++---- drivers/char/tpm/xen-tpmfront.c | 11 ++++++----- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/char/tpm/st33zp24/st33zp24.c b/drivers/char/tpm/st33zp24/st33zp24.c index 2834c6f..ca3bad1 100644 --- a/drivers/char/tpm/st33zp24/st33zp24.c +++ b/drivers/char/tpm/st33zp24/st33zp24.c @@ -324,7 +324,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->timeout_c, - &chip->vendor.read_queue, true) == 0) { + &tpm_dev->read_queue, true) == 0) { burstcnt = get_burstcount(chip); if (burstcnt < 0) return burstcnt; @@ -351,7 +351,7 @@ static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id) struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev); 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; @@ -389,7 +389,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->timeout_b, - &chip->vendor.read_queue, false) < 0) { + &tpm_dev->read_queue, false) < 0) { ret = -ETIME; goto out_err; } @@ -435,7 +435,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; } @@ -552,7 +552,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) { @@ -652,7 +652,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->timeout_b, - &chip->vendor.read_queue, false); + &tpm_dev->read_queue, false); } else { ret = tpm_pm_resume(dev); if (!ret) diff --git a/drivers/char/tpm/st33zp24/st33zp24.h b/drivers/char/tpm/st33zp24/st33zp24.h index b139a8d..e687942 100644 --- a/drivers/char/tpm/st33zp24/st33zp24.h +++ b/drivers/char/tpm/st33zp24/st33zp24.h @@ -27,6 +27,7 @@ struct st33zp24_dev { int irq; u32 intrs; int io_lpcpd; + wait_queue_head_t read_queue; }; struct st33zp24_phy_ops { diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index cfd5420..765ac0c 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -128,12 +128,6 @@ enum tpm2_startup_types { TPM2_SU_STATE = 0x0001, }; -struct tpm_chip; - -struct tpm_vendor_specific { - wait_queue_head_t read_queue; -}; - #define TPM_VID_INTEL 0x8086 #define TPM_VID_WINBOND 0x1050 #define TPM_VID_STM 0x104A diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c index 97f0e1a..fda5e22 100644 --- a/drivers/char/tpm/tpm_i2c_nuvoton.c +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c @@ -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 = dev_get_drvdata(&chip->dev); s32 rc; int burst_count, bytes2read, size = 0; while (size < count && i2c_nuvoton_wait_for_data_avail(chip, chip->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 = dev_get_drvdata(&chip->dev); 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->timeout_c, &chip->vendor.read_queue); + chip, chip->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 = dev_get_drvdata(&chip->dev); 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 = dev_get_drvdata(&chip->dev); priv->intrs++; - wake_up(&chip->vendor.read_queue); + wake_up(&priv->read_queue); disable_irq_nosync(priv->irq); return IRQ_HANDLED; } @@ -540,7 +544,7 @@ static int i2c_nuvoton_probe(struct i2c_client *client, if (!priv) return -ENOMEM; - init_waitqueue_head(&chip->vendor.read_queue); + init_waitqueue_head(&priv->read_queue); /* Default timeouts */ chip->timeout_a = msecs_to_jiffies(TPM_I2C_SHORT_TIMEOUT); diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c index 1ec4992..5416ad8 100644 --- a/drivers/char/tpm/tpm_tis.c +++ b/drivers/char/tpm/tpm_tis.c @@ -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) @@ -253,7 +254,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->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) 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) @@ -801,7 +802,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) { diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c index 0bdebe9..6daa66f 100644 --- a/drivers/char/tpm/xen-tpmfront.c +++ b/drivers/char/tpm/xen-tpmfront.c @@ -29,6 +29,7 @@ struct tpm_private { int ring_ref; domid_t backend_id; int irq; + wait_queue_head_t read_queue; }; enum status_bits { @@ -89,7 +90,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) /* Wait for completion of any existing command or cancellation */ if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->timeout_c, - &chip->vendor.read_queue, true) < 0) { + &priv->read_queue, true) < 0) { vtpm_cancel(chip); return -ETIME; } @@ -105,7 +106,7 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) duration = tpm_calc_ordinal_duration(chip, ordinal); if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, duration, - &chip->vendor.read_queue, true) < 0) { + &priv->read_queue, true) < 0) { /* got a signal or timeout, try to cancel */ vtpm_cancel(chip); return -ETIME; @@ -126,7 +127,7 @@ static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count) /* In theory the wait at the end of _send makes this one unnecessary */ if (wait_for_tpm_stat(chip, VTPM_STATUS_RESULT, chip->timeout_c, - &chip->vendor.read_queue, true) < 0) { + &priv->read_queue, true) < 0) { vtpm_cancel(chip); return -ETIME; } @@ -162,7 +163,7 @@ static irqreturn_t tpmif_interrupt(int dummy, void *dev_id) switch (priv->shr->state) { case VTPM_STATE_IDLE: case VTPM_STATE_FINISH: - wake_up_interruptible(&priv->chip->vendor.read_queue); + wake_up_interruptible(&priv->priv->read_queue); break; case VTPM_STATE_SUBMIT: case VTPM_STATE_CANCEL: @@ -180,7 +181,7 @@ static int setup_chip(struct device *dev, struct tpm_private *priv) if (IS_ERR(chip)) return PTR_ERR(chip); - init_waitqueue_head(&chip->vendor.read_queue); + init_waitqueue_head(&priv->read_queue); priv->chip = chip; dev_set_drvdata(&chip->dev, priv);