public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: TPM: STMicroelectronics st33 driver SPI
       [not found]     ` <201308230054.34660.PeterHuewe@gmx.de>
@ 2013-08-27  3:28       ` Ashley Lai
  2013-09-11 23:47         ` [tpmdd-devel] " Peter Hüwe
  0 siblings, 1 reply; 2+ messages in thread
From: Ashley Lai @ 2013-08-27  3:28 UTC (permalink / raw)
  To: Mathias.LEBLANC, jean-luc.blanc, Peter Hüwe, linux-kernel
  Cc: tpmdd-devel, Leonidas Da Silva Barbosa,
	Rajiv Andrade (mail@srajiv.net), Sirrix AG (tpmdd@sirrix.com),
	andy.shevchenko, adlai


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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [tpmdd-devel] TPM: STMicroelectronics st33 driver SPI
  2013-08-27  3:28       ` TPM: STMicroelectronics st33 driver SPI Ashley Lai
@ 2013-09-11 23:47         ` Peter Hüwe
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Hüwe @ 2013-09-11 23:47 UTC (permalink / raw)
  To: tpmdd-devel, jean-luc.blanc
  Cc: Ashley Lai, linux-kernel, Leonidas Da Silva Barbosa, adlai,
	Rajiv Andrade (mail@srajiv.net), andy.shevchenko,
	Sirrix AG (tpmdd@sirrix.com)

When compiling it I get
WARNING: modpost: missing MODULE_LICENSE() in 
drivers/char/tpm/tpm_spi_stm_st33.o

Thanks,
Peter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-11 23:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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       ` TPM: STMicroelectronics st33 driver SPI Ashley Lai
2013-09-11 23:47         ` [tpmdd-devel] " Peter Hüwe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox