Browse Source

AP_HAL_Linux: move dirname to I2CDevice core

All entries would need the "devices/" prefix and it's more natural not
using it.
mission-4.1.18
Lucas De Marchi 9 years ago
parent
commit
6a6175df1c
  1. 4
      libraries/AP_HAL_Linux/HAL_Linux_Class.cpp
  2. 4
      libraries/AP_HAL_Linux/I2CDevice.cpp

4
libraries/AP_HAL_Linux/HAL_Linux_Class.cpp

@ -55,9 +55,9 @@ static I2CDriver i2cDriver0(2); @@ -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 */

4
libraries/AP_HAL_Linux/I2CDevice.cpp

@ -223,7 +223,7 @@ I2CDeviceManager::I2CDeviceManager() @@ -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 @@ -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;

Loading…
Cancel
Save