From: Ashley Lai <ashley@ashleylai.com>
To: Mathias.LEBLANC@st.com, jean-luc.blanc@st.com,
"Peter Hüwe" <PeterHuewe@gmx.de>,
linux-kernel@vger.kernel.org
Cc: tpmdd-devel@lists.sourceforge.net,
Leonidas Da Silva Barbosa <leosilva@linux.vnet.ibm.com>,
"Rajiv Andrade (mail@srajiv.net)" <mail@srajiv.net>,
"Sirrix AG (tpmdd@sirrix.com)" <tpmdd@sirrix.com>,
andy.shevchenko@gmail.com, adlai@linux.vnet.ibm.com
Subject: Re: TPM: STMicroelectronics st33 driver SPI
Date: Mon, 26 Aug 2013 22:28:10 -0500 (CDT) [thread overview]
Message-ID: <alpine.DEB.2.02.1308262145290.13156@fishsauce> (raw)
In-Reply-To: <201308230054.34660.PeterHuewe@gmx.de>
Please see my comments below. Did you get a chance to run the trousers
testsuite?
git://trousers.git.sourceforge.net/gitroot/trousers/testsuite
+static u8 spi_read8_reg(struct tpm_chip *tpm, u8 tpm_register,
+ u8 *tpm_data, u16 tpm_size)
+{
+ ...
+
+ /* header + status byte + size of the data + status byte */
+ value = spi_sync_transfer(dev, &xfer, 1);
+
+ if (tpm_size > 0 && value == 0) {
+ nbr_dummy_bytes = 2;
Why use 2 for the dummy bytes? Some comments here would be
helpful. Should we use a #define for 2?
...
+static unsigned long wait_for_serirq_timeout(struct tpm_chip *chip,
+ bool condition, unsigned long timeout)
+{
+ long status = 0;
+ struct spi_device *client;
+ struct st33zp24_platform_data *pin_infos;
+
+ client = (struct spi_device __force *)chip->vendor.iobase;
+ pin_infos = client->dev.platform_data;
+
+ status = wait_for_completion_interruptible_timeout(
+ &pin_infos->irq_detection, timeout);
+ if (status > 0)
+ enable_irq(gpio_to_irq(pin_infos->io_serirq));
+ gpio_direction_input(pin_infos->io_serirq);
+
+ if (!status)
+ return -EBUSY;
This function returns -EBUSY but the return function type is unsigned.
...
+static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
+{
+ u32 size = 0, burstcnt, len;
+ long status = 0;
+
+ while (size < count &&
+ wait_for_stat(chip,
+ TPM_STS_DATA_AVAIL | TPM_STS_VALID,
+ chip->vendor.timeout_c,
+ &chip->vendor.read_queue)
+ == 0) {
+ burstcnt = get_burstcount(chip);
+ len = min_t(int, burstcnt, count - size);
What if get_burstcount returns -EBUSY? Should burstcnt be checked
and handled here in case of error?
+ status = spi_read8_reg(chip, TPM_DATA_FIFO, buf + size,
len);
+ if (status < 0)
+ return status;
+
+
Extra empty line here.
+ size += len;
See above comment. If len is -EBUSY, there might be an issue here.
+ }
+return size;
...
+static int tpm_stm_spi_send(struct tpm_chip *chip, unsigned char *buf,
+ size_t len)
+{
...
+ for (i = 0; i < len - 1;) {
+ burstcnt = get_burstcount(chip);
Again burstcnt needs to be checked to make sure it is > 0.
+ size = min_t(int, len - i - 1, burstcnt);
+ ret = spi_write8_reg(chip, TPM_DATA_FIFO, buf, size);
+ if (ret < 0)
+ goto out_err;
+ i += size;
+ }
...
+ /* write last byte */
+ spi_write8_reg(chip, TPM_DATA_FIFO, buf + len - 1, 1);
Should we check for the return code here? A few lines below it checks
for the return value.
...
+
+
+ /* go and do it */
+ data = TPM_STS_GO;
+ ret = spi_write8_reg(chip, TPM_STS, &data, 1);
Regards,
--Ashley Lai
next parent reply other threads:[~2013-08-27 3:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <35286B1AE75A7C47BFF0870081A31B4B4C87C3BED8@SAFEX1MAIL4.st.com>
[not found] ` <201308171245.20964.PeterHuewe@gmx.de>
[not found] ` <CALfuBuR9ucum5Na=f_rqUgAZxrdAdOBQ1BZDbpCCKDsk2TUVXQ@mail.gmail.com>
[not found] ` <201308230054.34660.PeterHuewe@gmx.de>
2013-08-27 3:28 ` Ashley Lai [this message]
2013-09-11 23:47 ` [tpmdd-devel] " Peter Hüwe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.02.1308262145290.13156@fishsauce \
--to=ashley@ashleylai.com \
--cc=Mathias.LEBLANC@st.com \
--cc=PeterHuewe@gmx.de \
--cc=adlai@linux.vnet.ibm.com \
--cc=andy.shevchenko@gmail.com \
--cc=jean-luc.blanc@st.com \
--cc=leosilva@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mail@srajiv.net \
--cc=tpmdd-devel@lists.sourceforge.net \
--cc=tpmdd@sirrix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®