* [PATCH] tpm_tis_core: Use common error handling code in tpm_tis_send_data()
@ 2017-10-22 10:16 SF Markus Elfring
2017-10-23 7:34 ` Dan Carpenter
2017-10-23 13:42 ` Jarkko Sakkinen
0 siblings, 2 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-10-22 10:16 UTC (permalink / raw)
To: linux-integrity, Jarkko Sakkinen, Jason Gunthorpe, Peter Hüwe
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 22 Oct 2017 11:41:09 +0200
Add a jump target so that a specific error code assignment for timeout
conditions will be in the implementation only at the end of this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/char/tpm/tpm_tis_core.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index fdde971bc810..3681f7a74d1b 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -262,12 +262,10 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
status = tpm_tis_status(chip);
if ((status & TPM_STS_COMMAND_READY) == 0) {
tpm_tis_ready(chip);
- if (wait_for_tpm_stat
- (chip, TPM_STS_COMMAND_READY, chip->timeout_b,
- &priv->int_queue, false) < 0) {
- rc = -ETIME;
- goto out_err;
- }
+ if (wait_for_tpm_stat(chip, TPM_STS_COMMAND_READY,
+ chip->timeout_b, &priv->int_queue, false)
+ < 0)
+ goto report_timeout;
}
while (count < len - 1) {
@@ -286,10 +284,9 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
count += burstcnt;
if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
- &priv->int_queue, false) < 0) {
- rc = -ETIME;
- goto out_err;
- }
+ &priv->int_queue, false) < 0)
+ goto report_timeout;
+
status = tpm_tis_status(chip);
if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) {
rc = -EIO;
@@ -303,10 +300,9 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
goto out_err;
if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
- &priv->int_queue, false) < 0) {
- rc = -ETIME;
- goto out_err;
- }
+ &priv->int_queue, false) < 0)
+ goto report_timeout;
+
status = tpm_tis_status(chip);
if (!itpm && (status & TPM_STS_DATA_EXPECT) != 0) {
rc = -EIO;
@@ -315,6 +311,8 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
return 0;
+report_timeout:
+ rc = -ETIME;
out_err:
tpm_tis_ready(chip);
return rc;
--
2.14.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] tpm_tis_core: Use common error handling code in tpm_tis_send_data()
2017-10-22 10:16 [PATCH] tpm_tis_core: Use common error handling code in tpm_tis_send_data() SF Markus Elfring
@ 2017-10-23 7:34 ` Dan Carpenter
2017-10-23 13:42 ` Jarkko Sakkinen
1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2017-10-23 7:34 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-integrity, Jarkko Sakkinen, Jason Gunthorpe,
Peter Hüwe, LKML, kernel-janitors
Markus, you should focus on fixing bugs. The original code is fine.
These patches are a waste of reviewer time.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tpm_tis_core: Use common error handling code in tpm_tis_send_data()
2017-10-22 10:16 [PATCH] tpm_tis_core: Use common error handling code in tpm_tis_send_data() SF Markus Elfring
2017-10-23 7:34 ` Dan Carpenter
@ 2017-10-23 13:42 ` Jarkko Sakkinen
2017-10-23 13:51 ` SF Markus Elfring
1 sibling, 1 reply; 5+ messages in thread
From: Jarkko Sakkinen @ 2017-10-23 13:42 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-integrity, Jason Gunthorpe, Peter Hüwe, LKML, kernel-janitors
On Sun, Oct 22, 2017 at 12:16:19PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 22 Oct 2017 11:41:09 +0200
>
> Add a jump target so that a specific error code assignment for timeout
> conditions will be in the implementation only at the end of this function.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/char/tpm/tpm_tis_core.c | 26 ++++++++++++--------------
> 1 file changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index fdde971bc810..3681f7a74d1b 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -262,12 +262,10 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
> status = tpm_tis_status(chip);
> if ((status & TPM_STS_COMMAND_READY) == 0) {
> tpm_tis_ready(chip);
> - if (wait_for_tpm_stat
> - (chip, TPM_STS_COMMAND_READY, chip->timeout_b,
> - &priv->int_queue, false) < 0) {
> - rc = -ETIME;
> - goto out_err;
> - }
> + if (wait_for_tpm_stat(chip, TPM_STS_COMMAND_READY,
> + chip->timeout_b, &priv->int_queue, false)
> + < 0)
> + goto report_timeout;
> }
>
> while (count < len - 1) {
> @@ -286,10 +284,9 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
> count += burstcnt;
>
> if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
> - &priv->int_queue, false) < 0) {
> - rc = -ETIME;
> - goto out_err;
> - }
> + &priv->int_queue, false) < 0)
> + goto report_timeout;
> +
> status = tpm_tis_status(chip);
> if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) {
> rc = -EIO;
> @@ -303,10 +300,9 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
> goto out_err;
>
> if (wait_for_tpm_stat(chip, TPM_STS_VALID, chip->timeout_c,
> - &priv->int_queue, false) < 0) {
> - rc = -ETIME;
> - goto out_err;
> - }
> + &priv->int_queue, false) < 0)
> + goto report_timeout;
> +
> status = tpm_tis_status(chip);
> if (!itpm && (status & TPM_STS_DATA_EXPECT) != 0) {
> rc = -EIO;
> @@ -315,6 +311,8 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
>
> return 0;
>
> +report_timeout:
> + rc = -ETIME;
> out_err:
> tpm_tis_ready(chip);
> return rc;
> --
> 2.14.2
>
NAK. wait_for_tpm_stat() should give that error code.
/Jarkko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tpm_tis_core: Use common error handling code in tpm_tis_send_data()
2017-10-23 13:42 ` Jarkko Sakkinen
@ 2017-10-23 13:51 ` SF Markus Elfring
2017-10-24 13:55 ` Jarkko Sakkinen
0 siblings, 1 reply; 5+ messages in thread
From: SF Markus Elfring @ 2017-10-23 13:51 UTC (permalink / raw)
To: Jarkko Sakkinen, linux-integrity
Cc: Jason Gunthorpe, Peter Hüwe, LKML, kernel-janitors
>> @@ -315,6 +311,8 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
>>
>> return 0;
>>
>> +report_timeout:
>> + rc = -ETIME;
>> out_err:
>> tpm_tis_ready(chip);
>> return rc;
>> --
>> 2.14.2
>>
>
> NAK. wait_for_tpm_stat() should give that error code.
This is a pity that you reject another bit of code reduction.
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tpm_tis_core: Use common error handling code in tpm_tis_send_data()
2017-10-23 13:51 ` SF Markus Elfring
@ 2017-10-24 13:55 ` Jarkko Sakkinen
0 siblings, 0 replies; 5+ messages in thread
From: Jarkko Sakkinen @ 2017-10-24 13:55 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-integrity, Jason Gunthorpe, Peter Hüwe, LKML, kernel-janitors
On Mon, Oct 23, 2017 at 03:51:09PM +0200, SF Markus Elfring wrote:
> >> @@ -315,6 +311,8 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
> >>
> >> return 0;
> >>
> >> +report_timeout:
> >> + rc = -ETIME;
> >> out_err:
> >> tpm_tis_ready(chip);
> >> return rc;
> >> --
> >> 2.14.2
> >>
> >
> > NAK. wait_for_tpm_stat() should give that error code.
>
> This is a pity that you reject another bit of code reduction.
>
> Regards,
> Markus
It is a pity that you continue doing this constant patch trolling.
That is what it is.
/Jarkko.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-24 13:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-22 10:16 [PATCH] tpm_tis_core: Use common error handling code in tpm_tis_send_data() SF Markus Elfring
2017-10-23 7:34 ` Dan Carpenter
2017-10-23 13:42 ` Jarkko Sakkinen
2017-10-23 13:51 ` SF Markus Elfring
2017-10-24 13:55 ` Jarkko Sakkinen
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).