mirror of
https://github.com/gnif/vendor-reset.git
synced 2026-06-27 22:14:28 +02:00
Parse PCI devices in DBDF form.
This commit is contained in:
+24
-18
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Vendor Reset - Vendor Specific Reset
|
||||
Copyright (C) 2020 Geoffrey McRae <geoff@hostfission.com>
|
||||
Copyright (C) 2020 Adam Madsen <adam@ajmadsen.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free Software
|
||||
@@ -22,24 +23,30 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "vendor-reset.h"
|
||||
#include "ucommon.h"
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
void help_(const char *prog);
|
||||
|
||||
void help_(const char *prog)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage:\n"
|
||||
" %s [domain:]bus:dev.fn\n",
|
||||
prog);
|
||||
exit(1);
|
||||
}
|
||||
#define help() help_(argv[0])
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
struct dbdf devref;
|
||||
|
||||
if (argc < 4)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage:\n"
|
||||
" %s <domain> <bus> <devfn>\n",
|
||||
argv[0]
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
if (argc < 2)
|
||||
help();
|
||||
|
||||
int domain = atoi(argv[1]);
|
||||
int bus = atoi(argv[2]);
|
||||
int devfn = atoi(argv[3]);
|
||||
if (parse_dbdf(argv[1], &devref))
|
||||
help();
|
||||
|
||||
int fd = open("/dev/vendor_reset", O_RDWR);
|
||||
if (fd < 0)
|
||||
@@ -48,11 +55,10 @@ int main(int argc, char * argv[])
|
||||
return fd;
|
||||
}
|
||||
|
||||
struct vendor_reset_ioctl dev =
|
||||
{
|
||||
.domain = domain,
|
||||
.bus = bus,
|
||||
.devfn = devfn
|
||||
struct vendor_reset_ioctl dev = {
|
||||
.domain = devref.domain,
|
||||
.bus = devref.bus,
|
||||
.devfn = ((devref.device & 0x1f) << 3) | (devref.function & 0x07),
|
||||
};
|
||||
|
||||
ret = ioctl(fd, VENDOR_RESET_RESET, &dev);
|
||||
|
||||
Reference in New Issue
Block a user