Added --i2c command line option

This commit is contained in:
2025-02-16 22:28:16 -08:00
parent c4e7f7e8b9
commit 7cd23384f6
4 changed files with 26 additions and 6 deletions
+10 -1
View File
@@ -8,7 +8,7 @@
/* Search all i2c device files for ones are on a PCI device of a supported GPU,
and respond with the correct iCX3 version information */
int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus)
int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus, int i2c_bus)
{
char i2c_devices_path[NAME_MAX];
char device_path[NAME_MAX];
@@ -20,6 +20,7 @@ int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus)
struct dirent *ent;
int num_gpus = 0;
int current_i2c_bus = -1;
unsigned short pci_vendor, pci_device, pci_subsystem_vendor, pci_subsystem_device = 0;
/* Start looking for I2C adapters in /sys/bus/i2c/devices/ */
@@ -37,6 +38,14 @@ int find_evga_gpu_i2cs(struct card_info *infos, int max_gpus)
if(strncmp(ent->d_name, "i2c-", 4) != 0)
continue;
/* Only probe the specific device given (if provided) */
if (i2c_bus >= 0) {
sscanf(ent->d_name, "i2c-%i", &current_i2c_bus);
if (current_i2c_bus != i2c_bus)
continue;
}
strcpy(device_path, i2c_devices_path);
strcat(device_path, ent->d_name);