[LTP] [PATCH] ltp_block_dev: Check HAVE_LINUX_GENHD_H to include genhd.h

Tiezhu Yang yangtiezhu@loongson.cn
Tue Jul 22 13:52:30 CEST 2025


After the LTP commit d4dd360b05f8 ("device-drivers/acpi/ltp_acpi_cmds:
Fix build errors"), HAVE_LINUX_GENHD_H is defined to 1 if you have the
<linux/genhd.h> header file.

The macro definition DISK_NAME_LEN may be completely removed, so it is
better to use #ifdef HAVE_LINUX_GENHD_H to include genhd.h.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
By the way, it seems that the following file is not used, should it be
deleted? If yes, I will send a formal patch later.

  testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c

 .../device-drivers/block/block_dev_kernel/ltp_block_dev.c       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c b/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c
index 0fd278981..f50530f23 100644
--- a/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c
+++ b/testcases/kernel/device-drivers/block/block_dev_kernel/ltp_block_dev.c
@@ -13,7 +13,7 @@
 #include <linux/device.h>
 #include <linux/fs.h>
 #include <linux/blkdev.h>
-#ifndef DISK_NAME_LEN
+#ifdef HAVE_LINUX_GENHD_H
 # include <linux/genhd.h>
 #endif
 
-- 
2.42.0



More information about the ltp mailing list