summaryrefslogtreecommitdiff
path: root/lib/sysfs.c
Commit message (Collapse)AuthorAgeFilesLines
* libsensors: Add support for temp[1-*]_min_hyst and temp[1-*]_lcrit_hystkhali2014-04-221-0/+2
| | | | | | | | | Add support for sysfs attributes temp[1-*]_min_hyst (already implemented by drivers adt7x10, lm77 and lm92) and temp[1-*]_lcrit_hyst (no known users yet.) git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6244 7894878c-1315-0410-8ee3-d5d059ff63e0
* Update my e-mail address and copyright yearskhali2014-03-201-1/+1
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6243 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: Avoid insane memory allocationskhali2014-01-301-3/+4
| | | | | | | | | | | While there is no longer a hard limit to the number of sensor of a given type per chip, I feel a little uncomfortable having no limit at all on the amount of memory we may try to allocate. Add an arbitrary safety limit so that a design error or a bug in a hwmon driver can't result into an insane memory allocation. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6223 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: Adjust memory pre-allocation stepskhali2014-01-291-1/+3
| | | | | | | | | | | Make memory pre-allocation steps depend on the sensor type. Things like voltages, temperatures or fans are typically plenty, however vid and chassis intrusion are typically only a few, and there can only be one beep_enable by design. This saves a small amount of temporary memory for cheap. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6222 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: Get rid of FEATURE_SIZEkhali2014-01-291-16/+15
| | | | | | | | | max_subfeatures is computed the first time it is needed, we can do exactly the same with FEATURE_SIZE. Introduce feature_size as a static variable so that we don't have to recompute it again and again. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6221 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: Get rid of arbitrary limit on per-type sensor countkhali2014-01-291-77/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When gathering the attributes of each hwmon chip, libsensors uses a temporary structure in memory to order and group all the attributes into features. This temporary structure used to be a single array with room for every possible attribute/subfeature. While simple, this approach required to predefine a maximum number of per-type sensor that could be handled. In order to get rid of this arbitrary limit, which we hit and had to raise three times already, I changed the temporary structure to an array of dynamically allocated per-type subattribute arrays. This lets us not allocate any memory for types which aren't implemented by a given chip, and more importantly, this lets us reallocate room for more attributes of a given type as needed. I decided to allocate chunks of 8 attributes at a time, as this seemed a good compromise between two frequent reallocations and over-provisioning. It could be tweaked if needed. Icing on the cake, I benchmarked this change on two different systems and it results in performance gains. The total heap usage as reported by valgrind is down by 50% on average, with peak memory consumption (as reported by valgrind's massif) also down by 43% on average. The total instructions count (as reported by valgrind's callgrind) is down by 11% on average, with measured execution time also down by a few percents. Valgrind rocks, BTW. I have some ideas to optimize the memory allocations further, but I do not expect such a huge gain from them. They may not even improve peak memory consumption as massif shows the peak is somewhere else now at least in some cases. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6218 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: rename function sensors_compute_maxkhali2014-01-281-2/+2
| | | | | | | | The new function name, sensors_compute_max_sf, better reflects what the function is actually doing. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6217 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: Increase MAX_SENSORS_PER_TYPE to 33khali2014-01-141-1/+1
| | | | | | | | This is needed to properly support all temperatures reported by the coretemp driver on recent hardware. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6208 7894878c-1315-0410-8ee3-d5d059ff63e0
* Add support for fan[1-*]_max, fan[1-*]_min_alarm and fan[1-*]_max_alarmkhali2012-03-061-0/+3
| | | | | | | | | attributes. These are defined in the standard sysfs interface for quite some time, and at least three drivers (max6650, lm63 and applesmc) implement them so we should support them. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6029 7894878c-1315-0410-8ee3-d5d059ff63e0
* Upcoming change in sysfs will break the way libsensors detects ifkhali2012-01-311-3/+5
| | | | | | | | sysfs is mounted. Adjust the implementation so that it still works after said change. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6017 7894878c-1315-0410-8ee3-d5d059ff63e0
* Add support for additional sysfs attributes to libsensors and to sensors commandgroeck2012-01-091-0/+8
| | | | | | | | | | | | | | | | inX_average inX_lowest inX_highest tempX_lowest tempX_highest currX_average currX_lowest currX_highest git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6007 7894878c-1315-0410-8ee3-d5d059ff63e0
* Added support for SENSORS_SUBFEATURE_FAN_PULSES to libsensors.groeck2011-03-041-0/+1
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5938 7894878c-1315-0410-8ee3-d5d059ff63e0
* Added support for humidity sensors to libsensorsgroeck2011-02-131-2/+13
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5918 7894878c-1315-0410-8ee3-d5d059ff63e0
* Add support for recently added sysfs ABI attributesgroeck2011-02-091-0/+12
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5917 7894878c-1315-0410-8ee3-d5d059ff63e0
* Added support for new sysfs attributesgroeck2010-12-141-0/+9
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5898 7894878c-1315-0410-8ee3-d5d059ff63e0
* Compute MAX_*_SENSOR_TYPES at build time (#2378).khali2010-12-141-2/+2
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5897 7894878c-1315-0410-8ee3-d5d059ff63e0
* Compute MAX_SUBFEATURES at run-time (#2378).khali2010-12-141-3/+35
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5896 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: Add support for intrusion detection.khali2010-11-031-4/+12
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5879 7894878c-1315-0410-8ee3-d5d059ff63e0
* Some features are never scaled.khali2010-11-021-1/+2
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5876 7894878c-1315-0410-8ee3-d5d059ff63e0
* Work with the feature type instead of the shifted subfeature type wherekhali2010-11-021-13/+15
| | | | | | | possible. This makes the code more readable. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5875 7894878c-1315-0410-8ee3-d5d059ff63e0
* Reorganize the temporary sparse subfeature table. It's a little largerkhali2010-11-021-21/+23
| | | | | | | | | | | | | now, but this make it possible to add more feature types without increasing the code complexity beyond reason. Define constants and use them to make the code even easier to understand. If anyone is really worried about the relatively large memory allocation, one way to improve the situation would be a two-pass approach. But remember the memory is only needed for a short time... git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5874 7894878c-1315-0410-8ee3-d5d059ff63e0
* Change libsensors license from GPL to LGPL.khali2010-07-011-6/+6
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5844 7894878c-1315-0410-8ee3-d5d059ff63e0
* Map individual beep features. We had symbols for them for a long time,khali2010-06-211-0/+4
| | | | | | | I have no idea why they weren't mapped to the sysfs file names. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5843 7894878c-1315-0410-8ee3-d5d059ff63e0
* Fix a comment.khali2010-02-231-2/+2
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5827 7894878c-1315-0410-8ee3-d5d059ff63e0
* Increase MAX_SENSORS_PER_TYPE to 24. The old value of 20 isn't enoughkhali2010-02-231-1/+1
| | | | | | | at least for the W83795G, which has up to 21 voltage inputs. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5826 7894878c-1315-0410-8ee3-d5d059ff63e0
* Add support for HID devices.khali2009-10-181-1/+8
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5786 7894878c-1315-0410-8ee3-d5d059ff63e0
* Support upcoming sysfs path to i2c adapters.khali2009-07-221-0/+2
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5759 7894878c-1315-0410-8ee3-d5d059ff63e0
* If str(n)dup fails, there is no more memory left. We should exit withkhali2009-02-201-0/+8
| | | | | | | "Out of memory". Patch from Andre Prendel. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5661 7894878c-1315-0410-8ee3-d5d059ff63e0
* When looking for hwmon device attributes, skip non-file sysfs entries.khali2009-02-061-2/+5
| | | | | | | This speeds things up a little. Patch from Andre Prendel. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5636 7894878c-1315-0410-8ee3-d5d059ff63e0
* Add ACPI busjwrdegoede2009-01-131-0/+5
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5593 7894878c-1315-0410-8ee3-d5d059ff63e0
* Add support for current sensors.khali2008-10-241-1/+15
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5379 7894878c-1315-0410-8ee3-d5d059ff63e0
* Add support for instantaneous power sensors.khali2008-10-241-0/+3
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5378 7894878c-1315-0410-8ee3-d5d059ff63e0
* Subject: [PATCH 1/3 v3] libsensors: Support energy and power metersdjwong2008-04-171-13/+44
| | | | | | | | | | | Add power and sensor meters to libsensors, with minor tweaks and documentation updates as suggested by Jean Delvare. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5183 7894878c-1315-0410-8ee3-d5d059ff63e0
* Add support for virtual hwmon devices. This closes Red Hat bug #437637khali2008-04-141-10/+24
| | | | | | | and ticket #2305. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5176 7894878c-1315-0410-8ee3-d5d059ff63e0
* Subject: [PATCH 1/4] libsensors: Detect OpenFirmware hwmon devicesdjwong2008-04-101-1/+2
| | | | | | | | | | On a QS22 blade, the BMC containing the (ibmpex) power meters is enumerated via Open Firmware. Check for "of_platform" to handle this case. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5174 7894878c-1315-0410-8ee3-d5d059ff63e0
* Patch from Aurelien Jarno:khali2008-03-261-1/+2
| | | | | | | | I have just noticed that the FSF address is the old one in all files except COPYING. Please find a patch below to fix that. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5163 7894878c-1315-0410-8ee3-d5d059ff63e0
* The platform casejwrdegoede2008-03-161-7/+7
| | | | | | acts as a fallback solution so it must be last in the list. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5145 7894878c-1315-0410-8ee3-d5d059ff63e0
* Use __func__ instead of __FUNCTION__. The former is standard, the latterkhali2008-03-051-8/+7
| | | | | | | is not. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5134 7894878c-1315-0410-8ee3-d5d059ff63e0
* Add support for drivers that place the hwmon attributes in the hwmonkhali2008-01-051-11/+32
| | | | | | | | | class device directory rather than directly in the device directory. The latter is what all drivers do at the moment, but in the long run the former is preferred as it prevents attribute name collisions. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5093 7894878c-1315-0410-8ee3-d5d059ff63e0
* Get the device type from the subsystem symlink, rather thankhali2008-01-051-9/+40
| | | | | | | | | | | guessing it from how the device identifier looks like. For kernels <= 2.6.17, we use the bus symlink instead. For kernels <= 2.6.11, neither symlink exist so we fallback to the old type guessing approach. It doesn't really matter as all hwmon devices were i2c devices back then. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5092 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: minor cleanupmmh2007-12-161-9/+9
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5075 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: No longer depend on libsysfs.khali2007-12-101-134/+191
| | | | | | | | | | | | | | | | | Instead, access sysfs directly, using 3 embedded helper functions. My motivations for doing this are: * As far as I know, libsysfs is no longer maintained. * libsysfs does much more than we need. For example, when asking for a device attribute list, libsysfs will read the contents and permissions of all attributes. Not only does this waste CPU cycles per se, but in the case of hwmon driver it also triggers register reads, which can be slow for SMBus chips. * libsysfs enforces the difference between devices and class devices, while future changes will be easier if we can handle both types alike. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5067 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: Report I/O errors as such.khali2007-09-291-6/+34
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4899 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: Differentiate between different read error types.khali2007-09-291-3/+2
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4896 7894878c-1315-0410-8ee3-d5d059ff63e0
* libsensors: Notify the caller when writing a value fails.khali2007-09-291-2/+4
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4895 7894878c-1315-0410-8ee3-d5d059ff63e0
* Drop SENSORS_ERR_NO_DEVS: we return success, not error, when no devicekhali2007-09-241-4/+4
| | | | | | | is found. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4879 7894878c-1315-0410-8ee3-d5d059ff63e0
* Add support for platform devices with no ID.khali2007-09-241-2/+6
| | | | git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4878 7894878c-1315-0410-8ee3-d5d059ff63e0
* Renumber feature and subfeature types to leave more room if we laterkhali2007-09-231-4/+4
| | | | | | | need to add more feature or subfeature types. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4858 7894878c-1315-0410-8ee3-d5d059ff63e0
* Don't arbitrarily write errors to stderr. In production mode,khali2007-09-231-9/+12
| | | | | | | | | | | | | simply ignore the errors. In debug mode, call sensors_fatal_error(). As a side note, there is certainly room for improvement in the way errors are reported by libsensors. sensors_fatal_error() is fatal, and sensors_parse_error() is too specific, so we lack a more general error reporting function. printf-like formatting for error messages would also be a good idea. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4855 7894878c-1315-0410-8ee3-d5d059ff63e0
* Delete unused SENSORS_ERR_ACCESS.khali2007-09-231-10/+10
| | | | | | | | | | Rename SENSORS_ERR_PROC to the more neutral SENSORS_ERR_KERNEL. Introduce SENSORS_ERR_NO_DEVS for finer-grained error reporting. Use SENSORS_ERR_KERNEL and SENSORS_ERR_NO_DEVS where appropriate. No error message for invalid error codes. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4854 7894878c-1315-0410-8ee3-d5d059ff63e0