[PATCH] tpm:correct tpm timeouts to jiffies conversion - Kernel

This is a discussion on [PATCH] tpm:correct tpm timeouts to jiffies conversion - Kernel ; This patch fixes timeouts conversion to jiffies, by replacing msecs_to_jiffies() calls with usecs_to_jiffies(). According to TCG TPM Specification Version 1.2 Revision 103 (pages 166, 167) TPM timeouts and durations are returned in microseconds (usec) not in miliseconds (msec). Signed-off-by: Marcin ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: [PATCH] tpm:correct tpm timeouts to jiffies conversion

  1. [PATCH] tpm:correct tpm timeouts to jiffies conversion

    This patch fixes timeouts conversion to jiffies,
    by replacing msecs_to_jiffies() calls with usecs_to_jiffies().
    According to TCG TPM Specification Version 1.2 Revision 103 (pages 166, 167)
    TPM timeouts and durations are returned in microseconds (usec)
    not in miliseconds (msec).

    Signed-off-by: Marcin Obara

    --- linux/drivers/char/tpm/tpm.c 2008-06-05 20:57:06.000000000 +0200
    +++ linux_tpm/drivers/char/tpm/tpm.c 2008-06-05 20:54:52.000000000 +0200
    @@ -524,19 +524,19 @@ void tpm_get_timeouts(struct tpm_chip *c
    timeout =
    be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)));
    if (timeout)
    - chip->vendor.timeout_a = msecs_to_jiffies(timeout);
    + chip->vendor.timeout_a = usecs_to_jiffies(timeout);
    timeout =
    be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_2_IDX)));
    if (timeout)
    - chip->vendor.timeout_b = msecs_to_jiffies(timeout);
    + chip->vendor.timeout_b = usecs_to_jiffies(timeout);
    timeout =
    be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_3_IDX)));
    if (timeout)
    - chip->vendor.timeout_c = msecs_to_jiffies(timeout);
    + chip->vendor.timeout_c = usecs_to_jiffies(timeout);
    timeout =
    be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_4_IDX)));
    if (timeout)
    - chip->vendor.timeout_d = msecs_to_jiffies(timeout);
    + chip->vendor.timeout_d = usecs_to_jiffies(timeout);

    duration:
    memcpy(data, tpm_cap, sizeof(tpm_cap));
    @@ -553,15 +553,15 @@ duration:
    return;

    chip->vendor.duration[TPM_SHORT] =
    - msecs_to_jiffies(be32_to_cpu
    + usecs_to_jiffies(be32_to_cpu
    (*((__be32 *) (data +
    TPM_GET_CAP_RET_UINT32_1_IDX))));
    chip->vendor.duration[TPM_MEDIUM] =
    - msecs_to_jiffies(be32_to_cpu
    + usecs_to_jiffies(be32_to_cpu
    (*((__be32 *) (data +
    TPM_GET_CAP_RET_UINT32_2_IDX))));
    chip->vendor.duration[TPM_LONG] =
    - msecs_to_jiffies(be32_to_cpu
    + usecs_to_jiffies(be32_to_cpu
    (*((__be32 *) (data +
    TPM_GET_CAP_RET_UINT32_3_IDX))));
    }
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. Re: [PATCH] tpm:correct tpm timeouts to jiffies conversion

    Acked-by: Marcel Selhorst

    Marcin Obara schrieb:
    > This patch fixes timeouts conversion to jiffies,
    > by replacing msecs_to_jiffies() calls with usecs_to_jiffies().
    > According to TCG TPM Specification Version 1.2 Revision 103 (pages 166, 167)
    > TPM timeouts and durations are returned in microseconds (usec)
    > not in miliseconds (msec).
    >
    > Signed-off-by: Marcin Obara
    >
    > --- linux/drivers/char/tpm/tpm.c 2008-06-05 20:57:06.000000000 +0200
    > +++ linux_tpm/drivers/char/tpm/tpm.c 2008-06-05 20:54:52.000000000 +0200
    > @@ -524,19 +524,19 @@ void tpm_get_timeouts(struct tpm_chip *c
    > timeout =
    > be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)));
    > if (timeout)
    > - chip->vendor.timeout_a = msecs_to_jiffies(timeout);
    > + chip->vendor.timeout_a = usecs_to_jiffies(timeout);
    > timeout =
    > be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_2_IDX)));
    > if (timeout)
    > - chip->vendor.timeout_b = msecs_to_jiffies(timeout);
    > + chip->vendor.timeout_b = usecs_to_jiffies(timeout);
    > timeout =
    > be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_3_IDX)));
    > if (timeout)
    > - chip->vendor.timeout_c = msecs_to_jiffies(timeout);
    > + chip->vendor.timeout_c = usecs_to_jiffies(timeout);
    > timeout =
    > be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_4_IDX)));
    > if (timeout)
    > - chip->vendor.timeout_d = msecs_to_jiffies(timeout);
    > + chip->vendor.timeout_d = usecs_to_jiffies(timeout);
    >
    > duration:
    > memcpy(data, tpm_cap, sizeof(tpm_cap));
    > @@ -553,15 +553,15 @@ duration:
    > return;
    >
    > chip->vendor.duration[TPM_SHORT] =
    > - msecs_to_jiffies(be32_to_cpu
    > + usecs_to_jiffies(be32_to_cpu
    > (*((__be32 *) (data +
    > TPM_GET_CAP_RET_UINT32_1_IDX))));
    > chip->vendor.duration[TPM_MEDIUM] =
    > - msecs_to_jiffies(be32_to_cpu
    > + usecs_to_jiffies(be32_to_cpu
    > (*((__be32 *) (data +
    > TPM_GET_CAP_RET_UINT32_2_IDX))));
    > chip->vendor.duration[TPM_LONG] =
    > - msecs_to_jiffies(be32_to_cpu
    > + usecs_to_jiffies(be32_to_cpu
    > (*((__be32 *) (data +
    > TPM_GET_CAP_RET_UINT32_3_IDX))));
    > }
    >

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread