Skip to content

Commit 61d3bc0

Browse files
committed
On Linux include both the I2C/SMBus bus name and device path in the device_name
1 parent 77ff2a3 commit 61d3bc0

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

i2c_smbus/Linux/i2c_smbus_linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ bool i2c_smbus_linux_detect()
232232
}
233233

234234
bus = new i2c_smbus_linux();
235-
strcpy(bus->device_name, device_string);
235+
snprintf(bus->device_name, sizeof(bus->device_name), "%s (%s)", device_string, device_path);
236236
bus->handle = test_fd;
237237
bus->pci_device = pci_device;
238238
bus->pci_vendor = pci_vendor;

i2c_smbus/i2c_amd_gpu.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ inline bool is_amd_gpu_i2c_bus(const i2c_smbus_interface *bus)
3030
size_t idx = 0;
3131
while((name = RECOGNIZED_I2C_BUS_NAMES[idx++]) != nullptr)
3232
{
33-
if(std::strcmp(name, bus->device_name) == 0)
33+
const char *pos = std::strstr(bus->device_name, name);
34+
if(pos == bus->device_name)
3435
{
3536
return true;
3637
}

0 commit comments

Comments
 (0)