summaryrefslogtreecommitdiff
path: root/drivers/hwmon/max6650.c
AgeCommit message (Collapse)Author
2019-06-23hwmon: (max6650) Fix unused variable warningArnd Bergmann
The newly added variable is only used in an #if block: drivers/hwmon/max6650.c: In function 'max6650_probe': drivers/hwmon/max6650.c:766:33: error: unused variable 'cooling_dev' [-Werror=unused-variable] Change the #if to if() so the compiler can see what is actually going on. Fixes: a8463754a5a9 ("hwmon: (max6650) Use devm function to register thermal device") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (max6650) Fix minor formatting issuesGuenter Roeck
CHECK: struct mutex definition without comment CHECK: Alignment should match open parenthesis Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (max6650) Improve error handling in max6650_update_deviceGuenter Roeck
Pass errors from i2c_smbus_read_byte_data() back to the caller of max6650_update_device(). Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (max6650) Read non-volatile registers only onceGuenter Roeck
Only tachometer and alarm status registers are modified by the chip. All other registers only need to be read only once, and reading them repeatedly does not add any value. Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (max6650) Convert to use devm_hwmon_device_register_with_infoGuenter Roeck
Convert driver to use devm_hwmon_device_register_with_info to simplify the code and to reduce its size. Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (max6650) Simplify alarm handlingGuenter Roeck
Instead of re-reading the alarm register after reporting an alarm, mark cached values as invalid. While this results in always reading all data on subsequent reads, it is quite unlikely that such reads will actually happen before the cache times out. The upside is avoiding unnecessary unconditional i2c read operations. Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (max6650) Cache alarm_en registerGuenter Roeck
The alarm_en register is read each time the is_visible function is called. Since it is a configuration register, this is completely unnecessary. Read it once and cache its value. Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (max6650) Declare valid as booleanGuenter Roeck
Declare valid as boolean to match its use case. Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (max6650) Improve error handling in max6650_init_clientGuenter Roeck
Do not overwrite errors reported from i2c functions, and don't ignore any errors. Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (max6650) Introduce pwm_to_dac and dac_to_pwmGuenter Roeck
Consolidate conversion from pwm value to dac value and from dac value to pwm value into helper functions. While doing this, only update the cached dac value if writing it to the chip was successful after an update. Also, put macro argument of DIV_FROM_REG() into (), and simplify return statement of max6650_set_cur_state(). Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-06-23hwmon: (max6650) Use devm function to register thermal deviceGuenter Roeck
Use devm_thermal_of_cooling_device_register to register the thermal cooling device. This lets us drop the remove function. At the same time, use 'dev' variable in probe function consistently. Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-05-24treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 61Thomas Gleixner
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-23hwmon: (max6650) Drop call to thermal_cdev_updateGuenter Roeck
The call to thermal_cdev_update() causes any fan connected to the chip to stop immediately. If the thermal subsystem is not set up to actually handle the chip as cooling device, the remains stopped until is is restarted manually with a write to a sysfs attribute. There is evidence that thermal_cdev_update() should only be called from thermal governors, not from thermal cooling device drivers. Drop the call. Cc: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Tested-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-04-20hwmon: (max6650) add thermal cooling device capabilityJean-Francois Dagenais
This allows max6650 devices to be referenced in dts as a cooling device. The pwm value seems duplicated in cooling_dev_state but since pwm goes through rounding logic into data->dac, it is modified and messes with the thermal zone state algorithms. It's also better to serve a cache value, thus avoiding periodic actual i2c traffic. Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-04-15hwmon: (max6650) Fix build warningGuenter Roeck
If CONFIG_OF is not enabled, the following build warning is observed. drivers/hwmon/max6650.c:137:34: warning: ‘max6650_dt_match’ defined but not used Mark max6650_dt_match as __maybe_unused to fix the problem. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-02-18hwmon: (max6650) Use permission specific SENSOR[_DEVICE]_ATTR variantsGuenter Roeck
Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readability, 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/hwmon/. 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>
2018-12-16hwmon: (max6650) Auto-convert to use SENSOR_DEVICE_ATTR_{RO, RW, WO}Guenter Roeck
Conversion was done done using the coccinelle script at https://github.com/groeck/coccinelle-patches/raw/master/hwmon/sensor-devattr-w6.cocci Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-01-02hwmon: (max6650) use permission-specific DEVICE_ATTR variantsJulia Lawall
Use 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: Updated description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (max6650) Allow fan shutdown and initial rpm targetMike Looijmans
The fan can be stopped by writing "3" to pwm1_enable in sysfs. Add devicetree property for early initialization of the fan controller to prevent overheating, for example when resetting the board while the fan was completely turned off. Also improve error reporting, I2C failures were ignored while writing new values. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-09-08hwmon: (max6650) Add devicetree supportMike Looijmans
Parse devicetree parameters for voltage and prescaler setting. This allows using multiple max6550 devices with varying settings, and also makes it possible to instantiate and configure the device using devicetree. Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-03-03hwmon: (max6650) Introduce local 'dev' variableGuenter Roeck
This makes the code a bit easier to read. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-03-03hwmon: (max6650) Drop error message after memory allocation failuresGuenter Roeck
The core code already generates an error message. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-03-03hwmon: (max6650) Convert to use devm_hwmon_device_register_with_groupsGuenter Roeck
Simplify code, reduce code size, and attach sensor attributes to hwmon device. Reviewed-by: Jean Delvare <jdelvare@suse.de> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-03-03hwmon: (max6650) Rearrange code to no longer require forward declarationsGuenter Roeck
Cleanup only; no functional change. Reviewed-by: Jean Delvare <jdelvare@suse.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2013-10-18hwmon: Correct some typosLABBE Corentin
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2013-01-25hwmon: Replace SENSORS_LIMIT with clamp_valGuenter Roeck
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: (max6650) Convert to use devm_ functionsGuenter Roeck
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Hans J. Koch <hjk@hansjkoch.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Hans J. Koch <hjk@hansjkoch.de>
2012-03-18hwmon: convert drivers/hwmon/* to use module_i2c_driver()Axel Lin
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>
2012-03-18hwmon: (max6650) Fix multi-line commentsGuenter Roeck
Cc: Hans J. Koch <hjk@hansjkoch.de> Acked-by: Hans J. Koch <hjk@hansjkoch.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2012-03-18hwmon: (max6650) Fix checkpatch issuesGuenter Roeck
Fixed: ERROR: do not use assignment in if condition ERROR: open brace '{' following struct go on the same line ERROR: spaces required around that '||' (ctx:VxV) ERROR: switch and case should be at the same indent WARNING: simple_strtoul is obsolete, use kstrtoul instead Cc: Hans J. Koch <hjk@hansjkoch.de> Acked-by: Hans J. Koch <hjk@hansjkoch.de> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2012-01-03switch ->is_visible() to returning umode_tAl Viro
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2011-05-25hwmon: (max6650) Properly support the MAX6650Jean Delvare
The MAX6650 has only one fan input. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: "Hans J. Koch" <hjk@hansjkoch.de> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
2011-05-25hwmon: (max6650) Drop device detectionJean Delvare
MAX6650 device detection is unreliable, we got reports of false positives. We now have many ways to let users instantiate the devices explicitly, so unreliable detection should be dropped. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: "Hans J. Koch" <hjk@hansjkoch.de> Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
2010-11-15hwmon: Change mail address of Hans J. KochHans J. Koch
My old mail address doesn't exist anymore. This changes all occurrences to my new address. Signed-off-by: Hans J. Koch <hjk@hansjkoch.de> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-12-14i2c: Drop I2C_CLIENT_INSMOD_1Jean Delvare
This macro simply declares an enum, so drivers might as well declare it themselves. 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 Delvare
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 Delvare
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: Clean up detect functionsJean Delvare
As kind is now hard-coded to -1, there is room for code clean-ups. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Corentin Labbe <corentin.labbe@geomatys.fr> Cc: "Mark M. Hoffman" <mhoffman@lightlink.com> Cc: Juerg Haefliger <juergh@gmail.com> Cc: Riku Voipio <riku.voipio@iki.fi> Acked-by: "Hans J. Koch" <hjk@linutronix.de> Cc: Rudolf Marek <r.marek@assembler.cz>
2009-07-11hwmon: (max6650) Fix lock imbalanceJiri Slaby
Add omitted update_lock to one switch/case in set_div. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Acked-by: Hans J. Koch <hjk@linutronix.de> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-06-15hwmon: (max6650) Add support for alarmsChristian Engelmayer
Export the alarm flags provided by the MAX6650/MAX6651 fan-speed regulator and monitor chips via sysfs. Signed-off-by: Christian Engelmayer <christian.engelmayer@frequentis.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-07-16hwmon: (max6650) Convert to a new-style i2c driverJean Delvare
The new-style max6650 driver implements the optional detect() callback to cover the use cases of the legacy driver. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Hans J. Koch <hjk@linutronix.de>
2008-02-18hwmon: normal_i2c arrays should be constMark M. Hoffman
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
2007-10-09hwmon: Convert from class_device to deviceTony Jones
Convert from class_device to device for hwmon_device_register/unregister Signed-off-by: Tony Jones <tonyj@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
2007-05-08hwmon: New max6650 driverHans-Juergen Koch
This driver supports the Maxim MAX6650 and MAX6651 fan speed monitoring and control chips. Signed-off-by: Hans J. Koch <hjk@linutronix.de> Signed-off-by: Jean Delvare <khali@linux-fr.org>