33 lines
1.1 KiB
Diff
33 lines
1.1 KiB
Diff
|
From f15355f16e8b3dc50c2f0e9c078a55d4224477ff Mon Sep 17 00:00:00 2001
|
||
|
From: Clayton Craft <clayton@craftyguy.net>
|
||
|
Date: Wed, 24 Feb 2021 17:04:17 -0800
|
||
|
Subject: [PATCH] torch: be more specific when searching for an led device
|
||
|
|
||
|
The previous implementation of this caused upower to select a thing
|
||
|
callsed 'flash_strobe' in the L5, which doesn't operate like a
|
||
|
flashlight. This changes the detection logic to look at the suffix, on
|
||
|
the pinephone the device ends in ':flash', and on the L5 it ends in
|
||
|
':torch'.
|
||
|
---
|
||
|
src/up-torch.c | 4 ++--
|
||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/src/up-torch.c b/src/up-torch.c
|
||
|
index 8705041..554d197 100644
|
||
|
--- a/src/up-torch.c
|
||
|
+++ b/src/up-torch.c
|
||
|
@@ -263,8 +263,8 @@ up_torch_find (UpTorch *torch)
|
||
|
|
||
|
/* find a led device that is a torch */
|
||
|
while ((filename = g_dir_read_name (dir)) != NULL) {
|
||
|
- if (g_strstr_len (filename, -1, "torch") != NULL ||
|
||
|
- g_strstr_len (filename, -1, "flash") != NULL) {
|
||
|
+ if (g_str_has_suffix(filename, ":torch") ||
|
||
|
+ g_str_has_suffix(filename, ":flash")) {
|
||
|
dir_path = g_build_filename ("/sys/class/leds",
|
||
|
filename, NULL);
|
||
|
break;
|
||
|
--
|
||
|
2.30.1
|
||
|
|