mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
pci: reorder static functions
virPCIDeviceGetDriverPathAndName is a static function that will need to be called by another function that occurs above it in the file. This patch reorders the static functions so that a forward declaration isn't needed.
This commit is contained in:
parent
797b1ffce1
commit
333a2a724a
@ -188,6 +188,81 @@ static int virPCIOnceInit(void)
|
||||
|
||||
VIR_ONCE_GLOBAL_INIT(virPCI)
|
||||
|
||||
|
||||
static int
|
||||
virPCIDriverDir(char **buffer, const char *driver)
|
||||
{
|
||||
VIR_FREE(*buffer);
|
||||
|
||||
return virAsprintf(buffer, PCI_SYSFS "drivers/%s", driver);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virPCIDriverFile(char **buffer, const char *driver, const char *file)
|
||||
{
|
||||
VIR_FREE(*buffer);
|
||||
|
||||
return virAsprintf(buffer, PCI_SYSFS "drivers/%s/%s", driver, file);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virPCIFile(char **buffer, const char *device, const char *file)
|
||||
{
|
||||
VIR_FREE(*buffer);
|
||||
|
||||
return virAsprintf(buffer, PCI_SYSFS "devices/%s/%s", device, file);
|
||||
}
|
||||
|
||||
|
||||
/* virPCIDeviceGetDriverPathAndName - put the path to the driver
|
||||
* directory of the driver in use for this device in @path and the
|
||||
* name of the driver in @name. Both could be NULL if it's not bound
|
||||
* to any driver.
|
||||
*
|
||||
* Return 0 for success, -1 for error.
|
||||
*/
|
||||
static int
|
||||
virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev, char **path, char **name)
|
||||
{
|
||||
int ret = -1;
|
||||
char *drvlink = NULL;
|
||||
|
||||
*path = *name = NULL;
|
||||
/* drvlink = "/sys/bus/pci/dddd:bb:ss.ff/driver" */
|
||||
if (virPCIFile(&drvlink, dev->name, "driver") < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virFileIsLink(drvlink) != 1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Invalid device %s driver file %s is not a symlink"),
|
||||
dev->name, drvlink);
|
||||
goto cleanup;
|
||||
}
|
||||
if (virFileResolveLink(drvlink, path) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to resolve device %s driver symlink %s"),
|
||||
dev->name, drvlink);
|
||||
goto cleanup;
|
||||
}
|
||||
/* path = "/sys/bus/pci/drivers/${drivername}" */
|
||||
|
||||
if (VIR_STRDUP(*name, last_component(*path)) < 0)
|
||||
goto cleanup;
|
||||
/* name = "${drivername}" */
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(drvlink);
|
||||
if (ret < 0) {
|
||||
VIR_FREE(*path);
|
||||
VIR_FREE(*name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virPCIDeviceConfigOpen(virPCIDevicePtr dev, bool fatal)
|
||||
{
|
||||
@ -839,78 +914,6 @@ cleanup:
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virPCIDriverDir(char **buffer, const char *driver)
|
||||
{
|
||||
VIR_FREE(*buffer);
|
||||
|
||||
return virAsprintf(buffer, PCI_SYSFS "drivers/%s", driver);
|
||||
}
|
||||
|
||||
static int
|
||||
virPCIDriverFile(char **buffer, const char *driver, const char *file)
|
||||
{
|
||||
VIR_FREE(*buffer);
|
||||
|
||||
return virAsprintf(buffer, PCI_SYSFS "drivers/%s/%s", driver, file);
|
||||
}
|
||||
|
||||
static int
|
||||
virPCIFile(char **buffer, const char *device, const char *file)
|
||||
{
|
||||
VIR_FREE(*buffer);
|
||||
|
||||
return virAsprintf(buffer, PCI_SYSFS "devices/%s/%s", device, file);
|
||||
}
|
||||
|
||||
|
||||
/* virPCIDeviceGetDriverPathAndName - put the path to the driver
|
||||
* directory of the driver in use for this device in @path and the
|
||||
* name of the driver in @name. Both could be NULL if it's not bound
|
||||
* to any driver.
|
||||
*
|
||||
* Return 0 for success, -1 for error.
|
||||
*/
|
||||
static int
|
||||
virPCIDeviceGetDriverPathAndName(virPCIDevicePtr dev, char **path, char **name)
|
||||
{
|
||||
int ret = -1;
|
||||
char *drvlink = NULL;
|
||||
|
||||
*path = *name = NULL;
|
||||
/* drvlink = "/sys/bus/pci/dddd:bb:ss.ff/driver" */
|
||||
if (virPCIFile(&drvlink, dev->name, "driver") < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virFileIsLink(drvlink) != 1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Invalid device %s driver file %s is not a symlink"),
|
||||
dev->name, drvlink);
|
||||
goto cleanup;
|
||||
}
|
||||
if (virFileResolveLink(drvlink, path) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to resolve device %s driver symlink %s"),
|
||||
dev->name, drvlink);
|
||||
goto cleanup;
|
||||
}
|
||||
/* path = "/sys/bus/pci/drivers/${drivername}" */
|
||||
|
||||
if (VIR_STRDUP(*name, last_component(*path)) < 0)
|
||||
goto cleanup;
|
||||
/* name = "${drivername}" */
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(drvlink);
|
||||
if (ret < 0) {
|
||||
VIR_FREE(*path);
|
||||
VIR_FREE(*name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virPCIProbeStubDriver(const char *driver)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user