libzpci: Extract get_device_node() from zpcictl to libzpci

The get_device_node() function for getting the name of an NVMe's
controller device e.g. "nvme0" as implemented in zpcictl is generally
useful and will be needed for NVMe SMART data collection in zpcimon as
well. Move it to libzpci and rename it to zpci_get_nvme_device_node() to
account for the change in namespace.

It would be tempting to pass a struct zpci_dev* instead of a const char*
but as zpcictl uses an incompatible struct zpci_device* this will
require a larger rework. Prioritize minimizing code duplication for now.

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Niklas Schnelle
2026-06-18 16:40:09 +02:00
committed by Jan Höppner
parent 113e9ebfef
commit 78dd82d129
3 changed files with 51 additions and 32 deletions

View File

@@ -17,6 +17,8 @@
#include "util_list.h"
#define PCI_BDF_LEN 13 /* DDDD:BB:dd.f\0 */
enum zpci_pft {
ZPCI_PFT_UNCLASSIFIED = 0x00,
@@ -96,4 +98,6 @@ operstate_t zpci_operstate_from_str(const char *oper_str);
struct zpci_dev *zpci_find_by_netdev(struct util_list *zpci_list, char *netdev_name,
struct zpci_netdev **netdev);
char *zpci_get_nvme_device_node(const char *pci_addr);
#endif /* LIB_ZPCI_PCI_LIST_H */