AP_HAL_Linux: move dirname to I2CDevice core

All entries would need the "devices/" prefix and it's more natural not
using it.
This commit is contained in:
Lucas De Marchi 2016-03-08 11:11:04 -03:00
parent f8c3ceca3a
commit 6a6175df1c
2 changed files with 4 additions and 4 deletions

View File

@ -55,9 +55,9 @@ static I2CDriver i2cDriver0(2);
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_MINLURE
static const std::vector<const char *> i2c_devpaths({
/* UEFI with lpss set to ACPI */
"/devices/platform/80860F41:05",
"platform/80860F41:05",
/* UEFI with lpss set to PCI */
"/devices/pci0000:00/0000:00:18.6",
"pci0000:00/0000:00:18.6",
});
static I2CDriver i2cDriver0(i2c_devpaths);
/* One additional emulated bus */

View File

@ -223,7 +223,7 @@ I2CDeviceManager::I2CDeviceManager()
AP_HAL::OwnPtr<AP_HAL::I2CDevice>
I2CDeviceManager::get_device(std::vector<const char *> devpaths, uint8_t address)
{
const char *dirname = "/sys/class/i2c-dev";
const char *dirname = "/sys/class/i2c-dev/";
struct dirent *de = nullptr;
DIR *d;
@ -245,7 +245,7 @@ I2CDeviceManager::get_device(std::vector<const char *> devpaths, uint8_t address
}
abs_str_device = realpath(str_device, nullptr);
if (!abs_str_device || !(p = startswith(abs_str_device, "/sys"))) {
if (!abs_str_device || !(p = startswith(abs_str_device, "/sys/devices/"))) {
free(abs_str_device);
free(str_device);
continue;