From be99f5452fc8a10e7b9a6b9088304ec47c7fde9f Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 4 Mar 2025 16:23:31 +1100 Subject: [PATCH] AP_HAL_Linux: add get_device-ptr to HAL DeviceMananger API --- libraries/AP_HAL_Linux/I2CDevice.h | 1 - libraries/AP_HAL_Linux/SPIDevice.cpp | 10 +++++----- libraries/AP_HAL_Linux/SPIDevice.h | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libraries/AP_HAL_Linux/I2CDevice.h b/libraries/AP_HAL_Linux/I2CDevice.h index 73b0497313..eda09ab39f 100644 --- a/libraries/AP_HAL_Linux/I2CDevice.h +++ b/libraries/AP_HAL_Linux/I2CDevice.h @@ -21,7 +21,6 @@ #include #include -#include #include "Semaphores.h" diff --git a/libraries/AP_HAL_Linux/SPIDevice.cpp b/libraries/AP_HAL_Linux/SPIDevice.cpp index 91a7e40dd8..785fb5c2ae 100644 --- a/libraries/AP_HAL_Linux/SPIDevice.cpp +++ b/libraries/AP_HAL_Linux/SPIDevice.cpp @@ -342,8 +342,8 @@ bool SPIDevice::adjust_periodic_callback( } -AP_HAL::OwnPtr -SPIDeviceManager::get_device(const char *name) +AP_HAL::SPIDevice * +SPIDeviceManager::get_device_ptr(const char *name) { SPIDesc *desc = nullptr; @@ -356,7 +356,7 @@ SPIDeviceManager::get_device(const char *name) } if (!desc) { - return AP_HAL::OwnPtr(nullptr); + return nullptr; } /* Find if bus already exists */ @@ -393,13 +393,13 @@ const char* SPIDeviceManager::get_device_name(uint8_t idx) } /* Create a new device increasing the bus reference */ -AP_HAL::OwnPtr +AP_HAL::SPIDevice * SPIDeviceManager::_create_device(SPIBus &b, SPIDesc &desc) const { // Ensure bus is open b.open(desc.subdev); - auto dev = AP_HAL::OwnPtr(NEW_NOTHROW SPIDevice(b, desc)); + auto *dev = NEW_NOTHROW SPIDevice(b, desc); if (!dev) { return nullptr; } diff --git a/libraries/AP_HAL_Linux/SPIDevice.h b/libraries/AP_HAL_Linux/SPIDevice.h index fde7e45e31..900cda381e 100644 --- a/libraries/AP_HAL_Linux/SPIDevice.h +++ b/libraries/AP_HAL_Linux/SPIDevice.h @@ -110,7 +110,7 @@ public: } /* AP_HAL::SPIDeviceManager implementation */ - AP_HAL::OwnPtr get_device(const char *name) override; + AP_HAL::SPIDevice *get_device_ptr(const char *name) override; /* * Stop all SPI threads and block until they are finalized. This doesn't @@ -127,7 +127,7 @@ public: protected: void _unregister(SPIBus &b); - AP_HAL::OwnPtr _create_device(SPIBus &b, SPIDesc &device_desc) const; + AP_HAL::SPIDevice *_create_device(SPIBus &b, SPIDesc &device_desc) const; std::vector _buses;