OSDN Git Service

driver core: Simplify async probe test code by using ktime_ms_delta()
authorMark-PK Tsai <mark-pk.tsai@mediatek.com>
Tue, 28 Dec 2021 09:27:07 +0000 (17:27 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Dec 2021 09:57:22 +0000 (10:57 +0100)
Simplify async probe test code by using ktime_ms_delta().

Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Link: https://lore.kernel.org/r/20211228092707.29987-1-mark-pk.tsai@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/test/test_async_driver_probe.c

index 3bb7beb..4d1976c 100644 (file)
@@ -104,7 +104,7 @@ static int __init test_async_probe_init(void)
        struct platform_device **pdev = NULL;
        int async_id = 0, sync_id = 0;
        unsigned long long duration;
-       ktime_t calltime, delta;
+       ktime_t calltime;
        int err, nid, cpu;
 
        pr_info("registering first set of asynchronous devices...\n");
@@ -133,8 +133,7 @@ static int __init test_async_probe_init(void)
                goto err_unregister_async_devs;
        }
 
-       delta = ktime_sub(ktime_get(), calltime);
-       duration = (unsigned long long) ktime_to_ms(delta);
+       duration = (unsigned long long)ktime_ms_delta(ktime_get(), calltime);
        pr_info("registration took %lld msecs\n", duration);
        if (duration > TEST_PROBE_THRESHOLD) {
                pr_err("test failed: probe took too long\n");
@@ -161,8 +160,7 @@ static int __init test_async_probe_init(void)
                async_id++;
        }
 
-       delta = ktime_sub(ktime_get(), calltime);
-       duration = (unsigned long long) ktime_to_ms(delta);
+       duration = (unsigned long long)ktime_ms_delta(ktime_get(), calltime);
        dev_info(&(*pdev)->dev,
                 "registration took %lld msecs\n", duration);
        if (duration > TEST_PROBE_THRESHOLD) {
@@ -197,8 +195,7 @@ static int __init test_async_probe_init(void)
                goto err_unregister_sync_devs;
        }
 
-       delta = ktime_sub(ktime_get(), calltime);
-       duration = (unsigned long long) ktime_to_ms(delta);
+       duration = (unsigned long long)ktime_ms_delta(ktime_get(), calltime);
        pr_info("registration took %lld msecs\n", duration);
        if (duration < TEST_PROBE_THRESHOLD) {
                dev_err(&(*pdev)->dev,
@@ -223,8 +220,7 @@ static int __init test_async_probe_init(void)
 
        sync_id++;
 
-       delta = ktime_sub(ktime_get(), calltime);
-       duration = (unsigned long long) ktime_to_ms(delta);
+       duration = (unsigned long long)ktime_ms_delta(ktime_get(), calltime);
        dev_info(&(*pdev)->dev,
                 "registration took %lld msecs\n", duration);
        if (duration < TEST_PROBE_THRESHOLD) {