linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm/tpm_i2c_infineon: Fix init endian vendor check
@ 2021-09-08 13:34 Florian Eckert
  2021-09-08 13:40 ` Jason Gunthorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Eckert @ 2021-09-08 13:34 UTC (permalink / raw)
  To: peterhuewe, jarkko, jgg, Eckert.Florian; +Cc: linux-integrity, linux-kernel

On my embedded system I use this tpm infineon chip via I2C.
My system is a MIPS architecture and therefore works in big endian mode.

The problem is that the chip type is not recognised, because the vendor ID
is incorrectly stored in memory.

By converting the vendor ID with ie32_to_cpus() to the correct format,
the TPM chip is recognised by the driver and works as expected.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
---
 drivers/char/tpm/tpm_i2c_infineon.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index a19d32cb4e94..111a8c34329a 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -638,6 +638,8 @@ static int tpm_tis_i2c_init(struct device *dev)
 		goto out_release;
 	}
 
+	le32_to_cpus(&vendor);
+
 	if (vendor == TPM_TIS_I2C_DID_VID_9645) {
 		tpm_dev.chip_type = SLB9645;
 	} else if (vendor == TPM_TIS_I2C_DID_VID_9635) {
-- 
2.20.1


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

* Re: [PATCH] tpm/tpm_i2c_infineon: Fix init endian vendor check
  2021-09-08 13:34 [PATCH] tpm/tpm_i2c_infineon: Fix init endian vendor check Florian Eckert
@ 2021-09-08 13:40 ` Jason Gunthorpe
  2021-09-13 12:05   ` Florian Eckert
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Gunthorpe @ 2021-09-08 13:40 UTC (permalink / raw)
  To: Florian Eckert
  Cc: peterhuewe, jarkko, Eckert.Florian, linux-integrity, linux-kernel

On Wed, Sep 08, 2021 at 03:34:16PM +0200, Florian Eckert wrote:
> On my embedded system I use this tpm infineon chip via I2C.
> My system is a MIPS architecture and therefore works in big endian mode.
> 
> The problem is that the chip type is not recognised, because the vendor ID
> is incorrectly stored in memory.
> 
> By converting the vendor ID with ie32_to_cpus() to the correct format,
> the TPM chip is recognised by the driver and works as expected.
> 
> Signed-off-by: Florian Eckert <fe@dev.tdt.de>
> ---
>  drivers/char/tpm/tpm_i2c_infineon.c | 2 ++
>  1 file changed, 2 insertions(+)

vendor should be marked as a __le32 and so forth 

Jason

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

* Re: [PATCH] tpm/tpm_i2c_infineon: Fix init endian vendor check
  2021-09-08 13:40 ` Jason Gunthorpe
@ 2021-09-13 12:05   ` Florian Eckert
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Eckert @ 2021-09-13 12:05 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: peterhuewe, jarkko, Eckert.Florian, linux-integrity, linux-kernel

>> By converting the vendor ID with ie32_to_cpus() to the correct format,
>> the TPM chip is recognised by the driver and works as expected.
>> 
>> Signed-off-by: Florian Eckert <fe@dev.tdt.de>
>> ---
>>  drivers/char/tpm/tpm_i2c_infineon.c | 2 ++
>>  1 file changed, 2 insertions(+)
> 
> vendor should be marked as a __le32 and so forth

Thanks for your feedback. I will push a v2.

> 
> Jason

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

end of thread, other threads:[~2021-09-13 12:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-08 13:34 [PATCH] tpm/tpm_i2c_infineon: Fix init endian vendor check Florian Eckert
2021-09-08 13:40 ` Jason Gunthorpe
2021-09-13 12:05   ` Florian Eckert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).