aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm85.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-05-24treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61Thomas Gleixner1-14/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 675 mass ave cambridge ma 02139 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 441 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc) Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190520071858.739733335@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-15hwmon: (lm85) Use permission specific SENSOR[_DEVICE]_ATTR variantsGuenter Roeck1-166/+174
Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readbility, and to reduce the chance of inconsistencies. Also replace any remaining S_<PERMS> in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-04-15hwmon: (lm85) Fix build warningGuenter Roeck1-1/+1
The following build warning is seen if CONFIG_OF is disabled. drivers/hwmon/lm85.c:1645:34: warning: ‘lm85_of_match’ defined but not used Mark lm85_of_match as __maybe_unused to ix the problem. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-02-18hwmon: (lm85) add support for LM96000 high frequenciesJeremy Gebben1-0/+9
The LM96000 expands the freqency field from 3 to 4 bits, to add more frequencies in the 22.5 to 30 kHz ranges. Signed-off-by: Jeremy Gebben <jgebben@sweptlaser.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-02-18hwmon: (lm85) support the LM96000Jeremy Gebben1-2/+7
It has been supported as a generic lm85 for quite some time. Signed-off-by: Jeremy Gebben <jgebben@sweptlaser.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-02-18hwmon: (lm85) remove freq_map size hardcodesJeremy Gebben1-10/+15
Allow support for chips that support more than 8 frequencies. Signed-off-by: Jeremy Gebben <jgebben@sweptlaser.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-04-02hwmon: (lm85) Add OF device ID tableJavier Martinez Canillas1-1/+55
The driver doesn't have a struct of_device_id table but supported devices are registered via Device Trees. This is working on the assumption that a I2C device registered via OF will always match a legacy I2C device ID and that the MODALIAS reported will always be of the form i2c:<device>. But this could change in the future so the correct approach is to have an OF device ID table if the devices are registered via OF. Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-01-02hwmon: (lm85) use permission-specific DEVICE_ATTR variantsJulia Lawall1-11/+11
Use DEVICE_ATTR_RO for read only attributes and DEVICE_ATTR_RW for read/write attributes. This simplifies the source code, improves readbility, and reduces the chance of inconsistencies. The conversion was done automatically using coccinelle. It was validated by compiling both the old and the new source code and comparing its text, data, and bss size. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> [groeck: Update description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-12-12hwmon: (lm85) Fix overflows seen when writing voltage limit attributesGuenter Roeck1-1/+2
Writes into voltage limit attributes can overflow due to an unbound multiplication. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-04-17hwmon: (lm85) use find_closest() in x_TO_REG() functionsBartosz Golaszewski1-18/+8
Replace RANGE_TO_REG() and FREQ_TO_REG() implementations with calls to find_closest(). Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Cc: Guenter Roeck <linux@roeck-us.net> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-08-04hwmon: (lm85) Convert to devm_hwmon_device_register_with_groupsAxel Lin1-93/+51
Use devm_hwmon_device_register_with_groups() to simplify the code a bit. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-08-04hwmon: (lm85) Avoid forward declarationAxel Lin1-263/+250
Reorder functions to avoid forward declaration. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-07-30hwmon: (lm85) Fix various errors on attribute writesGuenter Roeck1-3/+6
Temperature limit register writes did not account for negative numbers. As a result, writing -127000 resulted in -126000 written into the temperature limit register. This problem affected temp[1-3]_min, temp[1-3]_max, temp[1-3]_auto_temp_crit, and temp[1-3]_auto_temp_min. When writing pwm[1-3]_freq, a long variable was auto-converted into an int without range check. Wiring values larger than MAXINT resulted in unexpected register values. When writing temp[1-3]_auto_temp_max, an unsigned long variable was auto-converted into an int without range check. Writing values larger than MAXINT resulted in unexpected register values. vrm is an u8, so the written value needs to be limited to [0, 255]. Cc: Axel Lin <axel.lin@ingics.com> Cc: stable@vger.kernel.org Reviewed-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-06-12hwmon: (lm85) Drop generic detectionJean Delvare1-23/+10
Generic detection leads to too many false positives, so drop it. FWIW sensors-detect does not have such generic detection. If the user wants to force the driver to bind to a not yet supported chip, he/she can still do so using sysfs attribute new_device. Signed-off-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-01-29Update Jean Delvare's e-mail addressJean Delvare1-1/+1
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2013-04-07hwmon: Fix checkpatch warning 'quoted string split across lines'Guenter Roeck1-2/+2
Cc: Corentin Labbe <corentin.labbe@geomatys.fr> Cc: Mark M. Hoffman <mhoffman@lightlink.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Juerg Haefliger <juergh@gmail.com> Cc: Andreas Herrmann <herrmann.der.user@googlemail.com> Cc: Rudolf Marek <r.marek@assembler.cz> Cc: Jim Cromie <jim.cromie@gmail.com> Cc: Roger Lucas <vt8231@hiddenengine.co.uk> Cc: Marc Hulsman <m.hulsman@tudelft.nl> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2013-01-25hwmon: Replace SENSORS_LIMIT with clamp_valGuenter Roeck1-5/+5
SENSORS_LIMIT and the generic clamp_val have the same functionality, and clamp_val is more efficient. This patch reduces text size by 9052 bytes and bss size by 11624 bytes for x86_64 builds. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: George Joseph <george.joseph@fairview5.com> Acked-by: Jean Delvare <khali@linux-fr.org>
2012-07-21hwmon: (lm85) Convert to use devm_ functionsGuenter Roeck1-5/+2
Convert to use devm_ functions to reduce code size and simplify the code. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Jean Delvare <khali@linux-fr.org>
2012-03-18hwmon: (lm85) Fix checkpatch issuesGuenter Roeck1-130/+230
Fixed: ERROR: code indent should use tabs where possible ERROR: do not use assignment in if condition WARNING: simple_strtol is obsolete, use kstrtol instead WARNING: simple_strtoul is obsolete, use kstrtoul instead Modify multi-line comments to follow Documentation/CodingStyle. Also: s/#define^I/#define / Not fixed (false positive): ERROR: Macros with multiple statements should be enclosed in a do - while loop Cc: Jean Delvare <khali@linux-fr.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2012-03-18hwmon: convert drivers/hwmon/* to use module_i2c_driver()Axel Lin1-13/+1
This patch converts the drivers in drivers/hwmon/* to use the module_i2c_driver() macro which makes the code smaller and a bit simpler. Signed-off-by: Axel Lin <axel.lin@gmail.com> Cc: Corentin Labbe <corentin.labbe@geomatys.fr> Cc: Dirk Eibach <eibach@gdsys.de> Cc: "Mark M. Hoffman" <mhoffman@lightlink.com> Cc: Steve Glendinning <steve.glendinning@smsc.com> Cc: Riku Voipio <riku.voipio@iki.fi> Cc: Guillaume Ligneul <guillaume.ligneul@gmail.com> Cc: David George <david.george@ska.ac.za> Cc: "Hans J. Koch" <hjk@hansjkoch.de> Cc: Marc Hulsman <m.hulsman@tudelft.nl> Cc: Rudolf Marek <r.marek@assembler.cz> Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
2011-04-29hwmon: (lm85) Fix error paths in probe functionJean Delvare1-2/+2
We must remove all files we created, even in error cases. Fixes second part of kernel bug #34072: https://bugzilla.kernel.org/show_bug.cgi?id=34072 Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
2011-04-29hwmon: (lm85) Add missing list terminatorsJean Delvare1-0/+2
Fixes kernel bug #34072: https://bugzilla.kernel.org/show_bug.cgi?id=34072 Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
2011-03-31Fix common misspellingsLucas De Marchi1-1/+1
Fixes generated by 'codespell' and manually reviewed. Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
2011-03-14hwmon: (lm85) Add support for EMC6D103SGuenter Roeck1-24/+51
EMC6D103S is similar to EMC6D103, only it does not support registers 62[5:7], 6D[0:7], and 6E[0:7]. Register respective sysfs attributes and update affected registers for all other chips only. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
2011-03-14hwmon: (lm85) Do not update hysteresis and temp_auto_off if auto_temp_min is changedGuenter Roeck1-17/+0
So far, the driver updates temp_auto_hyst and temp_auto_off if temp_auto_min changes. This may cause problems if temp_auto_off was not configured before configuring temp_auto_min, because one of the variables used (off_desired) is not initialized in this case. To simplify the code, and for consistency with other drivers, no longer update the delta between "min" and "off" until the user sets the "off" value again. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
2011-03-14hwmon: (lm85) Use function to remove sysfs attribute filesGuenter Roeck1-8/+11
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
2011-03-14hwmon: (lm85) Use boolean to determine if VID5 is configuredGuenter Roeck1-12/+13
ADT7463 and ADT7468 optionally support VID5 instead of the standard +12V measurement input. Use a boolean to identify the chip configuration instead of hardcoding it several times. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
2011-02-18hwmon: (lm85) extend to support EMC6D103 chipsJan Beulich1-2/+21
The interface is identical EMC6D102, so all that needs to be added are some definitions and their uses. Registers apparently missing in EMC6D103S/EMC6D103:A2 compared to EMC6D103:A0, EMC6D103:A1, and EMC6D102 (according to the data sheets), but used unconditionally in the driver: 62[5:7], 6D[0:7], and 6E[0:7]. For that reason, EMC6D103S chips don't get enabled for the time being. Signed-off-by: Jan Beulich <jbeulich@novell.com> (Guenter Roeck: Replaced EMC6D103_A2 with EMC6D103S per EMC6D103S datasheet) Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Cc: stable@kernel.org
2010-10-28hwmon: (lm85) Add support for ADT7468 high-frequency PWM modeJean Delvare1-7/+28
The ADT7468 supports a high-frequency PWM output mode where all PWM outputs are driven by a 22.5 kHz clock. Add support for this mode, and document it, as it may surprise the user that setting one PWM output frequency also affects the other PWM outputs. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Darrick J. Wong <djwong@us.ibm.com> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
2010-10-28hwmon: (lm85) Fix ADT7468 frequency tableJean Delvare1-0/+1
The ADT7468 uses the same frequency table as the ADT7463. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: stable@kernel.org Cc: Darrick J. Wong <djwong@us.ibm.com> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
2009-12-14i2c: Drop I2C_CLIENT_INSMOD_2 to 8Jean Delvare1-3/+5
These macros simply declare an enum, so drivers might as well declare it themselves. This puts an end to the arbitrary limit of 8 chip types per i2c driver. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Wolfram Sang <w.sang@pengutronix.de>
2009-12-14i2c: Get rid of struct i2c_client_address_dataJean Delvare1-1/+1
Struct i2c_client_address_data only contains one field at this point, which makes its usefulness questionable. Get rid of it and pass simple address lists around instead. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Wolfram Sang <w.sang@pengutronix.de>
2009-12-14i2c: Drop the kind parameter from detect callbacksJean Delvare1-4/+2
The "kind" parameter always has value -1, and nobody is using it any longer, so we can remove it. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Wolfram Sang <w.sang@pengutronix.de>
2009-12-09hwmon: (lm85) Clean up detect functionJean Delvare1-92/+65
As kind is now hard-coded to -1, there is room for code clean-ups. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-09-15hwmon: (lm85) Don't bind to Winbond/Nuvoton WPCD377IJean Delvare1-0/+32
The Winbond/Nuvoton WPCD377I is the reduced version of a Super-I/O which emulates the National Semiconductor LM96000 hardware monitoring chips, but without the hardware monitoring part. Instead of plain disabling the emulation, the vendor left the emulated chip visible, but all monitored values are always zero. This is rather confusing for the users. So detect this case and refuse to bind to such fake chips. This fixes lm-sensors ticket #2182: http://www.lm-sensors.org/ticket/2182 Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-03-10lm85: add VRM10 support for adt7468 chipDarrick J. Wong1-1/+2
The adt7468 chip supports VRM10 sensors just like the adt7463; add a missing check for it. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Cc: Jean Delvare <khali@linux-fr.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-03-10lm85: fix the version check that broke adt7468 probingDarrick J. Wong1-1/+4
The verstep check in the lm85 driver fails because the upper nibble of the version register is 0x7, not 0x6, on the adt7468 chip. Probing of all adt7468s was broken by 69fc1feba2d5856ff74dedb6ae9d8c490210825c ("hwmon: (lm85) Rework the device detection"), and this patch fixes that. Also add in a missing i2c_device_id that accidentally got dropped from the original patch. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Cc: Jean Delvare <khali@linux-fr.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-11-12lm85: support adt7468 chipsDarrick J. Wong1-6/+46
The adt7468 is a follow-on to the adt7463, so plumb in adt7468 support along the same code paths. Signed-off-by: Darrick J. Wong <djwong@us.ibm.com> Cc: Jean Delvare <khali@linux-fr.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-10-17hwmon: (lm85) Better label namesJean Delvare1-6/+6
Label names ERROR1 and ERROR3 aren't exactly explicit. Change them for better names that indicate what we are up to. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Herbert Poetzl <herbert@13thfloor.at>
2008-10-17hwmon: (lm85) Simplify RANGE_TO_REGJean Delvare1-11/+4
Function RANGE_TO_REG can easily be simplified. Credits go to Herbert Poetzl for indirectly suggesting this to me. I tested that the new implementation returns the same result as the original implementation for all input values. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Herbert Poetzl <herbert@13thfloor.at>
2008-10-17hwmon: (lm85) Convert to a new-style i2c driverJean Delvare1-57/+64
The new-style lm85 driver implements the optional detect() callback to cover the use cases of the legacy driver. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Herbert Poetzl <herbert@13thfloor.at>
2008-10-17hwmon: (lm85) Support different PWM frequency tablesJean Delvare1-6/+23
The Analog Devices and SMSC devices supported by the lm85 driver do not have the same PWM frequency table as the National Semiconductor devices. Add support for per-device frequency tables. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Herbert Poetzl <herbert@13thfloor.at>
2008-10-17hwmon: (lm85) Select the closest PWM frequencyJean Delvare1-3/+2
The LM85 and compatible chips only support 8 arbitrary PWM frequencies. The algorithm to pick one of them based on the user input is not optimum. Improve it to always pick the closest supported frequency. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Herbert Poetzl <herbert@13thfloor.at>
2008-10-17hwmon: (lm85) Implement the standard PWM frequency interfaceJean Delvare1-39/+38
Implement the standard PWM frequency interface: pwm[1-*]_freq in units of 1 Hz, instead of the non-standard pwm[1-*]_auto_pwm_freq in units of 0.1 Hz. The old naming was not only non-standard, it was also confusing, because it suggested that the frequency value only applied in automatic fan speed mode, which isn't true. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Herbert Poetzl <herbert@13thfloor.at>
2008-10-17hwmon: (lm85) Rework the device detectionJean Delvare1-73/+50
Rework the device detection to make it clearer and faster in the general case (when a known device is found.) Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Herbert Poetzl <herbert@13thfloor.at>
2008-07-31hwmon: (lm85) Simplify device initialization functionJean Delvare1-43/+18
Clean up and simplify the device initialization function: * Degrade error messages to warnings - what they really are. * Stop warning about VxI mode, we don't really care. * Drop comment about lack of limit initialization - that's the standard way, all hardware monitoring drivers do that. * Only read the configuration register once. * Only write back to the configuration register if needed. * Don't attempt to clear the lock bit, it locks itself to 1. * Move the function to before it's called, so that we no longer need to forware declare it. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
2008-07-31hwmon: (lm85) Misc cleanupsJean Delvare1-84/+67
Misc cleanups to the lm85 hardware monitoring driver: * Mark constant arrays as const. * Remove useless masks. * Have lm85_write_value return void - nobody is checking the returned value anyway and in some cases it was plain wrong. * Remove useless initializations. * Rename new_client to client in lm85_detect. * Replace cascaded if/else with a switch/case in lm85_detect. * Group similar loops in lm85_update_device. * Remove legacy comments. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Juerg Haefliger <juergh at gmail.com> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
2008-07-31hwmon: (lm85) Don't write back cached valuesJean Delvare1-9/+6
In set_pwm_auto_pwm_minctl, we write cached register bits back to the chip. This is a bad idea as we have no guarantee that the cache is up-to-date. Better read a fresh register value from the chip, it's safer and in fact it is also more simple. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Juerg Haefliger <juergh at gmail.com> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
2008-07-31hwmon: (lm85) Drop dead codeJean Delvare1-80/+2
Drop a lot of useless register defines, conversion macros, data structure members and update code. All these register values were read from the device but nothing is done out of them, so this is all dead code in practice. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Juerg Haefliger <juergh at gmail.com> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
2008-07-31hwmon: (lm85) Coding-style cleanupsJean Delvare1-250/+255
Fix most style issues reported by checkpatch, including: * Trailing, missing and extra whitespace * Extra parentheses, curly braces and semi-colons * Broken indentation * Lines too long I verified that the generated code is the same before and after these changes. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Juerg Haefliger <juergh at gmail.com> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>