Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 251893 - app-laptop/laptop-mode-tools depends on deprecated /proc/acpi directories to determine AC status
Summary: app-laptop/laptop-mode-tools depends on deprecated /proc/acpi directories to ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Mobile Herd (OBSOLETE)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-21 16:27 UTC by horrovac
Modified: 2009-02-28 06:48 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
patch for /usr/sbin/laptop_mode (laptop_mode.patch,427 bytes, patch)
2008-12-21 16:28 UTC, horrovac
Details | Diff
Ebuild or app-laptop/laptop-mode-tools-1.45 (laptop-mode-tools-1.45.ebuild,2.43 KB, text/plain)
2008-12-24 14:12 UTC, horrovac
Details
laptop-mode-tools init script (laptop_mode.init,982 bytes, text/plain)
2008-12-24 14:13 UTC, horrovac
Details

Note You need to log in before you can comment on or make changes to this bug.
Description horrovac 2008-12-21 16:27:13 UTC
/usr/sbin/laptop_mode searches /proc/acpi/ac_adapter/ for information on ac adapter status, this is marked deprecated in newest kernels. This functionality will be moved to /sys/class/power_supply/. Here's a quick patch I created to get the status from sys/class/power_supply/AC/online. It works here (I haven't tested it extensively yet), please test and commit if it's ok:

--- laptop_mode	2008-11-19 10:40:20.000000000 +0100
+++ laptop_mode.new	2008-12-21 16:55:59.000000000 +0100
@@ -541,7 +541,9 @@
 # Determine the power state.
 export ON_AC=1
 
-if [ -d /proc/acpi/ac_adapter ] ; then
+if [ -d /sys/class/power_supply/AC ] ; then
+	read ON_AC < /sys/class/power_supply/AC/online
+elif [ -d /proc/acpi/ac_adapter ] ; then
 	ADAPTERS_FOUND=0
 	ON_AC=0
 	for ADAPTER in /proc/acpi/ac_adapter/* ; do

Reproducible: Always

Steps to Reproduce:
1.Compile kernel without deprecated /proc/acpi files and directories (or just prevent laptop_mode from accessing them)
2.Unplug the AC adapter
3.Nada



Expected Results:  
laptop_mode should use the /sys interface to determine power status
Comment 1 horrovac 2008-12-21 16:28:31 UTC
Created attachment 176054 [details, diff]
patch for /usr/sbin/laptop_mode
Comment 2 horrovac 2008-12-24 10:25:29 UTC
UPDATE: I've since found out that this has been fixed in upstream in version 1.36, and battery level checking was fixed in 1.40. Please take no action on my patch, I'm currently testing an ebuild for laptop-mode-tools-1.45 and will submit it for review.

p.s: This bug is obviously invalid, but I'm unsure as to which status could be assigned, please advise)
Comment 3 horrovac 2008-12-24 14:12:34 UTC
Created attachment 176300 [details]
Ebuild or app-laptop/laptop-mode-tools-1.45

Here's an ebuild for laptop-mode-tools-1.45, works on my system. Please test and advise if I've done something wrong. NOTE: a new init script is also necessary (uploading next)
Comment 4 horrovac 2008-12-24 14:13:40 UTC
Created attachment 176302 [details]
laptop-mode-tools init script
Comment 5 Olivier Crete (RETIRED) gentoo-dev 2009-02-28 06:48:50 UTC
Version 1.47 fixes that