[Bug 215799] apple-mfi-fastcharge causes automatic pm hibernation entry, when iPhone gets attached

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.kernel.org/show_bug.cgi?id=215799

--- Comment #6 from Manuel Ullmann (labre@xxxxxxxxx) ---
(In reply to Oliver Neukum from comment #5)
> just to make this clear. We seem to have two bugs. Do both need to be fixed
> to remedy this issue, or do we have two independent bugs?

They are partially dependent on each other, however the kernel can’t fix the
issue alone, while userspace can by adding a safe guard/workaround.

Is it technically more correct to report the charger as USB or should it rather
stay like it is? If the answer is yes, then the patch should be incorporated.
Whether it is required depends on how the laptop-mode-tools developing
community considers workarounds for buggy drivers.

Consider the following commit [1]:

diff --git a/usr/sbin/laptop_mode b/usr/sbin/laptop_mode
index 5e2ef72..c4387ab 100755
--- a/usr/sbin/laptop_mode
+++ b/usr/sbin/laptop_mode
@@ -488,7 +488,7 @@ lmt_load_config ()
        BATTERY_NOT_DISCHARGING=0
        for POWER_SUPPLY in /sys/class/power_supply/* ; do
                if [ -f $POWER_SUPPLY/type ] ; then
-                       SYSFS_POWER_SUPPLY=1
+                       SYSFS_POWER_SUPPLY=$(( SYSFS_POWER_SUPPLY + 1 ))
                        if [ "$(cat $POWER_SUPPLY/type)" = "Mains" ]; then
                                log "VERBOSE" "Determining power state from
$POWER_SUPPLY/online."
                                if [ "$(cat $POWER_SUPPLY/online)" = 1 ]; then
@@ -497,6 +497,14 @@ lmt_load_config ()
                                fi
                         elif [ "$(cat $POWER_SUPPLY/type)" = "Battery" ]; then
                                log "VERBOSE" "Determining power state from
status of battery $POWER_SUPPLY."
+                               #INFO: Because there are and will always be
br0ken drivers
+                               if [ ! -f $POWER_SUPPLY/status ]; then
+                                       log "ERR" "Your power_supply is lacking
a status node"
+                                       log "ERR" "Its driver might be
reporting a wrong type"
+                                       log "ERR" "Ignoring this battery"
+                                       SYSFS_POWER_SUPPLY=$((
SYSFS_POWER_SUPPLY - 1 ))
+                                       continue
+                               fi
                                 #INFO: Because there are and will always be
br0ken batteries
                                if [ "$(cat $POWER_SUPPLY/status)" !=
"Discharging" ]; then
                                        if [ "$(cat $POWER_SUPPLY/status)" =
"Unknown" ]; then
@@ -512,11 +520,15 @@ lmt_load_config ()
                                        ON_AC=0
                                        break
                                fi
+                       else
+                           log "VERBOSE" "Power_supply has unexpected type
$(cat $POWER_SUPPLY/type)"
+                           log "VERBOSE" "Ignoring it"
+                           SYSFS_POWER_SUPPLY=$(( SYSFS_POWER_SUPPLY - 1 ))
                        fi
                fi
        done

-       if [ $SYSFS_POWER_SUPPLY = 1 ] ; then
+       if [ $SYSFS_POWER_SUPPLY -gt 0 ] ; then
                # Already found it!
                log "VERBOSE" "Not trying other options, already found a power
supply."
        elif [ $BATTERY_NOT_DISCHARGING = 1 ]; then
-- 
2.35.1

With the kernel patch, just the else case and increment/decrement would be
required. Without it, the handling in the battery case is required. As I said,
I would consider this a reasonable addition for robustness, but I don’t know,
whether the laptop-mode-tools community shares that opinion.

Thank you again for pointing me in the right direction.

[1]:
https://github.com/rickysarraf/laptop-mode-tools/pull/186/commits/9ddcb2e9f4665fa0b0620fc7eb397917d029fdfd

-- 
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux