smatch complains as follows when checking lm63.c.
drivers/hwmon/lm63.c:594 set_temp11() warn:
'65504' 65504 can't fit into 32767 'data->temp11[nr]'
drivers/hwmon/lm63.c:596 set_temp11() warn:
'32768' 32768 can't fit into 32767 'data->temp11[nr]'
Fix by using DIV_ROUND_CLOSEST and clamp_val to convert the values.
While we are at it, modify other macros as well for consistency and
to make the code easier to understand.
Signed-off-by: Guenter Roeck <[email protected]>
We can create all sysfs groups in one call by using sysfs_create_groups
instead of using sysfs_create_group individually for each group.
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
client->dev is used multiple times in several functions.
Introduce dev variable pointing to it to simplify the code.
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
With the new hwmon API, we can only add groups of attributes, not individual
attributes. To prepare for the use of the new API, add an additional sensor
group for the temp2_type attribute and register it with sysfs_create_group
instead of device_create_file.
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
time_after (as opposed to time_after_equal) already ensures that the
cache lifetime is at least as much as requested. There is no point in
manually adding another jiffy to that value, and this can confuse the
reader into wrong interpretation.
Signed-off-by: Jean Delvare <[email protected]>
Cc: Imre Deak <[email protected]>
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 <[email protected]>
Acked-by: George Joseph <[email protected]>
Acked-by: Jean Delvare <[email protected]>
Convert to use devm_ functions to reduce code size and simplify the code.
Signed-off-by: Guenter Roeck <[email protected]>
Acked-by: Jean Delvare <[email protected]>
Make the automatic fan speed control lookup table writable. This lets
the user tweak the fan speed / temperature response curve.
Signed-off-by: Jean Delvare <[email protected]>
Acked-by: Guenter Roeck <[email protected]>
Tested-by: Guenter Roeck <[email protected]>
Let the user switch between automatic and manual fan speed control.
Before switching to automatic fan speed control, we always check that
the lookup table looks sane.
Signed-off-by: Jean Delvare <[email protected]>
Acked-by: Guenter Roeck <[email protected]>
Reorder functions and driver declaration to no longer need to
forward-declare functions. Also rename new_client to just client
everywhere for readability.
Signed-off-by: Jean Delvare <[email protected]>
Acked-by: Guenter Roeck <[email protected]>
The LM96163 has an extended lookup table with 12 entries instead of 8,
add support for that.
Signed-off-by: Jean Delvare <[email protected]>
Tested-by: Guenter Roeck <[email protected]>
Acked-by: Guenter Roeck <[email protected]>
The LM63 and compatible devices have a lookup table to control the fan
speed automatically. Expose it in sysfs. Values are cached for 5
seconds, independently of the other register values to avoid slowing
down "sensors". We might make the table values writable in the future.
Signed-off-by: Jean Delvare <[email protected]>
Tested-by: Guenter Roeck <[email protected]>
Acked-by: Guenter Roeck <[email protected]>
On the LM64, the tachometer function has a dedicated pin and fan speed
monitoring is always enabled.
Signed-off-by: Jean Delvare <[email protected]>
Acked-by: Guenter Roeck <[email protected]>
On LM96163, the external temperature sensor type is configurable to
either a thermal diode or a 3904 transistor. The chip reports a wrong
temperature if misconfigured. Add writable attribute to support it.
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
The update interval is configurable on LM63 and compatibles. Add
support for it.
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
On LM64, the external critical temperature limit is always writable. On LM96163,
it is writable if the chip is configured for it. Add conditional support for
writing the register dependent on chip type and configuration.
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
LM96163 supports unsigned upper limits for the external temperature sensor.
Add support for it.
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
LM96163 is an enhanced version of LM63 with improved PWM resolution. Add chip
detection code as well as support for improved PWM resolution if the chip is
configured to use it.
Signed-off-by: Guenter Roeck <[email protected]>
Tested-by: Thierry Reding <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
LM63 and compatibles support a temperature offset register for the external
temperature sensor. Add support for it.
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
LM64 has 16 degrees Celsius temperature offset on all
remote sensor registers.
This was not considered When LM64 support was added to lm63.c.
Signed-off-by: Dirk Eibach <[email protected]>
Signed-off-by: Guenter Roeck <[email protected]>
Cc: [email protected]
The LM64 appears to be an LM63 with added GPIO lines. Add support for the
hwmon functionality - GPIO can be added at some later stage if someone
has a need for them.
Signed-off-by: Matthew Garrett <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
This macro simply declares an enum, so drivers might as well declare
it themselves.
Signed-off-by: Jean Delvare <[email protected]>
Tested-by: Wolfram Sang <[email protected]>
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 <[email protected]>
Tested-by: Wolfram Sang <[email protected]>
The "kind" parameter always has value -1, and nobody is using it any
longer, so we can remove it.
Signed-off-by: Jean Delvare <[email protected]>
Tested-by: Wolfram Sang <[email protected]>
The new-style lm63 driver implements the optional detect() callback
to cover the use cases of the legacy driver.
Signed-off-by: Jean Delvare <[email protected]>
We have the following naming convention documented in
Documentation/hwmon/sysfs-interface for fault files:
in[0-*]_input_fault
fan[1-*]_input_fault
temp[1-*]_input_fault
Some drivers follow this convention (lm63, lm83, lm90, smsc47m192).
However some drivers omit the "input" part and create files named
fan1_fault (pc87427) or temp1_fault (dme1737). And the new "generic"
libsensors follows this second (non-standard) convention, so it fails
to report fault conditions for drivers which follow the standard.
We want a single naming scheme, and everyone seems to prefer the
shorter variant, so let's go for it.
Signed-off-by: Jean Delvare <[email protected]>
hwmon: Fix unchecked return status, batch 4
Fix up some hwmon drivers so that they no longer ignore return status
from device_create_file().
Note: f71805f actually checked the status from device_create_file
already. However it did not remove the files on device destruction.
It was also an opportunity to use sysfs_create/remove_group instead
of hand-made loops. This makes the changes much more important but
I think the result is worth it.
Signed-off-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
hwmon: Add individual alarm files to 4 drivers
Add individual sysfs files for all f71805f, lm63, lm83 and lm90 alarm
and fault conditions. This is a requirement for the planned
chip-independent libsensors. Almost all other hwmon drivers will need
the same improvement.
Signed-off-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
convert drivers/hwmon/*.c semaphore use to mutexes.
the conversion was generated via scripts, and the result was validated
automatically via a script as well.
all affected hwmon drivers were build-tested.
Signed-off-by: Ingo Molnar <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Now that i2c_add_driver() doesn't need the module owner to be set by
hand, we can delete it from the drivers. This patch catches all of the
drivers that I found in the current tree (if a driver sets the .owner by
hand, it's not a problem, just not needed.)
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Cc: Jean Delvare <[email protected]>
We should use the i2c_driver.driver's .name and .owner fields
instead of the i2c_driver's ones.
This patch updates the hwmon drivers.
Signed-off-by: Laurent Riffard <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Just about every i2c chip driver sets the I2C_DF_NOTIFY flag, so we
can simply make it the default and drop the flag. If any driver really
doesn't want to be notified when i2c adapters are added, that driver
can simply omit to set .attach_adapter. This approach is also more
robust as it prevents accidental NULL pointer dereferences.
Signed-off-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Use kzalloc instead of kmalloc+memset in all hardware monitoring
drivers.
Signed-off-by: Deepak Saxena <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
The only thing left in i2c-sensor.h are module parameter definition
macros. It's only an extension of what i2c.h offers, and this extension
is not sensors-specific. As a matter of fact, a few non-sensors drivers
use them. So we better merge them in i2c.h, and get rid of i2c-sensor.h
altogether.
Signed-off-by: Jean Delvare <khali@linux-fr>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
i2c_probe and i2c_detect now do the exact same thing and operate on
the same data structure, so we can have everyone call i2c_probe.
Signed-off-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
We could refactor the error message 34 different i2c drivers print if
i2c_detach_client() fails in this function itself. Saves quite a few
lines of code. Documentation is updated to reflect that change.
Note that this patch should be applied after Rudolf Marek's w83792d
patches.
Signed-off-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Kill normal_isa in header files, documentation and all chip drivers, as
it is no more used.
normal_i2c could be renamed to normal, but I decided not to do so at the
moment, so as to limit the number of changes. This might be done later
as part of the i2c_probe/i2c_detect merge.
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This patch modifies sensors chip drivers to make use of the new
sysfs class "hwmon".
Signed-off-by: Mark M. Hoffman <[email protected]>
Signed-off-by: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Part 2: Move the driver files themselves.
Note that the patch "adds trailing whitespace", because it does move the
files as-is, and some files happen to have trailing whitespace.
From: Jean Delvare <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>