temp/upower: fix led detection on the librem5 (MR 1986)

The previous implementation of this caused upower to select a thing
called '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'.

fixed #967
This commit is contained in:
Clayton Craft 2021-02-24 17:07:23 -08:00 committed by Alexey Min
parent 81e374c3c6
commit 184bc634e6
No known key found for this signature in database
GPG key ID: 0B19D2A65870B448
2 changed files with 36 additions and 2 deletions

View file

@ -0,0 +1,32 @@
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

View file

@ -4,7 +4,7 @@ pkgname=upower
pkgver=9999
_pkgver=0.99.11
_distver="UPOWER_${_pkgver//./_}"
pkgrel=1
pkgrel=2
pkgdesc="Power Management Services"
url="https://upower.freedesktop.org"
arch="aarch64 armv7"
@ -17,6 +17,7 @@ options="!check" # need unpackaged umockdev
source="https://gitlab.freedesktop.org/upower/upower/-/archive/$_distver/upower-$_distver.tar.bz2
0001-Add-torch-support.patch
0002-Detect-USB-Type-C-port-controller-and-other-chargers.patch
0003-torch-be-more-specific-when-searching-for-an-led-dev.patch
"
builddir="$srcdir/$pkgname-$_distver"
@ -56,4 +57,5 @@ package() {
sha512sums="918fdba13df7ba85fd276daae68228554e71df95011b48dc42b006a059cf2996f906ce08e98f6d1da07c8f2a4235bc9622992fa42eaaf05a08f1a3650f4ae4b6 upower-UPOWER_0_99_11.tar.bz2
c6c8a557f8ca650e6e2b8b1f64f70744dc610f86f71d88602014b6c241c96821b5662f48ab63da6a2da9e52017b8d9f7a87655f8f640e87b5d17417577079b0b 0001-Add-torch-support.patch
0673d32e8c3d313e21437e7d431068b4a0c51a4d63acf414fc93430c461ab5acbcc2ae8740d6614ed9487fadb8ae2c685e02fb7ad3623b71a20ccb90c1a0bd28 0002-Detect-USB-Type-C-port-controller-and-other-chargers.patch"
0673d32e8c3d313e21437e7d431068b4a0c51a4d63acf414fc93430c461ab5acbcc2ae8740d6614ed9487fadb8ae2c685e02fb7ad3623b71a20ccb90c1a0bd28 0002-Detect-USB-Type-C-port-controller-and-other-chargers.patch
c0c440103f3712106728e02520de66875de36fb7799c57bfef8952d03bae00beaa2c9b6335115050e9d484d013f3bcb88230d7d9a1bc8c0f0305f77a0e8fcfa8 0003-torch-be-more-specific-when-searching-for-an-led-dev.patch"