tpm/st33zp24: Fix the name collisions in tpm_st33zp24_spi and tpm_i2c_infineon
Subsystems (4)
PATCH v2 1/1 tpm/st33zp24: Fix the name collisions in tpm_st33zp24_spi and tpm_i2c_infineon
Rename TPM_BUFSIZE defined in drivers/char/tpm/st33zp24/st33zp24.h to ST33ZP24_BUFSIZE.
Rename TPM_BUFSIZE defined in drivers/char/tpm/tpm_i2c_infineon.c to TPM_I2C_INFINEON_BUFSIZE.
---
v2: Fix also the name collision in tpm_ic2_infineon.
drivers/char/tpm/st33zp24/i2c.c | 2 +- drivers/char/tpm/st33zp24/spi.c | 2 +- drivers/char/tpm/st33zp24/st33zp24.h | 4 ++-- drivers/char/tpm/tpm_i2c_infineon.c | 15 ++++++++------- 4 files changed, 12 insertions(+), 11 deletions(-)
drivers/char/tpm/st33zp24/i2c.c +1 -1
@@ -33,7 +33,7 @@struct st33zp24_i2c_phy {struct i2c_client *client; -u8 buf[TPM_BUFSIZE +1 ]; +u8 buf[ST33ZP24_BUFSIZE +1 ];int io_lpcpd; };
drivers/char/tpm/st33zp24/spi.c +1 -1
@@ -63,7 +63,7 @@* some latency byte before the answer is available (max 15). * We have 2048 + 1024 + 15. */ -#define ST33ZP24_SPI_BUFFER_SIZE (TPM_BUFSIZE + (TPM_BUFSIZE / 2) +\ +#define ST33ZP24_SPI_BUFFER_SIZE (ST33ZP24_BUFSIZE + (ST33ZP24_BUFSIZE / 2) +\ MAX_SPI_LATENCY)
drivers/char/tpm/st33zp24/st33zp24.h +2 -2
@@ -18,8 +18,8 @@ #ifndef __LOCAL_ST33ZP24_H__ #define __LOCAL_ST33ZP24_H__ -#define TPM_WRITE_DIRECTION 0x80 -#define TPM_BUFSIZE 2048 +#define TPM_WRITE_DIRECTION 0x80 +#define ST33ZP24_BUFSIZE 2048 struct st33zp24_dev { struct tpm_chip *chip;
drivers/char/tpm/tpm_i2c_infineon.c +8 -7
@@ -26,8 +26,7 @@#include <linux/wait.h> #include "tpm.h" -/* max. buffer size supported by our TPM */ -#define TPM_BUFSIZE 1260 +#define TPM_I2C_INFINEON_MAX_BUFSIZE 1260/* max. number of iterations after I2C NAK */ #define MAX_COUNT 3
@@ -63,11 +62,13 @@ enum i2c_chip_type { UNKNOWN, }; -/* Structure to store I2C TPM specific stuff */ struct tpm_inf_dev {struct i2c_client *client;int locality; -u8 buf[TPM_BUFSIZE +sizeof (u8)];/* max. buffer size + addr */ +/* In addition to the data itself, the buffer must fit the 7-bit I2C +* address and the direction bit. +*/ +u8 buf[TPM_I2C_INFINEON_MAX_BUFSIZE +1 ];struct tpm_chip *chip;enum i2c_chip_type chip_type;unsigned int adapterlimit;
@@ -219,7 +220,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len, .buf = tpm_dev.buf }; -if (len >TPM_BUFSIZE ) +if (len >TPM_I2C_INFINEON_MAX_BUFSIZE )return -EINVAL ;if (!tpm_dev.client->adapter->algo->master_xfer)
@@ -527,8 +528,8 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)u8 retries =0 ;u8 sts =TPM_STS_GO ; -if (len >TPM_BUFSIZE ) -return -E2BIG ;/* command is too long for our tpm, sorry */ +if (len >TPM_I2C_INFINEON_BUFSIZE ) +return -E2BIG ;if (request_locality (chip,0 ) <0 )return -EBUSY ;
Signature · 1 line
2.19.1
Quoted 5 lines · Jarkko Sakkinen
Rename
TPM_BUFSIZEdefined indrivers/char/tpm/st33zp24/st33zp24.htoST33ZP24_BUFSIZE.Rename
TPM_BUFSIZEdefined indrivers/char/tpm/tpm_i2c_infineon.ctoTPM_I2C_INFINEON_BUFSIZE.
Please also add a prefix to TPM_RETRY in tpm_i2c_nuvoton.c.
Thanks
Roberto
Quoted 104 lines
Fixes bf38b8710892 ("tpm/tpm_i2c_stm_st33: Split tpm_i2c_tpm_st33 in 2 layers (core + phy)")Fixes aad628c1d91a ("char/tpm: Add new driver for Infineon I2C TIS TPM")Signed-off-by Jarkko Sakkinen <[email protected]>---
v2: Fix also the name collision intpm_ic2_infineon.drivers/char/tpm/st33zp24/i2c.c | 2 +- drivers/char/tpm/st33zp24/spi.c | 2 +- drivers/char/tpm/st33zp24/st33zp24.h | 4 ++-- drivers/char/tpm/tpm_i2c_infineon.c | 15 ++++++++------- 4 files changed, 12 insertions(+), 11 deletions(-)drivers/char/tpm/st33zp24/i2c.c +1
-1@@ -33,7 +33,7 @@struct st33zp24_i2c_phy {struct i2c_client *client; -u8 buf[TPM_BUFSIZE +1 ]; +u8 buf[ST33ZP24_BUFSIZE +1 ];int io_lpcpd; };drivers/char/tpm/st33zp24/spi.c +1
-1@@ -63,7 +63,7 @@* some latency byte before the answer is available (max 15). * We have 2048 + 1024 + 15. */ -#define ST33ZP24_SPI_BUFFER_SIZE (TPM_BUFSIZE + (TPM_BUFSIZE / 2) +\ +#define ST33ZP24_SPI_BUFFER_SIZE (ST33ZP24_BUFSIZE + (ST33ZP24_BUFSIZE / 2) +\ MAX_SPI_LATENCY)drivers/char/tpm/st33zp24/st33zp24.h +2
-2@@ -18,8 +18,8 @@ #ifndef __LOCAL_ST33ZP24_H__ #define __LOCAL_ST33ZP24_H__ -#define TPM_WRITE_DIRECTION 0x80 -#define TPM_BUFSIZE 2048 +#define TPM_WRITE_DIRECTION 0x80 +#define ST33ZP24_BUFSIZE 2048 struct st33zp24_dev { struct tpm_chip *chip;drivers/char/tpm/tpm_i2c_infineon.c +8
-7@@ -26,8 +26,7 @@#include <linux/wait.h> #include "tpm.h" -/* max. buffer size supported by our TPM */ -#define TPM_BUFSIZE 1260 +#define TPM_I2C_INFINEON_MAX_BUFSIZE 1260/* max. number of iterations after I2C NAK */ #define MAX_COUNT 3@@ -63,11 +62,13 @@ enum i2c_chip_type { UNKNOWN, }; -/* Structure to store I2C TPM specific stuff */ struct tpm_inf_dev {struct i2c_client *client;int locality; -u8 buf[TPM_BUFSIZE +sizeof (u8)];/* max. buffer size + addr */ +/* In addition to the data itself, the buffer must fit the 7-bit I2C +* address and the direction bit. +*/ +u8 buf[TPM_I2C_INFINEON_MAX_BUFSIZE +1 ];struct tpm_chip *chip;enum i2c_chip_type chip_type;unsigned int adapterlimit;@@ -219,7 +220,7 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len, .buf = tpm_dev.buf }; -if (len >TPM_BUFSIZE ) +if (len >TPM_I2C_INFINEON_MAX_BUFSIZE )return -EINVAL ;if (!tpm_dev.client->adapter->algo->master_xfer)@@ -527,8 +528,8 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)u8 retries =0 ;u8 sts =TPM_STS_GO ; -if (len >TPM_BUFSIZE ) -return -E2BIG ;/* command is too long for our tpm, sorry */ +if (len >TPM_I2C_INFINEON_BUFSIZE ) +return -E2BIG ;if (request_locality (chip,0 ) <0 )return -EBUSY ;
Signature · 2 lines
HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Jian LI, Yanli SHI
Quoted 8 lines · Roberto Sassu
Quoted 5 lines · Jarkko Sakkinen
Rename
TPM_BUFSIZEdefined indrivers/char/tpm/st33zp24/st33zp24.htoST33ZP24_BUFSIZE.Rename
TPM_BUFSIZEdefined indrivers/char/tpm/tpm_i2c_infineon.ctoTPM_I2C_INFINEON_BUFSIZE.Please also add a prefix to
TPM_RETRYintpm_i2c_nuvoton.c.
Thanks, can do.
/Jarkko
Quoted 11 lines · Jarkko Sakkinen
Quoted 8 lines · Roberto Sassu
Quoted 5 lines · Jarkko Sakkinen
Rename
TPM_BUFSIZEdefined indrivers/char/tpm/st33zp24/st33zp24.htoST33ZP24_BUFSIZE.Rename
TPM_BUFSIZEdefined indrivers/char/tpm/tpm_i2c_infineon.ctoTPM_I2C_INFINEON_BUFSIZE.Please also add a prefix to
TPM_RETRYintpm_i2c_nuvoton.c.Thanks, can do.
TPM_RETRY defined in
32d33b29ba07 ("TPM: Retry SaveState command in suspend path")
has nothing to do with time. I'll also remove the comment about 5 seconds.
The definitions for TPM_RETRY seem fairly arbitrary. Jason, could tpm_i2c_nuvoton also use the same constant as tpm_tis_spi and TPM 1.2 suspend, try max 50 times instead of five?
/Jarkko
Quoted 11 lines · Jarkko Sakkinen
Quoted 10 lines · Jarkko Sakkinen
Quoted 8 lines · Roberto Sassu
Quoted 5 lines · Jarkko Sakkinen
Rename
TPM_BUFSIZEdefined indrivers/char/tpm/st33zp24/st33zp24.htoST33ZP24_BUFSIZE.Rename
TPM_BUFSIZEdefined indrivers/char/tpm/tpm_i2c_infineon.ctoTPM_I2C_INFINEON_BUFSIZE.Please also add a prefix to
TPM_RETRYintpm_i2c_nuvoton.c.
Quoted 8 lines
Quoted 1 line
Thanks, can do.
TPM_RETRYdefined in
32d33b29ba07("TPM: Retry SaveState command in suspend path")has nothing to do with time. I'll also remove the comment about 5 seconds.
I'll do the same for patch 4/6.
Roberto
Quoted 6 lines
The definitions for
TPM_RETRYseem fairly arbitrary. Jason, couldtpm_i2c_nuvotonalso use the same constant astpm_tis_spiand TPM 1.2 suspend, try max 50 times instead of five?/Jarkko
Signature · 2 lines
HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Jian LI, Yanli SHI
Quoted 14 lines · Roberto Sassu
Quoted 13 lines · Jarkko Sakkinen
Quoted 11 lines · Jarkko Sakkinen
Quoted 8 lines · Roberto Sassu
Quoted 5 lines · Jarkko Sakkinen
Rename
TPM_BUFSIZEdefined indrivers/char/tpm/st33zp24/st33zp24.htoST33ZP24_BUFSIZE.Rename
TPM_BUFSIZEdefined indrivers/char/tpm/tpm_i2c_infineon.ctoTPM_I2C_INFINEON_BUFSIZE.Please also add a prefix to
TPM_RETRYintpm_i2c_nuvoton.c.Thanks, can do.
Quoted 8 lines
Quoted 6 lines
TPM_RETRYdefined in
32d33b29ba07("TPM: Retry SaveState command in suspend path")has nothing to do with time. I'll also remove the comment about 5 seconds.
I'll do the same for patch 4/6.
Yep. I'll post a new patch ASAP.
/Jarkko
kbuild test robot
build botI love your patch! Yet something to improve:
Hi Jarkko,
I love your patch! Yet something to improve:
[auto build test ERROR on jss-tpmdd/next]
[also build test ERROR on v5.0-rc4 next-20190204]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Jarkko-Sakkinen/tpm-st33zp24-Fix-the-name-collisions-in-tpm_st33zp24_spi-and-tpm_i2c_infineon/20190205-150003 base: git://git.infradead.org/users/jjs/linux-tpmdd next config: nds32-allyesconfig (attached as .config) compiler: nds32le-linux-gcc (GCC) 6.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=6.4.0 make.cross ARCH=nds32
All errors (new ones prefixed by >>):
drivers/char/tpm/tpm_i2c_infineon.c: In function 'tpm_tis_i2c_send':
>> drivers/char/tpm/tpm_i2c_infineon.c:531:12: error: 'TPM_I2C_INFINEON_BUFSIZE' undeclared (first use in this function)
if (len > TPM_I2C_INFINEON_BUFSIZE)
^~~~~~~~~~~~~~~~~~~~~~~~
drivers/char/tpm/tpm_i2c_infineon.c:531:12: note: each undeclared identifier is reported only once for each function it appears in
vim +/TPM_I2C_INFINEON_BUFSIZE +531 drivers/char/tpm/tpm_i2c_infineon.c
522
523 static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
524 {
525 int rc, status;
526 ssize_t burstcnt;
527 size_t count = 0;
528 u8 retries = 0;
529 u8 sts = TPM_STS_GO;
530
> 531 if (len > TPM_I2C_INFINEON_BUFSIZE)
532 return -E2BIG;
533
534 if (request_locality(chip, 0) < 0)
535 return -EBUSY;
536
537 status = tpm_tis_i2c_status(chip);
538 if ((status & TPM_STS_COMMAND_READY) == 0) {
539 tpm_tis_i2c_ready(chip);
540 if (wait_for_stat
541 (chip, TPM_STS_COMMAND_READY,
542 chip->timeout_b, &status) < 0) {
543 rc = -ETIME;
544 goto out_err;
545 }
546 }
547
548 while (count < len - 1) {
549 burstcnt = get_burstcount(chip);
550
551 /* burstcnt < 0 = TPM is busy */
552 if (burstcnt < 0)
553 return burstcnt;
554
555 if (burstcnt > (len - 1 - count))
556 burstcnt = len - 1 - count;
557
558 rc = iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality),
559 &(buf[count]), burstcnt);
560 if (rc == 0)
561 count += burstcnt;
562 else if (rc < 0)
563 retries++;
564
565 /* avoid endless loop in case of broken HW */
566 if (retries > MAX_COUNT_LONG) {
567 rc = -EIO;
568 goto out_err;
569 }
570
571 wait_for_stat(chip, TPM_STS_VALID,
572 chip->timeout_c, &status);
573
574 if ((status & TPM_STS_DATA_EXPECT) == 0) {
575 rc = -EIO;
576 goto out_err;
577 }
578 }
579
580 /* write last byte */
581 iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality), &(buf[count]), 1);
582 wait_for_stat(chip, TPM_STS_VALID, chip->timeout_c, &status);
583 if ((status & TPM_STS_DATA_EXPECT) != 0) {
584 rc = -EIO;
585 goto out_err;
586 }
587
588 /* go and do it */
589 iic_tpm_write(TPM_STS(tpm_dev.locality), &sts, 1);
590
591 return len;
592 out_err:
593 tpm_tis_i2c_ready(chip);
594 /* The TPM needs some time to clean up here,
595 * so we sleep rather than keeping the bus busy
596 */
597 usleep_range(SLEEP_DURATION_RESET_LOW, SLEEP_DURATION_RESET_HI);
598 release_locality(chip, tpm_dev.locality, 0);
599 return rc;
600 }
601
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botI love your patch! Yet something to improve:
Hi Jarkko,
I love your patch! Yet something to improve:
[auto build test ERROR on jss-tpmdd/next]
[also build test ERROR on v5.0-rc4 next-20190204]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Jarkko-Sakkinen/tpm-st33zp24-Fix-the-name-collisions-in-tpm_st33zp24_spi-and-tpm_i2c_infineon/20190205-150003 base: git://git.infradead.org/users/jjs/linux-tpmdd next config: x86_64-randconfig-x013-201905 (attached as .config) compiler: gcc-8 (Debian 8.2.0-14) 8.2.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64
All errors (new ones prefixed by >>):
drivers/char//tpm/tpm_i2c_infineon.c: In function 'tpm_tis_i2c_send':
>> drivers/char//tpm/tpm_i2c_infineon.c:531:12: error: 'TPM_I2C_INFINEON_BUFSIZE' undeclared (first use in this function); did you mean 'TPM_I2C_INFINEON_MAX_BUFSIZE'?
if (len > TPM_I2C_INFINEON_BUFSIZE)
^~~~~~~~~~~~~~~~~~~~~~~~
TPM_I2C_INFINEON_MAX_BUFSIZE
drivers/char//tpm/tpm_i2c_infineon.c:531:12: note: each undeclared identifier is reported only once for each function it appears in
vim +531 drivers/char//tpm/tpm_i2c_infineon.c
522
523 static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)
524 {
525 int rc, status;
526 ssize_t burstcnt;
527 size_t count = 0;
528 u8 retries = 0;
529 u8 sts = TPM_STS_GO;
530
> 531 if (len > TPM_I2C_INFINEON_BUFSIZE)
532 return -E2BIG;
533
534 if (request_locality(chip, 0) < 0)
535 return -EBUSY;
536
537 status = tpm_tis_i2c_status(chip);
538 if ((status & TPM_STS_COMMAND_READY) == 0) {
539 tpm_tis_i2c_ready(chip);
540 if (wait_for_stat
541 (chip, TPM_STS_COMMAND_READY,
542 chip->timeout_b, &status) < 0) {
543 rc = -ETIME;
544 goto out_err;
545 }
546 }
547
548 while (count < len - 1) {
549 burstcnt = get_burstcount(chip);
550
551 /* burstcnt < 0 = TPM is busy */
552 if (burstcnt < 0)
553 return burstcnt;
554
555 if (burstcnt > (len - 1 - count))
556 burstcnt = len - 1 - count;
557
558 rc = iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality),
559 &(buf[count]), burstcnt);
560 if (rc == 0)
561 count += burstcnt;
562 else if (rc < 0)
563 retries++;
564
565 /* avoid endless loop in case of broken HW */
566 if (retries > MAX_COUNT_LONG) {
567 rc = -EIO;
568 goto out_err;
569 }
570
571 wait_for_stat(chip, TPM_STS_VALID,
572 chip->timeout_c, &status);
573
574 if ((status & TPM_STS_DATA_EXPECT) == 0) {
575 rc = -EIO;
576 goto out_err;
577 }
578 }
579
580 /* write last byte */
581 iic_tpm_write(TPM_DATA_FIFO(tpm_dev.locality), &(buf[count]), 1);
582 wait_for_stat(chip, TPM_STS_VALID, chip->timeout_c, &status);
583 if ((status & TPM_STS_DATA_EXPECT) != 0) {
584 rc = -EIO;
585 goto out_err;
586 }
587
588 /* go and do it */
589 iic_tpm_write(TPM_STS(tpm_dev.locality), &sts, 1);
590
591 return len;
592 out_err:
593 tpm_tis_i2c_ready(chip);
594 /* The TPM needs some time to clean up here,
595 * so we sleep rather than keeping the bus busy
596 */
597 usleep_range(SLEEP_DURATION_RESET_LOW, SLEEP_DURATION_RESET_HI);
598 release_locality(chip, tpm_dev.locality, 0);
599 return rc;
600 }
601
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
James Bottomley
maintainerQuoted 5 lines · Jarkko Sakkinen
drivers/char/tpm/tpm_i2c_infineon.c +0
-0
[...]
drivers/char/tpm/tpm_i2c_infineon.c static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len) · line 531
Quoted 9 lines
drivers/char/tpm/tpm_i2c_infineon.c +0
-2@@ -527,8 +528,8 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len) u8 retries = 0;u8 sts =TPM_STS_GO ; -if (len >TPM_BUFSIZE ) -return -E2BIG ;/* command is too long for our tpm, sorry */
drivers/char/tpm/tpm_i2c_infineon.c +1
-0+if (len >TPM_I2C_INFINEON_BUFSIZE )
TPM_I2C_INFINEON_MAX_BUFSIZE, surely, otherwise it won't compile ... the kbuild robot just spotted this as well.
James
Quoted 12 lines · James Bottomley
Quoted 5 lines · Jarkko Sakkinen
drivers/char/tpm/tpm_i2c_infineon.c +0
-0[...]
Quoted 5 lines
drivers/char/tpm/tpm_i2c_infineon.c +0
-0@@ -527,8 +528,8 @@ static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len) u8 retries = 0;u8 sts =TPM_STS_GO ;
Quoted 7 lines
drivers/char/tpm/tpm_i2c_infineon.c static int tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len) · line 531
Quoted 4 lines
drivers/char/tpm/tpm_i2c_infineon.c +0
-2-if (len >TPM_BUFSIZE ) -return -E2BIG ;/* command is too long for our tpm, sorry */
drivers/char/tpm/tpm_i2c_infineon.c +1
-0+if (len >TPM_I2C_INFINEON_BUFSIZE )
TPM_I2C_INFINEON_MAX_BUFSIZE, surely, otherwise it won't compile ... the kbuild robot just spotted this as well.
Correct, unluckily, I had unstaged diff.
/Jarkko