* [PATCH 0/2] fix bad constant expressions in tpm.h
@ 2016-09-19 20:22 ` Jarkko Sakkinen
0 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-09-19 20:22 UTC (permalink / raw)
To: Peter Huewe
Cc: Jarkko Sakkinen, Jason Gunthorpe, open list,
moderated list:TPM DEVICE DRIVER
Even though the cpu_to_be32() is open coded it is not a good convention
to call it in the enum definitions. This will also sparse errors about
invalid constant expressions.
Ed Swierk (1):
tpm: Clean up reading of timeout and duration capabilities
Jarkko Sakkinen (1):
tpm: fix bad constant expressions
drivers/char/tpm/tpm-interface.c | 78 +++++++++++++---------------------------
drivers/char/tpm/tpm-sysfs.c | 4 +--
drivers/char/tpm/tpm.h | 23 ++++++------
3 files changed, 38 insertions(+), 67 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 0/2] fix bad constant expressions in tpm.h
@ 2016-09-19 20:22 ` Jarkko Sakkinen
0 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-09-19 20:22 UTC (permalink / raw)
To: Peter Huewe
Cc: Jarkko Sakkinen, Jason Gunthorpe, open list,
moderated list:TPM DEVICE DRIVER
Even though the cpu_to_be32() is open coded it is not a good convention
to call it in the enum definitions. This will also sparse errors about
invalid constant expressions.
Ed Swierk (1):
tpm: Clean up reading of timeout and duration capabilities
Jarkko Sakkinen (1):
tpm: fix bad constant expressions
drivers/char/tpm/tpm-interface.c | 78 +++++++++++++---------------------------
drivers/char/tpm/tpm-sysfs.c | 4 +--
drivers/char/tpm/tpm.h | 23 ++++++------
3 files changed, 38 insertions(+), 67 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/2] tpm: Clean up reading of timeout and duration capabilities
@ 2016-09-19 20:22 ` Jarkko Sakkinen
0 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-09-19 20:22 UTC (permalink / raw)
To: Peter Huewe
Cc: Ed Swierk, Jarkko Sakkinen, Marcel Selhorst, Jason Gunthorpe,
moderated list:TPM DEVICE DRIVER, open list
From: Ed Swierk <eswierk@skyportsystems.com>
Call tpm_getcap() from tpm_get_timeouts() to eliminate redundant
code. Return all errors to the caller rather than swallowing them
(e.g. when tpm_transmit_cmd() returns nonzero).
Signed-off-by: Ed Swierk <eswierk@skyportsystems.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
drivers/char/tpm/tpm-interface.c | 65 +++++++++++-----------------------------
1 file changed, 17 insertions(+), 48 deletions(-)
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 8de6187..ca6162e 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -488,10 +488,9 @@ static int tpm_startup(struct tpm_chip *chip, __be16 startup_type)
int tpm_get_timeouts(struct tpm_chip *chip)
{
- struct tpm_cmd_t tpm_cmd;
+ cap_t cap;
unsigned long new_timeout[4];
unsigned long old_timeout[4];
- struct duration_t *duration_cap;
ssize_t rc;
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
@@ -509,43 +508,25 @@ int tpm_get_timeouts(struct tpm_chip *chip)
return 0;
}
- tpm_cmd.header.in = tpm_getcap_header;
- tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
- tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
- tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0,
- NULL);
-
+ rc = tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap,
+ "attempting to determine the timeouts");
if (rc == TPM_ERR_INVALID_POSTINIT) {
/* The TPM is not started, we are the first to talk to it.
Execute a startup command. */
- dev_info(&chip->dev, "Issuing TPM_STARTUP");
+ dev_info(&chip->dev, "Issuing TPM_STARTUP\n");
if (tpm_startup(chip, TPM_ST_CLEAR))
return rc;
- tpm_cmd.header.in = tpm_getcap_header;
- tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
- tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
- tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
- 0, NULL);
+ rc = tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap,
+ "attempting to determine the timeouts");
}
- if (rc) {
- dev_err(&chip->dev,
- "A TPM error (%zd) occurred attempting to determine the timeouts\n",
- rc);
- goto duration;
- }
-
- if (be32_to_cpu(tpm_cmd.header.out.return_code) != 0 ||
- be32_to_cpu(tpm_cmd.header.out.length)
- != sizeof(tpm_cmd.header.out) + sizeof(u32) + 4 * sizeof(u32))
- return -EINVAL;
+ if (rc)
+ return rc;
- old_timeout[0] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.a);
- old_timeout[1] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.b);
- old_timeout[2] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.c);
- old_timeout[3] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.d);
+ old_timeout[0] = be32_to_cpu(cap.timeout.a);
+ old_timeout[1] = be32_to_cpu(cap.timeout.b);
+ old_timeout[2] = be32_to_cpu(cap.timeout.c);
+ old_timeout[3] = be32_to_cpu(cap.timeout.d);
memcpy(new_timeout, old_timeout, sizeof(new_timeout));
/*
@@ -583,29 +564,17 @@ int tpm_get_timeouts(struct tpm_chip *chip)
chip->timeout_c = usecs_to_jiffies(new_timeout[2]);
chip->timeout_d = usecs_to_jiffies(new_timeout[3]);
-duration:
- tpm_cmd.header.in = tpm_getcap_header;
- tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
- tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
- tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_DURATION;
-
- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0,
- "attempting to determine the durations");
+ rc = tpm_getcap(chip, TPM_CAP_PROP_TIS_DURATION, &cap,
+ "attempting to determine the durations");
if (rc)
return rc;
- if (be32_to_cpu(tpm_cmd.header.out.return_code) != 0 ||
- be32_to_cpu(tpm_cmd.header.out.length)
- != sizeof(tpm_cmd.header.out) + sizeof(u32) + 3 * sizeof(u32))
- return -EINVAL;
-
- duration_cap = &tpm_cmd.params.getcap_out.cap.duration;
chip->duration[TPM_SHORT] =
- usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_short));
+ usecs_to_jiffies(be32_to_cpu(cap.duration.tpm_short));
chip->duration[TPM_MEDIUM] =
- usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_medium));
+ usecs_to_jiffies(be32_to_cpu(cap.duration.tpm_medium));
chip->duration[TPM_LONG] =
- usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_long));
+ usecs_to_jiffies(be32_to_cpu(cap.duration.tpm_long));
/* The Broadcom BCM0102 chipset in a Dell Latitude D820 gets the above
* value wrong and apparently reports msecs rather than usecs. So we
--
2.7.4
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 1/2] tpm: Clean up reading of timeout and duration capabilities
@ 2016-09-19 20:22 ` Jarkko Sakkinen
0 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-09-19 20:22 UTC (permalink / raw)
To: Peter Huewe; +Cc: open list, moderated list:TPM DEVICE DRIVER
From: Ed Swierk <eswierk-FilZDy9cOaHkQYj/0HfcvtBPR1lH4CV8@public.gmane.org>
Call tpm_getcap() from tpm_get_timeouts() to eliminate redundant
code. Return all errors to the caller rather than swallowing them
(e.g. when tpm_transmit_cmd() returns nonzero).
Signed-off-by: Ed Swierk <eswierk-FilZDy9cOaHkQYj/0HfcvtBPR1lH4CV8@public.gmane.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/char/tpm/tpm-interface.c | 65 +++++++++++-----------------------------
1 file changed, 17 insertions(+), 48 deletions(-)
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 8de6187..ca6162e 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -488,10 +488,9 @@ static int tpm_startup(struct tpm_chip *chip, __be16 startup_type)
int tpm_get_timeouts(struct tpm_chip *chip)
{
- struct tpm_cmd_t tpm_cmd;
+ cap_t cap;
unsigned long new_timeout[4];
unsigned long old_timeout[4];
- struct duration_t *duration_cap;
ssize_t rc;
if (chip->flags & TPM_CHIP_FLAG_TPM2) {
@@ -509,43 +508,25 @@ int tpm_get_timeouts(struct tpm_chip *chip)
return 0;
}
- tpm_cmd.header.in = tpm_getcap_header;
- tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
- tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
- tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0,
- NULL);
-
+ rc = tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap,
+ "attempting to determine the timeouts");
if (rc == TPM_ERR_INVALID_POSTINIT) {
/* The TPM is not started, we are the first to talk to it.
Execute a startup command. */
- dev_info(&chip->dev, "Issuing TPM_STARTUP");
+ dev_info(&chip->dev, "Issuing TPM_STARTUP\n");
if (tpm_startup(chip, TPM_ST_CLEAR))
return rc;
- tpm_cmd.header.in = tpm_getcap_header;
- tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
- tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
- tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
- 0, NULL);
+ rc = tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap,
+ "attempting to determine the timeouts");
}
- if (rc) {
- dev_err(&chip->dev,
- "A TPM error (%zd) occurred attempting to determine the timeouts\n",
- rc);
- goto duration;
- }
-
- if (be32_to_cpu(tpm_cmd.header.out.return_code) != 0 ||
- be32_to_cpu(tpm_cmd.header.out.length)
- != sizeof(tpm_cmd.header.out) + sizeof(u32) + 4 * sizeof(u32))
- return -EINVAL;
+ if (rc)
+ return rc;
- old_timeout[0] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.a);
- old_timeout[1] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.b);
- old_timeout[2] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.c);
- old_timeout[3] = be32_to_cpu(tpm_cmd.params.getcap_out.cap.timeout.d);
+ old_timeout[0] = be32_to_cpu(cap.timeout.a);
+ old_timeout[1] = be32_to_cpu(cap.timeout.b);
+ old_timeout[2] = be32_to_cpu(cap.timeout.c);
+ old_timeout[3] = be32_to_cpu(cap.timeout.d);
memcpy(new_timeout, old_timeout, sizeof(new_timeout));
/*
@@ -583,29 +564,17 @@ int tpm_get_timeouts(struct tpm_chip *chip)
chip->timeout_c = usecs_to_jiffies(new_timeout[2]);
chip->timeout_d = usecs_to_jiffies(new_timeout[3]);
-duration:
- tpm_cmd.header.in = tpm_getcap_header;
- tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
- tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
- tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_DURATION;
-
- rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0,
- "attempting to determine the durations");
+ rc = tpm_getcap(chip, TPM_CAP_PROP_TIS_DURATION, &cap,
+ "attempting to determine the durations");
if (rc)
return rc;
- if (be32_to_cpu(tpm_cmd.header.out.return_code) != 0 ||
- be32_to_cpu(tpm_cmd.header.out.length)
- != sizeof(tpm_cmd.header.out) + sizeof(u32) + 3 * sizeof(u32))
- return -EINVAL;
-
- duration_cap = &tpm_cmd.params.getcap_out.cap.duration;
chip->duration[TPM_SHORT] =
- usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_short));
+ usecs_to_jiffies(be32_to_cpu(cap.duration.tpm_short));
chip->duration[TPM_MEDIUM] =
- usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_medium));
+ usecs_to_jiffies(be32_to_cpu(cap.duration.tpm_medium));
chip->duration[TPM_LONG] =
- usecs_to_jiffies(be32_to_cpu(duration_cap->tpm_long));
+ usecs_to_jiffies(be32_to_cpu(cap.duration.tpm_long));
/* The Broadcom BCM0102 chipset in a Dell Latitude D820 gets the above
* value wrong and apparently reports msecs rather than usecs. So we
--
2.7.4
------------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/2] tpm: fix bad constant expressions
@ 2016-09-19 20:22 ` Jarkko Sakkinen
0 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-09-19 20:22 UTC (permalink / raw)
To: Peter Huewe
Cc: Jarkko Sakkinen, Marcel Selhorst, Jason Gunthorpe,
moderated list:TPM DEVICE DRIVER, open list
Sparse reports "bad constant expression" for the use of cpu_to_be32
inside enums tpm_capabilities and tpm_sub_capabilities. Even though it
is probably expanded to a constant expression, it is probably cleaner not
to use it there.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
drivers/char/tpm/tpm-interface.c | 13 ++++++++-----
drivers/char/tpm/tpm-sysfs.c | 4 ++--
drivers/char/tpm/tpm.h | 23 +++++++++++------------
3 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index ca6162e..db7359f 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -444,19 +444,22 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
int rc;
tpm_cmd.header.in = tpm_getcap_header;
- if (subcap_id == CAP_VERSION_1_1 || subcap_id == CAP_VERSION_1_2) {
- tpm_cmd.params.getcap_in.cap = subcap_id;
+ if (subcap_id == TPM_CAP_VERSION_1_1 ||
+ subcap_id == TPM_CAP_VERSION_1_2) {
+ tpm_cmd.params.getcap_in.cap = cpu_to_be32(subcap_id);
/*subcap field not necessary */
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(0);
tpm_cmd.header.in.length -= cpu_to_be32(sizeof(__be32));
} else {
if (subcap_id == TPM_CAP_FLAG_PERM ||
subcap_id == TPM_CAP_FLAG_VOL)
- tpm_cmd.params.getcap_in.cap = TPM_CAP_FLAG;
+ tpm_cmd.params.getcap_in.cap =
+ cpu_to_be32(TPM_CAP_FLAG);
else
- tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
+ tpm_cmd.params.getcap_in.cap =
+ cpu_to_be32(TPM_CAP_PROP);
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
- tpm_cmd.params.getcap_in.subcap = subcap_id;
+ tpm_cmd.params.getcap_in.subcap = cpu_to_be32(subcap_id);
}
rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0,
desc);
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index a76ab4a..59a1ead 100644
--- a/drivers/char/tpm/tpm-sysfs.c
+++ b/drivers/char/tpm/tpm-sysfs.c
@@ -193,7 +193,7 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,
be32_to_cpu(cap.manufacturer_id));
/* Try to get a TPM version 1.2 TPM_CAP_VERSION_INFO */
- rc = tpm_getcap(chip, CAP_VERSION_1_2, &cap,
+ rc = tpm_getcap(chip, TPM_CAP_VERSION_1_2, &cap,
"attempting to determine the 1.2 version");
if (!rc) {
str += sprintf(str,
@@ -204,7 +204,7 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,
cap.tpm_version_1_2.revMinor);
} else {
/* Otherwise just use TPM_STRUCT_VER */
- rc = tpm_getcap(chip, CAP_VERSION_1_1, &cap,
+ rc = tpm_getcap(chip, TPM_CAP_VERSION_1_1, &cap,
"attempting to determine the 1.1 version");
if (rc)
return 0;
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 4d183c9..edc6f75 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -282,21 +282,20 @@ typedef union {
} cap_t;
enum tpm_capabilities {
- TPM_CAP_FLAG = cpu_to_be32(4),
- TPM_CAP_PROP = cpu_to_be32(5),
- CAP_VERSION_1_1 = cpu_to_be32(0x06),
- CAP_VERSION_1_2 = cpu_to_be32(0x1A)
+ TPM_CAP_FLAG = 4,
+ TPM_CAP_PROP = 5,
+ TPM_CAP_VERSION_1_1 = 0x06,
+ TPM_CAP_VERSION_1_2 = 0x1A,
};
enum tpm_sub_capabilities {
- TPM_CAP_PROP_PCR = cpu_to_be32(0x101),
- TPM_CAP_PROP_MANUFACTURER = cpu_to_be32(0x103),
- TPM_CAP_FLAG_PERM = cpu_to_be32(0x108),
- TPM_CAP_FLAG_VOL = cpu_to_be32(0x109),
- TPM_CAP_PROP_OWNER = cpu_to_be32(0x111),
- TPM_CAP_PROP_TIS_TIMEOUT = cpu_to_be32(0x115),
- TPM_CAP_PROP_TIS_DURATION = cpu_to_be32(0x120),
-
+ TPM_CAP_PROP_PCR = 0x101,
+ TPM_CAP_PROP_MANUFACTURER = 0x103,
+ TPM_CAP_FLAG_PERM = 0x108,
+ TPM_CAP_FLAG_VOL = 0x109,
+ TPM_CAP_PROP_OWNER = 0x111,
+ TPM_CAP_PROP_TIS_TIMEOUT = 0x115,
+ TPM_CAP_PROP_TIS_DURATION = 0x120,
};
struct tpm_getcap_params_in {
--
2.7.4
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/2] tpm: fix bad constant expressions
@ 2016-09-19 20:22 ` Jarkko Sakkinen
0 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-09-19 20:22 UTC (permalink / raw)
To: Peter Huewe; +Cc: moderated list:TPM DEVICE DRIVER, open list
Sparse reports "bad constant expression" for the use of cpu_to_be32
inside enums tpm_capabilities and tpm_sub_capabilities. Even though it
is probably expanded to a constant expression, it is probably cleaner not
to use it there.
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
drivers/char/tpm/tpm-interface.c | 13 ++++++++-----
drivers/char/tpm/tpm-sysfs.c | 4 ++--
drivers/char/tpm/tpm.h | 23 +++++++++++------------
3 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index ca6162e..db7359f 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -444,19 +444,22 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
int rc;
tpm_cmd.header.in = tpm_getcap_header;
- if (subcap_id == CAP_VERSION_1_1 || subcap_id == CAP_VERSION_1_2) {
- tpm_cmd.params.getcap_in.cap = subcap_id;
+ if (subcap_id == TPM_CAP_VERSION_1_1 ||
+ subcap_id == TPM_CAP_VERSION_1_2) {
+ tpm_cmd.params.getcap_in.cap = cpu_to_be32(subcap_id);
/*subcap field not necessary */
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(0);
tpm_cmd.header.in.length -= cpu_to_be32(sizeof(__be32));
} else {
if (subcap_id == TPM_CAP_FLAG_PERM ||
subcap_id == TPM_CAP_FLAG_VOL)
- tpm_cmd.params.getcap_in.cap = TPM_CAP_FLAG;
+ tpm_cmd.params.getcap_in.cap =
+ cpu_to_be32(TPM_CAP_FLAG);
else
- tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
+ tpm_cmd.params.getcap_in.cap =
+ cpu_to_be32(TPM_CAP_PROP);
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
- tpm_cmd.params.getcap_in.subcap = subcap_id;
+ tpm_cmd.params.getcap_in.subcap = cpu_to_be32(subcap_id);
}
rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0,
desc);
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index a76ab4a..59a1ead 100644
--- a/drivers/char/tpm/tpm-sysfs.c
+++ b/drivers/char/tpm/tpm-sysfs.c
@@ -193,7 +193,7 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,
be32_to_cpu(cap.manufacturer_id));
/* Try to get a TPM version 1.2 TPM_CAP_VERSION_INFO */
- rc = tpm_getcap(chip, CAP_VERSION_1_2, &cap,
+ rc = tpm_getcap(chip, TPM_CAP_VERSION_1_2, &cap,
"attempting to determine the 1.2 version");
if (!rc) {
str += sprintf(str,
@@ -204,7 +204,7 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,
cap.tpm_version_1_2.revMinor);
} else {
/* Otherwise just use TPM_STRUCT_VER */
- rc = tpm_getcap(chip, CAP_VERSION_1_1, &cap,
+ rc = tpm_getcap(chip, TPM_CAP_VERSION_1_1, &cap,
"attempting to determine the 1.1 version");
if (rc)
return 0;
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 4d183c9..edc6f75 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -282,21 +282,20 @@ typedef union {
} cap_t;
enum tpm_capabilities {
- TPM_CAP_FLAG = cpu_to_be32(4),
- TPM_CAP_PROP = cpu_to_be32(5),
- CAP_VERSION_1_1 = cpu_to_be32(0x06),
- CAP_VERSION_1_2 = cpu_to_be32(0x1A)
+ TPM_CAP_FLAG = 4,
+ TPM_CAP_PROP = 5,
+ TPM_CAP_VERSION_1_1 = 0x06,
+ TPM_CAP_VERSION_1_2 = 0x1A,
};
enum tpm_sub_capabilities {
- TPM_CAP_PROP_PCR = cpu_to_be32(0x101),
- TPM_CAP_PROP_MANUFACTURER = cpu_to_be32(0x103),
- TPM_CAP_FLAG_PERM = cpu_to_be32(0x108),
- TPM_CAP_FLAG_VOL = cpu_to_be32(0x109),
- TPM_CAP_PROP_OWNER = cpu_to_be32(0x111),
- TPM_CAP_PROP_TIS_TIMEOUT = cpu_to_be32(0x115),
- TPM_CAP_PROP_TIS_DURATION = cpu_to_be32(0x120),
-
+ TPM_CAP_PROP_PCR = 0x101,
+ TPM_CAP_PROP_MANUFACTURER = 0x103,
+ TPM_CAP_FLAG_PERM = 0x108,
+ TPM_CAP_FLAG_VOL = 0x109,
+ TPM_CAP_PROP_OWNER = 0x111,
+ TPM_CAP_PROP_TIS_TIMEOUT = 0x115,
+ TPM_CAP_PROP_TIS_DURATION = 0x120,
};
struct tpm_getcap_params_in {
--
2.7.4
------------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] tpm: Clean up reading of timeout and duration capabilities
2016-09-19 20:22 ` Jarkko Sakkinen
@ 2016-09-19 23:24 ` Jason Gunthorpe
-1 siblings, 0 replies; 20+ messages in thread
From: Jason Gunthorpe @ 2016-09-19 23:24 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: Peter Huewe, Ed Swierk, Marcel Selhorst,
moderated list:TPM DEVICE DRIVER, open list
On Mon, Sep 19, 2016 at 11:22:08PM +0300, Jarkko Sakkinen wrote:
> From: Ed Swierk <eswierk@skyportsystems.com>
>
> Call tpm_getcap() from tpm_get_timeouts() to eliminate redundant
> code. Return all errors to the caller rather than swallowing them
> (e.g. when tpm_transmit_cmd() returns nonzero).
I didn't look at these closely, but I agree with the idea.
Jason
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] tpm: Clean up reading of timeout and duration capabilities
@ 2016-09-19 23:24 ` Jason Gunthorpe
0 siblings, 0 replies; 20+ messages in thread
From: Jason Gunthorpe @ 2016-09-19 23:24 UTC (permalink / raw)
To: Jarkko Sakkinen
Cc: Peter Huewe, Ed Swierk, Marcel Selhorst,
moderated list:TPM DEVICE DRIVER, open list
On Mon, Sep 19, 2016 at 11:22:08PM +0300, Jarkko Sakkinen wrote:
> From: Ed Swierk <eswierk@skyportsystems.com>
>
> Call tpm_getcap() from tpm_get_timeouts() to eliminate redundant
> code. Return all errors to the caller rather than swallowing them
> (e.g. when tpm_transmit_cmd() returns nonzero).
I didn't look at these closely, but I agree with the idea.
Jason
^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
@ 2016-09-20 7:08 ` Winkler, Tomas
0 siblings, 0 replies; 20+ messages in thread
From: Winkler, Tomas @ 2016-09-20 7:08 UTC (permalink / raw)
To: Jarkko Sakkinen, Peter Huewe; +Cc: moderated list:TPM DEVICE DRIVER, open list
> -----Original Message-----
> From: Jarkko Sakkinen [mailto:jarkko.sakkinen@linux.intel.com]
> Sent: Monday, September 19, 2016 23:22
> To: Peter Huewe <peterhuewe@gmx.de>
> Cc: moderated list:TPM DEVICE DRIVER <tpmdd-
> devel@lists.sourceforge.net>; open list <linux-kernel@vger.kernel.org>
> Subject: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
>
> Sparse reports "bad constant expression" for the use of cpu_to_be32 inside
> enums tpm_capabilities and tpm_sub_capabilities. Even though it is probably
> expanded to a constant expression, it is probably cleaner not to use it there.
Swap macros were rewritten due to possible compiler bug https://lkml.org/lkml/2016/5/2/597
And the warning is actually a bug in sparse, it fails to detect constant expression now.
Tomas
>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
> drivers/char/tpm/tpm-interface.c | 13 ++++++++-----
> drivers/char/tpm/tpm-sysfs.c | 4 ++--
> drivers/char/tpm/tpm.h | 23 +++++++++++------------
> 3 files changed, 21 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-
> interface.c
> index ca6162e..db7359f 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -444,19 +444,22 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32
> subcap_id, cap_t *cap,
> int rc;
>
> tpm_cmd.header.in = tpm_getcap_header;
> - if (subcap_id == CAP_VERSION_1_1 || subcap_id ==
> CAP_VERSION_1_2) {
> - tpm_cmd.params.getcap_in.cap = subcap_id;
> + if (subcap_id == TPM_CAP_VERSION_1_1 ||
> + subcap_id == TPM_CAP_VERSION_1_2) {
> + tpm_cmd.params.getcap_in.cap = cpu_to_be32(subcap_id);
> /*subcap field not necessary */
> tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(0);
> tpm_cmd.header.in.length -= cpu_to_be32(sizeof(__be32));
> } else {
> if (subcap_id == TPM_CAP_FLAG_PERM ||
> subcap_id == TPM_CAP_FLAG_VOL)
> - tpm_cmd.params.getcap_in.cap = TPM_CAP_FLAG;
> + tpm_cmd.params.getcap_in.cap =
> + cpu_to_be32(TPM_CAP_FLAG);
> else
> - tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
> + tpm_cmd.params.getcap_in.cap =
> + cpu_to_be32(TPM_CAP_PROP);
> tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
> - tpm_cmd.params.getcap_in.subcap = subcap_id;
> + tpm_cmd.params.getcap_in.subcap =
> cpu_to_be32(subcap_id);
> }
> rc = tpm_transmit_cmd(chip, &tpm_cmd,
> TPM_INTERNAL_RESULT_SIZE, 0,
> desc);
> diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
> index a76ab4a..59a1ead 100644
> --- a/drivers/char/tpm/tpm-sysfs.c
> +++ b/drivers/char/tpm/tpm-sysfs.c
> @@ -193,7 +193,7 @@ static ssize_t caps_show(struct device *dev, struct
> device_attribute *attr,
> be32_to_cpu(cap.manufacturer_id));
>
> /* Try to get a TPM version 1.2 TPM_CAP_VERSION_INFO */
> - rc = tpm_getcap(chip, CAP_VERSION_1_2, &cap,
> + rc = tpm_getcap(chip, TPM_CAP_VERSION_1_2, &cap,
> "attempting to determine the 1.2 version");
> if (!rc) {
> str += sprintf(str,
> @@ -204,7 +204,7 @@ static ssize_t caps_show(struct device *dev, struct
> device_attribute *attr,
> cap.tpm_version_1_2.revMinor);
> } else {
> /* Otherwise just use TPM_STRUCT_VER */
> - rc = tpm_getcap(chip, CAP_VERSION_1_1, &cap,
> + rc = tpm_getcap(chip, TPM_CAP_VERSION_1_1, &cap,
> "attempting to determine the 1.1 version");
> if (rc)
> return 0;
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index
> 4d183c9..edc6f75 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -282,21 +282,20 @@ typedef union {
> } cap_t;
>
> enum tpm_capabilities {
> - TPM_CAP_FLAG = cpu_to_be32(4),
> - TPM_CAP_PROP = cpu_to_be32(5),
> - CAP_VERSION_1_1 = cpu_to_be32(0x06),
> - CAP_VERSION_1_2 = cpu_to_be32(0x1A)
> + TPM_CAP_FLAG = 4,
> + TPM_CAP_PROP = 5,
> + TPM_CAP_VERSION_1_1 = 0x06,
> + TPM_CAP_VERSION_1_2 = 0x1A,
> };
>
> enum tpm_sub_capabilities {
> - TPM_CAP_PROP_PCR = cpu_to_be32(0x101),
> - TPM_CAP_PROP_MANUFACTURER = cpu_to_be32(0x103),
> - TPM_CAP_FLAG_PERM = cpu_to_be32(0x108),
> - TPM_CAP_FLAG_VOL = cpu_to_be32(0x109),
> - TPM_CAP_PROP_OWNER = cpu_to_be32(0x111),
> - TPM_CAP_PROP_TIS_TIMEOUT = cpu_to_be32(0x115),
> - TPM_CAP_PROP_TIS_DURATION = cpu_to_be32(0x120),
> -
> + TPM_CAP_PROP_PCR = 0x101,
> + TPM_CAP_PROP_MANUFACTURER = 0x103,
> + TPM_CAP_FLAG_PERM = 0x108,
> + TPM_CAP_FLAG_VOL = 0x109,
> + TPM_CAP_PROP_OWNER = 0x111,
> + TPM_CAP_PROP_TIS_TIMEOUT = 0x115,
> + TPM_CAP_PROP_TIS_DURATION = 0x120,
> };
>
> struct tpm_getcap_params_in {
> --
> 2.7.4
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> tpmdd-devel mailing list
> tpmdd-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/2] tpm: fix bad constant expressions
@ 2016-09-20 7:08 ` Winkler, Tomas
0 siblings, 0 replies; 20+ messages in thread
From: Winkler, Tomas @ 2016-09-20 7:08 UTC (permalink / raw)
To: Jarkko Sakkinen, Peter Huewe; +Cc: moderated list:TPM DEVICE DRIVER, open list
> -----Original Message-----
> From: Jarkko Sakkinen [mailto:jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org]
> Sent: Monday, September 19, 2016 23:22
> To: Peter Huewe <peterhuewe-Mmb7MZpHnFY@public.gmane.org>
> Cc: moderated list:TPM DEVICE DRIVER <tpmdd-
> devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>; open list <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
> Subject: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
>
> Sparse reports "bad constant expression" for the use of cpu_to_be32 inside
> enums tpm_capabilities and tpm_sub_capabilities. Even though it is probably
> expanded to a constant expression, it is probably cleaner not to use it there.
Swap macros were rewritten due to possible compiler bug https://lkml.org/lkml/2016/5/2/597
And the warning is actually a bug in sparse, it fails to detect constant expression now.
Tomas
>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> ---
> drivers/char/tpm/tpm-interface.c | 13 ++++++++-----
> drivers/char/tpm/tpm-sysfs.c | 4 ++--
> drivers/char/tpm/tpm.h | 23 +++++++++++------------
> 3 files changed, 21 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-
> interface.c
> index ca6162e..db7359f 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -444,19 +444,22 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32
> subcap_id, cap_t *cap,
> int rc;
>
> tpm_cmd.header.in = tpm_getcap_header;
> - if (subcap_id == CAP_VERSION_1_1 || subcap_id ==
> CAP_VERSION_1_2) {
> - tpm_cmd.params.getcap_in.cap = subcap_id;
> + if (subcap_id == TPM_CAP_VERSION_1_1 ||
> + subcap_id == TPM_CAP_VERSION_1_2) {
> + tpm_cmd.params.getcap_in.cap = cpu_to_be32(subcap_id);
> /*subcap field not necessary */
> tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(0);
> tpm_cmd.header.in.length -= cpu_to_be32(sizeof(__be32));
> } else {
> if (subcap_id == TPM_CAP_FLAG_PERM ||
> subcap_id == TPM_CAP_FLAG_VOL)
> - tpm_cmd.params.getcap_in.cap = TPM_CAP_FLAG;
> + tpm_cmd.params.getcap_in.cap =
> + cpu_to_be32(TPM_CAP_FLAG);
> else
> - tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
> + tpm_cmd.params.getcap_in.cap =
> + cpu_to_be32(TPM_CAP_PROP);
> tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
> - tpm_cmd.params.getcap_in.subcap = subcap_id;
> + tpm_cmd.params.getcap_in.subcap =
> cpu_to_be32(subcap_id);
> }
> rc = tpm_transmit_cmd(chip, &tpm_cmd,
> TPM_INTERNAL_RESULT_SIZE, 0,
> desc);
> diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
> index a76ab4a..59a1ead 100644
> --- a/drivers/char/tpm/tpm-sysfs.c
> +++ b/drivers/char/tpm/tpm-sysfs.c
> @@ -193,7 +193,7 @@ static ssize_t caps_show(struct device *dev, struct
> device_attribute *attr,
> be32_to_cpu(cap.manufacturer_id));
>
> /* Try to get a TPM version 1.2 TPM_CAP_VERSION_INFO */
> - rc = tpm_getcap(chip, CAP_VERSION_1_2, &cap,
> + rc = tpm_getcap(chip, TPM_CAP_VERSION_1_2, &cap,
> "attempting to determine the 1.2 version");
> if (!rc) {
> str += sprintf(str,
> @@ -204,7 +204,7 @@ static ssize_t caps_show(struct device *dev, struct
> device_attribute *attr,
> cap.tpm_version_1_2.revMinor);
> } else {
> /* Otherwise just use TPM_STRUCT_VER */
> - rc = tpm_getcap(chip, CAP_VERSION_1_1, &cap,
> + rc = tpm_getcap(chip, TPM_CAP_VERSION_1_1, &cap,
> "attempting to determine the 1.1 version");
> if (rc)
> return 0;
> diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index
> 4d183c9..edc6f75 100644
> --- a/drivers/char/tpm/tpm.h
> +++ b/drivers/char/tpm/tpm.h
> @@ -282,21 +282,20 @@ typedef union {
> } cap_t;
>
> enum tpm_capabilities {
> - TPM_CAP_FLAG = cpu_to_be32(4),
> - TPM_CAP_PROP = cpu_to_be32(5),
> - CAP_VERSION_1_1 = cpu_to_be32(0x06),
> - CAP_VERSION_1_2 = cpu_to_be32(0x1A)
> + TPM_CAP_FLAG = 4,
> + TPM_CAP_PROP = 5,
> + TPM_CAP_VERSION_1_1 = 0x06,
> + TPM_CAP_VERSION_1_2 = 0x1A,
> };
>
> enum tpm_sub_capabilities {
> - TPM_CAP_PROP_PCR = cpu_to_be32(0x101),
> - TPM_CAP_PROP_MANUFACTURER = cpu_to_be32(0x103),
> - TPM_CAP_FLAG_PERM = cpu_to_be32(0x108),
> - TPM_CAP_FLAG_VOL = cpu_to_be32(0x109),
> - TPM_CAP_PROP_OWNER = cpu_to_be32(0x111),
> - TPM_CAP_PROP_TIS_TIMEOUT = cpu_to_be32(0x115),
> - TPM_CAP_PROP_TIS_DURATION = cpu_to_be32(0x120),
> -
> + TPM_CAP_PROP_PCR = 0x101,
> + TPM_CAP_PROP_MANUFACTURER = 0x103,
> + TPM_CAP_FLAG_PERM = 0x108,
> + TPM_CAP_FLAG_VOL = 0x109,
> + TPM_CAP_PROP_OWNER = 0x111,
> + TPM_CAP_PROP_TIS_TIMEOUT = 0x115,
> + TPM_CAP_PROP_TIS_DURATION = 0x120,
> };
>
> struct tpm_getcap_params_in {
> --
> 2.7.4
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> tpmdd-devel mailing list
> tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/tpmdd-devel
------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
2016-09-20 7:08 ` Winkler, Tomas
@ 2016-09-20 9:56 ` Jarkko Sakkinen
-1 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-09-20 9:56 UTC (permalink / raw)
To: Winkler, Tomas; +Cc: Peter Huewe, moderated list:TPM DEVICE DRIVER, open list
On Tue, Sep 20, 2016 at 07:08:40AM +0000, Winkler, Tomas wrote:
>
> > -----Original Message-----
> > From: Jarkko Sakkinen [mailto:jarkko.sakkinen@linux.intel.com]
> > Sent: Monday, September 19, 2016 23:22
> > To: Peter Huewe <peterhuewe@gmx.de>
> > Cc: moderated list:TPM DEVICE DRIVER <tpmdd-
> > devel@lists.sourceforge.net>; open list <linux-kernel@vger.kernel.org>
> > Subject: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
> >
> > Sparse reports "bad constant expression" for the use of cpu_to_be32 inside
> > enums tpm_capabilities and tpm_sub_capabilities. Even though it is probably
> > expanded to a constant expression, it is probably cleaner not to use it there.
>
>
> Swap macros were rewritten due to possible compiler bug https://lkml.org/lkml/2016/5/2/597
> And the warning is actually a bug in sparse, it fails to detect constant expression now.
I still think that these must be change in order to have some
consistency in the subsystem. Now there are two differing
conventions.
/Jarkko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
@ 2016-09-20 9:56 ` Jarkko Sakkinen
0 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-09-20 9:56 UTC (permalink / raw)
To: Winkler, Tomas; +Cc: Peter Huewe, moderated list:TPM DEVICE DRIVER, open list
On Tue, Sep 20, 2016 at 07:08:40AM +0000, Winkler, Tomas wrote:
>
> > -----Original Message-----
> > From: Jarkko Sakkinen [mailto:jarkko.sakkinen@linux.intel.com]
> > Sent: Monday, September 19, 2016 23:22
> > To: Peter Huewe <peterhuewe@gmx.de>
> > Cc: moderated list:TPM DEVICE DRIVER <tpmdd-
> > devel@lists.sourceforge.net>; open list <linux-kernel@vger.kernel.org>
> > Subject: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
> >
> > Sparse reports "bad constant expression" for the use of cpu_to_be32 inside
> > enums tpm_capabilities and tpm_sub_capabilities. Even though it is probably
> > expanded to a constant expression, it is probably cleaner not to use it there.
>
>
> Swap macros were rewritten due to possible compiler bug https://lkml.org/lkml/2016/5/2/597
> And the warning is actually a bug in sparse, it fails to detect constant expression now.
I still think that these must be change in order to have some
consistency in the subsystem. Now there are two differing
conventions.
/Jarkko
^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
2016-09-20 9:56 ` Jarkko Sakkinen
@ 2016-09-20 9:57 ` Winkler, Tomas
-1 siblings, 0 replies; 20+ messages in thread
From: Winkler, Tomas @ 2016-09-20 9:57 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: Peter Huewe, moderated list:TPM DEVICE DRIVER, open list
> On Tue, Sep 20, 2016 at 07:08:40AM +0000, Winkler, Tomas wrote:
> >
> > > -----Original Message-----
> > > From: Jarkko Sakkinen [mailto:jarkko.sakkinen@linux.intel.com]
> > > Sent: Monday, September 19, 2016 23:22
> > > To: Peter Huewe <peterhuewe@gmx.de>
> > > Cc: moderated list:TPM DEVICE DRIVER <tpmdd-
> > > devel@lists.sourceforge.net>; open list
> > > <linux-kernel@vger.kernel.org>
> > > Subject: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
> > >
> > > Sparse reports "bad constant expression" for the use of cpu_to_be32
> > > inside enums tpm_capabilities and tpm_sub_capabilities. Even though
> > > it is probably expanded to a constant expression, it is probably cleaner
> not to use it there.
> >
> >
> > Swap macros were rewritten due to possible compiler bug
> > https://lkml.org/lkml/2016/5/2/597
> > And the warning is actually a bug in sparse, it fails to detect constant
> expression now.
>
> I still think that these must be change in order to have some consistency in
> the subsystem. Now there are two differing conventions.
Nothing against the convention just the commit message is misleading in that sense.
Tomas
^ permalink raw reply [flat|nested] 20+ messages in thread
* RE: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
@ 2016-09-20 9:57 ` Winkler, Tomas
0 siblings, 0 replies; 20+ messages in thread
From: Winkler, Tomas @ 2016-09-20 9:57 UTC (permalink / raw)
To: Jarkko Sakkinen; +Cc: Peter Huewe, moderated list:TPM DEVICE DRIVER, open list
> On Tue, Sep 20, 2016 at 07:08:40AM +0000, Winkler, Tomas wrote:
> >
> > > -----Original Message-----
> > > From: Jarkko Sakkinen [mailto:jarkko.sakkinen@linux.intel.com]
> > > Sent: Monday, September 19, 2016 23:22
> > > To: Peter Huewe <peterhuewe@gmx.de>
> > > Cc: moderated list:TPM DEVICE DRIVER <tpmdd-
> > > devel@lists.sourceforge.net>; open list
> > > <linux-kernel@vger.kernel.org>
> > > Subject: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
> > >
> > > Sparse reports "bad constant expression" for the use of cpu_to_be32
> > > inside enums tpm_capabilities and tpm_sub_capabilities. Even though
> > > it is probably expanded to a constant expression, it is probably cleaner
> not to use it there.
> >
> >
> > Swap macros were rewritten due to possible compiler bug
> > https://lkml.org/lkml/2016/5/2/597
> > And the warning is actually a bug in sparse, it fails to detect constant
> expression now.
>
> I still think that these must be change in order to have some consistency in
> the subsystem. Now there are two differing conventions.
Nothing against the convention just the commit message is misleading in that sense.
Tomas
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
2016-09-20 9:57 ` Winkler, Tomas
@ 2016-09-20 12:03 ` Jarkko Sakkinen
-1 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-09-20 12:03 UTC (permalink / raw)
To: Winkler, Tomas; +Cc: Peter Huewe, moderated list:TPM DEVICE DRIVER, open list
On Tue, Sep 20, 2016 at 09:57:48AM +0000, Winkler, Tomas wrote:
>
> > On Tue, Sep 20, 2016 at 07:08:40AM +0000, Winkler, Tomas wrote:
> > >
> > > > -----Original Message-----
> > > > From: Jarkko Sakkinen [mailto:jarkko.sakkinen@linux.intel.com]
> > > > Sent: Monday, September 19, 2016 23:22
> > > > To: Peter Huewe <peterhuewe@gmx.de>
> > > > Cc: moderated list:TPM DEVICE DRIVER <tpmdd-
> > > > devel@lists.sourceforge.net>; open list
> > > > <linux-kernel@vger.kernel.org>
> > > > Subject: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
> > > >
> > > > Sparse reports "bad constant expression" for the use of cpu_to_be32
> > > > inside enums tpm_capabilities and tpm_sub_capabilities. Even though
> > > > it is probably expanded to a constant expression, it is probably cleaner
> > not to use it there.
> > >
> > >
> > > Swap macros were rewritten due to possible compiler bug
> > > https://lkml.org/lkml/2016/5/2/597
> > > And the warning is actually a bug in sparse, it fails to detect constant
> > expression now.
> >
> > I still think that these must be change in order to have some consistency in
> > the subsystem. Now there are two differing conventions.
>
> Nothing against the convention just the commit message is misleading
> in that sense. Tomas
Right. I can edit it to say that "sanitize the constant declarations" or
something like that.
/Jarkko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
@ 2016-09-20 12:03 ` Jarkko Sakkinen
0 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-09-20 12:03 UTC (permalink / raw)
To: Winkler, Tomas; +Cc: Peter Huewe, moderated list:TPM DEVICE DRIVER, open list
On Tue, Sep 20, 2016 at 09:57:48AM +0000, Winkler, Tomas wrote:
>
> > On Tue, Sep 20, 2016 at 07:08:40AM +0000, Winkler, Tomas wrote:
> > >
> > > > -----Original Message-----
> > > > From: Jarkko Sakkinen [mailto:jarkko.sakkinen@linux.intel.com]
> > > > Sent: Monday, September 19, 2016 23:22
> > > > To: Peter Huewe <peterhuewe@gmx.de>
> > > > Cc: moderated list:TPM DEVICE DRIVER <tpmdd-
> > > > devel@lists.sourceforge.net>; open list
> > > > <linux-kernel@vger.kernel.org>
> > > > Subject: [tpmdd-devel] [PATCH 2/2] tpm: fix bad constant expressions
> > > >
> > > > Sparse reports "bad constant expression" for the use of cpu_to_be32
> > > > inside enums tpm_capabilities and tpm_sub_capabilities. Even though
> > > > it is probably expanded to a constant expression, it is probably cleaner
> > not to use it there.
> > >
> > >
> > > Swap macros were rewritten due to possible compiler bug
> > > https://lkml.org/lkml/2016/5/2/597
> > > And the warning is actually a bug in sparse, it fails to detect constant
> > expression now.
> >
> > I still think that these must be change in order to have some consistency in
> > the subsystem. Now there are two differing conventions.
>
> Nothing against the convention just the commit message is misleading
> in that sense. Tomas
Right. I can edit it to say that "sanitize the constant declarations" or
something like that.
/Jarkko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] tpm: Clean up reading of timeout and duration capabilities
2016-09-19 23:24 ` Jason Gunthorpe
@ 2016-10-21 20:33 ` Jarkko Sakkinen
-1 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-10-21 20:33 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Peter Huewe, Ed Swierk, Marcel Selhorst,
moderated list:TPM DEVICE DRIVER, open list
On Mon, Sep 19, 2016 at 05:24:06PM -0600, Jason Gunthorpe wrote:
> On Mon, Sep 19, 2016 at 11:22:08PM +0300, Jarkko Sakkinen wrote:
> > From: Ed Swierk <eswierk@skyportsystems.com>
> >
> > Call tpm_getcap() from tpm_get_timeouts() to eliminate redundant
> > code. Return all errors to the caller rather than swallowing them
> > (e.g. when tpm_transmit_cmd() returns nonzero).
>
> I didn't look at these closely, but I agree with the idea.
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
/Jarkko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] tpm: Clean up reading of timeout and duration capabilities
@ 2016-10-21 20:33 ` Jarkko Sakkinen
0 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-10-21 20:33 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Peter Huewe, Ed Swierk, Marcel Selhorst,
moderated list:TPM DEVICE DRIVER, open list
On Mon, Sep 19, 2016 at 05:24:06PM -0600, Jason Gunthorpe wrote:
> On Mon, Sep 19, 2016 at 11:22:08PM +0300, Jarkko Sakkinen wrote:
> > From: Ed Swierk <eswierk@skyportsystems.com>
> >
> > Call tpm_getcap() from tpm_get_timeouts() to eliminate redundant
> > code. Return all errors to the caller rather than swallowing them
> > (e.g. when tpm_transmit_cmd() returns nonzero).
>
> I didn't look at these closely, but I agree with the idea.
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
/Jarkko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] tpm: Clean up reading of timeout and duration capabilities
2016-10-21 20:33 ` Jarkko Sakkinen
@ 2016-10-21 20:35 ` Jarkko Sakkinen
-1 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-10-21 20:35 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Peter Huewe, Ed Swierk, Marcel Selhorst,
moderated list:TPM DEVICE DRIVER, open list
On Fri, Oct 21, 2016 at 11:33:44PM +0300, Jarkko Sakkinen wrote:
> On Mon, Sep 19, 2016 at 05:24:06PM -0600, Jason Gunthorpe wrote:
> > On Mon, Sep 19, 2016 at 11:22:08PM +0300, Jarkko Sakkinen wrote:
> > > From: Ed Swierk <eswierk@skyportsystems.com>
> > >
> > > Call tpm_getcap() from tpm_get_timeouts() to eliminate redundant
> > > code. Return all errors to the caller rather than swallowing them
> > > (e.g. when tpm_transmit_cmd() returns nonzero).
> >
> > I didn't look at these closely, but I agree with the idea.
>
> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
I applied this.
/Jarkko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/2] tpm: Clean up reading of timeout and duration capabilities
@ 2016-10-21 20:35 ` Jarkko Sakkinen
0 siblings, 0 replies; 20+ messages in thread
From: Jarkko Sakkinen @ 2016-10-21 20:35 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Peter Huewe, Ed Swierk, Marcel Selhorst,
moderated list:TPM DEVICE DRIVER, open list
On Fri, Oct 21, 2016 at 11:33:44PM +0300, Jarkko Sakkinen wrote:
> On Mon, Sep 19, 2016 at 05:24:06PM -0600, Jason Gunthorpe wrote:
> > On Mon, Sep 19, 2016 at 11:22:08PM +0300, Jarkko Sakkinen wrote:
> > > From: Ed Swierk <eswierk@skyportsystems.com>
> > >
> > > Call tpm_getcap() from tpm_get_timeouts() to eliminate redundant
> > > code. Return all errors to the caller rather than swallowing them
> > > (e.g. when tpm_transmit_cmd() returns nonzero).
> >
> > I didn't look at these closely, but I agree with the idea.
>
> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
I applied this.
/Jarkko
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2016-10-21 20:35 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19 20:22 [PATCH 0/2] fix bad constant expressions in tpm.h Jarkko Sakkinen
2016-09-19 20:22 ` Jarkko Sakkinen
2016-09-19 20:22 ` [PATCH 1/2] tpm: Clean up reading of timeout and duration capabilities Jarkko Sakkinen
2016-09-19 20:22 ` Jarkko Sakkinen
2016-09-19 23:24 ` Jason Gunthorpe
2016-09-19 23:24 ` Jason Gunthorpe
2016-10-21 20:33 ` Jarkko Sakkinen
2016-10-21 20:33 ` Jarkko Sakkinen
2016-10-21 20:35 ` Jarkko Sakkinen
2016-10-21 20:35 ` Jarkko Sakkinen
2016-09-19 20:22 ` [PATCH 2/2] tpm: fix bad constant expressions Jarkko Sakkinen
2016-09-19 20:22 ` Jarkko Sakkinen
2016-09-20 7:08 ` [tpmdd-devel] " Winkler, Tomas
2016-09-20 7:08 ` Winkler, Tomas
2016-09-20 9:56 ` [tpmdd-devel] " Jarkko Sakkinen
2016-09-20 9:56 ` Jarkko Sakkinen
2016-09-20 9:57 ` Winkler, Tomas
2016-09-20 9:57 ` Winkler, Tomas
2016-09-20 12:03 ` Jarkko Sakkinen
2016-09-20 12:03 ` Jarkko Sakkinen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.