提交 31f67652 编写于 作者: L Linus Torvalds

Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging

Pull hwmon changes for v3.4 from Guenter Roeck:
 "Mostly cleanup.  No new drivers this time around, but support for
  several chips added to existing drivers: TPS40400, TPS40422, MTD040,
  MAX34446, ZL9101M, ZL9117M, and LM96080.  Also, added watchdog support
  for SCH56xx, and additional attributes for a couple of drivers."

* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (137 commits)
  hwmon: (sch56xx) Add support for the integrated watchdog (v2)
  hwmon: (w83627ehf) Add support for temperature offset registers
  hwmon: (jc42) Remove unnecessary device IDs
  hwmon: (zl6100) Add support for ZL9101M and ZL9117M
  hwmon: (adm1275) Add support for ADM1075
  hwmon: (max34440) Add support for MAX34446
  hwmon: (pmbus) Add more virtual registers
  hwmon: (pmbus) Add support for Lineage Power MDT040
  hwmon: (pmbus) Add support for TI TPS40400 and TPS40422
  hwmon: (max34440) Add support for 'lowest' output voltage attribute
  hwmon: (jc42) Convert to use devm_kzalloc
  hwmon: (max16065) Convert to use devm_kzalloc
  hwmon: (smm665) Convert to use devm_kzalloc
  hwmon: (ltc4261) Convert to use devm_kzalloc
  hwmon: (pmbus) Simplify remove functions
  hwmon: (pmbus) Convert pmbus drivers to use devm_kzalloc
  hwmon: (lineage-pem) Convert to use devm_kzalloc
  hwmon: (hwmon-vid) Fix checkpatch issues
  hwmon: (hwmon-vid) Add new entries to VRM model table
  hwmon: (lm80) Add detection of NatSemi/TI LM96080
  ...
......@@ -2,6 +2,10 @@ Kernel driver adm1275
=====================
Supported chips:
* Analog Devices ADM1075
Prefix: 'adm1075'
Addresses scanned: -
Datasheet: www.analog.com/static/imported-files/data_sheets/ADM1075.pdf
* Analog Devices ADM1275
Prefix: 'adm1275'
Addresses scanned: -
......@@ -17,13 +21,13 @@ Author: Guenter Roeck <guenter.roeck@ericsson.com>
Description
-----------
This driver supports hardware montoring for Analog Devices ADM1275 and ADM1276
Hot-Swap Controller and Digital Power Monitor.
This driver supports hardware montoring for Analog Devices ADM1075, ADM1275,
and ADM1276 Hot-Swap Controller and Digital Power Monitor.
ADM1275 and ADM1276 are hot-swap controllers that allow a circuit board to be
removed from or inserted into a live backplane. They also feature current and
voltage readback via an integrated 12-bit analog-to-digital converter (ADC),
accessed using a PMBus interface.
ADM1075, ADM1275, and ADM1276 are hot-swap controllers that allow a circuit
board to be removed from or inserted into a live backplane. They also feature
current and voltage readback via an integrated 12-bit analog-to-digital
converter (ADC), accessed using a PMBus interface.
The driver is a client driver to the core PMBus driver. Please see
Documentation/hwmon/pmbus for details on PMBus client drivers.
......@@ -36,6 +40,10 @@ This driver does not auto-detect devices. You will have to instantiate the
devices explicitly. Please see Documentation/i2c/instantiating-devices for
details.
The ADM1075, unlike many other PMBus devices, does not support internal voltage
or current scaling. Reported voltages, currents, and power are raw measurements,
and will typically have to be scaled.
Platform data support
---------------------
......@@ -51,7 +59,8 @@ The following attributes are supported. Limits are read-write, history reset
attributes are write-only, all other attributes are read-only.
in1_label "vin1" or "vout1" depending on chip variant and
configuration.
configuration. On ADM1075, vout1 reports the voltage on
the VAUX pin.
in1_input Measured voltage.
in1_min Minimum Voltage.
in1_max Maximum voltage.
......@@ -74,3 +83,10 @@ curr1_crit Critical maximum current. Depending on the chip
curr1_crit_alarm Critical current high alarm.
curr1_highest Historical maximum current.
curr1_reset_history Write any value to reset history.
power1_label "pin1"
power1_input Input power.
power1_reset_history Write any value to reset history.
Power attributes are supported on ADM1075 and ADM1276
only.
......@@ -3,71 +3,50 @@ Kernel driver jc42
Supported chips:
* Analog Devices ADT7408
Prefix: 'adt7408'
Addresses scanned: I2C 0x18 - 0x1f
Datasheets:
http://www.analog.com/static/imported-files/data_sheets/ADT7408.pdf
* Atmel AT30TS00
Prefix: 'at30ts00'
Addresses scanned: I2C 0x18 - 0x1f
Datasheets:
http://www.atmel.com/Images/doc8585.pdf
* IDT TSE2002B3, TSE2002GB2, TS3000B3, TS3000GB2
Prefix: 'tse2002', 'ts3000'
Addresses scanned: I2C 0x18 - 0x1f
Datasheets:
http://www.idt.com/sites/default/files/documents/IDT_TSE2002B3C_DST_20100512_120303152056.pdf
http://www.idt.com/sites/default/files/documents/IDT_TSE2002GB2A1_DST_20111107_120303145914.pdf
http://www.idt.com/sites/default/files/documents/IDT_TS3000B3A_DST_20101129_120303152013.pdf
http://www.idt.com/sites/default/files/documents/IDT_TS3000GB2A1_DST_20111104_120303151012.pdf
* Maxim MAX6604
Prefix: 'max6604'
Addresses scanned: I2C 0x18 - 0x1f
Datasheets:
http://datasheets.maxim-ic.com/en/ds/MAX6604.pdf
* Microchip MCP9804, MCP9805, MCP98242, MCP98243, MCP9843
Prefixes: 'mcp9804', 'mcp9805', 'mcp98242', 'mcp98243', 'mcp9843'
Addresses scanned: I2C 0x18 - 0x1f
Datasheets:
http://ww1.microchip.com/downloads/en/DeviceDoc/22203C.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/21977b.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/21996a.pdf
http://ww1.microchip.com/downloads/en/DeviceDoc/22153c.pdf
* NXP Semiconductors SE97, SE97B
Prefix: 'se97'
Addresses scanned: I2C 0x18 - 0x1f
* NXP Semiconductors SE97, SE97B, SE98, SE98A
Datasheets:
http://www.nxp.com/documents/data_sheet/SE97.pdf
http://www.nxp.com/documents/data_sheet/SE97B.pdf
* NXP Semiconductors SE98
Prefix: 'se98'
Addresses scanned: I2C 0x18 - 0x1f
Datasheets:
http://www.nxp.com/documents/data_sheet/SE98.pdf
http://www.nxp.com/documents/data_sheet/SE98A.pdf
* ON Semiconductor CAT34TS02, CAT6095
Prefix: 'cat34ts02', 'cat6095'
Addresses scanned: I2C 0x18 - 0x1f
Datasheet:
http://www.onsemi.com/pub_link/Collateral/CAT34TS02-D.PDF
http://www.onsemi.com/pub/Collateral/CAT6095-D.PDF
* ST Microelectronics STTS424, STTS424E02
Prefix: 'stts424'
Addresses scanned: I2C 0x18 - 0x1f
Datasheets:
http://www.st.com/stonline/products/literature/ds/13447/stts424.pdf
http://www.st.com/stonline/products/literature/ds/13448/stts424e02.pdf
* ST Microelectronics STTS2002, STTS3000
Prefix: 'stts2002', 'stts3000'
Addresses scanned: I2C 0x18 - 0x1f
* ST Microelectronics STTS424, STTS424E02, STTS2002, STTS3000
Datasheets:
http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00157556.pdf
http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00157558.pdf
http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00225278.pdf
http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATA_BRIEF/CD00270920.pdf
* JEDEC JC 42.4 compliant temperature sensor chips
Prefix: 'jc42'
Addresses scanned: I2C 0x18 - 0x1f
Datasheet:
http://www.jedec.org/sites/default/files/docs/4_01_04R19.pdf
Common for all chips:
Prefix: 'jc42'
Addresses scanned: I2C 0x18 - 0x1f
Author:
Guenter Roeck <guenter.roeck@ericsson.com>
......
......@@ -7,6 +7,11 @@ Supported chips:
Addresses scanned: I2C 0x28 - 0x2f
Datasheet: Publicly available at the National Semiconductor website
http://www.national.com/
* National Semiconductor LM96080
Prefix: 'lm96080'
Addresses scanned: I2C 0x28 - 0x2f
Datasheet: Publicly available at the National Semiconductor website
http://www.national.com/
Authors:
Frodo Looijaard <frodol@dds.nl>,
......@@ -17,7 +22,9 @@ Description
This driver implements support for the National Semiconductor LM80.
It is described as a 'Serial Interface ACPI-Compatible Microprocessor
System Hardware Monitor'.
System Hardware Monitor'. The LM96080 is a more recent incarnation,
it is pin and register compatible, with a few additional features not
yet supported by the driver.
The LM80 implements one temperature sensor, two fan rotation speed sensors,
seven voltage sensors, alarms, and some miscellaneous stuff.
......
......@@ -11,6 +11,11 @@ Supported chips:
Prefixes: 'max34441'
Addresses scanned: -
Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX34441.pdf
* Maxim MAX34446
PMBus Power-Supply Data Logger
Prefixes: 'max34446'
Addresses scanned: -
Datasheet: http://datasheets.maxim-ic.com/en/ds/MAX34446.pdf
Author: Guenter Roeck <guenter.roeck@ericsson.com>
......@@ -19,8 +24,8 @@ Description
-----------
This driver supports hardware montoring for Maxim MAX34440 PMBus 6-Channel
Power-Supply Manager and MAX34441 PMBus 5-Channel Power-Supply Manager
and Intelligent Fan Controller.
Power-Supply Manager, MAX34441 PMBus 5-Channel Power-Supply Manager
and Intelligent Fan Controller, and MAX34446 PMBus Power-Supply Data Logger.
The driver is a client driver to the core PMBus driver. Please see
Documentation/hwmon/pmbus for details on PMBus client drivers.
......@@ -33,6 +38,13 @@ This driver does not auto-detect devices. You will have to instantiate the
devices explicitly. Please see Documentation/i2c/instantiating-devices for
details.
For MAX34446, the value of the currX_crit attribute determines if current or
voltage measurement is enabled for a given channel. Voltage measurement is
enabled if currX_crit is set to 0; current measurement is enabled if the
attribute is set to a positive value. Power measurement is only enabled if
channel 1 (3) is configured for voltage measurement, and channel 2 (4) is
configured for current measurement.
Platform data support
---------------------
......@@ -56,19 +68,31 @@ in[1-6]_min_alarm Voltage low alarm. From VOLTAGE_UV_WARNING status.
in[1-6]_max_alarm Voltage high alarm. From VOLTAGE_OV_WARNING status.
in[1-6]_lcrit_alarm Voltage critical low alarm. From VOLTAGE_UV_FAULT status.
in[1-6]_crit_alarm Voltage critical high alarm. From VOLTAGE_OV_FAULT status.
in[1-6]_lowest Historical minimum voltage.
in[1-6]_highest Historical maximum voltage.
in[1-6]_reset_history Write any value to reset history.
MAX34446 only supports in[1-4].
curr[1-6]_label "iout[1-6]".
curr[1-6]_input Measured current. From READ_IOUT register.
curr[1-6]_max Maximum current. From IOUT_OC_WARN_LIMIT register.
curr[1-6]_crit Critical maximum current. From IOUT_OC_FAULT_LIMIT register.
curr[1-6]_max_alarm Current high alarm. From IOUT_OC_WARNING status.
curr[1-6]_crit_alarm Current critical high alarm. From IOUT_OC_FAULT status.
curr[1-4]_average Historical average current (MAX34446 only).
curr[1-6]_highest Historical maximum current.
curr[1-6]_reset_history Write any value to reset history.
in6 and curr6 attributes only exist for MAX34440.
MAX34446 only supports curr[1-4].
power[1,3]_label "pout[1,3]"
power[1,3]_input Measured power.
power[1,3]_average Historical average power.
power[1,3]_highest Historical maximum power.
Power attributes only exist for MAX34446.
temp[1-8]_input Measured temperatures. From READ_TEMPERATURE_1 register.
temp1 is the chip's internal temperature. temp2..temp5
......@@ -79,7 +103,9 @@ temp[1-8]_max Maximum temperature. From OT_WARN_LIMIT register.
temp[1-8]_crit Critical high temperature. From OT_FAULT_LIMIT register.
temp[1-8]_max_alarm Temperature high alarm.
temp[1-8]_crit_alarm Temperature critical high alarm.
temp[1-8]_average Historical average temperature (MAX34446 only).
temp[1-8]_highest Historical maximum temperature.
temp[1-8]_reset_history Write any value to reset history.
temp7 and temp8 attributes only exist for MAX34440.
MAX34446 only supports temp[1-3].
......@@ -15,13 +15,20 @@ Supported chips:
http://www.onsemi.com/pub_link/Collateral/NCP4200-D.PDF
http://www.onsemi.com/pub_link/Collateral/JUNE%202009-%20REV.%200.PDF
* Lineage Power
Prefixes: 'pdt003', 'pdt006', 'pdt012', 'udt020'
Prefixes: 'mdt040', 'pdt003', 'pdt006', 'pdt012', 'udt020'
Addresses scanned: -
Datasheets:
http://www.lineagepower.com/oem/pdf/PDT003A0X.pdf
http://www.lineagepower.com/oem/pdf/PDT006A0X.pdf
http://www.lineagepower.com/oem/pdf/PDT012A0X.pdf
http://www.lineagepower.com/oem/pdf/UDT020A0X.pdf
http://www.lineagepower.com/oem/pdf/MDT040A0X.pdf
* Texas Instruments TPS40400, TPS40422
Prefixes: 'tps40400', 'tps40422'
Addresses scanned: -
Datasheets:
http://www.ti.com/lit/gpn/tps40400
http://www.ti.com/lit/gpn/tps40422
* Generic PMBus devices
Prefix: 'pmbus'
Addresses scanned: -
......
......@@ -16,6 +16,11 @@ Description
SMSC SCH5627 Super I/O chips include complete hardware monitoring
capabilities. They can monitor up to 5 voltages, 4 fans and 8 temperatures.
The SMSC SCH5627 hardware monitoring part also contains an integrated
watchdog. In order for this watchdog to function some motherboard specific
initialization most be done by the BIOS, so if the watchdog is not enabled
by the BIOS the sch5627 driver will not register a watchdog device.
The hardware monitoring part of the SMSC SCH5627 is accessed by talking
through an embedded microcontroller. An application note describing the
protocol for communicating with the microcontroller is available upon
......
......@@ -26,6 +26,9 @@ temperatures. Note that the driver detects how many fan headers /
temperature sensors are actually implemented on the motherboard, so you will
likely see fewer temperature and fan inputs.
The Fujitsu Theseus hwmon solution also contains an integrated watchdog.
This watchdog is fully supported by the sch5636 driver.
An application note describing the Theseus' registers, as well as an
application note describing the protocol for communicating with the
microcontroller is available upon request. Please mail me if you want a copy.
......@@ -34,6 +34,14 @@ Supported chips:
Prefix: 'zl6105'
Addresses scanned: -
Datasheet: http://www.intersil.com/data/fn/fn6906.pdf
* Intersil / Zilker Labs ZL9101M
Prefix: 'zl9101'
Addresses scanned: -
Datasheet: http://www.intersil.com/data/fn/fn7669.pdf
* Intersil / Zilker Labs ZL9117M
Prefix: 'zl9117'
Addresses scanned: -
Datasheet: http://www.intersil.com/data/fn/fn7914.pdf
* Ericsson BMR450, BMR451
Prefix: 'bmr450', 'bmr451'
Addresses scanned: -
......
......@@ -598,11 +598,11 @@ config SENSORS_LM78
will be called lm78.
config SENSORS_LM80
tristate "National Semiconductor LM80"
tristate "National Semiconductor LM80 and LM96080"
depends on I2C
help
If you say yes here you get support for National Semiconductor
LM80 sensor chips.
LM80 and LM96080 sensor chips.
This driver can also be built as a module. If so, the module
will be called lm80.
......@@ -1028,7 +1028,8 @@ config SENSORS_SCH5627
select SENSORS_SCH56XX_COMMON
help
If you say yes here you get support for the hardware monitoring
features of the SMSC SCH5627 Super-I/O chip.
features of the SMSC SCH5627 Super-I/O chip including support for
the integrated watchdog.
This driver can also be built as a module. If so, the module
will be called sch5627.
......@@ -1044,7 +1045,8 @@ config SENSORS_SCH5636
Currently this driver only supports the Fujitsu Theseus SCH5636 based
hwmon solution. Say yes here if you want support for the Fujitsu
Theseus' hardware monitoring features.
Theseus' hardware monitoring features including support for the
integrated watchdog.
This driver can also be built as a module. If so, the module
will be called sch5636.
......
此差异已折叠。
/*
abituguru3.c
Copyright (c) 2006-2008 Hans de Goede <hdegoede@redhat.com>
Copyright (c) 2008 Alistair John Strachan <alistair@devzero.co.uk>
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.
*/
* abituguru3.c
*
* Copyright (c) 2006-2008 Hans de Goede <hdegoede@redhat.com>
* Copyright (c) 2008 Alistair John Strachan <alistair@devzero.co.uk>
*
* 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.
*/
/*
This driver supports the sensor part of revision 3 of the custom Abit uGuru
chip found on newer Abit uGuru motherboards. Note: because of lack of specs
only reading the sensors and their settings is supported.
*/
* This driver supports the sensor part of revision 3 of the custom Abit uGuru
* chip found on newer Abit uGuru motherboards. Note: because of lack of specs
* only reading the sensors and their settings is supported.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
......@@ -62,13 +62,17 @@
#define ABIT_UGURU3_TEMP_SENSOR 1
#define ABIT_UGURU3_FAN_SENSOR 2
/* Timeouts / Retries, if these turn out to need a lot of fiddling we could
convert them to params. Determined by trial and error. I assume this is
cpu-speed independent, since the ISA-bus and not the CPU should be the
bottleneck. */
/*
* Timeouts / Retries, if these turn out to need a lot of fiddling we could
* convert them to params. Determined by trial and error. I assume this is
* cpu-speed independent, since the ISA-bus and not the CPU should be the
* bottleneck.
*/
#define ABIT_UGURU3_WAIT_TIMEOUT 250
/* Normally the 0xAC at the end of synchronize() is reported after the
first read, but sometimes not and we need to poll */
/*
* Normally the 0xAC at the end of synchronize() is reported after the
* first read, but sometimes not and we need to poll
*/
#define ABIT_UGURU3_SYNCHRONIZE_TIMEOUT 5
/* utility macros */
#define ABIT_UGURU3_NAME "abituguru3"
......@@ -78,32 +82,45 @@
/* Macros to help calculate the sysfs_names array length */
#define ABIT_UGURU3_MAX_NO_SENSORS 26
/* sum of strlen +1 of: in??_input\0, in??_{min,max}\0, in??_{min,max}_alarm\0,
in??_{min,max}_alarm_enable\0, in??_beep\0, in??_shutdown\0, in??_label\0 */
#define ABIT_UGURU3_IN_NAMES_LENGTH (11 + 2 * 9 + 2 * 15 + 2 * 22 + 10 + 14 + 11)
/* sum of strlen +1 of: temp??_input\0, temp??_max\0, temp??_crit\0,
temp??_alarm\0, temp??_alarm_enable\0, temp??_beep\0, temp??_shutdown\0,
temp??_label\0 */
/*
* sum of strlen +1 of: in??_input\0, in??_{min,max}\0, in??_{min,max}_alarm\0,
* in??_{min,max}_alarm_enable\0, in??_beep\0, in??_shutdown\0, in??_label\0
*/
#define ABIT_UGURU3_IN_NAMES_LENGTH \
(11 + 2 * 9 + 2 * 15 + 2 * 22 + 10 + 14 + 11)
/*
* sum of strlen +1 of: temp??_input\0, temp??_max\0, temp??_crit\0,
* temp??_alarm\0, temp??_alarm_enable\0, temp??_beep\0, temp??_shutdown\0,
* temp??_label\0
*/
#define ABIT_UGURU3_TEMP_NAMES_LENGTH (13 + 11 + 12 + 13 + 20 + 12 + 16 + 13)
/* sum of strlen +1 of: fan??_input\0, fan??_min\0, fan??_alarm\0,
fan??_alarm_enable\0, fan??_beep\0, fan??_shutdown\0, fan??_label\0 */
/*
* sum of strlen +1 of: fan??_input\0, fan??_min\0, fan??_alarm\0,
* fan??_alarm_enable\0, fan??_beep\0, fan??_shutdown\0, fan??_label\0
*/
#define ABIT_UGURU3_FAN_NAMES_LENGTH (12 + 10 + 12 + 19 + 11 + 15 + 12)
/* Worst case scenario 16 in sensors (longest names_length) and the rest
temp sensors (second longest names_length). */
/*
* Worst case scenario 16 in sensors (longest names_length) and the rest
* temp sensors (second longest names_length).
*/
#define ABIT_UGURU3_SYSFS_NAMES_LENGTH (16 * ABIT_UGURU3_IN_NAMES_LENGTH + \
(ABIT_UGURU3_MAX_NO_SENSORS - 16) * ABIT_UGURU3_TEMP_NAMES_LENGTH)
/* All the macros below are named identical to the openguru2 program
reverse engineered by Louis Kruger, hence the names might not be 100%
logical. I could come up with better names, but I prefer keeping the names
identical so that this driver can be compared with his work more easily. */
/*
* All the macros below are named identical to the openguru2 program
* reverse engineered by Louis Kruger, hence the names might not be 100%
* logical. I could come up with better names, but I prefer keeping the names
* identical so that this driver can be compared with his work more easily.
*/
/* Two i/o-ports are used by uGuru */
#define ABIT_UGURU3_BASE 0x00E0
#define ABIT_UGURU3_CMD 0x00
#define ABIT_UGURU3_DATA 0x04
#define ABIT_UGURU3_REGION_LENGTH 5
/* The wait_xxx functions return this on success and the last contents
of the DATA register (0-255) on failure. */
/*
* The wait_xxx functions return this on success and the last contents
* of the DATA register (0-255) on failure.
*/
#define ABIT_UGURU3_SUCCESS -1
/* uGuru status flags */
#define ABIT_UGURU3_STATUS_READY_FOR_READ 0x01
......@@ -112,7 +129,7 @@
/* Structures */
struct abituguru3_sensor_info {
const char* name;
const char *name;
int port;
int type;
int multiplier;
......@@ -130,9 +147,11 @@ struct abituguru3_motherboard_info {
struct abituguru3_sensor_info sensors[ABIT_UGURU3_MAX_NO_SENSORS + 1];
};
/* For the Abit uGuru, we need to keep some data in memory.
The structure is dynamically allocated, at the same time when a new
abituguru3 device is allocated. */
/*
* For the Abit uGuru, we need to keep some data in memory.
* The structure is dynamically allocated, at the same time when a new
* abituguru3 device is allocated.
*/
struct abituguru3_data {
struct device *hwmon_dev; /* hwmon registered device */
struct mutex update_lock; /* protect access to data and uGuru */
......@@ -140,8 +159,10 @@ struct abituguru3_data {
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
/* For convenience the sysfs attr and their names are generated
automatically. We have max 10 entries per sensor (for in sensors) */
/*
* For convenience the sysfs attr and their names are generated
* automatically. We have max 10 entries per sensor (for in sensors)
*/
struct sensor_device_attribute_2 sysfs_attr[ABIT_UGURU3_MAX_NO_SENSORS
* 10];
......@@ -151,9 +172,11 @@ struct abituguru3_data {
/* Pointer to the sensors info for the detected motherboard */
const struct abituguru3_sensor_info *sensors;
/* The abituguru3 supports up to 48 sensors, and thus has registers
sets for 48 sensors, for convienence reasons / simplicity of the
code we always read and store all registers for all 48 sensors */
/*
* The abituguru3 supports up to 48 sensors, and thus has registers
* sets for 48 sensors, for convienence reasons / simplicity of the
* code we always read and store all registers for all 48 sensors
*/
/* Alarms for all 48 sensors (1 bit per sensor) */
u8 alarms[48/8];
......@@ -161,9 +184,11 @@ struct abituguru3_data {
/* Value of all 48 sensors */
u8 value[48];
/* Settings of all 48 sensors, note in and temp sensors (the first 32
sensors) have 3 bytes of settings, while fans only have 2 bytes,
for convenience we use 3 bytes for all sensors */
/*
* Settings of all 48 sensors, note in and temp sensors (the first 32
* sensors) have 3 bytes of settings, while fans only have 2 bytes,
* for convenience we use 3 bytes for all sensors
*/
u8 settings[48][3];
};
......@@ -626,8 +651,10 @@ static int abituguru3_wait_while_busy(struct abituguru3_data *data)
timeout--;
if (timeout == 0)
return x;
/* sleep a bit before our last try, to give the uGuru3 one
last chance to respond. */
/*
* sleep a bit before our last try, to give the uGuru3 one
* last chance to respond.
*/
if (timeout == 1)
msleep(1);
}
......@@ -645,48 +672,57 @@ static int abituguru3_wait_for_read(struct abituguru3_data *data)
timeout--;
if (timeout == 0)
return x;
/* sleep a bit before our last try, to give the uGuru3 one
last chance to respond. */
/*
* sleep a bit before our last try, to give the uGuru3 one
* last chance to respond.
*/
if (timeout == 1)
msleep(1);
}
return ABIT_UGURU3_SUCCESS;
}
/* This synchronizes us with the uGuru3's protocol state machine, this
must be done before each command. */
/*
* This synchronizes us with the uGuru3's protocol state machine, this
* must be done before each command.
*/
static int abituguru3_synchronize(struct abituguru3_data *data)
{
int x, timeout = ABIT_UGURU3_SYNCHRONIZE_TIMEOUT;
if ((x = abituguru3_wait_while_busy(data)) != ABIT_UGURU3_SUCCESS) {
x = abituguru3_wait_while_busy(data);
if (x != ABIT_UGURU3_SUCCESS) {
ABIT_UGURU3_DEBUG("synchronize timeout during initial busy "
"wait, status: 0x%02x\n", x);
return -EIO;
}
outb(0x20, data->addr + ABIT_UGURU3_DATA);
if ((x = abituguru3_wait_while_busy(data)) != ABIT_UGURU3_SUCCESS) {
x = abituguru3_wait_while_busy(data);
if (x != ABIT_UGURU3_SUCCESS) {
ABIT_UGURU3_DEBUG("synchronize timeout after sending 0x20, "
"status: 0x%02x\n", x);
return -EIO;
}
outb(0x10, data->addr + ABIT_UGURU3_CMD);
if ((x = abituguru3_wait_while_busy(data)) != ABIT_UGURU3_SUCCESS) {
x = abituguru3_wait_while_busy(data);
if (x != ABIT_UGURU3_SUCCESS) {
ABIT_UGURU3_DEBUG("synchronize timeout after sending 0x10, "
"status: 0x%02x\n", x);
return -EIO;
}
outb(0x00, data->addr + ABIT_UGURU3_CMD);
if ((x = abituguru3_wait_while_busy(data)) != ABIT_UGURU3_SUCCESS) {
x = abituguru3_wait_while_busy(data);
if (x != ABIT_UGURU3_SUCCESS) {
ABIT_UGURU3_DEBUG("synchronize timeout after sending 0x00, "
"status: 0x%02x\n", x);
return -EIO;
}
if ((x = abituguru3_wait_for_read(data)) != ABIT_UGURU3_SUCCESS) {
x = abituguru3_wait_for_read(data);
if (x != ABIT_UGURU3_SUCCESS) {
ABIT_UGURU3_DEBUG("synchronize timeout waiting for read, "
"status: 0x%02x\n", x);
return -EIO;
......@@ -705,18 +741,22 @@ static int abituguru3_synchronize(struct abituguru3_data *data)
return 0;
}
/* Read count bytes from sensor sensor_addr in bank bank_addr and store the
result in buf */
/*
* Read count bytes from sensor sensor_addr in bank bank_addr and store the
* result in buf
*/
static int abituguru3_read(struct abituguru3_data *data, u8 bank, u8 offset,
u8 count, u8 *buf)
{
int i, x;
if ((x = abituguru3_synchronize(data)))
x = abituguru3_synchronize(data);
if (x)
return x;
outb(0x1A, data->addr + ABIT_UGURU3_DATA);
if ((x = abituguru3_wait_while_busy(data)) != ABIT_UGURU3_SUCCESS) {
x = abituguru3_wait_while_busy(data);
if (x != ABIT_UGURU3_SUCCESS) {
ABIT_UGURU3_DEBUG("read from 0x%02x:0x%02x timed out after "
"sending 0x1A, status: 0x%02x\n", (unsigned int)bank,
(unsigned int)offset, x);
......@@ -724,7 +764,8 @@ static int abituguru3_read(struct abituguru3_data *data, u8 bank, u8 offset,
}
outb(bank, data->addr + ABIT_UGURU3_CMD);
if ((x = abituguru3_wait_while_busy(data)) != ABIT_UGURU3_SUCCESS) {
x = abituguru3_wait_while_busy(data);
if (x != ABIT_UGURU3_SUCCESS) {
ABIT_UGURU3_DEBUG("read from 0x%02x:0x%02x timed out after "
"sending the bank, status: 0x%02x\n",
(unsigned int)bank, (unsigned int)offset, x);
......@@ -732,7 +773,8 @@ static int abituguru3_read(struct abituguru3_data *data, u8 bank, u8 offset,
}
outb(offset, data->addr + ABIT_UGURU3_CMD);
if ((x = abituguru3_wait_while_busy(data)) != ABIT_UGURU3_SUCCESS) {
x = abituguru3_wait_while_busy(data);
if (x != ABIT_UGURU3_SUCCESS) {
ABIT_UGURU3_DEBUG("read from 0x%02x:0x%02x timed out after "
"sending the offset, status: 0x%02x\n",
(unsigned int)bank, (unsigned int)offset, x);
......@@ -740,7 +782,8 @@ static int abituguru3_read(struct abituguru3_data *data, u8 bank, u8 offset,
}
outb(count, data->addr + ABIT_UGURU3_CMD);
if ((x = abituguru3_wait_while_busy(data)) != ABIT_UGURU3_SUCCESS) {
x = abituguru3_wait_while_busy(data);
if (x != ABIT_UGURU3_SUCCESS) {
ABIT_UGURU3_DEBUG("read from 0x%02x:0x%02x timed out after "
"sending the count, status: 0x%02x\n",
(unsigned int)bank, (unsigned int)offset, x);
......@@ -748,8 +791,8 @@ static int abituguru3_read(struct abituguru3_data *data, u8 bank, u8 offset,
}
for (i = 0; i < count; i++) {
if ((x = abituguru3_wait_for_read(data)) !=
ABIT_UGURU3_SUCCESS) {
x = abituguru3_wait_for_read(data);
if (x != ABIT_UGURU3_SUCCESS) {
ABIT_UGURU3_DEBUG("timeout reading byte %d from "
"0x%02x:0x%02x, status: 0x%02x\n", i,
(unsigned int)bank, (unsigned int)offset, x);
......@@ -760,28 +803,34 @@ static int abituguru3_read(struct abituguru3_data *data, u8 bank, u8 offset,
return i;
}
/* Sensor settings are stored 1 byte per offset with the bytes
placed add consecutive offsets. */
/*
* Sensor settings are stored 1 byte per offset with the bytes
* placed add consecutive offsets.
*/
static int abituguru3_read_increment_offset(struct abituguru3_data *data,
u8 bank, u8 offset, u8 count,
u8 *buf, int offset_count)
{
int i, x;
for (i = 0; i < offset_count; i++)
if ((x = abituguru3_read(data, bank, offset + i, count,
buf + i * count)) != count) {
for (i = 0; i < offset_count; i++) {
x = abituguru3_read(data, bank, offset + i, count,
buf + i * count);
if (x != count) {
if (x < 0)
return x;
return i * count + x;
}
}
return i * count;
}
/* Following are the sysfs callback functions. These functions expect:
sensor_device_attribute_2->index: index into the data->sensors array
sensor_device_attribute_2->nr: register offset, bitmask or NA. */
/*
* Following are the sysfs callback functions. These functions expect:
* sensor_device_attribute_2->index: index into the data->sensors array
* sensor_device_attribute_2->nr: register offset, bitmask or NA.
*/
static struct abituguru3_data *abituguru3_update_device(struct device *dev);
static ssize_t show_value(struct device *dev,
......@@ -807,8 +856,10 @@ static ssize_t show_value(struct device *dev,
value = (value * sensor->multiplier) / sensor->divisor +
sensor->offset;
/* alternatively we could update the sensors settings struct for this,
but then its contents would differ from the windows sw ini files */
/*
* alternatively we could update the sensors settings struct for this,
* but then its contents would differ from the windows sw ini files
*/
if (sensor->type == ABIT_UGURU3_TEMP_SENSOR)
value *= 1000;
......@@ -827,10 +878,12 @@ static ssize_t show_alarm(struct device *dev,
port = data->sensors[attr->index].port;
/* See if the alarm bit for this sensor is set and if a bitmask is
given in attr->nr also check if the alarm matches the type of alarm
we're looking for (for volt it can be either low or high). The type
is stored in a few readonly bits in the settings of the sensor. */
/*
* See if the alarm bit for this sensor is set and if a bitmask is
* given in attr->nr also check if the alarm matches the type of alarm
* we're looking for (for volt it can be either low or high). The type
* is stored in a few readonly bits in the settings of the sensor.
*/
if ((data->alarms[port / 8] & (0x01 << (port % 8))) &&
(!attr->nr || (data->settings[port][0] & attr->nr)))
return sprintf(buf, "1\n");
......@@ -923,7 +976,8 @@ static int __devinit abituguru3_probe(struct platform_device *pdev)
u8 buf[2];
u16 id;
if (!(data = kzalloc(sizeof(struct abituguru3_data), GFP_KERNEL)))
data = kzalloc(sizeof(struct abituguru3_data), GFP_KERNEL);
if (!data)
return -ENOMEM;
data->addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
......@@ -931,10 +985,10 @@ static int __devinit abituguru3_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, data);
/* Read the motherboard ID */
if ((i = abituguru3_read(data, ABIT_UGURU3_MISC_BANK,
ABIT_UGURU3_BOARD_ID, 2, buf)) != 2) {
i = abituguru3_read(data, ABIT_UGURU3_MISC_BANK, ABIT_UGURU3_BOARD_ID,
2, buf);
if (i != 2)
goto abituguru3_probe_error;
}
/* Completely read the uGuru to see if one really is there */
if (!abituguru3_update_device(&pdev->dev))
......@@ -1091,8 +1145,10 @@ static struct abituguru3_data *abituguru3_update_device(struct device *dev)
static int abituguru3_suspend(struct platform_device *pdev, pm_message_t state)
{
struct abituguru3_data *data = platform_get_drvdata(pdev);
/* make sure all communications with the uguru3 are done and no new
ones are started */
/*
* make sure all communications with the uguru3 are done and no new
* ones are started
*/
mutex_lock(&data->update_lock);
return 0;
}
......@@ -1134,7 +1190,8 @@ static int __init abituguru3_dmi_detect(void)
if (!board_name)
return err;
/* At the moment, we don't care about the part of the vendor
/*
* At the moment, we don't care about the part of the vendor
* DMI string contained in brackets. Truncate the string at
* the first occurrence of a bracket. Trim any trailing space
* from the substring.
......@@ -1157,15 +1214,18 @@ static int __init abituguru3_dmi_detect(void)
return 1;
}
/* FIXME: Manual detection should die eventually; we need to collect stable
/*
* FIXME: Manual detection should die eventually; we need to collect stable
* DMI model names first before we can rely entirely on CONFIG_DMI.
*/
static int __init abituguru3_detect(void)
{
/* See if there is an uguru3 there. An idle uGuru3 will hold 0x00 or
0x08 at DATA and 0xAC at CMD. Sometimes the uGuru3 will hold 0x05
or 0x55 at CMD instead, why is unknown. */
/*
* See if there is an uguru3 there. An idle uGuru3 will hold 0x00 or
* 0x08 at DATA and 0xAC at CMD. Sometimes the uGuru3 will hold 0x05
* or 0x55 at CMD instead, why is unknown.
*/
u8 data_val = inb_p(ABIT_UGURU3_BASE + ABIT_UGURU3_DATA);
u8 cmd_val = inb_p(ABIT_UGURU3_BASE + ABIT_UGURU3_CMD);
if (((data_val == 0x00) || (data_val == 0x08)) &&
......@@ -1197,7 +1257,8 @@ static int __init abituguru3_init(void)
if (err < 0)
return err;
/* Fall back to manual detection if there was no exact
/*
* Fall back to manual detection if there was no exact
* board name match, or force was specified.
*/
if (err > 0) {
......
......@@ -167,17 +167,7 @@ static struct spi_driver ad7314_driver = {
.id_table = ad7314_id,
};
static __init int ad7314_init(void)
{
return spi_register_driver(&ad7314_driver);
}
module_init(ad7314_init);
static __exit void ad7314_exit(void)
{
spi_unregister_driver(&ad7314_driver);
}
module_exit(ad7314_exit);
module_spi_driver(ad7314_driver);
MODULE_AUTHOR("Sonic Zhang <sonic.zhang@analog.com>");
MODULE_DESCRIPTION("Analog Devices AD7314, ADT7301 and ADT7302 digital"
......
......@@ -50,7 +50,8 @@ struct ad7414_data {
/* REG: (0.25C/bit, two's complement) << 6 */
static inline int ad7414_temp_from_reg(s16 reg)
{
/* use integer division instead of equivalent right shift to
/*
* use integer division instead of equivalent right shift to
* guarantee arithmetic shift and preserve the sign
*/
return ((int)reg / 64) * 250;
......@@ -130,7 +131,11 @@ static ssize_t set_max_min(struct device *dev,
struct ad7414_data *data = i2c_get_clientdata(client);
int index = to_sensor_dev_attr(attr)->index;
u8 reg = AD7414_REG_LIMIT[index];
long temp = simple_strtol(buf, NULL, 10);
long temp;
int ret = kstrtol(buf, 10, &temp);
if (ret < 0)
return ret;
temp = SENSORS_LIMIT(temp, -40000, 85000);
temp = (temp + (temp < 0 ? -500 : 500)) / 1000;
......@@ -252,17 +257,7 @@ static struct i2c_driver ad7414_driver = {
.id_table = ad7414_id,
};
static int __init ad7414_init(void)
{
return i2c_add_driver(&ad7414_driver);
}
module_init(ad7414_init);
static void __exit ad7414_exit(void)
{
i2c_del_driver(&ad7414_driver);
}
module_exit(ad7414_exit);
module_i2c_driver(ad7414_driver);
MODULE_AUTHOR("Stefan Roese <sr at denx.de>, "
"Frank Edelhaeuser <frank.edelhaeuser at spansion.com>");
......
......@@ -167,7 +167,11 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev);
struct ad7418_data *data = i2c_get_clientdata(client);
long temp = simple_strtol(buf, NULL, 10);
long temp;
int ret = kstrtol(buf, 10, &temp);
if (ret < 0)
return ret;
mutex_lock(&data->lock);
data->temp[attr->index] = LM75_TEMP_TO_REG(temp);
......@@ -228,7 +232,8 @@ static int ad7418_probe(struct i2c_client *client,
goto exit;
}
if (!(data = kzalloc(sizeof(struct ad7418_data), GFP_KERNEL))) {
data = kzalloc(sizeof(struct ad7418_data), GFP_KERNEL);
if (!data) {
err = -ENOMEM;
goto exit;
}
......@@ -261,7 +266,8 @@ static int ad7418_probe(struct i2c_client *client,
ad7418_init_client(client);
/* Register sysfs hooks */
if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs)))
err = sysfs_create_group(&client->dev.kobj, &data->attrs);
if (err)
goto exit_free;
data->hwmon_dev = hwmon_device_register(&client->dev);
......@@ -289,20 +295,9 @@ static int ad7418_remove(struct i2c_client *client)
return 0;
}
static int __init ad7418_init(void)
{
return i2c_add_driver(&ad7418_driver);
}
static void __exit ad7418_exit(void)
{
i2c_del_driver(&ad7418_driver);
}
module_i2c_driver(ad7418_driver);
MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>");
MODULE_DESCRIPTION("AD7416/17/18 driver");
MODULE_LICENSE("GPL");
MODULE_VERSION(DRV_VERSION);
module_init(ad7418_init);
module_exit(ad7418_exit);
......@@ -248,18 +248,7 @@ static struct spi_driver adcxx_driver = {
.remove = __devexit_p(adcxx_remove),
};
static int __init init_adcxx(void)
{
return spi_register_driver(&adcxx_driver);
}
static void __exit exit_adcxx(void)
{
spi_unregister_driver(&adcxx_driver);
}
module_init(init_adcxx);
module_exit(exit_adcxx);
module_spi_driver(adcxx_driver);
MODULE_AUTHOR("Marc Pignat");
MODULE_DESCRIPTION("National Semiconductor adcxx8sxxx Linux driver");
......
/*
adm1021.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and
Philip Edelbrock <phil@netroedge.com>
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.
*/
* adm1021.c - Part of lm_sensors, Linux kernel modules for hardware
* monitoring
* Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> and
* Philip Edelbrock <phil@netroedge.com>
*
* 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.
*/
#include <linux/module.h>
#include <linux/init.h>
......@@ -70,10 +70,12 @@ enum chips {
/* Initial values */
/* Note: Even though I left the low and high limits named os and hyst,
they don't quite work like a thermostat the way the LM75 does. I.e.,
a lower temp than THYST actually triggers an alarm instead of
clearing it. Weird, ey? --Phil */
/*
* Note: Even though I left the low and high limits named os and hyst,
* they don't quite work like a thermostat the way the LM75 does. I.e.,
* a lower temp than THYST actually triggers an alarm instead of
* clearing it. Weird, ey? --Phil
*/
/* Each client has this additional data */
struct adm1021_data {
......@@ -182,7 +184,13 @@ static ssize_t set_temp_max(struct device *dev,
int index = to_sensor_dev_attr(devattr)->index;
struct i2c_client *client = to_i2c_client(dev);
struct adm1021_data *data = i2c_get_clientdata(client);
long temp = simple_strtol(buf, NULL, 10) / 1000;
long temp;
int err;
err = kstrtol(buf, 10, &temp);
if (err)
return err;
temp /= 1000;
mutex_lock(&data->update_lock);
data->temp_max[index] = SENSORS_LIMIT(temp, -128, 127);
......@@ -201,7 +209,13 @@ static ssize_t set_temp_min(struct device *dev,
int index = to_sensor_dev_attr(devattr)->index;
struct i2c_client *client = to_i2c_client(dev);
struct adm1021_data *data = i2c_get_clientdata(client);
long temp = simple_strtol(buf, NULL, 10) / 1000;
long temp;
int err;
err = kstrtol(buf, 10, &temp);
if (err)
return err;
temp /= 1000;
mutex_lock(&data->update_lock);
data->temp_min[index] = SENSORS_LIMIT(temp, -128, 127);
......@@ -226,7 +240,14 @@ static ssize_t set_low_power(struct device *dev,
{
struct i2c_client *client = to_i2c_client(dev);
struct adm1021_data *data = i2c_get_clientdata(client);
int low_power = simple_strtol(buf, NULL, 10) != 0;
char low_power;
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
low_power = val != 0;
mutex_lock(&data->update_lock);
if (low_power != data->low_power) {
......@@ -361,7 +382,8 @@ static int adm1021_probe(struct i2c_client *client,
adm1021_init_client(client);
/* Register sysfs hooks */
if ((err = sysfs_create_group(&client->dev.kobj, &adm1021_group)))
err = sysfs_create_group(&client->dev.kobj, &adm1021_group);
if (err)
goto error1;
data->hwmon_dev = hwmon_device_register(&client->dev);
......@@ -427,8 +449,10 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
data->alarms = i2c_smbus_read_byte_data(client,
ADM1021_REG_STATUS) & 0x7c;
if (data->type == adm1023) {
/* The ADM1023 provides 3 extra bits of precision for
* the remote sensor in extra registers. */
/*
* The ADM1023 provides 3 extra bits of precision for
* the remote sensor in extra registers.
*/
data->temp[1] += 125 * (i2c_smbus_read_byte_data(
client, ADM1023_REG_REM_TEMP_PREC) >> 5);
data->temp_max[1] += 125 * (i2c_smbus_read_byte_data(
......@@ -451,23 +475,12 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
return data;
}
static int __init sensors_adm1021_init(void)
{
return i2c_add_driver(&adm1021_driver);
}
static void __exit sensors_adm1021_exit(void)
{
i2c_del_driver(&adm1021_driver);
}
module_i2c_driver(adm1021_driver);
MODULE_AUTHOR ("Frodo Looijaard <frodol@dds.nl> and "
MODULE_AUTHOR("Frodo Looijaard <frodol@dds.nl> and "
"Philip Edelbrock <phil@netroedge.com>");
MODULE_DESCRIPTION("adm1021 driver");
MODULE_LICENSE("GPL");
module_param(read_only, bool, 0);
MODULE_PARM_DESC(read_only, "Don't set any values, read only mode");
module_init(sensors_adm1021_init)
module_exit(sensors_adm1021_exit)
......@@ -12,7 +12,7 @@
* resolution of about 0.5% of the nominal value). Temperature values are
* reported with a 1 deg resolution and a 3 deg accuracy. Complete
* datasheet can be obtained from Analog's website at:
* http://www.onsemi.com/PowerSolutions/product.do?id=ADM1025
* http://www.onsemi.com/PowerSolutions/product.do?id=ADM1025
*
* This driver also supports the ADM1025A, which differs from the ADM1025
* only in that it has "open-drain VID inputs while the ADM1025 has
......@@ -91,15 +91,16 @@ enum chips { adm1025, ne1619 };
static const int in_scale[6] = { 2500, 2250, 3300, 5000, 12000, 3300 };
#define IN_FROM_REG(reg,scale) (((reg) * (scale) + 96) / 192)
#define IN_TO_REG(val,scale) ((val) <= 0 ? 0 : \
#define IN_FROM_REG(reg, scale) (((reg) * (scale) + 96) / 192)
#define IN_TO_REG(val, scale) ((val) <= 0 ? 0 : \
(val) * 192 >= (scale) * 255 ? 255 : \
((val) * 192 + (scale)/2) / (scale))
((val) * 192 + (scale) / 2) / (scale))
#define TEMP_FROM_REG(reg) ((reg) * 1000)
#define TEMP_TO_REG(val) ((val) <= -127500 ? -128 : \
(val) >= 126500 ? 127 : \
(((val) < 0 ? (val)-500 : (val)+500) / 1000))
(((val) < 0 ? (val) - 500 : \
(val) + 500) / 1000))
/*
* Functions declaration
......@@ -218,7 +219,12 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
int index = to_sensor_dev_attr(attr)->index;
struct i2c_client *client = to_i2c_client(dev);
struct adm1025_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->in_min[index] = IN_TO_REG(val, in_scale[index]);
......@@ -234,7 +240,12 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
int index = to_sensor_dev_attr(attr)->index;
struct i2c_client *client = to_i2c_client(dev);
struct adm1025_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->in_max[index] = IN_TO_REG(val, in_scale[index]);
......@@ -264,7 +275,12 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
int index = to_sensor_dev_attr(attr)->index;
struct i2c_client *client = to_i2c_client(dev);
struct adm1025_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->temp_min[index] = TEMP_TO_REG(val);
......@@ -280,7 +296,12 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
int index = to_sensor_dev_attr(attr)->index;
struct i2c_client *client = to_i2c_client(dev);
struct adm1025_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->temp_max[index] = TEMP_TO_REG(val);
......@@ -343,7 +364,14 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct adm1025_data *data = dev_get_drvdata(dev);
data->vrm = simple_strtoul(buf, NULL, 10);
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
data->vrm = val;
return count;
}
static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm);
......@@ -462,14 +490,15 @@ static int adm1025_probe(struct i2c_client *client,
adm1025_init_client(client);
/* Register sysfs hooks */
if ((err = sysfs_create_group(&client->dev.kobj, &adm1025_group)))
err = sysfs_create_group(&client->dev.kobj, &adm1025_group);
if (err)
goto exit_free;
/* Pin 11 is either in4 (+12V) or VID4 */
config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG);
if (!(config & 0x20)) {
if ((err = sysfs_create_group(&client->dev.kobj,
&adm1025_group_in4)))
err = sysfs_create_group(&client->dev.kobj, &adm1025_group_in4);
if (err)
goto exit_remove;
}
......@@ -506,7 +535,7 @@ static void adm1025_init_client(struct i2c_client *client)
* setting yet, we better set the high limits to the max so that
* no alarm triggers.
*/
for (i=0; i<6; i++) {
for (i = 0; i < 6; i++) {
reg = i2c_smbus_read_byte_data(client,
ADM1025_REG_IN_MAX(i));
if (reg == 0)
......@@ -514,7 +543,7 @@ static void adm1025_init_client(struct i2c_client *client)
ADM1025_REG_IN_MAX(i),
0xFF);
}
for (i=0; i<2; i++) {
for (i = 0; i < 2; i++) {
reg = i2c_smbus_read_byte_data(client,
ADM1025_REG_TEMP_HIGH(i));
if (reg == 0)
......@@ -555,7 +584,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
int i;
dev_dbg(&client->dev, "Updating data.\n");
for (i=0; i<6; i++) {
for (i = 0; i < 6; i++) {
data->in[i] = i2c_smbus_read_byte_data(client,
ADM1025_REG_IN(i));
data->in_min[i] = i2c_smbus_read_byte_data(client,
......@@ -563,7 +592,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
data->in_max[i] = i2c_smbus_read_byte_data(client,
ADM1025_REG_IN_MAX(i));
}
for (i=0; i<2; i++) {
for (i = 0; i < 2; i++) {
data->temp[i] = i2c_smbus_read_byte_data(client,
ADM1025_REG_TEMP(i));
data->temp_min[i] = i2c_smbus_read_byte_data(client,
......@@ -589,19 +618,8 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
return data;
}
static int __init sensors_adm1025_init(void)
{
return i2c_add_driver(&adm1025_driver);
}
static void __exit sensors_adm1025_exit(void)
{
i2c_del_driver(&adm1025_driver);
}
module_i2c_driver(adm1025_driver);
MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
MODULE_DESCRIPTION("ADM1025 driver");
MODULE_LICENSE("GPL");
module_init(sensors_adm1025_init);
module_exit(sensors_adm1025_exit);
此差异已折叠。
......@@ -78,7 +78,7 @@ static const unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
#define TEMP_FROM_REG(val) ((val) * 1000)
#define DIV_FROM_REG(val) ( 1 << (((val) >> 6) - 1))
#define DIV_FROM_REG(val) (1 << (((val) >> 6) - 1))
/* Registers to be checked by adm1029_update_device() */
static const u8 ADM1029_REG_TEMP[] = {
......@@ -200,8 +200,11 @@ static ssize_t set_fan_div(struct device *dev,
struct i2c_client *client = to_i2c_client(dev);
struct adm1029_data *data = i2c_get_clientdata(client);
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
long val = simple_strtol(buf, NULL, 10);
u8 reg;
long val;
int ret = kstrtol(buf, 10, &val);
if (ret < 0)
return ret;
mutex_lock(&data->update_lock);
......@@ -237,9 +240,9 @@ static ssize_t set_fan_div(struct device *dev,
}
/*
Access rights on sysfs, S_IRUGO stand for Is Readable by User, Group and Others
S_IWUSR stand for Is Writable by User
*/
* Access rights on sysfs. S_IRUGO: Is Readable by User, Group and Others
* S_IWUSR: Is Writable by User.
*/
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
......@@ -300,7 +303,8 @@ static int adm1029_detect(struct i2c_client *client,
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;
/* ADM1029 doesn't have CHIP ID, check just MAN ID
/*
* ADM1029 doesn't have CHIP ID, check just MAN ID
* For better detection we check also ADM1029_TEMP_DEVICES_INSTALLED,
* ADM1029_REG_NB_FAN_SUPPORT and compare it with possible values
* documented
......@@ -318,8 +322,10 @@ static int adm1029_detect(struct i2c_client *client,
return -ENODEV;
if ((chip_id & 0xF0) != 0x00) {
/* There are no "official" CHIP ID, so actually
* we use Major/Minor revision for that */
/*
* There are no "official" CHIP ID, so actually
* we use Major/Minor revision for that
*/
pr_info("adm1029: Unknown major revision %x, "
"please let us know\n", chip_id);
return -ENODEV;
......@@ -355,7 +361,8 @@ static int adm1029_probe(struct i2c_client *client,
}
/* Register sysfs hooks */
if ((err = sysfs_create_group(&client->dev.kobj, &adm1029_group)))
err = sysfs_create_group(&client->dev.kobj, &adm1029_group);
if (err)
goto exit_free;
data->hwmon_dev = hwmon_device_register(&client->dev);
......@@ -403,8 +410,8 @@ static int adm1029_remove(struct i2c_client *client)
}
/*
function that update the status of the chips (temperature for example)
*/
* function that update the status of the chips (temperature for example)
*/
static struct adm1029_data *adm1029_update_device(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
......@@ -446,24 +453,8 @@ static struct adm1029_data *adm1029_update_device(struct device *dev)
return data;
}
/*
Common module stuff
*/
static int __init sensors_adm1029_init(void)
{
return i2c_add_driver(&adm1029_driver);
}
static void __exit sensors_adm1029_exit(void)
{
i2c_del_driver(&adm1029_driver);
}
module_i2c_driver(adm1029_driver);
MODULE_AUTHOR("Corentin LABBE <corentin.labbe@geomatys.fr>");
MODULE_DESCRIPTION("adm1029 driver");
MODULE_LICENSE("GPL v2");
module_init(sensors_adm1029_init);
module_exit(sensors_adm1029_exit);
/*
adm1031.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Based on lm75.c and lm85.c
Supports adm1030 / adm1031
Copyright (C) 2004 Alexandre d'Alton <alex@alexdalton.org>
Reworked by Jean Delvare <khali@linux-fr.org>
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.
*/
* adm1031.c - Part of lm_sensors, Linux kernel modules for hardware
* monitoring
* Based on lm75.c and lm85.c
* Supports adm1030 / adm1031
* Copyright (C) 2004 Alexandre d'Alton <alex@alexdalton.org>
* Reworked by Jean Delvare <khali@linux-fr.org>
*
* 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.
*/
#include <linux/module.h>
#include <linux/init.h>
......@@ -80,7 +80,8 @@ struct adm1031_data {
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
unsigned int update_interval; /* In milliseconds */
/* The chan_select_table contains the possible configurations for
/*
* The chan_select_table contains the possible configurations for
* auto fan control.
*/
const auto_chan_table_t *chan_select_table;
......@@ -205,7 +206,8 @@ static int AUTO_TEMP_MAX_TO_REG(int val, int reg, int pwm)
#define GET_FAN_AUTO_BITFIELD(data, idx) \
(*(data)->chan_select_table)[FAN_CHAN_FROM_REG((data)->conf1)][idx % 2]
/* The tables below contains the possible values for the auto fan
/*
* The tables below contains the possible values for the auto fan
* control bitfields. the index in the table is the register value.
* MSb is the auto fan control enable bit, so the four first entries
* in the table disables auto fan control when both bitfields are zero.
......@@ -226,7 +228,8 @@ static const auto_chan_table_t auto_channel_select_table_adm1030 = {
{ 3 /* 0b11 */ , 0 },
};
/* That function checks if a bitfield is valid and returns the other bitfield
/*
* That function checks if a bitfield is valid and returns the other bitfield
* nearest match if no exact match where found.
*/
static int
......@@ -252,7 +255,8 @@ get_fan_auto_nearest(struct adm1031_data *data,
break;
} else if (val == (*data->chan_select_table)[i][chan] &&
first_match == -1) {
/* Save the first match in case of an exact match has
/*
* Save the first match in case of an exact match has
* not been found
*/
first_match = i;
......@@ -306,9 +310,11 @@ set_fan_auto_channel(struct device *dev, struct device_attribute *attr,
if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) ^
(old_fan_mode & ADM1031_CONF1_AUTO_MODE)) {
if (data->conf1 & ADM1031_CONF1_AUTO_MODE) {
/* Switch to Auto Fan Mode
/*
* Switch to Auto Fan Mode
* Save PWM registers
* Set PWM registers to 33% Both */
* Set PWM registers to 33% Both
*/
data->old_pwm[0] = data->pwm[0];
data->old_pwm[1] = data->pwm[1];
adm1031_write_value(client, ADM1031_REG_PWM, 0x55);
......@@ -1131,19 +1137,8 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
return data;
}
static int __init sensors_adm1031_init(void)
{
return i2c_add_driver(&adm1031_driver);
}
static void __exit sensors_adm1031_exit(void)
{
i2c_del_driver(&adm1031_driver);
}
module_i2c_driver(adm1031_driver);
MODULE_AUTHOR("Alexandre d'Alton <alex@alexdalton.org>");
MODULE_DESCRIPTION("ADM1031/ADM1030 driver");
MODULE_LICENSE("GPL");
module_init(sensors_adm1031_init);
module_exit(sensors_adm1031_exit);
/*
* adm9240.c Part of lm_sensors, Linux kernel modules for hardware
* monitoring
* monitoring
*
* Copyright (C) 1999 Frodo Looijaard <frodol@dds.nl>
* Philip Edelbrock <phil@netroedge.com>
* Copyright (C) 2003 Michiel Rook <michiel@grendelproject.nl>
* Copyright (C) 2005 Grant Coady <gcoady.lk@gmail.com> with valuable
* guidance from Jean Delvare
* guidance from Jean Delvare
*
* Driver supports Analog Devices ADM9240
* Dallas Semiconductor DS1780
......@@ -204,7 +204,12 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev);
struct adm9240_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->temp_max[attr->index] = TEMP_TO_REG(val);
......@@ -255,7 +260,12 @@ static ssize_t set_in_min(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev);
struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->in_min[attr->index] = IN_TO_REG(val, attr->index);
......@@ -272,7 +282,12 @@ static ssize_t set_in_max(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev);
struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->in_max[attr->index] = IN_TO_REG(val, attr->index);
......@@ -283,7 +298,7 @@ static ssize_t set_in_max(struct device *dev,
}
#define vin(nr) \
static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \
static SENSOR_DEVICE_ATTR(in##nr##_input, S_IRUGO, \
show_in, NULL, nr); \
static SENSOR_DEVICE_ATTR(in##nr##_min, S_IRUGO | S_IWUSR, \
show_in_min, set_in_min, nr); \
......@@ -357,9 +372,14 @@ static ssize_t set_fan_min(struct device *dev,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev);
struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
int nr = attr->index;
u8 new_div;
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
......@@ -465,7 +485,12 @@ static ssize_t set_aout(struct device *dev,
{
struct i2c_client *client = to_i2c_client(dev);
struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtol(buf, NULL, 10);
long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->aout = AOUT_TO_REG(val);
......@@ -481,7 +506,12 @@ static ssize_t chassis_clear_legacy(struct device *dev,
const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
unsigned long val = simple_strtol(buf, NULL, 10);
long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
dev_warn(dev, "Attribute chassis_clear is deprecated, "
"use intrusion0_alarm instead\n");
......@@ -632,7 +662,8 @@ static int adm9240_probe(struct i2c_client *new_client,
adm9240_init_client(new_client);
/* populate sysfs filesystem */
if ((err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group)))
err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group);
if (err)
goto exit_free;
data->hwmon_dev = hwmon_device_register(&new_client->dev);
......@@ -681,8 +712,7 @@ static void adm9240_init_client(struct i2c_client *client)
} else { /* cold start: open limits before starting chip */
int i;
for (i = 0; i < 6; i++)
{
for (i = 0; i < 6; i++) {
i2c_smbus_write_byte_data(client,
ADM9240_REG_IN_MIN(i), 0);
i2c_smbus_write_byte_data(client,
......@@ -717,8 +747,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4))
|| !data->valid) {
for (i = 0; i < 6; i++) /* read voltages */
{
for (i = 0; i < 6; i++) { /* read voltages */
data->in[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_IN(i));
}
......@@ -727,16 +756,17 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
i2c_smbus_read_byte_data(client,
ADM9240_REG_INT(1)) << 8;
/* read temperature: assume temperature changes less than
/*
* read temperature: assume temperature changes less than
* 0.5'C per two measurement cycles thus ignore possible
* but unlikely aliasing error on lsb reading. --Grant */
* but unlikely aliasing error on lsb reading. --Grant
*/
data->temp = ((i2c_smbus_read_byte_data(client,
ADM9240_REG_TEMP) << 8) |
i2c_smbus_read_byte_data(client,
ADM9240_REG_TEMP_CONF)) / 128;
for (i = 0; i < 2; i++) /* read fans */
{
for (i = 0; i < 2; i++) { /* read fans */
data->fan[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_FAN(i));
......@@ -760,15 +790,13 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
if (time_after(jiffies, data->last_updated_config + (HZ * 300))
|| !data->valid) {
for (i = 0; i < 6; i++)
{
for (i = 0; i < 6; i++) {
data->in_min[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_IN_MIN(i));
data->in_max[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_IN_MAX(i));
}
for (i = 0; i < 2; i++)
{
for (i = 0; i < 2; i++) {
data->fan_min[i] = i2c_smbus_read_byte_data(client,
ADM9240_REG_FAN_MIN(i));
}
......@@ -795,21 +823,9 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
return data;
}
static int __init sensors_adm9240_init(void)
{
return i2c_add_driver(&adm9240_driver);
}
static void __exit sensors_adm9240_exit(void)
{
i2c_del_driver(&adm9240_driver);
}
module_i2c_driver(adm9240_driver);
MODULE_AUTHOR("Michiel Rook <michiel@grendelproject.nl>, "
"Grant Coady <gcoady.lk@gmail.com> and others");
MODULE_DESCRIPTION("ADM9240/DS1780/LM81 driver");
MODULE_LICENSE("GPL");
module_init(sensors_adm9240_init);
module_exit(sensors_adm9240_exit);
......@@ -305,19 +305,8 @@ static struct i2c_driver ads1015_driver = {
.id_table = ads1015_id,
};
static int __init sensors_ads1015_init(void)
{
return i2c_add_driver(&ads1015_driver);
}
static void __exit sensors_ads1015_exit(void)
{
i2c_del_driver(&ads1015_driver);
}
module_i2c_driver(ads1015_driver);
MODULE_AUTHOR("Dirk Eibach <eibach@gdsys.de>");
MODULE_DESCRIPTION("ADS1015 driver");
MODULE_LICENSE("GPL");
module_init(sensors_ads1015_init);
module_exit(sensors_ads1015_exit);
/*
ads7828.c - lm_sensors driver for ads7828 12-bit 8-channel ADC
(C) 2007 EADS Astrium
This driver is based on the lm75 and other lm_sensors/hwmon drivers
Written by Steve Hardy <shardy@redhat.com>
Datasheet available at: http://focus.ti.com/lit/ds/symlink/ads7828.pdf
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.
*/
* ads7828.c - lm_sensors driver for ads7828 12-bit 8-channel ADC
* (C) 2007 EADS Astrium
*
* This driver is based on the lm75 and other lm_sensors/hwmon drivers
*
* Written by Steve Hardy <shardy@redhat.com>
*
* Datasheet available at: http://focus.ti.com/lit/ds/symlink/ads7828.pdf
*
* 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.
*/
#include <linux/module.h>
#include <linux/init.h>
......@@ -188,12 +188,13 @@ static int ads7828_detect(struct i2c_client *client,
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_WORD_DATA))
return -ENODEV;
/* Now, we do the remaining detection. There is no identification
dedicated register so attempt to sanity check using knowledge of
the chip
- Read from the 8 channel addresses
- Check the top 4 bits of each result are not set (12 data bits)
*/
/*
* Now, we do the remaining detection. There is no identification
* dedicated register so attempt to sanity check using knowledge of
* the chip
* - Read from the 8 channel addresses
* - Check the top 4 bits of each result are not set (12 data bits)
*/
for (ch = 0; ch < ADS7828_NCH; ch++) {
u16 in_data;
u8 cmd = channel_cmd_byte(ch);
......
......@@ -34,9 +34,11 @@
#define REG_SER_CONTROL 24 /*Serial Interface Control Register*/
#define REG_ID 31 /*ID Register*/
/*From figure 17 in the datasheet
* These bits get ORed with the address to form
* the instruction byte */
/*
* From figure 17 in the datasheet
* These bits get ORed with the address to form
* the instruction byte
*/
/*Instruction Bit masks*/
#define INST_MODE_bm (1<<7)
#define INST_READ_bm (1<<6)
......@@ -105,8 +107,10 @@ static ssize_t show_voltage(struct device *dev,
uint8_t channel, mux_cnv;
channel = attr->index;
/*TODO: add support for conversions
*other than single ended with a gain of 1*/
/*
* TODO: add support for conversions
* other than single ended with a gain of 1
*/
/*MUX_M3_bm forces single ended*/
/*This is also where the gain of the PGA would be set*/
ads7871_write_reg8(spi, REG_GAIN_MUX,
......@@ -114,8 +118,10 @@ static ssize_t show_voltage(struct device *dev,
ret = ads7871_read_reg8(spi, REG_GAIN_MUX);
mux_cnv = ((ret & MUX_CNV_bm)>>MUX_CNV_bv);
/*on 400MHz arm9 platform the conversion
*is already done when we do this test*/
/*
* on 400MHz arm9 platform the conversion
* is already done when we do this test
*/
while ((i < 2) && mux_cnv) {
i++;
ret = ads7871_read_reg8(spi, REG_GAIN_MUX);
......@@ -179,8 +185,10 @@ static int __devinit ads7871_probe(struct spi_device *spi)
ret = ads7871_read_reg8(spi, REG_OSC_CONTROL);
dev_dbg(&spi->dev, "REG_OSC_CONTROL write:%x, read:%x\n", val, ret);
/*because there is no other error checking on an SPI bus
we need to make sure we really have a chip*/
/*
* because there is no other error checking on an SPI bus
* we need to make sure we really have a chip
*/
if (val != ret) {
err = -ENODEV;
goto exit;
......@@ -234,18 +242,7 @@ static struct spi_driver ads7871_driver = {
.remove = __devexit_p(ads7871_remove),
};
static int __init ads7871_init(void)
{
return spi_register_driver(&ads7871_driver);
}
static void __exit ads7871_exit(void)
{
spi_unregister_driver(&ads7871_driver);
}
module_init(ads7871_init);
module_exit(ads7871_exit);
module_spi_driver(ads7871_driver);
MODULE_AUTHOR("Paul Thomas <pthomas8589@gmail.com>");
MODULE_DESCRIPTION("TI ADS7871 A/D driver");
......
......@@ -8,7 +8,7 @@
* published by the Free Software Foundation.
*
* TODO: SPI, support for external temperature sensor
* use power-down mode for suspend?, interrupt handling?
* use power-down mode for suspend?, interrupt handling?
*/
#include <linux/kernel.h>
......@@ -348,17 +348,7 @@ static struct i2c_driver adt7411_driver = {
.class = I2C_CLASS_HWMON,
};
static int __init sensors_adt7411_init(void)
{
return i2c_add_driver(&adt7411_driver);
}
module_init(sensors_adt7411_init)
static void __exit sensors_adt7411_exit(void)
{
i2c_del_driver(&adt7411_driver);
}
module_exit(sensors_adt7411_exit)
module_i2c_driver(adt7411_driver);
MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de> and "
"Wolfram Sang <w.sang@pengutronix.de>");
......
......@@ -65,8 +65,8 @@ static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END };
#define ADT7462_REG_PWM_TEMP_MIN_MAX_ADDR 0x5F
#define ADT7462_REG_PWM_TEMP_RANGE_BASE_ADDR 0x60
#define ADT7462_REG_PWM_TEMP_RANGE_MAX_ADDR 0x63
#define ADT7462_PWM_HYST_MASK 0x0F
#define ADT7462_PWM_RANGE_MASK 0xF0
#define ADT7462_PWM_HYST_MASK 0x0F
#define ADT7462_PWM_RANGE_MASK 0xF0
#define ADT7462_PWM_RANGE_SHIFT 4
#define ADT7462_REG_PWM_CFG_BASE_ADDR 0x21
#define ADT7462_REG_PWM_CFG_MAX_ADDR 0x24
......@@ -85,7 +85,7 @@ static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END };
#define ADT7462_PIN15_INPUT 0x20
#define ADT7462_PIN13_INPUT 0x40
#define ADT7462_PIN8_INPUT 0x80
#define ADT7462_PIN23_MASK 0x03
#define ADT7462_PIN23_MASK 0x03
#define ADT7462_PIN23_SHIFT 0
#define ADT7462_PIN26_MASK 0x0C /* cfg2 */
#define ADT7462_PIN26_SHIFT 2
......@@ -99,7 +99,7 @@ static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END };
#define ADT7462_PIN28_VOLT 0x5
#define ADT7462_REG_ALARM1 0xB8
#define ADT7462_LT_ALARM 0x02
#define ADT7462_LT_ALARM 0x02
#define ADT7462_R1T_ALARM 0x04
#define ADT7462_R2T_ALARM 0x08
#define ADT7462_R3T_ALARM 0x10
......@@ -135,9 +135,9 @@ static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END };
#define ADT7462_ALARM_FLAG_MASK 0x0F
#define ADT7462_TEMP_COUNT 4
#define ADT7462_TEMP_REG(x) (ADT7462_REG_TEMP_BASE_ADDR + (x * 2))
#define ADT7462_TEMP_MIN_REG(x) (ADT7462_REG_MIN_TEMP_BASE_ADDR + (x))
#define ADT7462_TEMP_MAX_REG(x) (ADT7462_REG_MAX_TEMP_BASE_ADDR + (x))
#define ADT7462_TEMP_REG(x) (ADT7462_REG_TEMP_BASE_ADDR + ((x) * 2))
#define ADT7462_TEMP_MIN_REG(x) (ADT7462_REG_MIN_TEMP_BASE_ADDR + (x))
#define ADT7462_TEMP_MAX_REG(x) (ADT7462_REG_MAX_TEMP_BASE_ADDR + (x))
#define TEMP_FRAC_OFFSET 6
#define ADT7462_FAN_COUNT 8
......@@ -1727,8 +1727,7 @@ static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp, S_IWUSR | S_IRUGO,
static SENSOR_DEVICE_ATTR(pwm4_auto_channels_temp, S_IWUSR | S_IRUGO,
show_pwm_auto_temp, set_pwm_auto_temp, 3);
static struct attribute *adt7462_attr[] =
{
static struct attribute *adt7462_attr[] = {
&sensor_dev_attr_temp1_max.dev_attr.attr,
&sensor_dev_attr_temp2_max.dev_attr.attr,
&sensor_dev_attr_temp3_max.dev_attr.attr,
......@@ -1975,19 +1974,8 @@ static int adt7462_remove(struct i2c_client *client)
return 0;
}
static int __init adt7462_init(void)
{
return i2c_add_driver(&adt7462_driver);
}
static void __exit adt7462_exit(void)
{
i2c_del_driver(&adt7462_driver);
}
module_i2c_driver(adt7462_driver);
MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>");
MODULE_DESCRIPTION("ADT7462 driver");
MODULE_LICENSE("GPL");
module_init(adt7462_init);
module_exit(adt7462_exit);
......@@ -1131,8 +1131,7 @@ static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp, S_IWUSR | S_IRUGO,
static SENSOR_DEVICE_ATTR(pwm4_auto_channels_temp, S_IWUSR | S_IRUGO,
show_pwm_auto_temp, set_pwm_auto_temp, 3);
static struct attribute *adt7470_attr[] =
{
static struct attribute *adt7470_attr[] = {
&dev_attr_alarm_mask.attr,
&dev_attr_num_temp_sensors.attr,
&dev_attr_auto_update_interval.attr,
......@@ -1276,7 +1275,8 @@ static int adt7470_probe(struct i2c_client *client,
/* Register sysfs hooks */
data->attrs.attrs = adt7470_attr;
if ((err = sysfs_create_group(&client->dev.kobj, &data->attrs)))
err = sysfs_create_group(&client->dev.kobj, &data->attrs);
if (err)
goto exit_free;
data->hwmon_dev = hwmon_device_register(&client->dev);
......@@ -1317,19 +1317,8 @@ static int adt7470_remove(struct i2c_client *client)
return 0;
}
static int __init adt7470_init(void)
{
return i2c_add_driver(&adt7470_driver);
}
static void __exit adt7470_exit(void)
{
i2c_del_driver(&adt7470_driver);
}
module_i2c_driver(adt7470_driver);
MODULE_AUTHOR("Darrick J. Wong <djwong@us.ibm.com>");
MODULE_DESCRIPTION("ADT7470 driver");
MODULE_LICENSE("GPL");
module_init(adt7470_init);
module_exit(adt7470_exit);
......@@ -32,9 +32,10 @@
#define THERM 5
#define HYSTERSIS 6
/* These are unique identifiers for the sysfs functions - unlike the
numbers above, these are not also indexes into an array
*/
/*
* These are unique identifiers for the sysfs functions - unlike the
* numbers above, these are not also indexes into an array
*/
#define ALARM 9
#define FAULT 10
......@@ -288,8 +289,10 @@ static void adt7475_write_word(struct i2c_client *client, int reg, u16 val)
i2c_smbus_write_byte_data(client, reg, val & 0xFF);
}
/* Find the nearest value in a table - used for pwm frequency and
auto temp range */
/*
* Find the nearest value in a table - used for pwm frequency and
* auto temp range
*/
static int find_nearest(long val, const int *array, int size)
{
int i;
......@@ -385,16 +388,20 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
out = (out >> 4) & 0xF;
else
out = (out & 0xF);
/* Show the value as an absolute number tied to
* THERM */
/*
* Show the value as an absolute number tied to
* THERM
*/
out = reg2temp(data, data->temp[THERM][sattr->index]) -
out * 1000;
mutex_unlock(&data->lock);
break;
case OFFSET:
/* Offset is always 2's complement, regardless of the
* setting in CONFIG5 */
/*
* Offset is always 2's complement, regardless of the
* setting in CONFIG5
*/
mutex_lock(&data->lock);
out = (s8)data->temp[sattr->nr][sattr->index];
if (data->config5 & CONFIG5_TEMPOFFSET)
......@@ -452,8 +459,10 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr,
break;
case HYSTERSIS:
/* The value will be given as an absolute value, turn it
into an offset based on THERM */
/*
* The value will be given as an absolute value, turn it
* into an offset based on THERM
*/
/* Read fresh THERM and HYSTERSIS values from the chip */
data->temp[THERM][sattr->index] =
......@@ -478,8 +487,10 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr,
default:
data->temp[sattr->nr][sattr->index] = temp2reg(data, val);
/* We maintain an extra 2 digits of precision for simplicity
* - shift those back off before writing the value */
/*
* We maintain an extra 2 digits of precision for simplicity
* - shift those back off before writing the value
*/
out = (u8) (data->temp[sattr->nr][sattr->index] >> 2);
}
......@@ -514,8 +525,10 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *attr,
return count;
}
/* Table of autorange values - the user will write the value in millidegrees,
and we'll convert it */
/*
* Table of autorange values - the user will write the value in millidegrees,
* and we'll convert it
*/
static const int autorange_table[] = {
2000, 2500, 3330, 4000, 5000, 6670, 8000,
10000, 13330, 16000, 20000, 26670, 32000, 40000,
......@@ -558,8 +571,10 @@ static ssize_t set_point2(struct device *dev, struct device_attribute *attr,
data->range[sattr->index] =
adt7475_read(TEMP_TRANGE_REG(sattr->index));
/* The user will write an absolute value, so subtract the start point
to figure the range */
/*
* The user will write an absolute value, so subtract the start point
* to figure the range
*/
temp = reg2temp(data, data->temp[AUTOMIN][sattr->index]);
val = SENSORS_LIMIT(val, temp + autorange_table[0],
temp + autorange_table[ARRAY_SIZE(autorange_table) - 1]);
......@@ -664,8 +679,10 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
data->pwm[CONTROL][sattr->index] =
adt7475_read(PWM_CONFIG_REG(sattr->index));
/* If we are not in manual mode, then we shouldn't allow
* the user to set the pwm speed */
/*
* If we are not in manual mode, then we shouldn't allow
* the user to set the pwm speed
*/
if (((data->pwm[CONTROL][sattr->index] >> 5) & 7) != 7) {
mutex_unlock(&data->lock);
return count;
......@@ -1232,7 +1249,7 @@ static void adt7475_remove_files(struct i2c_client *client,
static int adt7475_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
static const char *names[] = {
static const char * const names[] = {
[adt7473] = "ADT7473",
[adt7475] = "ADT7475",
[adt7476] = "ADT7476",
......@@ -1280,9 +1297,11 @@ static int adt7475_probe(struct i2c_client *client,
if ((data->config4 & CONFIG4_PINFUNC) == 0x0)
data->has_fan4 = 1;
/* THERM configuration is more complex on the ADT7476 and ADT7490,
because 2 different pins (TACH4 and +2.5 Vin) can be used for
this function */
/*
* THERM configuration is more complex on the ADT7476 and ADT7490,
* because 2 different pins (TACH4 and +2.5 Vin) can be used for
* this function
*/
if (id->driver_data == adt7490) {
if ((data->config4 & CONFIG4_PINFUNC) == 0x1 &&
!(config3 & CONFIG3_THERM))
......@@ -1294,8 +1313,10 @@ static int adt7475_probe(struct i2c_client *client,
data->has_voltage |= (1 << 0); /* in0 */
}
/* On the ADT7476, the +12V input pin may instead be used as VID5,
and VID pins may alternatively be used as GPIO */
/*
* On the ADT7476, the +12V input pin may instead be used as VID5,
* and VID pins may alternatively be used as GPIO
*/
if (id->driver_data == adt7476) {
u8 vid = adt7475_read(REG_VID);
if (!(vid & VID_VIDSEL))
......@@ -1314,8 +1335,10 @@ static int adt7475_probe(struct i2c_client *client,
}
data->bypass_attn &= data->has_voltage;
/* Call adt7475_read_pwm for all pwm's as this will reprogram any
pwm's which are disabled to manual mode with 0% duty cycle */
/*
* Call adt7475_read_pwm for all pwm's as this will reprogram any
* pwm's which are disabled to manual mode with 0% duty cycle
*/
for (i = 0; i < ADT7475_PWM_COUNT; i++)
adt7475_read_pwm(client, i);
......@@ -1431,8 +1454,10 @@ static void adt7475_read_pwm(struct i2c_client *client, int index)
data->pwm[CONTROL][index] = adt7475_read(PWM_CONFIG_REG(index));
/* Figure out the internal value for pwmctrl and pwmchan
based on the current settings */
/*
* Figure out the internal value for pwmctrl and pwmchan
* based on the current settings
*/
v = (data->pwm[CONTROL][index] >> 5) & 7;
if (v == 3)
......@@ -1440,10 +1465,11 @@ static void adt7475_read_pwm(struct i2c_client *client, int index)
else if (v == 7)
data->pwmctl[index] = 1;
else if (v == 4) {
/* The fan is disabled - we don't want to
support that, so change to manual mode and
set the duty cycle to 0 instead
*/
/*
* The fan is disabled - we don't want to
* support that, so change to manual mode and
* set the duty cycle to 0 instead
*/
data->pwm[INPUT][index] = 0;
data->pwm[CONTROL][index] &= ~0xE0;
data->pwm[CONTROL][index] |= (7 << 5);
......@@ -1600,19 +1626,8 @@ static struct adt7475_data *adt7475_update_device(struct device *dev)
return data;
}
static int __init sensors_adt7475_init(void)
{
return i2c_add_driver(&adt7475_driver);
}
static void __exit sensors_adt7475_exit(void)
{
i2c_del_driver(&adt7475_driver);
}
module_i2c_driver(adt7475_driver);
MODULE_AUTHOR("Advanced Micro Devices, Inc");
MODULE_DESCRIPTION("adt7475 driver");
MODULE_LICENSE("GPL");
module_init(sensors_adt7475_init);
module_exit(sensors_adt7475_exit);
/*
amc6821.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Copyright (C) 2009 T. Mertelj <tomaz.mertelj@guest.arnes.si>
Based on max6650.c:
Copyright (C) 2007 Hans J. Koch <hjk@hansjkoch.de>
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.
*/
* amc6821.c - Part of lm_sensors, Linux kernel modules for hardware
* monitoring
* Copyright (C) 2009 T. Mertelj <tomaz.mertelj@guest.arnes.si>
*
* Based on max6650.c:
* Copyright (C) 2007 Hans J. Koch <hjk@hansjkoch.de>
*
* 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.
*/
#include <linux/kernel.h> /* Needed for KERN_INFO */
......@@ -47,7 +47,7 @@ static const unsigned short normal_i2c[] = {0x18, 0x19, 0x1a, 0x2c, 0x2d, 0x2e,
* Insmod parameters
*/
static int pwminv = 0; /*Inverted PWM output. */
static int pwminv; /*Inverted PWM output. */
module_param(pwminv, int, S_IRUGO);
static int init = 1; /*Power-on initialization.*/
......@@ -188,7 +188,7 @@ static struct i2c_driver amc6821_driver = {
/*
* Client data (each client gets its own)
*/
*/
struct amc6821_data {
struct device *hwmon_dev;
......@@ -836,8 +836,10 @@ static int amc6821_detect(
return -ENODEV;
}
/* Bit 7 of the address register is ignored, so we can check the
ID registers again */
/*
* Bit 7 of the address register is ignored, so we can check the
* ID registers again
*/
dev_id = i2c_smbus_read_byte_data(client, 0x80 | AMC6821_REG_DEV_ID);
comp_id = i2c_smbus_read_byte_data(client, 0x80 | AMC6821_REG_COMP_ID);
if (dev_id != 0x21 || comp_id != 0x49) {
......@@ -1080,9 +1082,10 @@ static struct amc6821_data *amc6821_update_device(struct device *dev)
data->pwm1_auto_channels_temp = 3;
data->pwm1_enable = 3;
break;
case 1: /*semi-open loop: software sets rpm, chip controls pwm1,
*currently not implemented
*/
case 1: /*
* semi-open loop: software sets rpm, chip controls
* pwm1, currently not implemented
*/
data->pwm1_auto_channels_temp = 0;
data->pwm1_enable = 0;
break;
......@@ -1095,20 +1098,7 @@ static struct amc6821_data *amc6821_update_device(struct device *dev)
return data;
}
static int __init amc6821_init(void)
{
return i2c_add_driver(&amc6821_driver);
}
static void __exit amc6821_exit(void)
{
i2c_del_driver(&amc6821_driver);
}
module_init(amc6821_init);
module_exit(amc6821_exit);
module_i2c_driver(amc6821_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("T. Mertelj <tomaz.mertelj@guest.arnes.si>");
......
......@@ -344,8 +344,10 @@ static int applesmc_get_lower_bound(unsigned int *lo, const char *key)
while (begin != end) {
int middle = begin + (end - begin) / 2;
entry = applesmc_get_entry_by_index(middle);
if (IS_ERR(entry))
if (IS_ERR(entry)) {
*lo = 0;
return PTR_ERR(entry);
}
if (strcmp(entry->key, key) < 0)
begin = middle + 1;
else
......@@ -364,8 +366,10 @@ static int applesmc_get_upper_bound(unsigned int *hi, const char *key)
while (begin != end) {
int middle = begin + (end - begin) / 2;
entry = applesmc_get_entry_by_index(middle);
if (IS_ERR(entry))
if (IS_ERR(entry)) {
*hi = smcreg.key_count;
return PTR_ERR(entry);
}
if (strcmp(key, entry->key) < 0)
end = middle;
else
......@@ -1189,8 +1193,10 @@ static int applesmc_dmi_match(const struct dmi_system_id *id)
return 1;
}
/* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
* So we need to put "Apple MacBook Pro" before "Apple MacBook". */
/*
* Note that DMI_MATCH(...,"MacBook") will match "MacBookPro1,1".
* So we need to put "Apple MacBook Pro" before "Apple MacBook".
*/
static __initdata struct dmi_system_id applesmc_whitelist[] = {
{ applesmc_dmi_match, "Apple MacBook Air", {
DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
......
/*
asb100.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Copyright (C) 2004 Mark M. Hoffman <mhoffman@lightlink.com>
(derived from w83781d.c)
Copyright (C) 1998 - 2003 Frodo Looijaard <frodol@dds.nl>,
Philip Edelbrock <phil@netroedge.com>, and
Mark Studebaker <mdsxyz123@yahoo.com>
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.
*/
* asb100.c - Part of lm_sensors, Linux kernel modules for hardware
* monitoring
*
* Copyright (C) 2004 Mark M. Hoffman <mhoffman@lightlink.com>
*
* (derived from w83781d.c)
*
* Copyright (C) 1998 - 2003 Frodo Looijaard <frodol@dds.nl>,
* Philip Edelbrock <phil@netroedge.com>, and
* Mark Studebaker <mdsxyz123@yahoo.com>
*
* 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.
*/
/*
This driver supports the hardware sensor chips: Asus ASB100 and
ASB100-A "BACH".
ASB100-A supports pwm1, while plain ASB100 does not. There is no known
way for the driver to tell which one is there.
Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
asb100 7 3 1 4 0x31 0x0694 yes no
*/
* This driver supports the hardware sensor chips: Asus ASB100 and
* ASB100-A "BACH".
*
* ASB100-A supports pwm1, while plain ASB100 does not. There is no known
* way for the driver to tell which one is there.
*
* Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
* asb100 7 3 1 4 0x31 0x0694 yes no
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
......@@ -99,15 +99,19 @@ static const u16 asb100_reg_temp_hyst[] = {0, 0x3a, 0x153, 0x253, 0x19};
/* bit 7 -> enable, bits 0-3 -> duty cycle */
#define ASB100_REG_PWM1 0x59
/* CONVERSIONS
Rounding and limit checking is only done on the TO_REG variants. */
/*
* CONVERSIONS
* Rounding and limit checking is only done on the TO_REG variants.
*/
/* These constants are a guess, consistent w/ w83781d */
#define ASB100_IN_MIN ( 0)
#define ASB100_IN_MAX (4080)
#define ASB100_IN_MIN 0
#define ASB100_IN_MAX 4080
/* IN: 1/1000 V (0V to 4.08V)
REG: 16mV/bit */
/*
* IN: 1/1000 V (0V to 4.08V)
* REG: 16mV/bit
*/
static u8 IN_TO_REG(unsigned val)
{
unsigned nval = SENSORS_LIMIT(val, ASB100_IN_MIN, ASB100_IN_MAX);
......@@ -131,19 +135,21 @@ static u8 FAN_TO_REG(long rpm, int div)
static int FAN_FROM_REG(u8 val, int div)
{
return val==0 ? -1 : val==255 ? 0 : 1350000/(val*div);
return val == 0 ? -1 : val == 255 ? 0 : 1350000 / (val * div);
}
/* These constants are a guess, consistent w/ w83781d */
#define ASB100_TEMP_MIN (-128000)
#define ASB100_TEMP_MAX ( 127000)
#define ASB100_TEMP_MIN -128000
#define ASB100_TEMP_MAX 127000
/* TEMP: 0.001C/bit (-128C to +127C)
REG: 1C/bit, two's complement */
/*
* TEMP: 0.001C/bit (-128C to +127C)
* REG: 1C/bit, two's complement
*/
static u8 TEMP_TO_REG(long temp)
{
int ntemp = SENSORS_LIMIT(temp, ASB100_TEMP_MIN, ASB100_TEMP_MAX);
ntemp += (ntemp<0 ? -500 : 500);
ntemp += (ntemp < 0 ? -500 : 500);
return (u8)(ntemp / 1000);
}
......@@ -152,8 +158,10 @@ static int TEMP_FROM_REG(u8 reg)
return (s8)reg * 1000;
}
/* PWM: 0 - 255 per sensors documentation
REG: (6.25% duty cycle per bit) */
/*
* PWM: 0 - 255 per sensors documentation
* REG: (6.25% duty cycle per bit)
*/
static u8 ASB100_PWM_TO_REG(int pwm)
{
pwm = SENSORS_LIMIT(pwm, 0, 255);
......@@ -167,16 +175,20 @@ static int ASB100_PWM_FROM_REG(u8 reg)
#define DIV_FROM_REG(val) (1 << (val))
/* FAN DIV: 1, 2, 4, or 8 (defaults to 2)
REG: 0, 1, 2, or 3 (respectively) (defaults to 1) */
/*
* FAN DIV: 1, 2, 4, or 8 (defaults to 2)
* REG: 0, 1, 2, or 3 (respectively) (defaults to 1)
*/
static u8 DIV_TO_REG(long val)
{
return val==8 ? 3 : val==4 ? 2 : val==1 ? 0 : 1;
return val == 8 ? 3 : val == 4 ? 2 : val == 1 ? 0 : 1;
}
/* For each registered client, we need to keep some data in memory. That
data is pointed to by client->data. The structure itself is
dynamically allocated, at the same time the client itself is allocated. */
/*
* For each registered client, we need to keep some data in memory. That
* data is pointed to by client->data. The structure itself is
* dynamically allocated, at the same time the client itself is allocated.
*/
struct asb100_data {
struct device *hwmon_dev;
struct mutex lock;
......@@ -253,8 +265,10 @@ static ssize_t set_in_##reg(struct device *dev, struct device_attribute *attr, \
int nr = to_sensor_dev_attr(attr)->index; \
struct i2c_client *client = to_i2c_client(dev); \
struct asb100_data *data = i2c_get_clientdata(client); \
unsigned long val = simple_strtoul(buf, NULL, 10); \
\
unsigned long val; \
int err = kstrtoul(buf, 10, &val); \
if (err) \
return err; \
mutex_lock(&data->update_lock); \
data->in_##reg[nr] = IN_TO_REG(val); \
asb100_write_value(client, ASB100_REG_IN_##REG(nr), \
......@@ -315,7 +329,12 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
int nr = to_sensor_dev_attr(attr)->index;
struct i2c_client *client = to_i2c_client(dev);
struct asb100_data *data = i2c_get_clientdata(client);
u32 val = simple_strtoul(buf, NULL, 10);
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
......@@ -324,10 +343,12 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
return count;
}
/* Note: we save and restore the fan minimum here, because its value is
determined in part by the fan divisor. This follows the principle of
least surprise; the user doesn't expect the fan minimum to change just
because the divisor changed. */
/*
* Note: we save and restore the fan minimum here, because its value is
* determined in part by the fan divisor. This follows the principle of
* least surprise; the user doesn't expect the fan minimum to change just
* because the divisor changed.
*/
static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
......@@ -335,8 +356,13 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
struct i2c_client *client = to_i2c_client(dev);
struct asb100_data *data = i2c_get_clientdata(client);
unsigned long min;
unsigned long val = simple_strtoul(buf, NULL, 10);
int reg;
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
......@@ -421,8 +447,10 @@ static ssize_t set_##reg(struct device *dev, struct device_attribute *attr, \
int nr = to_sensor_dev_attr(attr)->index; \
struct i2c_client *client = to_i2c_client(dev); \
struct asb100_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
long val; \
int err = kstrtol(buf, 10, &val); \
if (err) \
return err; \
mutex_lock(&data->update_lock); \
switch (nr) { \
case 1: case 2: \
......@@ -476,7 +504,13 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct asb100_data *data = dev_get_drvdata(dev);
data->vrm = simple_strtoul(buf, NULL, 10);
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
data->vrm = val;
return count;
}
......@@ -524,7 +558,12 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr,
{
struct i2c_client *client = to_i2c_client(dev);
struct asb100_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->pwm &= 0x80; /* keep the enable bit */
......@@ -546,7 +585,12 @@ static ssize_t set_pwm_enable1(struct device *dev,
{
struct i2c_client *client = to_i2c_client(dev);
struct asb100_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
unsigned long val;
int err;
err = kstrtoul(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->pwm &= 0x0f; /* keep the duty cycle bits */
......@@ -768,7 +812,8 @@ static int asb100_probe(struct i2c_client *client,
data->fan_min[2] = asb100_read_value(client, ASB100_REG_FAN_MIN(2));
/* Register sysfs hooks */
if ((err = sysfs_create_group(&client->dev.kobj, &asb100_group)))
err = sysfs_create_group(&client->dev.kobj, &asb100_group);
if (err)
goto ERROR3;
data->hwmon_dev = hwmon_device_register(&client->dev);
......@@ -805,8 +850,10 @@ static int asb100_remove(struct i2c_client *client)
return 0;
}
/* The SMBus locks itself, usually, but nothing may access the chip between
bank switches. */
/*
* The SMBus locks itself, usually, but nothing may access the chip between
* bank switches.
*/
static int asb100_read_value(struct i2c_client *client, u16 reg)
{
struct asb100_data *data = i2c_get_clientdata(client);
......@@ -971,19 +1018,8 @@ static struct asb100_data *asb100_update_device(struct device *dev)
return data;
}
static int __init asb100_init(void)
{
return i2c_add_driver(&asb100_driver);
}
static void __exit asb100_exit(void)
{
i2c_del_driver(&asb100_driver);
}
module_i2c_driver(asb100_driver);
MODULE_AUTHOR("Mark M. Hoffman <mhoffman@lightlink.com>");
MODULE_DESCRIPTION("ASB100 Bach driver");
MODULE_LICENSE("GPL");
module_init(asb100_init);
module_exit(asb100_exit);
......@@ -268,9 +268,11 @@ static ssize_t store_fan16(struct device *dev,
if (kstrtol(buf, 10, &reqval))
return -EINVAL;
/* If a minimum RPM of zero is requested, then we set the register to
0xffff. This value allows the fan to be stopped completely without
generating an alarm. */
/*
* If a minimum RPM of zero is requested, then we set the register to
* 0xffff. This value allows the fan to be stopped completely without
* generating an alarm.
*/
reqval =
(reqval <= 0 ? 0xffff : SENSORS_LIMIT(5400000 / reqval, 0, 0xfffe));
......
......@@ -38,7 +38,8 @@ static const struct dmi_system_id __initconst atk_force_new_if[] = {
{ }
};
/* Minimum time between readings, enforced in order to avoid
/*
* Minimum time between readings, enforced in order to avoid
* hogging the CPU.
*/
#define CACHE_TIME HZ
......@@ -161,7 +162,8 @@ struct atk_sensor_data {
char const *acpi_name;
};
/* Return buffer format:
/*
* Return buffer format:
* [0-3] "value" is valid flag
* [4-7] value
* [8- ] unknown stuff on newer mobos
......@@ -310,7 +312,8 @@ static union acpi_object *atk_get_pack_member(struct atk_data *data,
}
/* New package format is:
/*
* New package format is:
* - flag (int)
* class - used for de-muxing the request to the correct GITn
* type (volt, temp, fan)
......@@ -613,7 +616,8 @@ static int atk_read_value_new(struct atk_sensor_data *sensor, u64 *value)
buf = (struct atk_acpi_ret_buffer *)obj->buffer.pointer;
if (buf->flags == 0) {
/* The reading is not valid, possible causes:
/*
* The reading is not valid, possible causes:
* - sensor failure
* - enumeration was FUBAR (and we didn't notice)
*/
......@@ -1311,14 +1315,16 @@ static int atk_probe_if(struct atk_data *data)
dev_dbg(dev, "method " METHOD_WRITE " not found: %s\n",
acpi_format_exception(status));
/* Check for hwmon methods: first check "old" style methods; note that
/*
* Check for hwmon methods: first check "old" style methods; note that
* both may be present: in this case we stick to the old interface;
* analysis of multiple DSDTs indicates that when both interfaces
* are present the new one (GGRP/GITM) is not functional.
*/
if (new_if)
dev_info(dev, "Overriding interface detection\n");
if (data->rtmp_handle && data->rvlt_handle && data->rfan_handle && !new_if)
if (data->rtmp_handle &&
data->rvlt_handle && data->rfan_handle && !new_if)
data->old_interface = true;
else if (data->enumerate_handle && data->read_handle &&
data->write_handle)
......
/*
atxp1.c - kernel module for setting CPU VID and general purpose
I/Os using the Attansic ATXP1 chip.
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.
*/
* atxp1.c - kernel module for setting CPU VID and general purpose
* I/Os using the Attansic ATXP1 chip.
*
* 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.
*
*/
#include <linux/kernel.h>
#include <linux/init.h>
......@@ -48,7 +48,7 @@ static const unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END };
static int atxp1_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int atxp1_remove(struct i2c_client *client);
static struct atxp1_data * atxp1_update_device(struct device *dev);
static struct atxp1_data *atxp1_update_device(struct device *dev);
static int atxp1_detect(struct i2c_client *client, struct i2c_board_info *info);
static const struct i2c_device_id atxp1_id[] = {
......@@ -83,7 +83,7 @@ struct atxp1_data {
u8 vrm; /* Detected CPU VRM */
};
static struct atxp1_data * atxp1_update_device(struct device *dev)
static struct atxp1_data *atxp1_update_device(struct device *dev)
{
struct i2c_client *client;
struct atxp1_data *data;
......@@ -97,7 +97,8 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
/* Update local register data */
data->reg.vid = i2c_smbus_read_byte_data(client, ATXP1_VID);
data->reg.cpu_vid = i2c_smbus_read_byte_data(client, ATXP1_CVID);
data->reg.cpu_vid = i2c_smbus_read_byte_data(client,
ATXP1_CVID);
data->reg.gpio1 = i2c_smbus_read_byte_data(client, ATXP1_GPIO1);
data->reg.gpio2 = i2c_smbus_read_byte_data(client, ATXP1_GPIO2);
......@@ -106,33 +107,41 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
mutex_unlock(&data->update_lock);
return(data);
return data;
}
/* sys file functions for cpu0_vid */
static ssize_t atxp1_showvcore(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t atxp1_showvcore(struct device *dev,
struct device_attribute *attr, char *buf)
{
int size;
struct atxp1_data *data;
data = atxp1_update_device(dev);
size = sprintf(buf, "%d\n", vid_from_reg(data->reg.vid & ATXP1_VIDMASK, data->vrm));
size = sprintf(buf, "%d\n", vid_from_reg(data->reg.vid & ATXP1_VIDMASK,
data->vrm));
return size;
}
static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
static ssize_t atxp1_storevcore(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct atxp1_data *data;
struct i2c_client *client;
int vid, cvid;
unsigned int vcore;
unsigned long vcore;
int err;
client = to_i2c_client(dev);
data = atxp1_update_device(dev);
vcore = simple_strtoul(buf, NULL, 10);
err = kstrtoul(buf, 10, &vcore);
if (err)
return err;
vcore /= 25;
vcore *= 25;
......@@ -144,7 +153,10 @@ static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *att
return -1;
}
/* If output enabled, use control register value. Otherwise original CPU VID */
/*
* If output enabled, use control register value.
* Otherwise original CPU VID
*/
if (data->reg.vid & ATXP1_VIDENA)
cvid = data->reg.vid & ATXP1_VIDMASK;
else
......@@ -154,18 +166,17 @@ static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *att
if (vid == cvid)
return count;
dev_dbg(dev, "Setting VCore to %d mV (0x%02x)\n", vcore, vid);
dev_dbg(dev, "Setting VCore to %d mV (0x%02x)\n", (int)vcore, vid);
/* Write every 25 mV step to increase stability */
if (cvid > vid) {
for (; cvid >= vid; cvid--) {
i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA);
}
}
else {
for (; cvid <= vid; cvid++) {
i2c_smbus_write_byte_data(client, ATXP1_VID, cvid | ATXP1_VIDENA);
}
for (; cvid >= vid; cvid--)
i2c_smbus_write_byte_data(client,
ATXP1_VID, cvid | ATXP1_VIDENA);
} else {
for (; cvid <= vid; cvid++)
i2c_smbus_write_byte_data(client,
ATXP1_VID, cvid | ATXP1_VIDENA);
}
data->valid = 0;
......@@ -173,13 +184,16 @@ static ssize_t atxp1_storevcore(struct device *dev, struct device_attribute *att
return count;
}
/* CPU core reference voltage
unit: millivolt
*/
static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore, atxp1_storevcore);
/*
* CPU core reference voltage
* unit: millivolt
*/
static DEVICE_ATTR(cpu0_vid, S_IRUGO | S_IWUSR, atxp1_showvcore,
atxp1_storevcore);
/* sys file functions for GPIO1 */
static ssize_t atxp1_showgpio1(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t atxp1_showgpio1(struct device *dev,
struct device_attribute *attr, char *buf)
{
int size;
struct atxp1_data *data;
......@@ -191,21 +205,26 @@ static ssize_t atxp1_showgpio1(struct device *dev, struct device_attribute *attr
return size;
}
static ssize_t atxp1_storegpio1(struct device *dev, struct device_attribute *attr, const char*buf, size_t count)
static ssize_t atxp1_storegpio1(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t count)
{
struct atxp1_data *data;
struct i2c_client *client;
unsigned int value;
unsigned long value;
int err;
client = to_i2c_client(dev);
data = atxp1_update_device(dev);
value = simple_strtoul(buf, NULL, 16);
err = kstrtoul(buf, 16, &value);
if (err)
return err;
value &= ATXP1_GPIO1MASK;
if (value != (data->reg.gpio1 & ATXP1_GPIO1MASK)) {
dev_info(dev, "Writing 0x%x to GPIO1.\n", value);
dev_info(dev, "Writing 0x%x to GPIO1.\n", (unsigned int)value);
i2c_smbus_write_byte_data(client, ATXP1_GPIO1, value);
......@@ -215,13 +234,15 @@ static ssize_t atxp1_storegpio1(struct device *dev, struct device_attribute *att
return count;
}
/* GPIO1 data register
unit: Four bit as hex (e.g. 0x0f)
*/
/*
* GPIO1 data register
* unit: Four bit as hex (e.g. 0x0f)
*/
static DEVICE_ATTR(gpio1, S_IRUGO | S_IWUSR, atxp1_showgpio1, atxp1_storegpio1);
/* sys file functions for GPIO2 */
static ssize_t atxp1_showgpio2(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t atxp1_showgpio2(struct device *dev,
struct device_attribute *attr, char *buf)
{
int size;
struct atxp1_data *data;
......@@ -233,19 +254,22 @@ static ssize_t atxp1_showgpio2(struct device *dev, struct device_attribute *attr
return size;
}
static ssize_t atxp1_storegpio2(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
static ssize_t atxp1_storegpio2(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct atxp1_data *data;
struct i2c_client *client;
unsigned int value;
client = to_i2c_client(dev);
data = atxp1_update_device(dev);
struct atxp1_data *data = atxp1_update_device(dev);
struct i2c_client *client = to_i2c_client(dev);
unsigned long value;
int err;
value = simple_strtoul(buf, NULL, 16) & 0xff;
err = kstrtoul(buf, 16, &value);
if (err)
return err;
value &= 0xff;
if (value != data->reg.gpio2) {
dev_info(dev, "Writing 0x%x to GPIO1.\n", value);
dev_info(dev, "Writing 0x%x to GPIO1.\n", (unsigned int)value);
i2c_smbus_write_byte_data(client, ATXP1_GPIO2, value);
......@@ -255,9 +279,10 @@ static ssize_t atxp1_storegpio2(struct device *dev, struct device_attribute *att
return count;
}
/* GPIO2 data register
unit: Eight bit as hex (e.g. 0xff)
*/
/*
* GPIO2 data register
* unit: Eight bit as hex (e.g. 0xff)
*/
static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2);
static struct attribute *atxp1_attributes[] = {
......@@ -290,8 +315,10 @@ static int atxp1_detect(struct i2c_client *new_client,
(i2c_smbus_read_byte_data(new_client, 0xff) == 0)))
return -ENODEV;
/* No vendor ID, now checking if registers 0x10,0x11 (non-existent)
* showing the same as register 0x00 */
/*
* No vendor ID, now checking if registers 0x10,0x11 (non-existent)
* showing the same as register 0x00
*/
temp = i2c_smbus_read_byte_data(new_client, 0x00);
if (!((i2c_smbus_read_byte_data(new_client, 0x10) == temp) &&
......@@ -333,7 +360,8 @@ static int atxp1_probe(struct i2c_client *new_client,
mutex_init(&data->update_lock);
/* Register sysfs hooks */
if ((err = sysfs_create_group(&new_client->dev.kobj, &atxp1_group)))
err = sysfs_create_group(&new_client->dev.kobj, &atxp1_group);
if (err)
goto exit_free;
data->hwmon_dev = hwmon_device_register(&new_client->dev);
......@@ -357,7 +385,7 @@ static int atxp1_probe(struct i2c_client *new_client,
static int atxp1_remove(struct i2c_client *client)
{
struct atxp1_data * data = i2c_get_clientdata(client);
struct atxp1_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &atxp1_group);
......@@ -367,15 +395,4 @@ static int atxp1_remove(struct i2c_client *client)
return 0;
};
static int __init atxp1_init(void)
{
return i2c_add_driver(&atxp1_driver);
};
static void __exit atxp1_exit(void)
{
i2c_del_driver(&atxp1_driver);
};
module_init(atxp1_init);
module_exit(atxp1_exit);
module_i2c_driver(atxp1_driver);
......@@ -58,8 +58,8 @@ MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
#define TOTAL_ATTRS (MAX_CORE_ATTRS + 1)
#define MAX_CORE_DATA (NUM_REAL_CORES + BASE_SYSFS_ATTR_NO)
#define TO_PHYS_ID(cpu) cpu_data(cpu).phys_proc_id
#define TO_CORE_ID(cpu) cpu_data(cpu).cpu_core_id
#define TO_PHYS_ID(cpu) (cpu_data(cpu).phys_proc_id)
#define TO_CORE_ID(cpu) (cpu_data(cpu).cpu_core_id)
#define TO_ATTR_NO(cpu) (TO_CORE_ID(cpu) + BASE_SYSFS_ATTR_NO)
#ifdef CONFIG_SMP
......
此差异已折叠。
/*
ds1621.c - Part of lm_sensors, Linux kernel modules for hardware
monitoring
Christian W. Zuckschwerdt <zany@triq.net> 2000-11-23
based on lm75.c by Frodo Looijaard <frodol@dds.nl>
Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with
the help of Jean Delvare <khali@linux-fr.org>
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.
*/
* ds1621.c - Part of lm_sensors, Linux kernel modules for hardware
* monitoring
* Christian W. Zuckschwerdt <zany@triq.net> 2000-11-23
* based on lm75.c by Frodo Looijaard <frodol@dds.nl>
* Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with
* the help of Jean Delvare <khali@linux-fr.org>
*
* 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.
*/
#include <linux/module.h>
#include <linux/init.h>
......@@ -67,7 +67,7 @@ static const u8 DS1621_REG_TEMP[3] = {
/* Conversions */
#define ALARMS_FROM_REG(val) ((val) & \
(DS1621_ALARM_TEMP_HIGH | DS1621_ALARM_TEMP_LOW))
(DS1621_ALARM_TEMP_HIGH | DS1621_ALARM_TEMP_LOW))
/* Each client has this additional data */
struct ds1621_data {
......@@ -93,10 +93,10 @@ static void ds1621_init_client(struct i2c_client *client)
new_conf &= ~DS1621_REG_CONFIG_POLARITY;
else if (polarity == 1)
new_conf |= DS1621_REG_CONFIG_POLARITY;
if (conf != new_conf)
i2c_smbus_write_byte_data(client, DS1621_REG_CONF, new_conf);
/* start conversion */
i2c_smbus_write_byte(client, DS1621_COM_START);
}
......@@ -155,10 +155,15 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct i2c_client *client = to_i2c_client(dev);
struct ds1621_data *data = i2c_get_clientdata(client);
u16 val = LM75_TEMP_TO_REG(simple_strtol(buf, NULL, 10));
long val;
int err;
err = kstrtol(buf, 10, &val);
if (err)
return err;
mutex_lock(&data->update_lock);
data->temp[attr->index] = val;
data->temp[attr->index] = LM75_TEMP_TO_REG(val);
i2c_smbus_write_word_swapped(client, DS1621_REG_TEMP[attr->index],
data->temp[attr->index]);
mutex_unlock(&data->update_lock);
......@@ -212,14 +217,17 @@ static int ds1621_detect(struct i2c_client *client,
int conf, temp;
int i;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA
| I2C_FUNC_SMBUS_WORD_DATA
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA
| I2C_FUNC_SMBUS_WORD_DATA
| I2C_FUNC_SMBUS_WRITE_BYTE))
return -ENODEV;
/* Now, we do the remaining detection. It is lousy. */
/* The NVB bit should be low if no EEPROM write has been requested
during the latest 10ms, which is highly improbable in our case. */
/*
* Now, we do the remaining detection. It is lousy.
*
* The NVB bit should be low if no EEPROM write has been requested
* during the latest 10ms, which is highly improbable in our case.
*/
conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF);
if (conf < 0 || conf & DS1621_REG_CONFIG_NVB)
return -ENODEV;
......@@ -254,7 +262,8 @@ static int ds1621_probe(struct i2c_client *client,
ds1621_init_client(client);
/* Register sysfs hooks */
if ((err = sysfs_create_group(&client->dev.kobj, &ds1621_group)))
err = sysfs_create_group(&client->dev.kobj, &ds1621_group);
if (err)
goto exit_free;
data->hwmon_dev = hwmon_device_register(&client->dev);
......@@ -265,11 +274,11 @@ static int ds1621_probe(struct i2c_client *client,
return 0;
exit_remove_files:
exit_remove_files:
sysfs_remove_group(&client->dev.kobj, &ds1621_group);
exit_free:
exit_free:
kfree(data);
exit:
exit:
return err;
}
......@@ -305,20 +314,8 @@ static struct i2c_driver ds1621_driver = {
.address_list = normal_i2c,
};
static int __init ds1621_init(void)
{
return i2c_add_driver(&ds1621_driver);
}
static void __exit ds1621_exit(void)
{
i2c_del_driver(&ds1621_driver);
}
module_i2c_driver(ds1621_driver);
MODULE_AUTHOR("Christian W. Zuckschwerdt <zany@triq.net>");
MODULE_DESCRIPTION("DS1621 driver");
MODULE_LICENSE("GPL");
module_init(ds1621_init);
module_exit(ds1621_exit);
......@@ -297,19 +297,8 @@ static struct i2c_driver ds620_driver = {
.id_table = ds620_id,
};
static int __init ds620_init(void)
{
return i2c_add_driver(&ds620_driver);
}
static void __exit ds620_exit(void)
{
i2c_del_driver(&ds620_driver);
}
module_i2c_driver(ds620_driver);
MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>");
MODULE_DESCRIPTION("DS620 driver");
MODULE_LICENSE("GPL");
module_init(ds620_init);
module_exit(ds620_exit);
此差异已折叠。
此差异已折叠。
......@@ -552,17 +552,7 @@ static struct i2c_driver emc6w201_driver = {
.address_list = normal_i2c,
};
static int __init sensors_emc6w201_init(void)
{
return i2c_add_driver(&emc6w201_driver);
}
module_init(sensors_emc6w201_init);
static void __exit sensors_emc6w201_exit(void)
{
i2c_del_driver(&emc6w201_driver);
}
module_exit(sensors_emc6w201_exit);
module_i2c_driver(emc6w201_driver);
MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>");
MODULE_DESCRIPTION("SMSC EMC6W201 hardware monitoring driver");
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册