Skip to contentSkip to conversation

tpm: nuvoton: Use i2c_get_match_data()

PATCH Superseded Rob Herring 2 participants 2 messages Oct 6, 2023 – Oct 10, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: nuvoton: Use i2c_get_match_data()

Use preferred i2c_get_match_data() instead of of_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers.

---
 drivers/char/tpm/tpm_i2c_nuvoton.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/char/tpm/tpm_i2c_nuvoton.c +4 -11
index d7be03c41098..5490f7e0fa43 100644
@@ -19,7 +19,8 @@
 #include <linux/interrupt.h>
 #include <linux/wait.h>
 #include <linux/i2c.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/property.h>
 #include "tpm.h"
 
 /* I2C interface offsets */
@@ -524,7 +525,6 @@ static int get_vid(struct i2c_client *client, u32 *res)
 
 static int i2c_nuvoton_probe(struct i2c_client *client)
 {
-	const struct i2c_device_id *id = i2c_client_get_device_id(client);
 	int rc;
 	struct tpm_chip *chip;
 	struct device *dev = &client->dev;
@@ -546,15 +546,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client)
 	if (!priv)
 		return -ENOMEM;
 
-	if (dev->of_node) {
-		const struct of_device_id *of_id;
-
-		of_id = of_match_device(dev->driver->of_match_table, dev);
-		if (of_id && of_id->data == OF_IS_TPM2)
-			chip->flags |= TPM_CHIP_FLAG_TPM2;
-	} else
-		if (id->driver_data == I2C_IS_TPM2)
-			chip->flags |= TPM_CHIP_FLAG_TPM2;
+	if (i2c_get_match_data(client))
+		chip->flags |= TPM_CHIP_FLAG_TPM2;
 
 	init_waitqueue_head(&priv->read_queue);
 
Signature · 1 line
2.40.1
maintainer
#1 lore raw
Quoted 5 lines · Rob Herring

Use preferred i2c_get_match_data() instead of of_match_device() to get the driver match data. With this, adjust the includes to explicitly include the correct headers.

Perhaps self-evident but to have a closed story would be nice touch to write down the reason for the switch.

BR, Jarkko

Quoted 36 lines

---
 drivers/char/tpm/tpm_i2c_nuvoton.c | 15 ++++-----------

 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/char/tpm/tpm_i2c_nuvoton.c +2 -1
index d7be03c41098..5490f7e0fa43 100644
@@ -19,7 +19,8 @@
  #include <linux/interrupt.h>
  #include <linux/wait.h>
  #include <linux/i2c.h>
-#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/property.h>
  #include "tpm.h"


 /* I2C interface offsets */

drivers/char/tpm/tpm_i2c_nuvoton.c +0 -0
@@ -524,7 +525,6 @@ static int get_vid(struct i2c_client *client, u32 *res)


 static int i2c_nuvoton_probe(struct i2c_client *client)
 {
-       const struct i2c_device_id *id = i2c_client_get_device_id(client); int rc;
        struct tpm_chip *chip;
        struct device *dev = &client->dev;

drivers/char/tpm/tpm_i2c_nuvoton.c +0 -0
@@ -546,15 +546,8 @@ static int i2c_nuvoton_probe(struct i2c_client *client)
         if (!priv)
                 return -ENOMEM;


-       if (dev->of_node) {
-               const struct of_device_id *of_id;
-
-               of_id = of_match_device(dev->driver->of_match_table, dev); -               if (of_id && of_id->data == OF_IS_TPM2)
-                       chip->flags |= TPM_CHIP_FLAG_TPM2;

Quoted 8 lines

-       } else
-               if (id->driver_data == I2C_IS_TPM2) -                       chip->flags |= TPM_CHIP_FLAG_TPM2; +       if (i2c_get_match_data(client))
+               chip->flags |= TPM_CHIP_FLAG_TPM2;
        init_waitqueue_head(&priv->read_queue);

No complains about the code change.

BR, Jarkko