diff --git a/Devices/m5stack-tab5/Source/devices/tab5_headphone_detect.cpp b/Devices/m5stack-tab5/Source/devices/tab5_headphone_detect.cpp index a9355d4d5..f50bf7d72 100644 --- a/Devices/m5stack-tab5/Source/devices/tab5_headphone_detect.cpp +++ b/Devices/m5stack-tab5/Source/devices/tab5_headphone_detect.cpp @@ -1,5 +1,6 @@ #include "tab5_headphone_detect.h" +#include #include #include #include @@ -10,7 +11,7 @@ #include -#define TAG "Tab5" +constexpr auto* TAG = "Tab5"; // PI4IOE5V6408-0 (0x43) bit 1 constexpr auto GPIO_EXP0_PIN_SPEAKER_ENABLE = 1; @@ -28,8 +29,9 @@ static std::atomic hp_detect_initialized { false }; static void headphone_detect_callback(TimerHandle_t /*timer*/) { Device* cached = io_expander0_cached.load(std::memory_order_acquire); if (!cached) { - cached = device_find_by_name("io_expander0"); - io_expander0_cached.store(cached, std::memory_order_release); + if (device_get_by_name("io_expander0", &cached) == ERROR_NONE) { + io_expander0_cached.store(cached, std::memory_order_release); + } } auto* io_expander0 = cached; if (!io_expander0) { @@ -106,5 +108,10 @@ void tab5_headphone_detect_stop() { // Always clear the handle — stale non-null handle is worse than a resource leak, as it would // cause tab5_headphone_detect_start() to silently skip re-creating the timer. hp_detect_timer = nullptr; - io_expander0_cached.store(nullptr, std::memory_order_release); + + Device* cached = io_expander0_cached.load(std::memory_order_acquire); + if (cached) { + io_expander0_cached.store(nullptr, std::memory_order_release); + device_put(cached); + } } diff --git a/Drivers/lilygo-module/source/trackball.cpp b/Drivers/lilygo-module/source/trackball.cpp index 268874bb3..c8ed24693 100644 --- a/Drivers/lilygo-module/source/trackball.cpp +++ b/Drivers/lilygo-module/source/trackball.cpp @@ -76,8 +76,7 @@ lv_indev_t* init() { return g_indev; } - g_device = device_find_first_active_by_type(&TDECK_TRACKBALL_TYPE); - if (g_device == nullptr) { + if (device_get_first_active_by_type(&TDECK_TRACKBALL_TYPE, &g_device) != ERROR_NONE) { LOG_E(TAG, "tdeck_trackball kernel device not found or not started"); return nullptr; } @@ -129,6 +128,8 @@ void deinit() { lv_indev_delete(g_indev); g_indev = nullptr; + + device_put(g_device); g_device = nullptr; g_mode = Mode::Encoder; diff --git a/Tactility/Source/app/btmanage/BtManage.cpp b/Tactility/Source/app/btmanage/BtManage.cpp index 537e59a23..b42272df2 100644 --- a/Tactility/Source/app/btmanage/BtManage.cpp +++ b/Tactility/Source/app/btmanage/BtManage.cpp @@ -30,13 +30,18 @@ static void onBtToggled(bool requestOn) { } static void onScanToggled(bool enabled) { - Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE); - if (!dev) return; + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) != ERROR_NONE) { + return; + } + if (enabled) { bluetooth_scan_start(dev); } else { bluetooth_scan_stop(dev); } + + device_put(dev); } static void onConnectPeer(const std::array& addr, int profileId) { @@ -115,8 +120,8 @@ void BtManage::onBtEvent(const struct BtEvent& event) { case BT_EVENT_RADIO_STATE_CHANGED: if (event.radio_state == BT_RADIO_STATE_ON) { getState().updatePairedPeers(); - Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE); - if (dev && !bluetooth_is_scanning(dev)) { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE && !bluetooth_is_scanning(dev)) { bluetooth_scan_start(dev); } } @@ -144,7 +149,9 @@ void BtManage::onShow(AppContext& app, lv_obj_t* parent) { // Initialise state and view before subscribing to avoid incoming events // racing with state initialisation. state.setRadioState(bluetooth::getRadioState()); - Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE); + Device* dev; + device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev); + state.setScanning(dev ? bluetooth_is_scanning(dev) : false); state.updateScanResults(); state.updatePairedPeers(); @@ -155,6 +162,10 @@ void BtManage::onShow(AppContext& app, lv_obj_t* parent) { view.update(); unlock(); + if (btDevice) { + device_put(btDevice); + } + btDevice = dev; if (btDevice) { bluetooth_add_event_callback(btDevice, this, onKernelBtEvent); @@ -175,6 +186,7 @@ void BtManage::onHide(AppContext& app) { lock(); if (btDevice) { bluetooth_remove_event_callback(btDevice, onKernelBtEvent); + device_put(btDevice); btDevice = nullptr; } isViewEnabled = false; diff --git a/Tactility/Source/app/btmanage/View.cpp b/Tactility/Source/app/btmanage/View.cpp index c0d356fc9..f23233a51 100644 --- a/Tactility/Source/app/btmanage/View.cpp +++ b/Tactility/Source/app/btmanage/View.cpp @@ -46,8 +46,10 @@ static void onEnableOnBootParentClicked(lv_event_t* event) { static void onScanButtonClicked(lv_event_t* event) { auto bt = std::static_pointer_cast(getCurrentApp()); - Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE); + Device* dev; + device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev); bool scanning = dev ? bluetooth_is_scanning(dev) : false; + device_put(dev); bt->getBindings().onScanToggled(!scanning); } diff --git a/Tactility/Source/app/btpeersettings/BtPeerSettings.cpp b/Tactility/Source/app/btpeersettings/BtPeerSettings.cpp index d4c792a7f..003ed02b6 100644 --- a/Tactility/Source/app/btpeersettings/BtPeerSettings.cpp +++ b/Tactility/Source/app/btpeersettings/BtPeerSettings.cpp @@ -126,8 +126,12 @@ public: } void onShow(AppContext& app, lv_obj_t* parent) override { - if (Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE)) { - bluetooth_add_event_callback(dev, this, onKernelBtEvent); + { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { + bluetooth_add_event_callback(dev, this, onKernelBtEvent); + device_put(dev); + } } // Load stored settings (name, autoConnect) @@ -194,8 +198,10 @@ public: } void onHide(AppContext& app) override { - if (Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE)) { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { bluetooth_remove_event_callback(dev, onKernelBtEvent); + device_put(dev); } viewEnabled = false; } diff --git a/Tactility/Source/app/files/View.cpp b/Tactility/Source/app/files/View.cpp index b019a809a..16a5f45c9 100644 --- a/Tactility/Source/app/files/View.cpp +++ b/Tactility/Source/app/files/View.cpp @@ -436,12 +436,16 @@ void View::onEjectPressed() { std::string mount_path = state->getSelectedChildPath(); LOG_I(TAG, "Ejecting %s", mount_path.c_str()); - struct Device* msc_dev = device_find_first_active_by_type(&USB_HOST_MSC_TYPE); - if (!msc_dev || !usb_msc_eject(msc_dev, mount_path.c_str())) { + Device* msc_dev; + if (device_get_first_active_by_type(&USB_HOST_MSC_TYPE, &msc_dev) != ERROR_NONE || !usb_msc_eject(msc_dev, mount_path.c_str())) { LOG_W(TAG, "usb_msc_eject: %s not found", mount_path.c_str()); alertdialog::start("Eject failed", "Could not eject \"" + file::getLastPathSegment(mount_path) + "\"."); } + if (msc_dev) { + device_put(msc_dev); + } + onNavigate(); state->setEntriesForPath(state->getCurrentPath()); update(); diff --git a/Tactility/Source/app/keyboard/KeyboardSettings.cpp b/Tactility/Source/app/keyboard/KeyboardSettings.cpp index 073c4aa83..111341e16 100644 --- a/Tactility/Source/app/keyboard/KeyboardSettings.cpp +++ b/Tactility/Source/app/keyboard/KeyboardSettings.cpp @@ -28,9 +28,10 @@ static uint32_t timeoutMsToIndex(uint32_t ms) { static void applyKeyboardBacklight(bool enabled, uint8_t brightness) { // TODO: Get keyboard backlight from (optional) keyboard child device - Device* backlight = device_find_by_name("keyboard_backlight"); - if (backlight != nullptr) { + Device* backlight; + if (device_get_by_name("keyboard_backlight", &backlight) == ERROR_NONE) { backlight_set_brightness(backlight, enabled ? brightness : 0); + device_put(backlight); } } diff --git a/Tactility/Source/bluetooth/Bluetooth.cpp b/Tactility/Source/bluetooth/Bluetooth.cpp index b3a17c923..dca79bd6c 100644 --- a/Tactility/Source/bluetooth/Bluetooth.cpp +++ b/Tactility/Source/bluetooth/Bluetooth.cpp @@ -124,8 +124,10 @@ static void bt_event_bridge(Device*, void* /*context*/, BtEvent event) { } if (has_hid_host_auto) { LOG_I(TAG, "HID host auto-connect peer found — starting scan"); - if (Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE)) { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { bluetooth_scan_start(dev); + device_put(dev); } } else if (has_hid_device_auto) { LOG_I(TAG, "HID device auto-start (bonded peer found)"); @@ -231,10 +233,12 @@ static void bt_event_bridge(Device*, void* /*context*/, BtEvent event) { } } if (has_auto) { - if (Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE)) { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { if (!bluetooth_is_scanning(dev)) { bluetooth_scan_start(dev); } + device_put(dev); } } }); @@ -337,10 +341,19 @@ const char* radioStateToString(RadioState state) { } RadioState getRadioState() { - Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE); - if (dev == nullptr) return RadioState::Off; BtRadioState state = BT_RADIO_STATE_OFF; - bluetooth_get_radio_state(dev, &state); + + // Scoped to safeguard dev usage + { + Device* dev; + device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev); + if (dev == nullptr) { + return RadioState::Off; + } + bluetooth_get_radio_state(dev, &state); + device_put(dev); + } + switch (state) { case BT_RADIO_STATE_OFF: return RadioState::Off; case BT_RADIO_STATE_ON_PENDING: return RadioState::OnPending; @@ -405,9 +418,10 @@ void pair(const std::array& /*addr*/) { } void unpair(const std::array& addr) { - Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE); - if (dev != nullptr) { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { bluetooth_unpair(dev, addr.data()); + device_put(dev); } settings::remove(settings::addrToHex(addr)); } @@ -442,9 +456,11 @@ void disconnect(const std::array& addr, int profileId) { bluetooth_hid_device_stop(dev); } } else { - Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE); - if (dev == nullptr) return; - bluetooth_disconnect(dev, addr.data(), (BtProfileId)profileId); + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { + bluetooth_disconnect(dev, addr.data(), (BtProfileId)profileId); + device_put(dev); + } } } diff --git a/Tactility/Source/bluetooth/BluetoothHidHost.cpp b/Tactility/Source/bluetooth/BluetoothHidHost.cpp index e621ea0c9..6af3b8722 100644 --- a/Tactility/Source/bluetooth/BluetoothHidHost.cpp +++ b/Tactility/Source/bluetooth/BluetoothHidHost.cpp @@ -499,12 +499,14 @@ static void hidHostSubscribeNext(HidHostCtx& ctx) { } device.name = name; settings::save(device); - if (Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE)) { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { BtEvent e = {}; e.type = BT_EVENT_PROFILE_STATE_CHANGED; e.profile_state.state = BT_PROFILE_STATE_CONNECTED; e.profile_state.profile = BT_PROFILE_HID_HOST; bluetooth_fire_event(dev, e); + device_put(dev); } }); return; @@ -659,13 +661,15 @@ static int hidHostGapCb(struct ble_gap_event* event, void* /*arg*/) { } else { LOG_W(TAG, "Connect failed status=%d", event->connect.status); hid_host_ctx.reset(); - if (Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE)) { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { bluetooth_set_hid_host_active(dev, false); - struct BtEvent e = {}; + BtEvent e = {}; e.type = BT_EVENT_PROFILE_STATE_CHANGED; e.profile_state.state = BT_PROFILE_STATE_IDLE; e.profile_state.profile = BT_PROFILE_HID_HOST; bluetooth_fire_event(dev, e); + device_put(dev); } } break; @@ -684,13 +688,15 @@ static int hidHostGapCb(struct ble_gap_event* event, void* /*arg*/) { hid_host_mouse_btn.store(false); hid_host_mouse_active.store(false); - if (Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE)) { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { bluetooth_set_hid_host_active(dev, false); struct BtEvent e = {}; e.type = BT_EVENT_PROFILE_STATE_CHANGED; e.profile_state.state = BT_PROFILE_STATE_IDLE; e.profile_state.profile = BT_PROFILE_HID_HOST; bluetooth_fire_event(dev, e); + device_put(dev); } getMainDispatcher().dispatch([saved_kb, saved_mouse, saved_cursor, saved_queue] { @@ -792,7 +798,13 @@ void hidHostConnect(const std::array& addr) { } // Notify driver that a HID host central connection is starting. - if (Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE)) bluetooth_set_hid_host_active(dev, true); + { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { + bluetooth_set_hid_host_active(dev, true); + device_put(dev); + } + } // Look up the addr_type from the cached scan results. ble_addr_t ble_addr = {}; @@ -812,7 +824,8 @@ void hidHostConnect(const std::array& addr) { if (rc != 0) { LOG_W(TAG, "ble_gap_connect failed rc=%d", rc); hid_host_ctx.reset(); - if (Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE)) { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { bluetooth_set_hid_host_active(dev, false); // Fire IDLE so bt_event_bridge can start a new scan and retry. BtEvent e = {}; @@ -820,6 +833,7 @@ void hidHostConnect(const std::array& addr) { e.profile_state.state = BT_PROFILE_STATE_IDLE; e.profile_state.profile = BT_PROFILE_HID_HOST; bluetooth_fire_event(dev, e); + device_put(dev); } } else { LOG_I(TAG, "Connecting..."); @@ -866,11 +880,13 @@ void autoConnectHidHost() { auto peers = settings::loadAll(); for (const auto& peer : peers) { if (peer.autoConnect && peer.profileId == BT_PROFILE_HID_HOST) { - if (Device* dev = device_find_first_active_by_type(&BLUETOOTH_TYPE)) { + Device* dev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &dev) == ERROR_NONE) { if (!bluetooth_is_scanning(dev)) { LOG_I(TAG, "Auto-connect HID host: device not in scan, retrying scan"); bluetooth_scan_start(dev); } + device_put(dev); } break; } diff --git a/Tactility/Source/lvgl/UsbHidInput.cpp b/Tactility/Source/lvgl/UsbHidInput.cpp index dae388b09..0cd804322 100644 --- a/Tactility/Source/lvgl/UsbHidInput.cpp +++ b/Tactility/Source/lvgl/UsbHidInput.cpp @@ -181,8 +181,11 @@ static void usbHidInputTask(void* arg) { UsbHidEvent hid_evt; if (xQueueReceive(ctx->hid_queue, &hid_evt, pdMS_TO_TICKS(100)) != pdTRUE) { if (!ctx->subscribed) { - struct Device* hid_dev = device_find_first_active_by_type(&USB_HOST_HID_TYPE); - if (hid_dev) ctx->subscribed = usb_host_hid_subscribe(hid_dev, ctx->hid_queue); + Device* hid_dev; + if (device_get_first_active_by_type(&USB_HOST_HID_TYPE, &hid_dev) == ERROR_NONE) { + ctx->subscribed = usb_host_hid_subscribe(hid_dev, ctx->hid_queue); + } + device_put(hid_dev); } continue; } @@ -303,8 +306,11 @@ void startUsbHidInput() { return; } - struct Device* hid_dev = device_find_first_active_by_type(&USB_HOST_HID_TYPE); - if (hid_dev) ctx->subscribed = usb_host_hid_subscribe(hid_dev, ctx->hid_queue); + Device* hid_dev; + if (device_get_first_active_by_type(&USB_HOST_HID_TYPE, &hid_dev) == ERROR_NONE) { + ctx->subscribed = usb_host_hid_subscribe(hid_dev, ctx->hid_queue); + device_put(hid_dev); + } ctx->running = true; if (xTaskCreate(usbHidInputTask, "usb_hid_inp", TASK_STACK, ctx, TASK_PRIORITY, &ctx->task) != pdPASS) { @@ -348,8 +354,11 @@ void stopUsbHidInput() { ctx->task = nullptr; if (ctx->subscribed) { - struct Device* hid_dev = device_find_first_active_by_type(&USB_HOST_HID_TYPE); - if (hid_dev) usb_host_hid_unsubscribe(hid_dev, ctx->hid_queue); + Device* hid_dev; + if (device_get_first_active_by_type(&USB_HOST_HID_TYPE, &hid_dev) == ERROR_NONE) { + usb_host_hid_unsubscribe(hid_dev, ctx->hid_queue); + device_put(hid_dev); + } } vQueueDelete(ctx->hid_queue); vQueueDelete(ctx->key_queue); diff --git a/Tactility/Source/service/rtctime/RtcTimeService.cpp b/Tactility/Source/service/rtctime/RtcTimeService.cpp index 554a47e83..44a026ddf 100644 --- a/Tactility/Source/service/rtctime/RtcTimeService.cpp +++ b/Tactility/Source/service/rtctime/RtcTimeService.cpp @@ -19,7 +19,7 @@ constexpr auto* TAG = "RtcTime"; Device* RtcTimeService::findRtcDevice() { if (!rtcDevice) { - rtcDevice = device_find_first_active_by_type(&RTC_TYPE); + device_get_first_active_by_type(&RTC_TYPE, &rtcDevice); } return rtcDevice; } @@ -130,6 +130,11 @@ void RtcTimeService::onStop(ServiceContext& serviceContext) { kernel::unsubscribeSystemEvent(timeEventSubscription); timeEventSubscription = 0; } + + if (rtcDevice) { + device_put(rtcDevice); + rtcDevice = nullptr; + } } extern const ServiceManifest manifest = { diff --git a/Tactility/Source/service/statusbar/Statusbar.cpp b/Tactility/Source/service/statusbar/Statusbar.cpp index 72ee15d17..e590fe071 100644 --- a/Tactility/Source/service/statusbar/Statusbar.cpp +++ b/Tactility/Source/service/statusbar/Statusbar.cpp @@ -167,8 +167,18 @@ class StatusbarService final : public Service { void updateBluetoothIcon() { auto radio_state = bluetooth::getRadioState(); - Device* btdev = device_find_first_active_by_type(&BLUETOOTH_TYPE); - bool scanning = btdev ? bluetooth_is_scanning(btdev) : false; + bool scanning; + + { + Device* btdev; + if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &btdev) == ERROR_NONE) { + scanning = bluetooth_is_scanning(btdev); + device_put(btdev); + } else { + scanning = false; + } + } + Device* serial_dev = bluetooth_serial_get_device(); Device* midi_dev = bluetooth_midi_get_device(); bool connected = (serial_dev && bluetooth_serial_is_connected(serial_dev)) || @@ -213,10 +223,20 @@ class StatusbarService final : public Service { } void updateUsbIcon() { - Device* hid_dev = device_find_first_active_by_type(&USB_HOST_HID_TYPE); - Device* midi_dev = device_find_first_active_by_type(&USB_HOST_MIDI_TYPE); - bool connected = (hid_dev && usb_host_hid_is_connected(hid_dev)) || - (midi_dev && usb_midi_is_connected(midi_dev)); + bool connected; + { + Device* hid_dev; + device_get_first_active_by_type(&USB_HOST_HID_TYPE, &hid_dev); + Device* midi_dev; + device_get_first_active_by_type(&USB_HOST_MIDI_TYPE, &midi_dev); + + connected = (hid_dev && usb_host_hid_is_connected(hid_dev)) || + (midi_dev && usb_midi_is_connected(midi_dev)); + + device_put(hid_dev); + device_put(midi_dev); + } + if (!connected) { // MSC: scan filesystems for any mounted /usb* path file_system_for_each(&connected, [](struct FileSystem* fs, void* ctx) -> bool { diff --git a/TactilityKernel/include/tactility/device.h b/TactilityKernel/include/tactility/device.h index ee46d7313..ade4f224f 100644 --- a/TactilityKernel/include/tactility/device.h +++ b/TactilityKernel/include/tactility/device.h @@ -333,22 +333,6 @@ void device_for_each_of_type(const struct DeviceType* type, void* callback_conte */ bool device_exists_of_type(const struct DeviceType* type) ; -/** - * Find a device by its name. - * - * @param[in] name non-null device name to look up - * @return the device pointer if found, or NULL if not found - */ -struct Device* device_find_by_name(const char* name) __attribute__((deprecated("Use device_get_by_name() and device_put()"))); - -/** - * Find the first started device of the given type. - * - * @param[in] type non-null device type pointer - * @return the first started device of the given type, or NULL if none found - */ -struct Device* device_find_first_active_by_type(const struct DeviceType* type) __attribute__((deprecated("Use device_get_first_active_by_type() and device_put()"))); - /** * Find the first device of the given type. * @@ -366,13 +350,11 @@ struct Device* device_find_first_by_type(const struct DeviceType* type) __attrib struct Device* device_find_first_by_compatible(const char* compatible) __attribute__((deprecated("Use device_get_first_by_compatible() and device_put()"))); /** - * Find a device by name and atomically take a reference on it (equivalent to a device_find_by_name() + * Find a device by name and atomically take a reference on it. * immediately followed by a successful device_get(), but race-free: the lookup and the reference * are taken under the same lock, so a device that gets torn down concurrently either isn't found * or is safely referenced - there is no gap where a caller could be handed a pointer that's about - * to become invalid). Prefer this over device_find_by_name() + device_get() for any device that - * might be dynamically constructed/destructed at runtime (e.g. a hot-pluggable child device), - * rather than a static devicetree-defined one. + * to become invalid). * * @param[in] name non-null device name to look up * @param[out] out_device receives the found device on success; untouched on failure diff --git a/TactilityKernel/source/device.cpp b/TactilityKernel/source/device.cpp index eaa6c67af..f6cf974e3 100644 --- a/TactilityKernel/source/device.cpp +++ b/TactilityKernel/source/device.cpp @@ -466,31 +466,6 @@ bool device_exists_of_type(const DeviceType* type) { return found; } -Device* device_find_by_name(const char* name) { - Device* found = nullptr; - ledger_lock(); - for (auto* device : ledger.devices) { - if (device->name != nullptr && std::strcmp(device->name, name) == 0) { - found = device; - break; - } - } - ledger_unlock(); - return found; -} - -Device* device_find_first_active_by_type(const DeviceType* type) { - Device* found = nullptr; - device_for_each_of_type(type, &found, [](Device* dev, void* ctx) -> bool { - if (device_is_ready(dev)) { - *static_cast(ctx) = dev; - return false; - } - return true; - }); - return found; -} - Device* device_find_first_by_type(const DeviceType* type) { Device* found = nullptr; device_for_each_of_type(type, &found, [](Device* dev, void* ctx) -> bool { diff --git a/TactilityKernel/source/symbols.c b/TactilityKernel/source/symbols.c index 22248b3ca..7f5790917 100644 --- a/TactilityKernel/source/symbols.c +++ b/TactilityKernel/source/symbols.c @@ -81,7 +81,6 @@ const struct ModuleSymbol KERNEL_SYMBOLS[] = { DEFINE_MODULE_SYMBOL(device_for_each_child), DEFINE_MODULE_SYMBOL(device_for_each_of_type), DEFINE_MODULE_SYMBOL(device_exists_of_type), - DEFINE_MODULE_SYMBOL(device_find_by_name), DEFINE_MODULE_SYMBOL(device_find_first_active_by_type), DEFINE_MODULE_SYMBOL(device_find_first_by_type), DEFINE_MODULE_SYMBOL(device_find_first_by_compatible),