display backlight and bluetooth reference counting (#639)
This commit is contained in:
committed by
GitHub
parent
19b11eb9a8
commit
64fb1a9f52
@@ -10,10 +10,11 @@ const struct DeviceType BLUETOOTH_HID_DEVICE_TYPE = {
|
||||
.name = "bluetooth-hid-device",
|
||||
};
|
||||
|
||||
struct Device* bluetooth_hid_device_get_device() {
|
||||
struct Device* bluetooth_hid_device_get() {
|
||||
struct Device* found = nullptr;
|
||||
device_for_each_of_type(&BLUETOOTH_HID_DEVICE_TYPE, &found, [](struct Device* dev, void* ctx) -> bool {
|
||||
if (device_is_ready(dev)) {
|
||||
// device_get() while still inside the ledger-locked callback, same as device_get_by_name().
|
||||
if (device_is_ready(dev) && device_get(dev) == ERROR_NONE) {
|
||||
*static_cast<struct Device**>(ctx) = dev;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,10 +10,11 @@ const struct DeviceType BLUETOOTH_MIDI_TYPE = {
|
||||
.name = "bluetooth-midi",
|
||||
};
|
||||
|
||||
struct Device* bluetooth_midi_get_device() {
|
||||
struct Device* bluetooth_midi_get() {
|
||||
struct Device* found = nullptr;
|
||||
device_for_each_of_type(&BLUETOOTH_MIDI_TYPE, &found, [](struct Device* dev, void* ctx) -> bool {
|
||||
if (device_is_ready(dev)) {
|
||||
// device_get() while still inside the ledger-locked callback, same as device_get_by_name().
|
||||
if (device_is_ready(dev) && device_get(dev) == ERROR_NONE) {
|
||||
*static_cast<struct Device**>(ctx) = dev;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,10 +10,11 @@ const struct DeviceType BLUETOOTH_SERIAL_TYPE = {
|
||||
.name = "bluetooth-serial",
|
||||
};
|
||||
|
||||
struct Device* bluetooth_serial_get_device() {
|
||||
struct Device* bluetooth_serial_get() {
|
||||
struct Device* found = nullptr;
|
||||
device_for_each_of_type(&BLUETOOTH_SERIAL_TYPE, &found, [](struct Device* dev, void* ctx) -> bool {
|
||||
if (device_is_ready(dev)) {
|
||||
// device_get() while still inside the ledger-locked callback, same as device_get_by_name().
|
||||
if (device_is_ready(dev) && device_get(dev) == ERROR_NONE) {
|
||||
*static_cast<struct Device**>(ctx) = dev;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,16 @@ error_t display_get_backlight(Device* device, Device** backlight) {
|
||||
if (api->get_backlight == nullptr) {
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
return api->get_backlight(device, backlight);
|
||||
Device* found = nullptr;
|
||||
error_t error = api->get_backlight(device, &found);
|
||||
if (error != ERROR_NONE) {
|
||||
return error;
|
||||
}
|
||||
error = device_get(found);
|
||||
if (error == ERROR_NONE) {
|
||||
*backlight = found;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
const struct DeviceType DISPLAY_TYPE {
|
||||
|
||||
@@ -340,7 +340,8 @@ const struct ModuleSymbol KERNEL_SYMBOLS[] = {
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_fire_event),
|
||||
DEFINE_MODULE_SYMBOL(BLUETOOTH_TYPE),
|
||||
// drivers/bluetooth_serial
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_serial_get_device),
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_serial_get),
|
||||
DEFINE_MODULE_SYMBOL_ALIAS("bluetooth_serial_get_device", bluetooth_serial_get), // TODO remove in 2027
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_serial_start),
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_serial_stop),
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_serial_write),
|
||||
@@ -348,14 +349,16 @@ const struct ModuleSymbol KERNEL_SYMBOLS[] = {
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_serial_is_connected),
|
||||
DEFINE_MODULE_SYMBOL(BLUETOOTH_SERIAL_TYPE),
|
||||
// drivers/bluetooth_midi
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_midi_get_device),
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_midi_get),
|
||||
DEFINE_MODULE_SYMBOL_ALIAS("bluetooth_midi_get_device", bluetooth_midi_get), // TODO remove in 2027
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_midi_start),
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_midi_stop),
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_midi_send),
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_midi_is_connected),
|
||||
DEFINE_MODULE_SYMBOL(BLUETOOTH_MIDI_TYPE),
|
||||
// drivers/bluetooth_hid_device
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_hid_device_get_device),
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_hid_device_get),
|
||||
DEFINE_MODULE_SYMBOL_ALIAS("bluetooth_hid_device_get_device", bluetooth_hid_device_get), // TODO remove in 2027
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_hid_device_start),
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_hid_device_stop),
|
||||
DEFINE_MODULE_SYMBOL(bluetooth_hid_device_send_key),
|
||||
|
||||
Reference in New Issue
Block a user