diff mbox

scsi: debug: remove jiffies_to_timespec

Message ID 20171127113647.2352914-1-arnd@arndb.de (mailing list archive)
State Accepted
Headers show

Commit Message

Arnd Bergmann Nov. 27, 2017, 11:36 a.m. UTC
There is no need to go through an intermediate timespec to convert
to ktime_t when we just want a simple multiplication. This gets
rid of one of the few users of jiffies_to_timespec, which I
hope to remove as part of the y2038 cleanup.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/scsi_debug.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Johannes Thumshirn Nov. 27, 2017, 12:18 p.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Douglas Gilbert Nov. 27, 2017, 1:29 p.m. UTC | #2
On 2017-11-27 12:36 PM, Arnd Bergmann wrote:
> There is no need to go through an intermediate timespec to convert
> to ktime_t when we just want a simple multiplication. This gets
> rid of one of the few users of jiffies_to_timespec, which I
> hope to remove as part of the y2038 cleanup.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Douglas Gilbert <dgilbert@interlog.com>

> ---
>   drivers/scsi/scsi_debug.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index e4f037f0f38b..df7e9db44d44 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -4085,10 +4085,7 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
>   		ktime_t kt;
>   
>   		if (delta_jiff > 0) {
> -			struct timespec ts;
> -
> -			jiffies_to_timespec(delta_jiff, &ts);
> -			kt = ktime_set(ts.tv_sec, ts.tv_nsec);
> +			kt = ns_to_ktime((u64)delta_jiff * (NSEC_PER_SEC / HZ));
>   		} else
>   			kt = sdebug_ndelay;
>   		if (NULL == sd_dp) {
>
Martin K. Petersen Nov. 29, 2017, 5:01 a.m. UTC | #3
Arnd,

> There is no need to go through an intermediate timespec to convert to
> ktime_t when we just want a simple multiplication. This gets rid of
> one of the few users of jiffies_to_timespec, which I hope to remove as
> part of the y2038 cleanup.

Applied to 4.16/scsi-queue. Thanks!
diff mbox

Patch

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index e4f037f0f38b..df7e9db44d44 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -4085,10 +4085,7 @@  static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
 		ktime_t kt;
 
 		if (delta_jiff > 0) {
-			struct timespec ts;
-
-			jiffies_to_timespec(delta_jiff, &ts);
-			kt = ktime_set(ts.tv_sec, ts.tv_nsec);
+			kt = ns_to_ktime((u64)delta_jiff * (NSEC_PER_SEC / HZ));
 		} else
 			kt = sdebug_ndelay;
 		if (NULL == sd_dp) {