diff mbox series

[blktests,1/3] common/rc: introduce _get_pci_from_dev_sysfs

Message ID 20230526045843.168739-2-shinichiro.kawasaki@wdc.com (mailing list archive)
State New, archived
Headers show
Series improve block/011 | expand

Commit Message

Shinichiro Kawasaki May 26, 2023, 4:58 a.m. UTC
To prepare for block/011 test case improvement, add the helper function
which gets PCI device from the given sysfs path of a block device.

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index 57e0f42..90122c0 100644
--- a/common/rc
+++ b/common/rc
@@ -313,12 +313,16 @@  _require_test_dev_is_pci() {
 	return 0
 }
 
-_get_pci_dev_from_blkdev() {
-	readlink -f "$TEST_DEV_SYSFS/device" | \
+_get_pci_from_dev_sysfs() {
+	readlink -f "$1/device" | \
 		grep -Eo '[0-9a-f]{4,5}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]' | \
 		tail -1
 }
 
+_get_pci_dev_from_blkdev() {
+	_get_pci_from_dev_sysfs "$TEST_DEV_SYSFS"
+}
+
 _get_pci_parent_from_blkdev() {
 	readlink -f "$TEST_DEV_SYSFS/device" | \
 		grep -Eo '[0-9a-f]{4,5}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f]' | \