Skip to content

Commit ace8238

Browse files
committed
feat: Add optional hot-swap hook for PCI device reopening.
1 parent ef539f5 commit ace8238

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

pciApp/devLibPCI.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,16 @@ int devPCIDisableInterrupt(const epicsPCIDevice *dev);
451451
epicsShareFunc
452452
const char* devPCIDeviceClassToString(int classId);
453453

454+
/**
455+
* @brief Optional callback invoked on PCI device hot-swap.
456+
*
457+
* This function pointer may be set to a custom handler that will be called
458+
* when a PCI device is successfully reopened (e.g. after hot-swap).
459+
*
460+
* @param name Identifier or name of the reopened PCI device.
461+
*/
462+
epicsShareExtern void (*devPCIonHotSwapHook)(const char*);
463+
454464
#ifdef __cplusplus
455465
} /* extern "C" */
456466
#endif

pciApp/os/Linux/devLibPCIOSD.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,8 @@ static int reopen_uio(struct osdPCIDevice *osd)
944944
return 0;
945945
}
946946

947+
epicsShareDef void (*devPCIonHotSwapHook)(const char* name) = NULL;
948+
947949
static
948950
void isrThread(void* arg)
949951
{
@@ -995,6 +997,7 @@ void isrThread(void* arg)
995997
epicsMutexMustLock(osd->devLock);
996998
if (reopen_uio(osd) == 0) {
997999
errlogPrintf("isrThread '%s': Successfully reopened UIO device\n", name);
1000+
if (devPCIonHotSwapHook) devPCIonHotSwapHook(name);
9981001
} else {
9991002
errlogPrintf("isrThread '%s': UIO reopen failed. Will retry.\n", name);
10001003
}

0 commit comments

Comments
 (0)