Changeset View
Changeset View
Standalone View
Standalone View
ksysguardd/Linux/acpi.c
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | KSysGuard, the KDE System Guard | 2 | KSysGuard, the KDE System Guard | ||
3 | 3 | | |||
4 | Copyright (c) 2003 Stephan Uhlmann <su@su2.info> | 4 | Copyright (c) 2003 Stephan Uhlmann <su@su2.info> | ||
5 | Copyright (c) 2005 Sirtaj Singh Kang <taj@kde.org> -- Battery fixes and Thermal | 5 | Copyright (c) 2005 Sirtaj Singh Kang <taj@kde.org> -- Battery fixes and Thermal | ||
6 | Copyright (c) 2020 Jose Jorge <lists.jjorge@free.fr> -- Add energy sensor | ||||
6 | 7 | | |||
7 | This program is free software; you can redistribute it and/or | 8 | This program is free software; you can redistribute it and/or | ||
8 | modify it under the terms of version 2 of the GNU General Public | 9 | modify it under the terms of version 2 of the GNU General Public | ||
9 | License as published by the Free Software Foundation. | 10 | License as published by the Free Software Foundation. | ||
10 | 11 | | |||
11 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
Show All 40 Lines | |||||
54 | void registerBatteryCharge(int number, struct SensorModul *sm) | 55 | void registerBatteryCharge(int number, struct SensorModul *sm) | ||
55 | { | 56 | { | ||
56 | char name[ ACPIFILENAMELENGTHMAX ]; | 57 | char name[ ACPIFILENAMELENGTHMAX ]; | ||
57 | readTypeFile("/sys/class/power_supply/BAT%d/type", number, name, sizeof(name)); | 58 | readTypeFile("/sys/class/power_supply/BAT%d/type", number, name, sizeof(name)); | ||
58 | 59 | | |||
59 | char sensorName [ ACPIFILENAMELENGTHMAX ]; | 60 | char sensorName [ ACPIFILENAMELENGTHMAX ]; | ||
60 | snprintf(sensorName, sizeof(sensorName), "acpi/Battery/%d-%s/Charge", number, name); | 61 | snprintf(sensorName, sizeof(sensorName), "acpi/Battery/%d-%s/Charge", number, name); | ||
61 | 62 | | |||
62 | registerMonitor(sensorName, "integer", printSysBatteryCharge, | 63 | registerMonitor(sensorName, "float", printSysBatteryCharge, | ||
63 | printSysBatteryChargeInfo, sm); | 64 | printSysBatteryChargeInfo, sm); | ||
64 | } | 65 | } | ||
65 | 66 | | |||
66 | void registerBatteryChargeDesign(int number, struct SensorModul *sm) | 67 | void registerBatteryChargeDesign(int number, struct SensorModul *sm) | ||
67 | { | 68 | { | ||
68 | char name[ ACPIFILENAMELENGTHMAX ]; | 69 | char name[ ACPIFILENAMELENGTHMAX ]; | ||
69 | readTypeFile("/sys/class/power_supply/BAT%d/type", number, name, sizeof(name)); | 70 | readTypeFile("/sys/class/power_supply/BAT%d/type", number, name, sizeof(name)); | ||
70 | 71 | | |||
71 | char sensorName [ ACPIFILENAMELENGTHMAX ]; | 72 | char sensorName [ ACPIFILENAMELENGTHMAX ]; | ||
72 | snprintf(sensorName, sizeof(sensorName), "acpi/Battery/%d-%s/ChargeDesign", number, name); | 73 | snprintf(sensorName, sizeof(sensorName), "acpi/Battery/%d-%s/ChargeDesign", number, name); | ||
73 | 74 | | |||
74 | registerMonitor(sensorName, "integer", printSysBatteryChargeDesign, | 75 | registerMonitor(sensorName, "float", printSysBatteryChargeDesign, | ||
75 | printSysBatteryChargeDesignInfo, sm); | 76 | printSysBatteryChargeDesignInfo, sm); | ||
76 | } | 77 | } | ||
77 | 78 | | |||
79 | void registerBatteryEnergy(int number, struct SensorModul *sm) | ||||
80 | { | ||||
81 | char name[ ACPIFILENAMELENGTHMAX ]; | ||||
82 | readTypeFile("/sys/class/power_supply/BAT%d/type", number, name, sizeof(name)); | ||||
ahiemstra: These two lines are now repeated in all "registerX" functions. Maybe move this to… | |||||
83 | | ||||
84 | char sensorName [ ACPIFILENAMELENGTHMAX ]; | ||||
85 | snprintf(sensorName, sizeof(sensorName), "acpi/Battery/%d-%s/Energy", number, name); | ||||
86 | | ||||
87 | registerMonitor(sensorName, "float", printSysBatteryEnergy, | ||||
88 | printSysBatteryEnergyInfo, sm); | ||||
89 | } | ||||
90 | | ||||
91 | void registerBatteryEnergyDesign(int number, struct SensorModul *sm) | ||||
92 | { | ||||
93 | char name[ ACPIFILENAMELENGTHMAX ]; | ||||
94 | readTypeFile("/sys/class/power_supply/BAT%d/type", number, name, sizeof(name)); | ||||
95 | | ||||
96 | char sensorName [ ACPIFILENAMELENGTHMAX ]; | ||||
97 | snprintf(sensorName, sizeof(sensorName), "acpi/Battery/%d-%s/EnergyDesign", number, name); | ||||
98 | | ||||
99 | registerMonitor(sensorName, "float", printSysBatteryEnergyDesign, | ||||
100 | printSysBatteryEnergyDesignInfo, sm); | ||||
101 | } | ||||
102 | | ||||
78 | void registerBatteryRate(int number, struct SensorModul *sm) | 103 | void registerBatteryRate(int number, struct SensorModul *sm) | ||
Uhm, this should be const char *name right? I don't really see how this can work otherwise. ahiemstra: Uhm, this should be `const char *name` right? I don't really see how this can work otherwise. | |||||
79 | { | 104 | { | ||
80 | char name[ ACPIFILENAMELENGTHMAX ]; | 105 | char name[ ACPIFILENAMELENGTHMAX ]; | ||
81 | readTypeFile("/sys/class/power_supply/BAT%d/type", number, name, sizeof(name)); | 106 | readTypeFile("/sys/class/power_supply/BAT%d/type", number, name, sizeof(name)); | ||
82 | 107 | | |||
83 | char sensorName [ ACPIFILENAMELENGTHMAX ]; | 108 | char sensorName [ ACPIFILENAMELENGTHMAX ]; | ||
84 | snprintf(sensorName, sizeof(sensorName), "acpi/Battery/%d-%s/Rate", number, name); | 109 | snprintf(sensorName, sizeof(sensorName), "acpi/Battery/%d-%s/Rate", number, name); | ||
85 | 110 | | |||
86 | registerMonitor(sensorName, "integer", printSysBatteryRate, | 111 | registerMonitor(sensorName, "integer", printSysBatteryRate, | ||
87 | printSysBatteryRateInfo, sm); | 112 | printSysBatteryRateInfo, sm); | ||
88 | } | 113 | } | ||
89 | 114 | | |||
115 | void registerBatteryRatePower(int number, struct SensorModul *sm) | ||||
116 | { | ||||
117 | char name[ ACPIFILENAMELENGTHMAX ]; | ||||
118 | readTypeFile("/sys/class/power_supply/BAT%d/type", number, name, sizeof(name)); | ||||
119 | | ||||
120 | char sensorName [ ACPIFILENAMELENGTHMAX ]; | ||||
121 | snprintf(sensorName, sizeof(sensorName), "acpi/Battery/%d-%s/RatePower", number, name); | ||||
122 | | ||||
123 | registerMonitor(sensorName, "integer", printSysBatteryRate, | ||||
124 | printSysBatteryRateInfo, sm); | ||||
125 | } | ||||
126 | | ||||
90 | void initAcpiBattery( struct SensorModul* sm ) | 127 | void initAcpiBattery( struct SensorModul* sm ) | ||
91 | { | 128 | { | ||
92 | DIR *d; | 129 | DIR *d; | ||
93 | struct dirent *de; | 130 | struct dirent *de; | ||
94 | char s[ ACPIFILENAMELENGTHMAX ]; | | |||
95 | 131 | | |||
96 | d = opendir("/sys/class/power_supply/"); | 132 | d = opendir("/sys/class/power_supply/"); | ||
97 | if (d != NULL) { | 133 | if (d != NULL) { | ||
98 | while ( (de = readdir(d)) != NULL ) { | 134 | while ( (de = readdir(d)) != NULL ) { | ||
99 | if (!de->d_name || de->d_name[0] == '.') | 135 | if (!de->d_name || de->d_name[0] == '.') | ||
100 | continue; | 136 | continue; | ||
101 | if (strncmp( de->d_name, "BAT", sizeof("BAT")-1) == 0) { | 137 | if (strncmp( de->d_name, "BAT", sizeof("BAT")-1) == 0) { | ||
102 | int number = atoi(de->d_name + (sizeof("BAT")-1)); | 138 | int number = atoi(de->d_name + (sizeof("BAT")-1)); | ||
103 | registerBatteryCharge(number, sm); | 139 | registerBatteryCharge(number, sm); | ||
104 | registerBatteryChargeDesign(number, sm); | 140 | registerBatteryChargeDesign(number, sm); | ||
141 | registerBatteryEnergy(number, sm); | ||||
142 | registerBatteryEnergyDesign(number, sm); | ||||
105 | registerBatteryRate(number, sm); | 143 | registerBatteryRate(number, sm); | ||
144 | registerBatteryRatePower(number, sm); | ||||
106 | } | 145 | } | ||
107 | } | 146 | } | ||
108 | closedir( d ); | 147 | closedir( d ); | ||
109 | } | 148 | } | ||
110 | } | 149 | } | ||
111 | 150 | | |||
112 | void printSysBatteryCharge(const char *cmd) | 151 | void printSysBatteryCharge(const char *cmd) | ||
113 | { | 152 | { | ||
114 | int zone = 0; | 153 | int zone = 0; | ||
115 | if (sscanf(cmd, "acpi/Battery/%d", &zone) <= 0) { | 154 | if (sscanf(cmd, "acpi/Battery/%d", &zone) <= 0) { | ||
116 | output("-1\n"); | 155 | output("-1\n"); | ||
117 | return; | 156 | return; | ||
118 | } | 157 | } | ||
119 | 158 | | |||
120 | int charge = getSysFileValue("power_supply", "BAT", zone, "charge_now"); | 159 | int charge = getSysFileValue("power_supply", "BAT", zone, "charge_now"); | ||
121 | int maximum = getSysFileValue("power_supply", "BAT", zone, "charge_full"); | 160 | int maximum = getSysFileValue("power_supply", "BAT", zone, "charge_full"); | ||
122 | int state = 0; | 161 | float state = 0; | ||
123 | if ( maximum > 0) { | 162 | if ( maximum > 0) { | ||
124 | state = charge * 100 / maximum; | 163 | state = charge/(double)(maximum/100);/* to get 0.1% changes */ | ||
You cast to double but then store it in a float, which implies a cast to float. Probably better to just cast to float directly. (Also applies to the functions below.) ahiemstra: You cast to double but then store it in a float, which implies a cast to float. Probably better… | |||||
(float)(var_int/var_int) does not what you want, it should be ((float)var_int / var_int) anthonyfieroni: `(float)(var_int/var_int)` does not what you want, it should be `((float)var_int / var_int)` | |||||
125 | } | 164 | } | ||
126 | if (state > 100) { | 165 | if (state > 100) { | ||
127 | state = 100; /* prevent insane numbers with bad hardware */ | 166 | state = 100; /* prevent insane numbers with bad hardware */ | ||
128 | } else if (state < 0) { | 167 | } else if (state < 0) { | ||
129 | state = 0; /* prevent insane numbers with bad hardware */ | 168 | state = 0; /* prevent insane numbers with bad hardware */ | ||
130 | } | 169 | } | ||
131 | output( "%d\n", state); | 170 | output( "%f\n", state); | ||
132 | } | 171 | } | ||
133 | 172 | | |||
134 | void printSysBatteryChargeInfo(const char *cmd) | 173 | void printSysBatteryChargeInfo(const char *cmd) | ||
135 | { | 174 | { | ||
136 | char name [ 200 ]; | 175 | char name [ 200 ]; | ||
137 | if (sscanf(cmd, "acpi/Battery/%199[^/]", name) > 0) { | 176 | if (sscanf(cmd, "acpi/Battery/%199[^/]", name) > 0) { | ||
138 | output( "%s charge\t0\t100\t%%\n", name); | 177 | output( "%s charge\t0\t100\t%%\n", name); | ||
139 | } else { | 178 | } else { | ||
140 | output( "Current charge\t0\t100\t%%\n"); | 179 | output( "Current charge\t0\t100\t%%\n"); | ||
141 | } | 180 | } | ||
142 | } | 181 | } | ||
143 | 182 | | |||
144 | void printSysBatteryChargeDesign(const char *cmd) | 183 | void printSysBatteryChargeDesign(const char *cmd) | ||
145 | { | 184 | { | ||
146 | int zone = 0; | 185 | int zone = 0; | ||
147 | if (sscanf(cmd, "acpi/Battery/%d", &zone) <= 0) { | 186 | if (sscanf(cmd, "acpi/Battery/%d", &zone) <= 0) { | ||
148 | output("-1\n"); | 187 | output("-1\n"); | ||
149 | return; | 188 | return; | ||
150 | } | 189 | } | ||
151 | 190 | | |||
152 | int charge = getSysFileValue("power_supply", "BAT", zone, "charge_now"); | 191 | int charge = getSysFileValue("power_supply", "BAT", zone, "charge_now"); | ||
153 | int maximum = getSysFileValue("power_supply", "BAT", zone, "charge_full_design"); | 192 | int maximum = getSysFileValue("power_supply", "BAT", zone, "charge_full_design"); | ||
154 | int state = 0; | 193 | float state = 0; | ||
155 | if (maximum > 0) { | 194 | if (maximum > 0) { | ||
156 | state = charge * 100 / maximum; | 195 | state = charge/(double)(maximum/100);/* to get 0.1% changes */ | ||
anthonyfieroni: ditto | |||||
157 | } | 196 | } | ||
158 | if (state > 100) { | 197 | if (state > 100) { | ||
159 | state = 100; /* prevent insane numbers with bad hardware */ | 198 | state = 100; /* prevent insane numbers with bad hardware */ | ||
160 | } else if (state < 0) { | 199 | } else if (state < 0) { | ||
161 | state = 0; /* prevent insane numbers with bad hardware */ | 200 | state = 0; /* prevent insane numbers with bad hardware */ | ||
162 | } | 201 | } | ||
163 | output( "%d\n", state); | 202 | output( "%f\n", state); | ||
164 | } | 203 | } | ||
165 | 204 | | |||
166 | void printSysBatteryChargeDesignInfo(const char *cmd) | 205 | void printSysBatteryChargeDesignInfo(const char *cmd) | ||
167 | { | 206 | { | ||
168 | char name [ 200 ]; | 207 | char name [ 200 ]; | ||
169 | if (sscanf(cmd, "acpi/Battery/%199[^/]", name) > 0) { | 208 | if (sscanf(cmd, "acpi/Battery/%199[^/]", name) > 0) { | ||
170 | output( "%s charge (by design)\t0\t100\t%%\n", name); | 209 | output( "%s charge (by design)\t0\t100\t%%\n", name); | ||
171 | } else { | 210 | } else { | ||
172 | output( "Current charge (by design)\t0\t100\t%%\n"); | 211 | output( "Current charge (by design)\t0\t100\t%%\n"); | ||
173 | } | 212 | } | ||
174 | } | 213 | } | ||
175 | 214 | | |||
215 | void printSysBatteryEnergy(const char *cmd) | ||||
216 | { | ||||
217 | int zone = 0; | ||||
218 | if (sscanf(cmd, "acpi/Battery/%d", &zone) <= 0) { | ||||
219 | output("-1\n"); | ||||
220 | return; | ||||
221 | } | ||||
222 | | ||||
223 | int charge = getSysFileValue("power_supply", "BAT", zone, "energy_now"); | ||||
224 | int maximum = getSysFileValue("power_supply", "BAT", zone, "energy_full"); | ||||
225 | float state = 0; | ||||
226 | if ( maximum > 0) { | ||||
227 | state = charge/(double)(maximum/100);/* to get 0.1% changes */ | ||||
anthonyfieroni: ditto | |||||
228 | } | ||||
229 | if (state > 100) { | ||||
230 | state = 100; /* prevent insane numbers with bad hardware */ | ||||
231 | } else if (state < 0) { | ||||
232 | state = 0; /* prevent insane numbers with bad hardware */ | ||||
233 | } | ||||
234 | output( "%f\n", state); | ||||
235 | } | ||||
236 | | ||||
237 | void printSysBatteryEnergyInfo(const char *cmd) | ||||
238 | { | ||||
239 | char name [ 200 ]; | ||||
240 | if (sscanf(cmd, "acpi/Battery/%199[^/]", name) > 0) { | ||||
241 | output( "%s energy\t0\t100\t%%\n", name); | ||||
242 | } else { | ||||
243 | output( "Current energy\t0\t100\t%%\n"); | ||||
244 | } | ||||
245 | } | ||||
246 | | ||||
247 | void printSysBatteryEnergyDesign(const char *cmd) | ||||
248 | { | ||||
249 | int zone = 0; | ||||
250 | if (sscanf(cmd, "acpi/Battery/%d", &zone) <= 0) { | ||||
251 | output("-1\n"); | ||||
252 | return; | ||||
253 | } | ||||
254 | | ||||
255 | int charge = getSysFileValue("power_supply", "BAT", zone, "energy_now"); | ||||
256 | int maximum = getSysFileValue("power_supply", "BAT", zone, "energy_full_design"); | ||||
257 | float state = 0; | ||||
258 | if (maximum > 0) { | ||||
259 | state = charge/(double)(maximum/100);/* to get 0.1% changes */ | ||||
anthonyfieroni: ditto | |||||
260 | } | ||||
261 | if (state > 100) { | ||||
262 | state = 100; /* prevent insane numbers with bad hardware */ | ||||
263 | } else if (state < 0) { | ||||
264 | state = 0; /* prevent insane numbers with bad hardware */ | ||||
265 | } | ||||
266 | output( "%f\n", state); | ||||
267 | } | ||||
268 | | ||||
269 | void printSysBatteryEnergyDesignInfo(const char *cmd) | ||||
270 | { | ||||
271 | char name [ 200 ]; | ||||
272 | if (sscanf(cmd, "acpi/Battery/%199[^/]", name) > 0) { | ||||
273 | output( "%s energy (by design)\t0\t100\t%%\n", name); | ||||
274 | } else { | ||||
275 | output( "Current energy (by design)\t0\t100\t%%\n"); | ||||
276 | } | ||||
277 | } | ||||
278 | | ||||
176 | void printSysBatteryRate(const char *cmd) | 279 | void printSysBatteryRate(const char *cmd) | ||
177 | { | 280 | { | ||
178 | int zone = 0; | 281 | int zone = 0; | ||
179 | if (sscanf(cmd, "acpi/Battery/%d", &zone) <= 0) { | 282 | if (sscanf(cmd, "acpi/Battery/%d", &zone) <= 0) { | ||
180 | output("-1\n"); | 283 | output("-1\n"); | ||
181 | return; | 284 | return; | ||
182 | } | 285 | } | ||
183 | 286 | | |||
184 | output( "%d\n", getSysFileValue("power_supply", "BAT", zone, "current_now") / 1000); | 287 | output( "%d\n", getSysFileValue("power_supply", "BAT", zone, "current_now") / 1000); | ||
185 | } | 288 | } | ||
186 | 289 | | |||
187 | void printSysBatteryRateInfo(const char *cmd) | 290 | void printSysBatteryRateInfo(const char *cmd) | ||
188 | { | 291 | { | ||
189 | char name [ 200 ]; | 292 | char name [ 200 ]; | ||
190 | if (sscanf(cmd, "acpi/Battery/%199[^/]", name) > 0) { | 293 | if (sscanf(cmd, "acpi/Battery/%199[^/]", name) > 0) { | ||
191 | output( "%s rate\t0\t0\tmA\n", name); | 294 | output( "%s rate\t0\t0\tmA\n", name); | ||
192 | } else { | 295 | } else { | ||
193 | output( "Current rate\t0\t0\tmA\n"); | 296 | output( "Current rate\t0\t0\tmA\n"); | ||
194 | } | 297 | } | ||
195 | } | 298 | } | ||
196 | 299 | | |||
300 | void printSysBatteryRatePower(const char *cmd) | ||||
301 | { | ||||
302 | int zone = 0; | ||||
303 | if (sscanf(cmd, "acpi/Battery/%d", &zone) <= 0) { | ||||
304 | output("-1\n"); | ||||
305 | return; | ||||
306 | } | ||||
307 | | ||||
308 | output( "%d\n", getSysFileValue("power_supply", "BAT", zone, "power_now") / 1000); | ||||
309 | } | ||||
310 | | ||||
311 | void printSysBatteryRatePowerInfo(const char *cmd) | ||||
312 | { | ||||
313 | char name [ 200 ]; | ||||
314 | if (sscanf(cmd, "acpi/Battery/%199[^/]", name) > 0) { | ||||
315 | output( "%s rate\t0\t0\tmA\n", name); | ||||
316 | } else { | ||||
317 | output( "Current power rate\t0\t0\tmA\n"); | ||||
318 | } | ||||
319 | } | ||||
320 | | ||||
197 | 321 | | |||
198 | /************** ACPI Thermal *****************/ | 322 | /************** ACPI Thermal *****************/ | ||
199 | 323 | | |||
200 | #define OLD_THERMAL_ZONE_DIR "/proc/acpi/thermal_zone" | 324 | #define OLD_THERMAL_ZONE_DIR "/proc/acpi/thermal_zone" | ||
201 | #define OLD_TEMPERATURE_FILE "temperature" | 325 | #define OLD_TEMPERATURE_FILE "temperature" | ||
202 | #define OLD_TEMPERATURE_FILE_MAXLEN 255 | 326 | #define OLD_TEMPERATURE_FILE_MAXLEN 255 | ||
203 | 327 | | |||
204 | #define OLD_FAN_DIR "/proc/acpi/fan" | 328 | #define OLD_FAN_DIR "/proc/acpi/fan" | ||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | |||||
334 | 458 | | |||
335 | static int getSysFileValue(const char *className, const char *group, int value, const char *file) { | 459 | static int getSysFileValue(const char *className, const char *group, int value, const char *file) { | ||
336 | static int shownError = 0; | 460 | static int shownError = 0; | ||
337 | char th_file[ ACPIFILENAMELENGTHMAX ]; | 461 | char th_file[ ACPIFILENAMELENGTHMAX ]; | ||
338 | char input_buf[ 100 ]; | 462 | char input_buf[ 100 ]; | ||
339 | snprintf(th_file, sizeof(th_file), "/sys/class/%s/%s%d/%s", className, group, value, file); | 463 | snprintf(th_file, sizeof(th_file), "/sys/class/%s/%s%d/%s", className, group, value, file); | ||
340 | int fd = open(th_file, O_RDONLY); | 464 | int fd = open(th_file, O_RDONLY); | ||
341 | if (fd < 0) { | 465 | if (fd < 0) { | ||
342 | if (!shownError) | 466 | return -1;/* ignore failures, as sys files disappear when battery is removed */ | ||
343 | print_error( "Cannot open file \'%s\'!\n" | | |||
344 | "Load the thermal ACPI kernel module or\n" | | |||
345 | "compile it into your kernel.\n", th_file ); | | |||
346 | shownError = 1; | | |||
347 | return -1; | | |||
348 | } | 467 | } | ||
349 | int read_bytes = read( fd, input_buf, sizeof(input_buf) - 1 ); | 468 | int read_bytes = read( fd, input_buf, sizeof(input_buf) - 1 ); | ||
350 | if ( read_bytes == sizeof(input_buf) - 1 ) { | 469 | if ( read_bytes == sizeof(input_buf) - 1 ) { | ||
351 | if (!shownError) | 470 | if (!shownError) | ||
352 | log_error( "Internal buffer too small to read \'%s\'", th_file ); | 471 | log_error( "Internal buffer too small to read \'%s\'", th_file ); | ||
353 | shownError = 1; | 472 | shownError = 1; | ||
354 | close( fd ); | 473 | close( fd ); | ||
355 | return -1; | 474 | return -1; | ||
▲ Show 20 Lines • Show All 160 Lines • Show Last 20 Lines |
These two lines are now repeated in all "registerX" functions. Maybe move this to initAcpiBattery and pass it to each function as a parameter?