[PATCH v1.5 2/5] tpm: add module_put wrapper

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Mimi Zohar
Date: Tuesday, November 23, 2010 - 3:50 pm

For readability, define a tpm_chip_put() wrapper to call module_put().
Replace existing module_put() calls with the wrapper.

(Change based on trusted/encrypted patchset review by David Howells.)

Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: David Safford <safford@watson.ibm.com>
Acked-by: David Howells <dhowells@redhat.com>
---
 drivers/char/tpm/tpm.c |    4 ++--
 drivers/char/tpm/tpm.h |    5 +++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 7c41335..26c09f3 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -736,7 +736,7 @@ int tpm_pcr_read(u32 chip_num, int pcr_idx, u8 *res_buf)
 	if (chip == NULL)
 		return -ENODEV;
 	rc = __tpm_pcr_read(chip, pcr_idx, res_buf);
-	module_put(chip->dev->driver->owner);
+	tpm_chip_put(chip);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(tpm_pcr_read);
@@ -775,7 +775,7 @@ int tpm_pcr_extend(u32 chip_num, int pcr_idx, const u8 *hash)
 	rc = transmit_cmd(chip, &cmd, EXTEND_PCR_RESULT_SIZE,
 			  "attempting extend a PCR value");
 
-	module_put(chip->dev->driver->owner);
+	tpm_chip_put(chip);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(tpm_pcr_extend);
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 792868d..72ddb03 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -113,6 +113,11 @@ struct tpm_chip {
 
 #define to_tpm_chip(n) container_of(n, struct tpm_chip, vendor)
 
+static inline void tpm_chip_put(struct tpm_chip *chip)
+{
+	module_put(chip->dev->driver->owner);
+}
+
 static inline int tpm_read_index(int base, int index)
 {
 	outb(index, base);
-- 
1.7.2.2

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH v1.5 0/5] keys: trusted and encrypted keys, Mimi Zohar, (Tue Nov 23, 3:50 pm)
[PATCH v1.5 2/5] tpm: add module_put wrapper, Mimi Zohar, (Tue Nov 23, 3:50 pm)
[PATCH v1.5 4/5] keys: add new trusted key-type, Mimi Zohar, (Tue Nov 23, 3:50 pm)
[PATCH v1.5 3/5] key: add tpm_send command, Mimi Zohar, (Tue Nov 23, 4:54 pm)
Re: [PATCH v1.5 2/5] tpm: add module_put wrapper, Serge Hallyn, (Tue Nov 23, 7:19 pm)
Re: [PATCH v1.5 3/5] key: add tpm_send command, Serge Hallyn, (Tue Nov 23, 7:32 pm)
Re: [PATCH v1.5 3/5] key: add tpm_send command, David Safford, (Wed Nov 24, 5:46 am)
Re: [PATCH v1.5 3/5] key: add tpm_send command, Serge Hallyn, (Wed Nov 24, 7:59 am)
[PATCH v1.5 5/5] keys: add new key-type encrypted, Mimi Zohar, (Wed Nov 24, 9:21 am)
Re: [PATCH v1.5 3/5] key: add tpm_send command, David Safford, (Wed Nov 24, 9:31 am)
Re: [PATCH v1.5 0/5] keys: trusted and encrypted keys, James Morris, (Sun Nov 28, 2:56 pm)
Re: [PATCH v1.5 3/5] key: add tpm_send command, David Howells, (Tue Nov 30, 7:32 am)
Re: [PATCH v1.5 3/5] key: add tpm_send command, David Safford, (Tue Nov 30, 8:22 am)
Re: [PATCH v1.5 4/5] keys: add new trusted key-type, David Howells, (Wed Dec 1, 10:48 am)
Re: [PATCH v1.5 4/5] keys: add new trusted key-type, David Safford, (Wed Dec 1, 2:18 pm)
Re: [PATCH v1.5 5/5] keys: add new key-type encrypted, David Howells, (Fri Dec 3, 6:42 am)
Re: [PATCH v1.5 5/5] keys: add new key-type encrypted, David Howells, (Wed Dec 8, 3:54 am)