Skip to contentSkip to conversation

tpm: declare tpm2_get_pcr_allocation() as static

PATCH In review Jarkko Sakkinen 3 participants 7 messages Feb 15, 2017 – Feb 21, 2017 TPM device driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: declare tpm2_get_pcr_allocation() as static

There's no need to export tpm2_get_pcr_alloation() because it is only a helper function for tpm2_auto_startup(). For the same reason it does not make much sense to maintain documentation for it.

---
 drivers/char/tpm/tpm.h      |  1 -
 drivers/char/tpm/tpm2-cmd.c | 94 ++++++++++++++++++++++-----------------------
 2 files changed, 45 insertions(+), 50 deletions(-)
drivers/char/tpm/tpm.h +0 -1
index 6b4e7aa..4937b56 100644
@@ -554,5 +554,4 @@ int tpm2_auto_startup(struct tpm_chip *chip);
 void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
 unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
 int tpm2_probe(struct tpm_chip *chip);
-ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip);
 #endif
drivers/char/tpm/tpm2-cmd.c +45 -49

109 lines not on this page · raw message

Signature · 1 line
2.9.3
#1 lore raw
Quoted 3 lines · Jarkko Sakkinen

There's no need to export tpm2_get_pcr_alloation() because it is only a helper function for tpm2_auto_startup(). For the same reason it does not make much sense to maintain documentation for it.

Please stop moving these functions around, you are just breaking the git history and git blame - there cosmetic reason of having a certain order is not worth this damage.

Jason

#2 lore raw
Quoted 10 lines · Jason Gunthorpe
Quoted 3 lines · Jarkko Sakkinen

There's no need to export tpm2_get_pcr_alloation() because it is only a helper function for tpm2_auto_startup(). For the same reason it does not make much sense to maintain documentation for it.

Please stop moving these functions around, you are just breaking the git history and git blame - there cosmetic reason of having a certain order is not worth this damage.

Jason

So you rather want a predeclaration?

Moving code for the right reasons is perfectly justifiable.

/Jarkko

#3 lore raw
In reply to Jarkko Sakkinen
Quoted 5 lines · Jarkko Sakkinen

There's no need to export tpm2_get_pcr_alloation() because it is only a helper function for tpm2_auto_startup(). For the same reason it does not make much sense to maintain documentation for it.

Nayna, does this look good to you?

/Jarkko

Quoted 137 lines
---
 drivers/char/tpm/tpm.h      |  1 -
 drivers/char/tpm/tpm2-cmd.c | 94 ++++++++++++++++++++++-----------------------
 2 files changed, 45 insertions(+), 50 deletions(-)
drivers/char/tpm/tpm.h +0 -1
index 6b4e7aa..4937b56 100644
@@ -554,5 +554,4 @@ int tpm2_auto_startup(struct tpm_chip *chip);
 void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
 unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
 int tpm2_probe(struct tpm_chip *chip);
-ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip);
 #endif
drivers/char/tpm/tpm2-cmd.c +45 -49
index 10f97e6..881aea9 100644
@@ -997,61 +997,13 @@ int tpm2_probe(struct tpm_chip *chip)
 }
 EXPORT_SYMBOL_GPL(tpm2_probe);
 
-/**
- * tpm2_auto_startup - Perform the standard automatic TPM initialization
- *                     sequence
- * @chip: TPM chip to use
- *
- * Returns 0 on success, < 0 in case of fatal error.
- */
-int tpm2_auto_startup(struct tpm_chip *chip)
-{
-	int rc;
-
-	rc = tpm_get_timeouts(chip);
-	if (rc)
-		goto out;
-
-	rc = tpm2_do_selftest(chip);
-	if (rc != 0 && rc != TPM2_RC_INITIALIZE) {
-		dev_err(&chip->dev, "TPM self test failed\n");
-		goto out;
-	}
-
-	if (rc == TPM2_RC_INITIALIZE) {
-		rc = tpm2_startup(chip, TPM2_SU_CLEAR);
-		if (rc)
-			goto out;
-
-		rc = tpm2_do_selftest(chip);
-		if (rc) {
-			dev_err(&chip->dev, "TPM self test failed\n");
-			goto out;
-		}
-	}
-
-	rc = tpm2_get_pcr_allocation(chip);
-
-out:
-	if (rc > 0)
-		rc = -ENODEV;
-	return rc;
-}
-
 struct tpm2_pcr_selection {
 	__be16  hash_alg;
 	u8  size_of_select;
 	u8  pcr_select[3];
 } __packed;
 
-/**
- * tpm2_get_pcr_allocation() - get TPM active PCR banks.
- *
- * @chip: TPM chip to use.
- *
- * Return: Same as with tpm_transmit_cmd.
- */
-ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
+static ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
 {
 	struct tpm2_pcr_selection pcr_selection;
 	struct tpm_buf buf;
@@ -1114,3 +1066,47 @@ ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
 
 	return rc;
 }
+
+/**
+ * tpm2_auto_startup - Perform the standard automatic TPM initialization
+ *                     sequence
+ * @chip: TPM chip to use
+ *
+ * Initializes timeout values for operation and command durations, conducts
+ * a self-test and reads the list of active PCR banks.
+ *
+ * Return: 0 on success. Otherwise, a system error code is returned.
+ */
+int tpm2_auto_startup(struct tpm_chip *chip)
+{
+	int rc;
+
+	rc = tpm_get_timeouts(chip);
+	if (rc)
+		goto out;
+
+	rc = tpm2_do_selftest(chip);
+	if (rc != 0 && rc != TPM2_RC_INITIALIZE) {
+		dev_err(&chip->dev, "TPM self test failed\n");
+		goto out;
+	}
+
+	if (rc == TPM2_RC_INITIALIZE) {
+		rc = tpm2_startup(chip, TPM2_SU_CLEAR);
+		if (rc)
+			goto out;
+
+		rc = tpm2_do_selftest(chip);
+		if (rc) {
+			dev_err(&chip->dev, "TPM self test failed\n");
+			goto out;
+		}
+	}
+
+	rc = tpm2_get_pcr_allocation(chip);
+
+out:
+	if (rc > 0)
+		rc = -ENODEV;
+	return rc;
+}
Signature · 6 lines
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
Quoted 8 lines · Jarkko Sakkinen
Quoted 5 lines · Jarkko Sakkinen

There's no need to export tpm2_get_pcr_alloation() because it is only a helper function for tpm2_auto_startup(). For the same reason it does not make much sense to maintain documentation for it.

Nayna, does this look good to you?

I guess I'll just include this to the pull request as it is an obvious glitch.

/Jarkko

#5 lore raw
In reply to Jarkko Sakkinen
Quoted 8 lines · Jarkko Sakkinen
Quoted 5 lines · Jarkko Sakkinen

There's no need to export tpm2_get_pcr_alloation() because it is only a helper function for tpm2_auto_startup(). For the same reason it does not make much sense to maintain documentation for it.

Nayna, does this look good to you?

Oops !! I don't know how it is missed. Sorry for that..My internet connection wasn't working since my Friday evening and just started working yesterday. So, probably somewhere got this missed and saw it today

It is fine and I already see it in PULL request. So, Thanks !!

Thanks & Regards,
- Nayna

Quoted 136 lines

/Jarkko

Quoted 133 lines
---
  drivers/char/tpm/tpm.h      |  1 -
  drivers/char/tpm/tpm2-cmd.c | 94 ++++++++++++++++++++++-----------------------
  2 files changed, 45 insertions(+), 50 deletions(-)
drivers/char/tpm/tpm.h +0 -1
index 6b4e7aa..4937b56 100644
@@ -554,5 +554,4 @@ int tpm2_auto_startup(struct tpm_chip *chip);
  void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
  unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
  int tpm2_probe(struct tpm_chip *chip);
-ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip);
  #endif
drivers/char/tpm/tpm2-cmd.c +45 -50
index 10f97e6..881aea9 100644
@@ -997,61 +997,13 @@ int tpm2_probe(struct tpm_chip *chip)
  }
  EXPORT_SYMBOL_GPL(tpm2_probe);
 
-/**
- * tpm2_auto_startup - Perform the standard automatic TPM initialization
- *                     sequence
- * @chip: TPM chip to use
- *
- * Returns 0 on success, < 0 in case of fatal error.
- */
-int tpm2_auto_startup(struct tpm_chip *chip)
-{
-	int rc;
-
-	rc = tpm_get_timeouts(chip);
-	if (rc)
-		goto out;
-
-	rc = tpm2_do_selftest(chip);
-	if (rc != 0 && rc != TPM2_RC_INITIALIZE) {
-		dev_err(&chip->dev, "TPM self test failed\n");
-		goto out;
-	}
-
-	if (rc == TPM2_RC_INITIALIZE) {
-		rc = tpm2_startup(chip, TPM2_SU_CLEAR);
-		if (rc)
-			goto out;
-
-		rc = tpm2_do_selftest(chip);
-		if (rc) {
-			dev_err(&chip->dev, "TPM self test failed\n");
-			goto out;
-		}
-	}
-
-	rc = tpm2_get_pcr_allocation(chip);
-
-out:
-	if (rc > 0)
-		rc = -ENODEV;
-	return rc;
-}
-
  struct tpm2_pcr_selection {
  	__be16  hash_alg;
  	u8  size_of_select;
  	u8  pcr_select[3];
  } __packed;
 
-/**
- * tpm2_get_pcr_allocation() - get TPM active PCR banks.
- *
- * @chip: TPM chip to use.
- *
- * Return: Same as with tpm_transmit_cmd.
- */
-ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
+static ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
  {
  	struct tpm2_pcr_selection pcr_selection;
  	struct tpm_buf buf;
@@ -1114,3 +1066,47 @@ ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip)
 
  	return rc;
  }
+
+/**
+ * tpm2_auto_startup - Perform the standard automatic TPM initialization
+ *                     sequence
+ * @chip: TPM chip to use
+ *
+ * Initializes timeout values for operation and command durations, conducts
+ * a self-test and reads the list of active PCR banks.
+ *
+ * Return: 0 on success. Otherwise, a system error code is returned.
+ */
+int tpm2_auto_startup(struct tpm_chip *chip)
+{
+	int rc;
+
+	rc = tpm_get_timeouts(chip);
+	if (rc)
+		goto out;
+
+	rc = tpm2_do_selftest(chip);
+	if (rc != 0 && rc != TPM2_RC_INITIALIZE) {
+		dev_err(&chip->dev, "TPM self test failed\n");
+		goto out;
+	}
+
+	if (rc == TPM2_RC_INITIALIZE) {
+		rc = tpm2_startup(chip, TPM2_SU_CLEAR);
+		if (rc)
+			goto out;
+
+		rc = tpm2_do_selftest(chip);
+		if (rc) {
+			dev_err(&chip->dev, "TPM self test failed\n");
+			goto out;
+		}
+	}
+
+	rc = tpm2_get_pcr_allocation(chip);
+
+out:
+	if (rc > 0)
+		rc = -ENODEV;
+	return rc;
+}
--

2.9.3

Quoted 5 lines
Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot

#6 lore raw
Quoted 12 lines · Nayna
Quoted 8 lines · Jarkko Sakkinen
Quoted 5 lines · Jarkko Sakkinen

There's no need to export tpm2_get_pcr_alloation() because it is only a helper function for tpm2_auto_startup(). For the same reason it does not make much sense to maintain documentation for it.

Nayna, does this look good to you?

Quoted 8 lines

Oops !! I don't know how it is missed. Sorry for that..My internet connection wasn't working since my Friday evening and just started working yesterday. So, probably somewhere got this missed and saw it today

It is fine and I already see it in PULL request. So, Thanks !!

Thanks & Regards,
- Nayna

It's fine, just a minor glitch that I wanted to fix before it goes to release...

/Jarkko

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot