Commit 161d2e0a authored by Linus Torvalds's avatar Linus Torvalds

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

Pull hwmon updates from Guenter Roeck:
 "Notable changes:

   - Heiko Schocher provided a driver for TI TMP103.
   - Kamil Debski provided a driver for pwm-controlled fans.
   - Neelesh Gupta provided a driver for power, fan rpm, voltage and
     temperature reporting on powerpc/powernv systems.
   - Scott Kanowitz provided a driver supporting Lattice's POWR1220
     power manager IC.
   - Richard Zhu provided a pmbus front-end driver for TPS40422.
   - Frans Klaver added support for TMP112 to the lm75 driver.
   - Johannes Pointner added support for EPCOS B57330V2103 to the
     ntc_thermistor driver.
   - Guenter Roeck added support for TMP441 and TMP442 to the tmp421
     driver.
   - Axel Lin converted several drivers to the new hwmon API (36 of
     them, if I counted correctly), and cleaned up many of the drivers
     along the way.

  There are also a number of patches fixing bugs discovered while
  testing Axel's changes"

* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (88 commits)
  hwmon: (g762) Use of_property_read_u32 at appropriate place
  hwmon: (sis5595) Prevent overflow problem when writing large limits
  hwmon: (gpio-fan) Prevent overflow problem when writing large limits
  hwmon: (ibmpowernv) Use of_property_read_u32 at appropriate place
  hwmon: (lm85) Convert to devm_hwmon_device_register_with_groups
  hwmon: (lm85) Avoid forward declaration
  hwmon: (lm78) Convert to devm_hwmon_device_register_with_groups
  hwmon: (max6697) Use of_property_read_bool at appropriate places
  hwmon: (pwm-fan) Make SENSORS_PWM_FAN depend on OF
  hwmon: (pwm-fan) Remove duplicate dev_set_drvdata call
  hwmon: (nct6775) Remove num_attr_groups from struct nct6775_data
  hwmon: (nct6775) Update module description and Kconfig for NCT6106D and NCT6791D
  hwmon: (adt7411) Convert to devm_hwmon_device_register_with_groups
  hwmon: (g762) Convert to hwmon_device_register_with_groups
  hwmon: (emc2103) Convert to devm_hwmon_device_register_with_groups
  hwmon: (smsc47m1) Avoid forward declaration
  hwmon: (smsc47m192) Convert to devm_hwmon_device_register_with_groups
  hwmon: (smsc47m192) Avoid forward declaration
  hwmon: (max1668) Make max1668_addr_list array const
  hwmon: (max6639) Make normal_i2c array const
  ...
parents c489d98c fce9626c
IBM POWERNV platform sensors
----------------------------
Required node properties:
- compatible: must be one of
"ibm,opal-sensor-cooling-fan"
"ibm,opal-sensor-amb-temp"
"ibm,opal-sensor-power-supply"
"ibm,opal-sensor-power"
- sensor-id: an opaque id provided by the firmware to the kernel, identifies a
given sensor and its attribute data
Example sensors node:
cooling-fan#8-data {
sensor-id = <0x7052107>;
compatible = "ibm,opal-sensor-cooling-fan";
};
amb-temp#1-thrs {
sensor-id = <0x5096000>;
compatible = "ibm,opal-sensor-amb-temp";
};
...@@ -3,6 +3,7 @@ NTC Thermistor hwmon sensors ...@@ -3,6 +3,7 @@ NTC Thermistor hwmon sensors
Requires node properties: Requires node properties:
- "compatible" value : one of - "compatible" value : one of
"epcos,b57330v2103"
"murata,ncp15wb473" "murata,ncp15wb473"
"murata,ncp18wb473" "murata,ncp18wb473"
"murata,ncp21wb473" "murata,ncp21wb473"
......
Bindings for a fan connected to the PWM lines
Required properties:
- compatible : "pwm-fan"
- pwms : the PWM that is used to control the PWM fan
Example:
pwm-fan {
compatible = "pwm-fan";
status = "okay";
pwms = <&pwm 0 10000 0>;
};
...@@ -84,5 +84,6 @@ stm,m41t80 M41T80 - SERIAL ACCESS RTC WITH ALARMS ...@@ -84,5 +84,6 @@ stm,m41t80 M41T80 - SERIAL ACCESS RTC WITH ALARMS
taos,tsl2550 Ambient Light Sensor with SMBUS/Two Wire Serial Interface taos,tsl2550 Ambient Light Sensor with SMBUS/Two Wire Serial Interface
ti,tsc2003 I2C Touch-Screen Controller ti,tsc2003 I2C Touch-Screen Controller
ti,tmp102 Low Power Digital Temperature Sensor with SMBUS/Two Wire Serial Interface ti,tmp102 Low Power Digital Temperature Sensor with SMBUS/Two Wire Serial Interface
ti,tmp103 Low Power Digital Temperature Sensor with SMBUS/Two Wire Serial Interface
ti,tmp275 Digital Temperature Sensor ti,tmp275 Digital Temperature Sensor
winbond,wpct301 i2c trusted platform module (TPM) winbond,wpct301 i2c trusted platform module (TPM)
...@@ -42,6 +42,7 @@ dmo Data Modul AG ...@@ -42,6 +42,7 @@ dmo Data Modul AG
ebv EBV Elektronik ebv EBV Elektronik
edt Emerging Display Technologies edt Emerging Display Technologies
emmicro EM Microelectronic emmicro EM Microelectronic
epcos EPCOS AG
epfl Ecole Polytechnique Fédérale de Lausanne epfl Ecole Polytechnique Fédérale de Lausanne
epson Seiko Epson Corp. epson Seiko Epson Corp.
est ESTeem Wireless Modems est ESTeem Wireless Modems
......
Kernel Driver IBMPOWERNV
========================
Supported systems:
* Any recent IBM P servers based on POWERNV platform
Author: Neelesh Gupta
Description
-----------
This driver implements reading the platform sensors data like temperature/fan/
voltage/power for 'POWERNV' platform.
The driver uses the platform device infrastructure. It probes the device tree
for sensor devices during the __init phase and registers them with the 'hwmon'.
'hwmon' populates the 'sysfs' tree having attribute files, each for a given
sensor type and its attribute data.
All the nodes in the DT appear under "/ibm,opal/sensors" and each valid node in
the DT maps to an attribute file in 'sysfs'. The node exports unique 'sensor-id'
which the driver uses to make an OPAL call to the firmware.
Usage notes
-----------
The driver is built statically with the kernel by enabling the config
CONFIG_SENSORS_IBMPOWERNV. It can also be built as module 'ibmpowernv'.
Sysfs attributes
----------------
fanX_input Measured RPM value.
fanX_min Threshold RPM for alert generation.
fanX_fault 0: No fail condition
1: Failing fan
tempX_input Measured ambient temperature.
tempX_max Threshold ambient temperature for alert generation.
inX_input Measured power supply voltage
inX_fault 0: No fail condition.
1: Failing power supply.
power1_input System power consumption (microWatt)
...@@ -42,13 +42,14 @@ Supported chips: ...@@ -42,13 +42,14 @@ Supported chips:
Addresses scanned: none Addresses scanned: none
Datasheet: Publicly available at the ST website Datasheet: Publicly available at the ST website
http://www.st.com/internet/analog/product/121769.jsp http://www.st.com/internet/analog/product/121769.jsp
* Texas Instruments TMP100, TMP101, TMP105, TMP75, TMP175, TMP275 * Texas Instruments TMP100, TMP101, TMP105, TMP112, TMP75, TMP175, TMP275
Prefixes: 'tmp100', 'tmp101', 'tmp105', 'tmp175', 'tmp75', 'tmp275' Prefixes: 'tmp100', 'tmp101', 'tmp105', 'tmp112', 'tmp175', 'tmp75', 'tmp275'
Addresses scanned: none Addresses scanned: none
Datasheet: Publicly available at the Texas Instruments website Datasheet: Publicly available at the Texas Instruments website
http://www.ti.com/product/tmp100 http://www.ti.com/product/tmp100
http://www.ti.com/product/tmp101 http://www.ti.com/product/tmp101
http://www.ti.com/product/tmp105 http://www.ti.com/product/tmp105
http://www.ti.com/product/tmp112
http://www.ti.com/product/tmp75 http://www.ti.com/product/tmp75
http://www.ti.com/product/tmp175 http://www.ti.com/product/tmp175
http://www.ti.com/product/tmp275 http://www.ti.com/product/tmp275
......
...@@ -6,6 +6,11 @@ Supported thermistors from Murata: ...@@ -6,6 +6,11 @@ Supported thermistors from Murata:
Prefixes: 'ncp15wb473', 'ncp18wb473', 'ncp21wb473', 'ncp03wb473', 'ncp15wl333' Prefixes: 'ncp15wb473', 'ncp18wb473', 'ncp21wb473', 'ncp03wb473', 'ncp15wl333'
Datasheet: Publicly available at Murata Datasheet: Publicly available at Murata
Supported thermistors from EPCOS:
* EPCOS NTC Thermistors B57330V2103
Prefixes: b57330v2103
Datasheet: Publicly available at EPCOS
Other NTC thermistors can be supported simply by adding compensation Other NTC thermistors can be supported simply by adding compensation
tables; e.g., NCP15WL333 support is added by the table ncpXXwl333. tables; e.g., NCP15WL333 support is added by the table ncpXXwl333.
......
...@@ -23,12 +23,11 @@ Supported chips: ...@@ -23,12 +23,11 @@ Supported chips:
http://www.lineagepower.com/oem/pdf/PDT012A0X.pdf http://www.lineagepower.com/oem/pdf/PDT012A0X.pdf
http://www.lineagepower.com/oem/pdf/UDT020A0X.pdf http://www.lineagepower.com/oem/pdf/UDT020A0X.pdf
http://www.lineagepower.com/oem/pdf/MDT040A0X.pdf http://www.lineagepower.com/oem/pdf/MDT040A0X.pdf
* Texas Instruments TPS40400, TPS40422 * Texas Instruments TPS40400
Prefixes: 'tps40400', 'tps40422' Prefixes: 'tps40400'
Addresses scanned: - Addresses scanned: -
Datasheets: Datasheets:
http://www.ti.com/lit/gpn/tps40400 http://www.ti.com/lit/gpn/tps40400
http://www.ti.com/lit/gpn/tps40422
* Generic PMBus devices * Generic PMBus devices
Prefix: 'pmbus' Prefix: 'pmbus'
Addresses scanned: - Addresses scanned: -
......
Kernel driver powr1220
==================
Supported chips:
* Lattice POWR1220AT8
Prefix: 'powr1220'
Addresses scanned: none
Datasheet: Publicly available at the Lattice website
http://www.latticesemi.com/
Author: Scott Kanowitz <scott.kanowitz@gmail.com>
Description
-----------
This driver supports the Lattice POWR1220AT8 chip. The POWR1220
includes voltage monitoring for 14 inputs as well as trim settings
for output voltages and GPIOs. This driver implements the voltage
monitoring portion of the chip.
Voltages are sampled by a 12-bit ADC with a step size of 2 mV.
An in-line attenuator allows measurements from 0 to 6 V. The
attenuator is enabled or disabled depending on the setting of the
input's max value. The driver will enable the attenuator for any
value over the low measurement range maximum of 2 V.
The input naming convention is as follows:
driver name pin name
in0 VMON1
in1 VMON2
in2 VMON3
in2 VMON4
in4 VMON5
in5 VMON6
in6 VMON7
in7 VMON8
in8 VMON9
in9 VMON10
in10 VMON11
in11 VMON12
in12 VCCA
in13 VCCINP
The ADC readings are updated on request with a minimum period of 1s.
Kernel driver pwm-fan
=====================
This driver enables the use of a PWM module to drive a fan. It uses the
generic PWM interface thus it is hardware independent. It can be used on
many SoCs, as long as the SoC supplies a PWM line driver that exposes
the generic PWM API.
Author: Kamil Debski <k.debski@samsung.com>
Description
-----------
The driver implements a simple interface for driving a fan connected to
a PWM output. It uses the generic PWM interface, thus it can be used with
a range of SoCs. The driver exposes the fan to the user space through
the hwmon's sysfs interface.
Kernel driver tmp103
====================
Supported chips:
* Texas Instruments TMP103
Prefix: 'tmp103'
Addresses scanned: none
Product info and datasheet: http://www.ti.com/product/tmp103
Author:
Heiko Schocher <hs@denx.de>
Description
-----------
The TMP103 is a digital output temperature sensor in a four-ball
wafer chip-scale package (WCSP). The TMP103 is capable of reading
temperatures to a resolution of 1°C. The TMP103 is specified for
operation over a temperature range of –40°C to +125°C.
Resolution: 8 Bits
Accuracy: ±1°C Typ (–10°C to +100°C)
The driver provides the common sysfs-interface for temperatures (see
Documentation/hwmon/sysfs-interface under Temperatures).
Please refer how to instantiate this driver:
Documentation/i2c/instantiating-devices
...@@ -8,12 +8,20 @@ Supported chips: ...@@ -8,12 +8,20 @@ Supported chips:
Datasheet: http://focus.ti.com/docs/prod/folders/print/tmp421.html Datasheet: http://focus.ti.com/docs/prod/folders/print/tmp421.html
* Texas Instruments TMP422 * Texas Instruments TMP422
Prefix: 'tmp422' Prefix: 'tmp422'
Addresses scanned: I2C 0x2a, 0x4c, 0x4d, 0x4e and 0x4f Addresses scanned: I2C 0x4c, 0x4d, 0x4e and 0x4f
Datasheet: http://focus.ti.com/docs/prod/folders/print/tmp421.html Datasheet: http://focus.ti.com/docs/prod/folders/print/tmp421.html
* Texas Instruments TMP423 * Texas Instruments TMP423
Prefix: 'tmp423' Prefix: 'tmp423'
Addresses scanned: I2C 0x2a, 0x4c, 0x4d, 0x4e and 0x4f Addresses scanned: I2C 0x4c and 0x4d
Datasheet: http://focus.ti.com/docs/prod/folders/print/tmp421.html Datasheet: http://focus.ti.com/docs/prod/folders/print/tmp421.html
* Texas Instruments TMP441
Prefix: 'tmp441'
Addresses scanned: I2C 0x2a, 0x4c, 0x4d, 0x4e and 0x4f
Datasheet: http://www.ti.com/product/tmp441
* Texas Instruments TMP442
Prefix: 'tmp442'
Addresses scanned: I2C 0x4c and 0x4d
Datasheet: http://www.ti.com/product/tmp442
Authors: Authors:
Andre Prendel <andre.prendel@gmx.de> Andre Prendel <andre.prendel@gmx.de>
...@@ -21,13 +29,13 @@ Authors: ...@@ -21,13 +29,13 @@ Authors:
Description Description
----------- -----------
This driver implements support for Texas Instruments TMP421, TMP422 This driver implements support for Texas Instruments TMP421, TMP422,
and TMP423 temperature sensor chips. These chips implement one local TMP423, TMP441, and TMP442 temperature sensor chips. These chips
and up to one (TMP421), up to two (TMP422) or up to three (TMP423) implement one local and up to one (TMP421, TMP441), up to two (TMP422,
remote sensors. Temperature is measured in degrees Celsius. The chips TMP442) or up to three (TMP423) remote sensors. Temperature is measured
are wired over I2C/SMBus and specified over a temperature range of -40 in degrees Celsius. The chips are wired over I2C/SMBus and specified
to +125 degrees Celsius. Resolution for both the local and remote over a temperature range of -40 to +125 degrees Celsius. Resolution
channels is 0.0625 degree C. for both the local and remote channels is 0.0625 degree C.
The chips support only temperature measurement. The driver exports The chips support only temperature measurement. The driver exports
the temperature values via the following sysfs files: the temperature values via the following sysfs files:
......
Kernel driver tps40422
======================
Supported chips:
* TI TPS40422
Prefix: 'tps40422'
Addresses scanned: -
Datasheet: http://www.ti.com/lit/gpn/tps40422
Author: Zhu Laiwen <richard.zhu@nsn.com>
Description
-----------
This driver supports TI TPS40422 Dual-Output or Two-Phase Synchronous Buck
Controller with PMBus
The driver is a client driver to the core PMBus driver.
Please see Documentation/hwmon/pmbus for details on PMBus client drivers.
Usage Notes
-----------
This driver does not auto-detect devices. You will have to instantiate the
devices explicitly. Please see Documentation/i2c/instantiating-devices for
details.
Platform data support
---------------------
The driver supports standard PMBus driver platform data.
Sysfs entries
-------------
The following attributes are supported.
in[1-2]_label "vout[1-2]"
in[1-2]_input Measured voltage. From READ_VOUT register.
in[1-2]_alarm voltage alarm.
curr[1-2]_input Measured current. From READ_IOUT register.
curr[1-2]_label "iout[1-2]"
curr1_max Maximum current. From IOUT_OC_WARN_LIMIT register.
curr1_crit Critical maximum current. From IOUT_OC_FAULT_LIMIT register.
curr1_max_alarm Current high alarm. From IOUT_OC_WARN_LIMIT status.
curr1_crit_alarm Current critical high alarm. From IOUT_OC_FAULT status.
curr2_alarm Current high alarm. From IOUT_OC_WARNING status.
temp1_input Measured temperature. From READ_TEMPERATURE_2 register on page 0.
temp1_max Maximum temperature. From OT_WARN_LIMIT register.
temp1_crit Critical high temperature. From OT_FAULT_LIMIT register.
temp1_max_alarm Chip temperature high alarm. Set by comparing
READ_TEMPERATURE_2 on page 0 with OT_WARN_LIMIT if TEMP_OT_WARNING
status is set.
temp1_crit_alarm Chip temperature critical high alarm. Set by comparing
READ_TEMPERATURE_2 on page 0 with OT_FAULT_LIMIT if TEMP_OT_FAULT
status is set.
temp2_input Measured temperature. From READ_TEMPERATURE_2 register on page 1.
temp2_alarm Chip temperature alarm on page 1.
...@@ -554,6 +554,17 @@ config SENSORS_IBMPEX ...@@ -554,6 +554,17 @@ config SENSORS_IBMPEX
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called ibmpex. will be called ibmpex.
config SENSORS_IBMPOWERNV
tristate "IBM POWERNV platform sensors"
depends on PPC_POWERNV
default y
help
If you say yes here you get support for the temperature/fan/power
sensors on your PowerNV platform.
This driver can also be built as a module. If so, the module
will be called ibmpowernv.
config SENSORS_IIO_HWMON config SENSORS_IIO_HWMON
tristate "Hwmon driver that uses channels specified via iio maps" tristate "Hwmon driver that uses channels specified via iio maps"
depends on IIO depends on IIO
...@@ -608,6 +619,18 @@ config SENSORS_JC42 ...@@ -608,6 +619,18 @@ config SENSORS_JC42
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called jc42. will be called jc42.
config SENSORS_POWR1220
tristate "Lattice POWR1220 Power Monitoring"
depends on I2C
default n
help
If you say yes here you get access to the hardware monitoring
functions of the Lattice POWR1220 isp Power Supply Monitoring,
Sequencing and Margining Controller.
This driver can also be built as a module. If so, the module
will be called powr1220.
config SENSORS_LINEAGE config SENSORS_LINEAGE
tristate "Lineage Compact Power Line Power Entry Module" tristate "Lineage Compact Power Line Power Entry Module"
depends on I2C depends on I2C
...@@ -882,8 +905,8 @@ config SENSORS_LM75 ...@@ -882,8 +905,8 @@ config SENSORS_LM75
- NXP's LM75A - NXP's LM75A
- ST Microelectronics STDS75 - ST Microelectronics STDS75
- TelCom (now Microchip) TCN75 - TelCom (now Microchip) TCN75
- Texas Instruments TMP100, TMP101, TMP105, TMP75, TMP175, - Texas Instruments TMP100, TMP101, TMP105, TMP112, TMP75,
TMP275 TMP175, TMP275
This driver supports driver model based binding through board This driver supports driver model based binding through board
specific I2C device tables. specific I2C device tables.
...@@ -1061,7 +1084,7 @@ config SENSORS_NTC_THERMISTOR ...@@ -1061,7 +1084,7 @@ config SENSORS_NTC_THERMISTOR
Currently, this driver supports Currently, this driver supports
NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, and NCP15WL333 NCP15WB473, NCP18WB473, NCP21WB473, NCP03WB473, and NCP15WL333
from Murata. from Murata and B57330V2103 from EPCOS.
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called ntc-thermistor. will be called ntc-thermistor.
...@@ -1082,8 +1105,8 @@ config SENSORS_NCT6775 ...@@ -1082,8 +1105,8 @@ config SENSORS_NCT6775
select HWMON_VID select HWMON_VID
help help
If you say yes here you get support for the hardware monitoring If you say yes here you get support for the hardware monitoring
functionality of the Nuvoton NCT6775F, NCT6776F, NCT6779D functionality of the Nuvoton NCT6106D, NCT6775F, NCT6776F, NCT6779D,
and compatible Super-I/O chips. This driver replaces the NCT6791D and compatible Super-I/O chips. This driver replaces the
w83627ehf driver for NCT6775F and NCT6776F. w83627ehf driver for NCT6775F and NCT6776F.
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
...@@ -1105,6 +1128,17 @@ config SENSORS_PCF8591 ...@@ -1105,6 +1128,17 @@ config SENSORS_PCF8591
source drivers/hwmon/pmbus/Kconfig source drivers/hwmon/pmbus/Kconfig
config SENSORS_PWM_FAN
tristate "PWM fan"
depends on (PWM && OF) || COMPILE_TEST
help
If you say yes here you get support for fans connected to PWM lines.
The driver uses the generic PWM interface, thus it will work on a
variety of SoCs.
This driver can also be built as a module. If so, the module
will be called pwm-fan.
config SENSORS_SHT15 config SENSORS_SHT15
tristate "Sensiron humidity and temperature sensors. SHT15 and compat." tristate "Sensiron humidity and temperature sensors. SHT15 and compat."
depends on GPIOLIB depends on GPIOLIB
...@@ -1393,6 +1427,17 @@ config SENSORS_TMP102 ...@@ -1393,6 +1427,17 @@ config SENSORS_TMP102
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called tmp102. will be called tmp102.
config SENSORS_TMP103
tristate "Texas Instruments TMP103"
depends on I2C
select REGMAP_I2C
help
If you say yes here you get support for Texas Instruments TMP103
sensor chips.
This driver can also be built as a module. If so, the module
will be called tmp103.
config SENSORS_TMP401 config SENSORS_TMP401
tristate "Texas Instruments TMP401 and compatibles" tristate "Texas Instruments TMP401 and compatibles"
depends on I2C depends on I2C
...@@ -1408,7 +1453,7 @@ config SENSORS_TMP421 ...@@ -1408,7 +1453,7 @@ config SENSORS_TMP421
depends on I2C depends on I2C
help help
If you say yes here you get support for Texas Instruments TMP421, If you say yes here you get support for Texas Instruments TMP421,
TMP422 and TMP423 temperature sensor chips. TMP422, TMP423, TMP441, and TMP442 temperature sensor chips.
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called tmp421. will be called tmp421.
......
...@@ -71,6 +71,7 @@ obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o ...@@ -71,6 +71,7 @@ obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o
obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o
obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o
obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o obj-$(CONFIG_SENSORS_IBMPEX) += ibmpex.o
obj-$(CONFIG_SENSORS_IBMPOWERNV)+= ibmpowernv.o
obj-$(CONFIG_SENSORS_IIO_HWMON) += iio_hwmon.o obj-$(CONFIG_SENSORS_IIO_HWMON) += iio_hwmon.o
obj-$(CONFIG_SENSORS_INA209) += ina209.o obj-$(CONFIG_SENSORS_INA209) += ina209.o
obj-$(CONFIG_SENSORS_INA2XX) += ina2xx.o obj-$(CONFIG_SENSORS_INA2XX) += ina2xx.o
...@@ -120,6 +121,8 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR) += ntc_thermistor.o ...@@ -120,6 +121,8 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR) += ntc_thermistor.o
obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o
obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o
obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
obj-$(CONFIG_SENSORS_POWR1220) += powr1220.o
obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o
obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o
obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o
obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o
...@@ -135,6 +138,7 @@ obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o ...@@ -135,6 +138,7 @@ obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
obj-$(CONFIG_SENSORS_AMC6821) += amc6821.o obj-$(CONFIG_SENSORS_AMC6821) += amc6821.o
obj-$(CONFIG_SENSORS_THMC50) += thmc50.o obj-$(CONFIG_SENSORS_THMC50) += thmc50.o
obj-$(CONFIG_SENSORS_TMP102) += tmp102.o obj-$(CONFIG_SENSORS_TMP102) += tmp102.o
obj-$(CONFIG_SENSORS_TMP103) += tmp103.o
obj-$(CONFIG_SENSORS_TMP401) += tmp401.o obj-$(CONFIG_SENSORS_TMP401) += tmp401.o
obj-$(CONFIG_SENSORS_TMP421) += tmp421.o obj-$(CONFIG_SENSORS_TMP421) += tmp421.o
obj-$(CONFIG_SENSORS_TWL4030_MADC)+= twl4030-madc-hwmon.o obj-$(CONFIG_SENSORS_TWL4030_MADC)+= twl4030-madc-hwmon.o
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
static u8 AD7414_REG_LIMIT[] = { AD7414_REG_T_HIGH, AD7414_REG_T_LOW }; static u8 AD7414_REG_LIMIT[] = { AD7414_REG_T_HIGH, AD7414_REG_T_LOW };
struct ad7414_data { struct ad7414_data {
struct device *hwmon_dev; struct i2c_client *client;
struct mutex lock; /* atomic read data updates */ struct mutex lock; /* atomic read data updates */
char valid; /* !=0 if following fields are valid */ char valid; /* !=0 if following fields are valid */
unsigned long next_update; /* In jiffies */ unsigned long next_update; /* In jiffies */
...@@ -72,8 +72,8 @@ static inline int ad7414_write(struct i2c_client *client, u8 reg, u8 value) ...@@ -72,8 +72,8 @@ static inline int ad7414_write(struct i2c_client *client, u8 reg, u8 value)
static struct ad7414_data *ad7414_update_device(struct device *dev) static struct ad7414_data *ad7414_update_device(struct device *dev)
{ {
struct i2c_client *client = to_i2c_client(dev); struct ad7414_data *data = dev_get_drvdata(dev);
struct ad7414_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
mutex_lock(&data->lock); mutex_lock(&data->lock);
...@@ -127,8 +127,8 @@ static ssize_t set_max_min(struct device *dev, ...@@ -127,8 +127,8 @@ static ssize_t set_max_min(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct ad7414_data *data = dev_get_drvdata(dev);
struct ad7414_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
u8 reg = AD7414_REG_LIMIT[index]; u8 reg = AD7414_REG_LIMIT[index];
long temp; long temp;
...@@ -164,7 +164,7 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, ...@@ -164,7 +164,7 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 3); static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 3);
static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 4); static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 4);
static struct attribute *ad7414_attributes[] = { static struct attribute *ad7414_attrs[] = {
&sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr,
&sensor_dev_attr_temp1_max.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr,
&sensor_dev_attr_temp1_min.dev_attr.attr, &sensor_dev_attr_temp1_min.dev_attr.attr,
...@@ -173,27 +173,25 @@ static struct attribute *ad7414_attributes[] = { ...@@ -173,27 +173,25 @@ static struct attribute *ad7414_attributes[] = {
NULL NULL
}; };
static const struct attribute_group ad7414_group = { ATTRIBUTE_GROUPS(ad7414);
.attrs = ad7414_attributes,
};
static int ad7414_probe(struct i2c_client *client, static int ad7414_probe(struct i2c_client *client,
const struct i2c_device_id *dev_id) const struct i2c_device_id *dev_id)
{ {
struct device *dev = &client->dev;
struct ad7414_data *data; struct ad7414_data *data;
struct device *hwmon_dev;
int conf; int conf;
int err;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA |
I2C_FUNC_SMBUS_READ_WORD_DATA)) I2C_FUNC_SMBUS_READ_WORD_DATA))
return -EOPNOTSUPP; return -EOPNOTSUPP;
data = devm_kzalloc(&client->dev, sizeof(struct ad7414_data), data = devm_kzalloc(dev, sizeof(struct ad7414_data), GFP_KERNEL);
GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
i2c_set_clientdata(client, data); data->client = client;
mutex_init(&data->lock); mutex_init(&data->lock);
dev_info(&client->dev, "chip found\n"); dev_info(&client->dev, "chip found\n");
...@@ -201,38 +199,16 @@ static int ad7414_probe(struct i2c_client *client, ...@@ -201,38 +199,16 @@ static int ad7414_probe(struct i2c_client *client,
/* Make sure the chip is powered up. */ /* Make sure the chip is powered up. */
conf = i2c_smbus_read_byte_data(client, AD7414_REG_CONF); conf = i2c_smbus_read_byte_data(client, AD7414_REG_CONF);
if (conf < 0) if (conf < 0)
dev_warn(&client->dev, dev_warn(dev, "ad7414_probe unable to read config register.\n");
"ad7414_probe unable to read config register.\n");
else { else {
conf &= ~(1 << 7); conf &= ~(1 << 7);
i2c_smbus_write_byte_data(client, AD7414_REG_CONF, conf); i2c_smbus_write_byte_data(client, AD7414_REG_CONF, conf);
} }
/* Register sysfs hooks */ hwmon_dev = devm_hwmon_device_register_with_groups(dev,
err = sysfs_create_group(&client->dev.kobj, &ad7414_group); client->name,
if (err) data, ad7414_groups);
return err; return PTR_ERR_OR_ZERO(hwmon_dev);
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto exit_remove;
}
return 0;
exit_remove:
sysfs_remove_group(&client->dev.kobj, &ad7414_group);
return err;
}
static int ad7414_remove(struct i2c_client *client)
{
struct ad7414_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &ad7414_group);
return 0;
} }
static const struct i2c_device_id ad7414_id[] = { static const struct i2c_device_id ad7414_id[] = {
...@@ -246,7 +222,6 @@ static struct i2c_driver ad7414_driver = { ...@@ -246,7 +222,6 @@ static struct i2c_driver ad7414_driver = {
.name = "ad7414", .name = "ad7414",
}, },
.probe = ad7414_probe, .probe = ad7414_probe,
.remove = ad7414_remove,
.id_table = ad7414_id, .id_table = ad7414_id,
}; };
......
...@@ -44,8 +44,7 @@ static const u8 AD7418_REG_TEMP[] = { AD7418_REG_TEMP_IN, ...@@ -44,8 +44,7 @@ static const u8 AD7418_REG_TEMP[] = { AD7418_REG_TEMP_IN,
AD7418_REG_TEMP_OS }; AD7418_REG_TEMP_OS };
struct ad7418_data { struct ad7418_data {
struct device *hwmon_dev; struct i2c_client *client;
struct attribute_group attrs;
enum chips type; enum chips type;
struct mutex lock; struct mutex lock;
int adc_max; /* number of ADC channels */ int adc_max; /* number of ADC channels */
...@@ -55,48 +54,10 @@ struct ad7418_data { ...@@ -55,48 +54,10 @@ struct ad7418_data {
u16 in[4]; u16 in[4];
}; };
static int ad7418_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int ad7418_remove(struct i2c_client *client);
static const struct i2c_device_id ad7418_id[] = {
{ "ad7416", ad7416 },
{ "ad7417", ad7417 },
{ "ad7418", ad7418 },
{ }
};
MODULE_DEVICE_TABLE(i2c, ad7418_id);
static struct i2c_driver ad7418_driver = {
.driver = {
.name = "ad7418",
},
.probe = ad7418_probe,
.remove = ad7418_remove,
.id_table = ad7418_id,
};
static void ad7418_init_client(struct i2c_client *client)
{
struct ad7418_data *data = i2c_get_clientdata(client);
int reg = i2c_smbus_read_byte_data(client, AD7418_REG_CONF);
if (reg < 0) {
dev_err(&client->dev, "cannot read configuration register\n");
} else {
dev_info(&client->dev, "configuring for mode 1\n");
i2c_smbus_write_byte_data(client, AD7418_REG_CONF, reg & 0xfe);
if (data->type == ad7417 || data->type == ad7418)
i2c_smbus_write_byte_data(client,
AD7418_REG_CONF2, 0x00);
}
}
static struct ad7418_data *ad7418_update_device(struct device *dev) static struct ad7418_data *ad7418_update_device(struct device *dev)
{ {
struct i2c_client *client = to_i2c_client(dev); struct ad7418_data *data = dev_get_drvdata(dev);
struct ad7418_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
mutex_lock(&data->lock); mutex_lock(&data->lock);
...@@ -165,8 +126,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, ...@@ -165,8 +126,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct ad7418_data *data = dev_get_drvdata(dev);
struct ad7418_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
int ret = kstrtol(buf, 10, &temp); int ret = kstrtol(buf, 10, &temp);
...@@ -193,14 +154,15 @@ static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 1); ...@@ -193,14 +154,15 @@ static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_adc, NULL, 1);
static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 2); static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_adc, NULL, 2);
static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 3); static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_adc, NULL, 3);
static struct attribute *ad7416_attributes[] = { static struct attribute *ad7416_attrs[] = {
&sensor_dev_attr_temp1_max.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr,
&sensor_dev_attr_temp1_max_hyst.dev_attr.attr, &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
&sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr,
NULL NULL
}; };
ATTRIBUTE_GROUPS(ad7416);
static struct attribute *ad7417_attributes[] = { static struct attribute *ad7417_attrs[] = {
&sensor_dev_attr_temp1_max.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr,
&sensor_dev_attr_temp1_max_hyst.dev_attr.attr, &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
&sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr,
...@@ -210,83 +172,100 @@ static struct attribute *ad7417_attributes[] = { ...@@ -210,83 +172,100 @@ static struct attribute *ad7417_attributes[] = {
&sensor_dev_attr_in4_input.dev_attr.attr, &sensor_dev_attr_in4_input.dev_attr.attr,
NULL NULL
}; };
ATTRIBUTE_GROUPS(ad7417);
static struct attribute *ad7418_attributes[] = { static struct attribute *ad7418_attrs[] = {
&sensor_dev_attr_temp1_max.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr,
&sensor_dev_attr_temp1_max_hyst.dev_attr.attr, &sensor_dev_attr_temp1_max_hyst.dev_attr.attr,
&sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr,
&sensor_dev_attr_in1_input.dev_attr.attr, &sensor_dev_attr_in1_input.dev_attr.attr,
NULL NULL
}; };
ATTRIBUTE_GROUPS(ad7418);
static void ad7418_init_client(struct i2c_client *client)
{
struct ad7418_data *data = i2c_get_clientdata(client);
int reg = i2c_smbus_read_byte_data(client, AD7418_REG_CONF);
if (reg < 0) {
dev_err(&client->dev, "cannot read configuration register\n");
} else {
dev_info(&client->dev, "configuring for mode 1\n");
i2c_smbus_write_byte_data(client, AD7418_REG_CONF, reg & 0xfe);
if (data->type == ad7417 || data->type == ad7418)
i2c_smbus_write_byte_data(client,
AD7418_REG_CONF2, 0x00);
}
}
static int ad7418_probe(struct i2c_client *client, static int ad7418_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device *dev = &client->dev;
struct i2c_adapter *adapter = client->adapter; struct i2c_adapter *adapter = client->adapter;
struct ad7418_data *data; struct ad7418_data *data;
int err; struct device *hwmon_dev;
const struct attribute_group **attr_groups = NULL;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
I2C_FUNC_SMBUS_WORD_DATA)) I2C_FUNC_SMBUS_WORD_DATA))
return -EOPNOTSUPP; return -EOPNOTSUPP;
data = devm_kzalloc(&client->dev, sizeof(struct ad7418_data), data = devm_kzalloc(dev, sizeof(struct ad7418_data), GFP_KERNEL);
GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
i2c_set_clientdata(client, data); i2c_set_clientdata(client, data);
mutex_init(&data->lock); mutex_init(&data->lock);
data->client = client;
data->type = id->driver_data; data->type = id->driver_data;
switch (data->type) { switch (data->type) {
case ad7416: case ad7416:
data->adc_max = 0; data->adc_max = 0;
data->attrs.attrs = ad7416_attributes; attr_groups = ad7416_groups;
break; break;
case ad7417: case ad7417:
data->adc_max = 4; data->adc_max = 4;
data->attrs.attrs = ad7417_attributes; attr_groups = ad7417_groups;
break; break;
case ad7418: case ad7418:
data->adc_max = 1; data->adc_max = 1;
data->attrs.attrs = ad7418_attributes; attr_groups = ad7418_groups;
break; break;
} }
dev_info(&client->dev, "%s chip found\n", client->name); dev_info(dev, "%s chip found\n", client->name);
/* Initialize the AD7418 chip */ /* Initialize the AD7418 chip */
ad7418_init_client(client); ad7418_init_client(client);
/* Register sysfs hooks */ hwmon_dev = devm_hwmon_device_register_with_groups(dev,
err = sysfs_create_group(&client->dev.kobj, &data->attrs); client->name,
if (err) data, attr_groups);
return err; return PTR_ERR_OR_ZERO(hwmon_dev);
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto exit_remove;
}
return 0;
exit_remove:
sysfs_remove_group(&client->dev.kobj, &data->attrs);
return err;
} }
static int ad7418_remove(struct i2c_client *client) static const struct i2c_device_id ad7418_id[] = {
{ { "ad7416", ad7416 },
struct ad7418_data *data = i2c_get_clientdata(client); { "ad7417", ad7417 },
hwmon_device_unregister(data->hwmon_dev); { "ad7418", ad7418 },
sysfs_remove_group(&client->dev.kobj, &data->attrs); { }
return 0; };
} MODULE_DEVICE_TABLE(i2c, ad7418_id);
static struct i2c_driver ad7418_driver = {
.driver = {
.name = "ad7418",
},
.probe = ad7418_probe,
.id_table = ad7418_id,
};
module_i2c_driver(ad7418_driver); module_i2c_driver(ad7418_driver);
......
...@@ -98,41 +98,63 @@ struct adm1021_data { ...@@ -98,41 +98,63 @@ struct adm1021_data {
u8 remote_temp_offset_prec; u8 remote_temp_offset_prec;
}; };
static int adm1021_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int adm1021_detect(struct i2c_client *client,
struct i2c_board_info *info);
static void adm1021_init_client(struct i2c_client *client);
static struct adm1021_data *adm1021_update_device(struct device *dev);
/* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */ /* (amalysh) read only mode, otherwise any limit's writing confuse BIOS */
static bool read_only; static bool read_only;
static struct adm1021_data *adm1021_update_device(struct device *dev)
{
struct adm1021_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
static const struct i2c_device_id adm1021_id[] = { mutex_lock(&data->update_lock);
{ "adm1021", adm1021 },
{ "adm1023", adm1023 },
{ "max1617", max1617 },
{ "max1617a", max1617a },
{ "thmc10", thmc10 },
{ "lm84", lm84 },
{ "gl523sm", gl523sm },
{ "mc1066", mc1066 },
{ }
};
MODULE_DEVICE_TABLE(i2c, adm1021_id);
/* This is the driver that will be inserted */ if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
static struct i2c_driver adm1021_driver = { || !data->valid) {
.class = I2C_CLASS_HWMON, int i;
.driver = {
.name = "adm1021", dev_dbg(dev, "Starting adm1021 update\n");
},
.probe = adm1021_probe, for (i = 0; i < 2; i++) {
.id_table = adm1021_id, data->temp[i] = 1000 *
.detect = adm1021_detect, (s8) i2c_smbus_read_byte_data(
.address_list = normal_i2c, client, ADM1021_REG_TEMP(i));
}; data->temp_max[i] = 1000 *
(s8) i2c_smbus_read_byte_data(
client, ADM1021_REG_TOS_R(i));
if (data->type != lm84) {
data->temp_min[i] = 1000 *
(s8) i2c_smbus_read_byte_data(client,
ADM1021_REG_THYST_R(i));
}
}
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.
*/
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(
client, ADM1023_REG_REM_TOS_PREC) >> 5);
data->temp_min[1] += 125 * (i2c_smbus_read_byte_data(
client, ADM1023_REG_REM_THYST_PREC) >> 5);
data->remote_temp_offset =
i2c_smbus_read_byte_data(client,
ADM1023_REG_REM_OFFSET);
data->remote_temp_offset_prec =
i2c_smbus_read_byte_data(client,
ADM1023_REG_REM_OFFSET_PREC);
}
data->last_updated = jiffies;
data->valid = 1;
}
mutex_unlock(&data->update_lock);
return data;
}
static ssize_t show_temp(struct device *dev, static ssize_t show_temp(struct device *dev,
struct device_attribute *devattr, char *buf) struct device_attribute *devattr, char *buf)
...@@ -411,6 +433,15 @@ static int adm1021_detect(struct i2c_client *client, ...@@ -411,6 +433,15 @@ static int adm1021_detect(struct i2c_client *client,
return 0; return 0;
} }
static void adm1021_init_client(struct i2c_client *client)
{
/* Enable ADC and disable suspend mode */
i2c_smbus_write_byte_data(client, ADM1021_REG_CONFIG_W,
i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R) & 0xBF);
/* Set Conversion rate to 1/sec (this can be tinkered with) */
i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04);
}
static int adm1021_probe(struct i2c_client *client, static int adm1021_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
...@@ -440,69 +471,29 @@ static int adm1021_probe(struct i2c_client *client, ...@@ -440,69 +471,29 @@ static int adm1021_probe(struct i2c_client *client,
return PTR_ERR_OR_ZERO(hwmon_dev); return PTR_ERR_OR_ZERO(hwmon_dev);
} }
static void adm1021_init_client(struct i2c_client *client) static const struct i2c_device_id adm1021_id[] = {
{ { "adm1021", adm1021 },
/* Enable ADC and disable suspend mode */ { "adm1023", adm1023 },
i2c_smbus_write_byte_data(client, ADM1021_REG_CONFIG_W, { "max1617", max1617 },
i2c_smbus_read_byte_data(client, ADM1021_REG_CONFIG_R) & 0xBF); { "max1617a", max1617a },
/* Set Conversion rate to 1/sec (this can be tinkered with) */ { "thmc10", thmc10 },
i2c_smbus_write_byte_data(client, ADM1021_REG_CONV_RATE_W, 0x04); { "lm84", lm84 },
} { "gl523sm", gl523sm },
{ "mc1066", mc1066 },
static struct adm1021_data *adm1021_update_device(struct device *dev) { }
{ };
struct adm1021_data *data = dev_get_drvdata(dev); MODULE_DEVICE_TABLE(i2c, adm1021_id);
struct i2c_client *client = data->client;
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
int i;
dev_dbg(dev, "Starting adm1021 update\n");
for (i = 0; i < 2; i++) {
data->temp[i] = 1000 *
(s8) i2c_smbus_read_byte_data(
client, ADM1021_REG_TEMP(i));
data->temp_max[i] = 1000 *
(s8) i2c_smbus_read_byte_data(
client, ADM1021_REG_TOS_R(i));
if (data->type != lm84) {
data->temp_min[i] = 1000 *
(s8) i2c_smbus_read_byte_data(client,
ADM1021_REG_THYST_R(i));
}
}
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.
*/
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(
client, ADM1023_REG_REM_TOS_PREC) >> 5);
data->temp_min[1] += 125 * (i2c_smbus_read_byte_data(
client, ADM1023_REG_REM_THYST_PREC) >> 5);
data->remote_temp_offset =
i2c_smbus_read_byte_data(client,
ADM1023_REG_REM_OFFSET);
data->remote_temp_offset_prec =
i2c_smbus_read_byte_data(client,
ADM1023_REG_REM_OFFSET_PREC);
}
data->last_updated = jiffies;
data->valid = 1;
}
mutex_unlock(&data->update_lock);
return data; static struct i2c_driver adm1021_driver = {
} .class = I2C_CLASS_HWMON,
.driver = {
.name = "adm1021",
},
.probe = adm1021_probe,
.id_table = adm1021_id,
.detect = adm1021_detect,
.address_list = normal_i2c,
};
module_i2c_driver(adm1021_driver); module_i2c_driver(adm1021_driver);
......
...@@ -102,47 +102,13 @@ static const int in_scale[6] = { 2500, 2250, 3300, 5000, 12000, 3300 }; ...@@ -102,47 +102,13 @@ static const int in_scale[6] = { 2500, 2250, 3300, 5000, 12000, 3300 };
(((val) < 0 ? (val) - 500 : \ (((val) < 0 ? (val) - 500 : \
(val) + 500) / 1000)) (val) + 500) / 1000))
/*
* Functions declaration
*/
static int adm1025_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int adm1025_detect(struct i2c_client *client,
struct i2c_board_info *info);
static void adm1025_init_client(struct i2c_client *client);
static int adm1025_remove(struct i2c_client *client);
static struct adm1025_data *adm1025_update_device(struct device *dev);
/*
* Driver data (common to all clients)
*/
static const struct i2c_device_id adm1025_id[] = {
{ "adm1025", adm1025 },
{ "ne1619", ne1619 },
{ }
};
MODULE_DEVICE_TABLE(i2c, adm1025_id);
static struct i2c_driver adm1025_driver = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = "adm1025",
},
.probe = adm1025_probe,
.remove = adm1025_remove,
.id_table = adm1025_id,
.detect = adm1025_detect,
.address_list = normal_i2c,
};
/* /*
* Client data (each client gets its own) * Client data (each client gets its own)
*/ */
struct adm1025_data { struct adm1025_data {
struct device *hwmon_dev; struct i2c_client *client;
const struct attribute_group *groups[3];
struct mutex update_lock; struct mutex update_lock;
char valid; /* zero until following fields are valid */ char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */ unsigned long last_updated; /* in jiffies */
...@@ -158,6 +124,51 @@ struct adm1025_data { ...@@ -158,6 +124,51 @@ struct adm1025_data {
u8 vrm; u8 vrm;
}; };
static struct adm1025_data *adm1025_update_device(struct device *dev)
{
struct adm1025_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int i;
dev_dbg(&client->dev, "Updating data.\n");
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,
ADM1025_REG_IN_MIN(i));
data->in_max[i] = i2c_smbus_read_byte_data(client,
ADM1025_REG_IN_MAX(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,
ADM1025_REG_TEMP_LOW(i));
data->temp_max[i] = i2c_smbus_read_byte_data(client,
ADM1025_REG_TEMP_HIGH(i));
}
data->alarms = i2c_smbus_read_byte_data(client,
ADM1025_REG_STATUS1)
| (i2c_smbus_read_byte_data(client,
ADM1025_REG_STATUS2) << 8);
data->vid = (i2c_smbus_read_byte_data(client,
ADM1025_REG_VID) & 0x0f)
| ((i2c_smbus_read_byte_data(client,
ADM1025_REG_VID4) & 0x01) << 4);
data->last_updated = jiffies;
data->valid = 1;
}
mutex_unlock(&data->update_lock);
return data;
}
/* /*
* Sysfs stuff * Sysfs stuff
*/ */
...@@ -217,8 +228,8 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, ...@@ -217,8 +228,8 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct i2c_client *client = to_i2c_client(dev); struct adm1025_data *data = dev_get_drvdata(dev);
struct adm1025_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long val; long val;
int err; int err;
...@@ -238,8 +249,8 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, ...@@ -238,8 +249,8 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct i2c_client *client = to_i2c_client(dev); struct adm1025_data *data = dev_get_drvdata(dev);
struct adm1025_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long val; long val;
int err; int err;
...@@ -273,8 +284,8 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, ...@@ -273,8 +284,8 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct i2c_client *client = to_i2c_client(dev); struct adm1025_data *data = dev_get_drvdata(dev);
struct adm1025_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long val; long val;
int err; int err;
...@@ -294,8 +305,8 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, ...@@ -294,8 +305,8 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int index = to_sensor_dev_attr(attr)->index; int index = to_sensor_dev_attr(attr)->index;
struct i2c_client *client = to_i2c_client(dev); struct adm1025_data *data = dev_get_drvdata(dev);
struct adm1025_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long val; long val;
int err; int err;
...@@ -470,51 +481,6 @@ static int adm1025_detect(struct i2c_client *client, ...@@ -470,51 +481,6 @@ static int adm1025_detect(struct i2c_client *client,
return 0; return 0;
} }
static int adm1025_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct adm1025_data *data;
int err;
u8 config;
data = devm_kzalloc(&client->dev, sizeof(struct adm1025_data),
GFP_KERNEL);
if (!data)
return -ENOMEM;
i2c_set_clientdata(client, data);
mutex_init(&data->update_lock);
/* Initialize the ADM1025 chip */
adm1025_init_client(client);
/* Register sysfs hooks */
err = sysfs_create_group(&client->dev.kobj, &adm1025_group);
if (err)
return err;
/* Pin 11 is either in4 (+12V) or VID4 */
config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG);
if (!(config & 0x20)) {
err = sysfs_create_group(&client->dev.kobj, &adm1025_group_in4);
if (err)
goto exit_remove;
}
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto exit_remove;
}
return 0;
exit_remove:
sysfs_remove_group(&client->dev.kobj, &adm1025_group);
sysfs_remove_group(&client->dev.kobj, &adm1025_group_in4);
return err;
}
static void adm1025_init_client(struct i2c_client *client) static void adm1025_init_client(struct i2c_client *client)
{ {
u8 reg; u8 reg;
...@@ -557,61 +523,54 @@ static void adm1025_init_client(struct i2c_client *client) ...@@ -557,61 +523,54 @@ static void adm1025_init_client(struct i2c_client *client)
(reg&0x7E)|0x01); (reg&0x7E)|0x01);
} }
static int adm1025_remove(struct i2c_client *client) static int adm1025_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct adm1025_data *data = i2c_get_clientdata(client); struct device *dev = &client->dev;
struct device *hwmon_dev;
hwmon_device_unregister(data->hwmon_dev); struct adm1025_data *data;
sysfs_remove_group(&client->dev.kobj, &adm1025_group); u8 config;
sysfs_remove_group(&client->dev.kobj, &adm1025_group_in4);
return 0;
}
static struct adm1025_data *adm1025_update_device(struct device *dev) data = devm_kzalloc(dev, sizeof(struct adm1025_data), GFP_KERNEL);
{ if (!data)
struct i2c_client *client = to_i2c_client(dev); return -ENOMEM;
struct adm1025_data *data = i2c_get_clientdata(client);
mutex_lock(&data->update_lock); i2c_set_clientdata(client, data);
data->client = client;
mutex_init(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { /* Initialize the ADM1025 chip */
int i; adm1025_init_client(client);
dev_dbg(&client->dev, "Updating data.\n"); /* sysfs hooks */
for (i = 0; i < 6; i++) { data->groups[0] = &adm1025_group;
data->in[i] = i2c_smbus_read_byte_data(client, /* Pin 11 is either in4 (+12V) or VID4 */
ADM1025_REG_IN(i)); config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG);
data->in_min[i] = i2c_smbus_read_byte_data(client, if (!(config & 0x20))
ADM1025_REG_IN_MIN(i)); data->groups[1] = &adm1025_group_in4;
data->in_max[i] = i2c_smbus_read_byte_data(client,
ADM1025_REG_IN_MAX(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,
ADM1025_REG_TEMP_LOW(i));
data->temp_max[i] = i2c_smbus_read_byte_data(client,
ADM1025_REG_TEMP_HIGH(i));
}
data->alarms = i2c_smbus_read_byte_data(client,
ADM1025_REG_STATUS1)
| (i2c_smbus_read_byte_data(client,
ADM1025_REG_STATUS2) << 8);
data->vid = (i2c_smbus_read_byte_data(client,
ADM1025_REG_VID) & 0x0f)
| ((i2c_smbus_read_byte_data(client,
ADM1025_REG_VID4) & 0x01) << 4);
data->last_updated = jiffies; hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
data->valid = 1; data, data->groups);
} return PTR_ERR_OR_ZERO(hwmon_dev);
}
mutex_unlock(&data->update_lock); static const struct i2c_device_id adm1025_id[] = {
{ "adm1025", adm1025 },
{ "ne1619", ne1619 },
{ }
};
MODULE_DEVICE_TABLE(i2c, adm1025_id);
return data; static struct i2c_driver adm1025_driver = {
} .class = I2C_CLASS_HWMON,
.driver = {
.name = "adm1025",
},
.probe = adm1025_probe,
.id_table = adm1025_id,
.detect = adm1025_detect,
.address_list = normal_i2c,
};
module_i2c_driver(adm1025_driver); module_i2c_driver(adm1025_driver);
......
This diff is collapsed.
...@@ -105,46 +105,12 @@ static const u8 ADM1029_REG_FAN_DIV[] = { ...@@ -105,46 +105,12 @@ static const u8 ADM1029_REG_FAN_DIV[] = {
ADM1029_REG_FAN2_CONFIG, ADM1029_REG_FAN2_CONFIG,
}; };
/*
* Functions declaration
*/
static int adm1029_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int adm1029_detect(struct i2c_client *client,
struct i2c_board_info *info);
static int adm1029_remove(struct i2c_client *client);
static struct adm1029_data *adm1029_update_device(struct device *dev);
static int adm1029_init_client(struct i2c_client *client);
/*
* Driver data (common to all clients)
*/
static const struct i2c_device_id adm1029_id[] = {
{ "adm1029", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, adm1029_id);
static struct i2c_driver adm1029_driver = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = "adm1029",
},
.probe = adm1029_probe,
.remove = adm1029_remove,
.id_table = adm1029_id,
.detect = adm1029_detect,
.address_list = normal_i2c,
};
/* /*
* Client data (each client gets its own) * Client data (each client gets its own)
*/ */
struct adm1029_data { struct adm1029_data {
struct device *hwmon_dev; struct i2c_client *client;
struct mutex update_lock; struct mutex update_lock;
char valid; /* zero until following fields are valid */ char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */ unsigned long last_updated; /* in jiffies */
...@@ -155,6 +121,50 @@ struct adm1029_data { ...@@ -155,6 +121,50 @@ struct adm1029_data {
u8 fan_div[ARRAY_SIZE(ADM1029_REG_FAN_DIV)]; u8 fan_div[ARRAY_SIZE(ADM1029_REG_FAN_DIV)];
}; };
/*
* function that update the status of the chips (temperature for example)
*/
static struct adm1029_data *adm1029_update_device(struct device *dev)
{
struct adm1029_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
mutex_lock(&data->update_lock);
/*
* Use the "cache" Luke, don't recheck values
* if there are already checked not a long time later
*/
if (time_after(jiffies, data->last_updated + HZ * 2)
|| !data->valid) {
int nr;
dev_dbg(&client->dev, "Updating adm1029 data\n");
for (nr = 0; nr < ARRAY_SIZE(ADM1029_REG_TEMP); nr++) {
data->temp[nr] =
i2c_smbus_read_byte_data(client,
ADM1029_REG_TEMP[nr]);
}
for (nr = 0; nr < ARRAY_SIZE(ADM1029_REG_FAN); nr++) {
data->fan[nr] =
i2c_smbus_read_byte_data(client,
ADM1029_REG_FAN[nr]);
}
for (nr = 0; nr < ARRAY_SIZE(ADM1029_REG_FAN_DIV); nr++) {
data->fan_div[nr] =
i2c_smbus_read_byte_data(client,
ADM1029_REG_FAN_DIV[nr]);
}
data->last_updated = jiffies;
data->valid = 1;
}
mutex_unlock(&data->update_lock);
return data;
}
/* /*
* Sysfs stuff * Sysfs stuff
*/ */
...@@ -197,8 +207,8 @@ show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf) ...@@ -197,8 +207,8 @@ show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf)
static ssize_t set_fan_div(struct device *dev, static ssize_t set_fan_div(struct device *dev,
struct device_attribute *devattr, const char *buf, size_t count) struct device_attribute *devattr, const char *buf, size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct adm1029_data *data = dev_get_drvdata(dev);
struct adm1029_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
u8 reg; u8 reg;
long val; long val;
...@@ -270,7 +280,7 @@ static SENSOR_DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR, ...@@ -270,7 +280,7 @@ static SENSOR_DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR,
static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR, static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR,
show_fan_div, set_fan_div, 1); show_fan_div, set_fan_div, 1);
static struct attribute *adm1029_attributes[] = { static struct attribute *adm1029_attrs[] = {
&sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr,
&sensor_dev_attr_temp1_min.dev_attr.attr, &sensor_dev_attr_temp1_min.dev_attr.attr,
&sensor_dev_attr_temp1_max.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr,
...@@ -289,9 +299,7 @@ static struct attribute *adm1029_attributes[] = { ...@@ -289,9 +299,7 @@ static struct attribute *adm1029_attributes[] = {
NULL NULL
}; };
static const struct attribute_group adm1029_group = { ATTRIBUTE_GROUPS(adm1029);
.attrs = adm1029_attributes,
};
/* /*
* Real code * Real code
...@@ -340,48 +348,10 @@ static int adm1029_detect(struct i2c_client *client, ...@@ -340,48 +348,10 @@ static int adm1029_detect(struct i2c_client *client,
return 0; return 0;
} }
static int adm1029_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct adm1029_data *data;
int err;
data = devm_kzalloc(&client->dev, sizeof(struct adm1029_data),
GFP_KERNEL);
if (!data)
return -ENOMEM;
i2c_set_clientdata(client, data);
mutex_init(&data->update_lock);
/*
* Initialize the ADM1029 chip
* Check config register
*/
if (adm1029_init_client(client) == 0)
return -ENODEV;
/* Register sysfs hooks */
err = sysfs_create_group(&client->dev.kobj, &adm1029_group);
if (err)
return err;
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto exit_remove_files;
}
return 0;
exit_remove_files:
sysfs_remove_group(&client->dev.kobj, &adm1029_group);
return err;
}
static int adm1029_init_client(struct i2c_client *client) static int adm1029_init_client(struct i2c_client *client)
{ {
u8 config; u8 config;
config = i2c_smbus_read_byte_data(client, ADM1029_REG_CONFIG); config = i2c_smbus_read_byte_data(client, ADM1029_REG_CONFIG);
if ((config & 0x10) == 0) { if ((config & 0x10) == 0) {
i2c_smbus_write_byte_data(client, ADM1029_REG_CONFIG, i2c_smbus_write_byte_data(client, ADM1029_REG_CONFIG,
...@@ -396,59 +366,49 @@ static int adm1029_init_client(struct i2c_client *client) ...@@ -396,59 +366,49 @@ static int adm1029_init_client(struct i2c_client *client)
return 1; return 1;
} }
static int adm1029_remove(struct i2c_client *client) static int adm1029_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{ {
struct adm1029_data *data = i2c_get_clientdata(client); struct device *dev = &client->dev;
struct adm1029_data *data;
hwmon_device_unregister(data->hwmon_dev); struct device *hwmon_dev;
sysfs_remove_group(&client->dev.kobj, &adm1029_group);
return 0; data = devm_kzalloc(dev, sizeof(struct adm1029_data), GFP_KERNEL);
} if (!data)
return -ENOMEM;
/* data->client = client;
* function that update the status of the chips (temperature for example) mutex_init(&data->update_lock);
*/
static struct adm1029_data *adm1029_update_device(struct device *dev)
{
struct i2c_client *client = to_i2c_client(dev);
struct adm1029_data *data = i2c_get_clientdata(client);
mutex_lock(&data->update_lock);
/* /*
* Use the "cache" Luke, don't recheck values * Initialize the ADM1029 chip
* if there are already checked not a long time later * Check config register
*/ */
if (time_after(jiffies, data->last_updated + HZ * 2) if (adm1029_init_client(client) == 0)
|| !data->valid) { return -ENODEV;
int nr;
dev_dbg(&client->dev, "Updating adm1029 data\n");
for (nr = 0; nr < ARRAY_SIZE(ADM1029_REG_TEMP); nr++) {
data->temp[nr] =
i2c_smbus_read_byte_data(client,
ADM1029_REG_TEMP[nr]);
}
for (nr = 0; nr < ARRAY_SIZE(ADM1029_REG_FAN); nr++) {
data->fan[nr] =
i2c_smbus_read_byte_data(client,
ADM1029_REG_FAN[nr]);
}
for (nr = 0; nr < ARRAY_SIZE(ADM1029_REG_FAN_DIV); nr++) {
data->fan_div[nr] =
i2c_smbus_read_byte_data(client,
ADM1029_REG_FAN_DIV[nr]);
}
data->last_updated = jiffies; hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
data->valid = 1; data,
} adm1029_groups);
return PTR_ERR_OR_ZERO(hwmon_dev);
}
mutex_unlock(&data->update_lock); static const struct i2c_device_id adm1029_id[] = {
{ "adm1029", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, adm1029_id);
return data; static struct i2c_driver adm1029_driver = {
} .class = I2C_CLASS_HWMON,
.driver = {
.name = "adm1029",
},
.probe = adm1029_probe,
.id_table = adm1029_id,
.detect = adm1029_detect,
.address_list = normal_i2c,
};
module_i2c_driver(adm1029_driver); module_i2c_driver(adm1029_driver);
......
This diff is collapsed.
This diff is collapsed.
...@@ -198,7 +198,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client) ...@@ -198,7 +198,7 @@ static int ads1015_get_channels_config_of(struct i2c_client *client)
} }
channel = be32_to_cpup(property); channel = be32_to_cpup(property);
if (channel > ADS1015_CHANNELS) { if (channel >= ADS1015_CHANNELS) {
dev_err(&client->dev, dev_err(&client->dev,
"invalid channel index %d on %s\n", "invalid channel index %d on %s\n",
channel, node->full_name); channel, node->full_name);
......
...@@ -50,7 +50,7 @@ enum ads7828_chips { ads7828, ads7830 }; ...@@ -50,7 +50,7 @@ enum ads7828_chips { ads7828, ads7830 };
/* Client specific data */ /* Client specific data */
struct ads7828_data { struct ads7828_data {
struct device *hwmon_dev; struct i2c_client *client;
struct mutex update_lock; /* Mutex protecting updates */ struct mutex update_lock; /* Mutex protecting updates */
unsigned long last_updated; /* Last updated time (in jiffies) */ unsigned long last_updated; /* Last updated time (in jiffies) */
u16 adc_input[ADS7828_NCH]; /* ADS7828_NCH samples */ u16 adc_input[ADS7828_NCH]; /* ADS7828_NCH samples */
...@@ -72,8 +72,8 @@ static inline u8 ads7828_cmd_byte(u8 cmd, int ch) ...@@ -72,8 +72,8 @@ static inline u8 ads7828_cmd_byte(u8 cmd, int ch)
/* Update data for the device (all 8 channels) */ /* Update data for the device (all 8 channels) */
static struct ads7828_data *ads7828_update_device(struct device *dev) static struct ads7828_data *ads7828_update_device(struct device *dev)
{ {
struct i2c_client *client = to_i2c_client(dev); struct ads7828_data *data = dev_get_drvdata(dev);
struct ads7828_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
...@@ -116,7 +116,7 @@ static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, ads7828_show_in, NULL, 5); ...@@ -116,7 +116,7 @@ static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, ads7828_show_in, NULL, 5);
static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, ads7828_show_in, NULL, 6); static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, ads7828_show_in, NULL, 6);
static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, ads7828_show_in, NULL, 7); static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, ads7828_show_in, NULL, 7);
static struct attribute *ads7828_attributes[] = { static struct attribute *ads7828_attrs[] = {
&sensor_dev_attr_in0_input.dev_attr.attr, &sensor_dev_attr_in0_input.dev_attr.attr,
&sensor_dev_attr_in1_input.dev_attr.attr, &sensor_dev_attr_in1_input.dev_attr.attr,
&sensor_dev_attr_in2_input.dev_attr.attr, &sensor_dev_attr_in2_input.dev_attr.attr,
...@@ -128,29 +128,17 @@ static struct attribute *ads7828_attributes[] = { ...@@ -128,29 +128,17 @@ static struct attribute *ads7828_attributes[] = {
NULL NULL
}; };
static const struct attribute_group ads7828_group = { ATTRIBUTE_GROUPS(ads7828);
.attrs = ads7828_attributes,
};
static int ads7828_remove(struct i2c_client *client)
{
struct ads7828_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &ads7828_group);
return 0;
}
static int ads7828_probe(struct i2c_client *client, static int ads7828_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct ads7828_platform_data *pdata = dev_get_platdata(&client->dev); struct device *dev = &client->dev;
struct ads7828_platform_data *pdata = dev_get_platdata(dev);
struct ads7828_data *data; struct ads7828_data *data;
int err; struct device *hwmon_dev;
data = devm_kzalloc(&client->dev, sizeof(struct ads7828_data), data = devm_kzalloc(dev, sizeof(struct ads7828_data), GFP_KERNEL);
GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -182,24 +170,13 @@ static int ads7828_probe(struct i2c_client *client, ...@@ -182,24 +170,13 @@ static int ads7828_probe(struct i2c_client *client,
if (!data->diff_input) if (!data->diff_input)
data->cmd_byte |= ADS7828_CMD_SD_SE; data->cmd_byte |= ADS7828_CMD_SD_SE;
i2c_set_clientdata(client, data); data->client = client;
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
err = sysfs_create_group(&client->dev.kobj, &ads7828_group); hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
if (err) data,
return err; ads7828_groups);
return PTR_ERR_OR_ZERO(hwmon_dev);
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto error;
}
return 0;
error:
sysfs_remove_group(&client->dev.kobj, &ads7828_group);
return err;
} }
static const struct i2c_device_id ads7828_device_ids[] = { static const struct i2c_device_id ads7828_device_ids[] = {
...@@ -216,7 +193,6 @@ static struct i2c_driver ads7828_driver = { ...@@ -216,7 +193,6 @@ static struct i2c_driver ads7828_driver = {
.id_table = ads7828_device_ids, .id_table = ads7828_device_ids,
.probe = ads7828_probe, .probe = ads7828_probe,
.remove = ads7828_remove,
}; };
module_i2c_driver(ads7828_driver); module_i2c_driver(ads7828_driver);
......
...@@ -51,7 +51,7 @@ struct adt7411_data { ...@@ -51,7 +51,7 @@ struct adt7411_data {
struct mutex update_lock; struct mutex update_lock;
unsigned long next_update; unsigned long next_update;
int vref_cached; int vref_cached;
struct device *hwmon_dev; struct i2c_client *client;
}; };
/* /*
...@@ -111,7 +111,8 @@ static int adt7411_modify_bit(struct i2c_client *client, u8 reg, u8 bit, ...@@ -111,7 +111,8 @@ static int adt7411_modify_bit(struct i2c_client *client, u8 reg, u8 bit,
static ssize_t adt7411_show_vdd(struct device *dev, static ssize_t adt7411_show_vdd(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct i2c_client *client = to_i2c_client(dev); struct adt7411_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
int ret = adt7411_read_10_bit(client, ADT7411_REG_INT_TEMP_VDD_LSB, int ret = adt7411_read_10_bit(client, ADT7411_REG_INT_TEMP_VDD_LSB,
ADT7411_REG_VDD_MSB, 2); ADT7411_REG_VDD_MSB, 2);
...@@ -121,7 +122,8 @@ static ssize_t adt7411_show_vdd(struct device *dev, ...@@ -121,7 +122,8 @@ static ssize_t adt7411_show_vdd(struct device *dev,
static ssize_t adt7411_show_temp(struct device *dev, static ssize_t adt7411_show_temp(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct i2c_client *client = to_i2c_client(dev); struct adt7411_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
int val = adt7411_read_10_bit(client, ADT7411_REG_INT_TEMP_VDD_LSB, int val = adt7411_read_10_bit(client, ADT7411_REG_INT_TEMP_VDD_LSB,
ADT7411_REG_INT_TEMP_MSB, 0); ADT7411_REG_INT_TEMP_MSB, 0);
...@@ -137,8 +139,8 @@ static ssize_t adt7411_show_input(struct device *dev, ...@@ -137,8 +139,8 @@ static ssize_t adt7411_show_input(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
int nr = to_sensor_dev_attr(attr)->index; int nr = to_sensor_dev_attr(attr)->index;
struct i2c_client *client = to_i2c_client(dev); struct adt7411_data *data = dev_get_drvdata(dev);
struct adt7411_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
int val; int val;
u8 lsb_reg, lsb_shift; u8 lsb_reg, lsb_shift;
...@@ -180,7 +182,8 @@ static ssize_t adt7411_show_bit(struct device *dev, ...@@ -180,7 +182,8 @@ static ssize_t adt7411_show_bit(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(attr); struct sensor_device_attribute_2 *attr2 = to_sensor_dev_attr_2(attr);
struct i2c_client *client = to_i2c_client(dev); struct adt7411_data *data = dev_get_drvdata(dev);
struct i2c_client *client = data->client;
int ret = i2c_smbus_read_byte_data(client, attr2->index); int ret = i2c_smbus_read_byte_data(client, attr2->index);
return ret < 0 ? ret : sprintf(buf, "%u\n", !!(ret & attr2->nr)); return ret < 0 ? ret : sprintf(buf, "%u\n", !!(ret & attr2->nr));
...@@ -191,8 +194,8 @@ static ssize_t adt7411_set_bit(struct device *dev, ...@@ -191,8 +194,8 @@ static ssize_t adt7411_set_bit(struct device *dev,
size_t count) size_t count)
{ {
struct sensor_device_attribute_2 *s_attr2 = to_sensor_dev_attr_2(attr); struct sensor_device_attribute_2 *s_attr2 = to_sensor_dev_attr_2(attr);
struct i2c_client *client = to_i2c_client(dev); struct adt7411_data *data = dev_get_drvdata(dev);
struct adt7411_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
int ret; int ret;
unsigned long flag; unsigned long flag;
...@@ -245,9 +248,7 @@ static struct attribute *adt7411_attrs[] = { ...@@ -245,9 +248,7 @@ static struct attribute *adt7411_attrs[] = {
NULL NULL
}; };
static const struct attribute_group adt7411_attr_grp = { ATTRIBUTE_GROUPS(adt7411);
.attrs = adt7411_attrs,
};
static int adt7411_detect(struct i2c_client *client, static int adt7411_detect(struct i2c_client *client,
struct i2c_board_info *info) struct i2c_board_info *info)
...@@ -281,14 +282,17 @@ static int adt7411_detect(struct i2c_client *client, ...@@ -281,14 +282,17 @@ static int adt7411_detect(struct i2c_client *client,
static int adt7411_probe(struct i2c_client *client, static int adt7411_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device *dev = &client->dev;
struct adt7411_data *data; struct adt7411_data *data;
struct device *hwmon_dev;
int ret; int ret;
data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
i2c_set_clientdata(client, data); i2c_set_clientdata(client, data);
data->client = client;
mutex_init(&data->device_lock); mutex_init(&data->device_lock);
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
...@@ -300,32 +304,10 @@ static int adt7411_probe(struct i2c_client *client, ...@@ -300,32 +304,10 @@ static int adt7411_probe(struct i2c_client *client,
/* force update on first occasion */ /* force update on first occasion */
data->next_update = jiffies; data->next_update = jiffies;
ret = sysfs_create_group(&client->dev.kobj, &adt7411_attr_grp); hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
if (ret) data,
return ret; adt7411_groups);
return PTR_ERR_OR_ZERO(hwmon_dev);
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
ret = PTR_ERR(data->hwmon_dev);
goto exit_remove;
}
dev_info(&client->dev, "successfully registered\n");
return 0;
exit_remove:
sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp);
return ret;
}
static int adt7411_remove(struct i2c_client *client)
{
struct adt7411_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &adt7411_attr_grp);
return 0;
} }
static const struct i2c_device_id adt7411_id[] = { static const struct i2c_device_id adt7411_id[] = {
...@@ -339,7 +321,6 @@ static struct i2c_driver adt7411_driver = { ...@@ -339,7 +321,6 @@ static struct i2c_driver adt7411_driver = {
.name = "adt7411", .name = "adt7411",
}, },
.probe = adt7411_probe, .probe = adt7411_probe,
.remove = adt7411_remove,
.id_table = adt7411_id, .id_table = adt7411_id,
.detect = adt7411_detect, .detect = adt7411_detect,
.address_list = normal_i2c, .address_list = normal_i2c,
......
...@@ -202,8 +202,7 @@ static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END }; ...@@ -202,8 +202,7 @@ static const unsigned short normal_i2c[] = { 0x58, 0x5C, I2C_CLIENT_END };
(((value) & prefix##_MASK) >> prefix##_SHIFT) (((value) & prefix##_MASK) >> prefix##_SHIFT)
struct adt7462_data { struct adt7462_data {
struct device *hwmon_dev; struct i2c_client *client;
struct attribute_group attrs;
struct mutex lock; struct mutex lock;
char sensors_valid; char sensors_valid;
char limits_valid; char limits_valid;
...@@ -232,30 +231,6 @@ struct adt7462_data { ...@@ -232,30 +231,6 @@ struct adt7462_data {
u8 alarms[ADT7462_ALARM_REG_COUNT]; u8 alarms[ADT7462_ALARM_REG_COUNT];
}; };
static int adt7462_probe(struct i2c_client *client,
const struct i2c_device_id *id);
static int adt7462_detect(struct i2c_client *client,
struct i2c_board_info *info);
static int adt7462_remove(struct i2c_client *client);
static const struct i2c_device_id adt7462_id[] = {
{ "adt7462", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, adt7462_id);
static struct i2c_driver adt7462_driver = {
.class = I2C_CLASS_HWMON,
.driver = {
.name = "adt7462",
},
.probe = adt7462_probe,
.remove = adt7462_remove,
.id_table = adt7462_id,
.detect = adt7462_detect,
.address_list = normal_i2c,
};
/* /*
* 16-bit registers on the ADT7462 are low-byte first. The data sheet says * 16-bit registers on the ADT7462 are low-byte first. The data sheet says
* that the low byte must be read before the high byte. * that the low byte must be read before the high byte.
...@@ -705,8 +680,8 @@ static int find_trange_value(int trange) ...@@ -705,8 +680,8 @@ static int find_trange_value(int trange)
static struct adt7462_data *adt7462_update_device(struct device *dev) static struct adt7462_data *adt7462_update_device(struct device *dev)
{ {
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
unsigned long local_jiffies = jiffies; unsigned long local_jiffies = jiffies;
int i; int i;
...@@ -828,8 +803,8 @@ static ssize_t set_temp_min(struct device *dev, ...@@ -828,8 +803,8 @@ static ssize_t set_temp_min(struct device *dev,
size_t count) size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
if (kstrtol(buf, 10, &temp) || !temp_enabled(data, attr->index)) if (kstrtol(buf, 10, &temp) || !temp_enabled(data, attr->index))
...@@ -866,8 +841,8 @@ static ssize_t set_temp_max(struct device *dev, ...@@ -866,8 +841,8 @@ static ssize_t set_temp_max(struct device *dev,
size_t count) size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
if (kstrtol(buf, 10, &temp) || !temp_enabled(data, attr->index)) if (kstrtol(buf, 10, &temp) || !temp_enabled(data, attr->index))
...@@ -929,8 +904,8 @@ static ssize_t set_volt_max(struct device *dev, ...@@ -929,8 +904,8 @@ static ssize_t set_volt_max(struct device *dev,
size_t count) size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
int x = voltage_multiplier(data, attr->index); int x = voltage_multiplier(data, attr->index);
long temp; long temp;
...@@ -971,8 +946,8 @@ static ssize_t set_volt_min(struct device *dev, ...@@ -971,8 +946,8 @@ static ssize_t set_volt_min(struct device *dev,
size_t count) size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
int x = voltage_multiplier(data, attr->index); int x = voltage_multiplier(data, attr->index);
long temp; long temp;
...@@ -1061,8 +1036,8 @@ static ssize_t set_fan_min(struct device *dev, ...@@ -1061,8 +1036,8 @@ static ssize_t set_fan_min(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
if (kstrtol(buf, 10, &temp) || !temp || if (kstrtol(buf, 10, &temp) || !temp ||
...@@ -1109,8 +1084,8 @@ static ssize_t set_force_pwm_max(struct device *dev, ...@@ -1109,8 +1084,8 @@ static ssize_t set_force_pwm_max(struct device *dev,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
u8 reg; u8 reg;
...@@ -1142,8 +1117,8 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, ...@@ -1142,8 +1117,8 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
if (kstrtol(buf, 10, &temp)) if (kstrtol(buf, 10, &temp))
...@@ -1172,8 +1147,8 @@ static ssize_t set_pwm_max(struct device *dev, ...@@ -1172,8 +1147,8 @@ static ssize_t set_pwm_max(struct device *dev,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
if (kstrtol(buf, 10, &temp)) if (kstrtol(buf, 10, &temp))
...@@ -1204,8 +1179,8 @@ static ssize_t set_pwm_min(struct device *dev, ...@@ -1204,8 +1179,8 @@ static ssize_t set_pwm_min(struct device *dev,
size_t count) size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
if (kstrtol(buf, 10, &temp)) if (kstrtol(buf, 10, &temp))
...@@ -1238,8 +1213,8 @@ static ssize_t set_pwm_hyst(struct device *dev, ...@@ -1238,8 +1213,8 @@ static ssize_t set_pwm_hyst(struct device *dev,
size_t count) size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
if (kstrtol(buf, 10, &temp)) if (kstrtol(buf, 10, &temp))
...@@ -1283,8 +1258,8 @@ static ssize_t set_pwm_tmax(struct device *dev, ...@@ -1283,8 +1258,8 @@ static ssize_t set_pwm_tmax(struct device *dev,
{ {
int temp; int temp;
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
int tmin, trange_value; int tmin, trange_value;
long trange; long trange;
...@@ -1324,8 +1299,8 @@ static ssize_t set_pwm_tmin(struct device *dev, ...@@ -1324,8 +1299,8 @@ static ssize_t set_pwm_tmin(struct device *dev,
size_t count) size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
if (kstrtol(buf, 10, &temp)) if (kstrtol(buf, 10, &temp))
...@@ -1381,8 +1356,8 @@ static ssize_t set_pwm_auto(struct device *dev, ...@@ -1381,8 +1356,8 @@ static ssize_t set_pwm_auto(struct device *dev,
size_t count) size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
if (kstrtol(buf, 10, &temp)) if (kstrtol(buf, 10, &temp))
...@@ -1440,8 +1415,8 @@ static ssize_t set_pwm_auto_temp(struct device *dev, ...@@ -1440,8 +1415,8 @@ static ssize_t set_pwm_auto_temp(struct device *dev,
size_t count) size_t count)
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev); struct adt7462_data *data = dev_get_drvdata(dev);
struct adt7462_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
long temp; long temp;
if (kstrtol(buf, 10, &temp)) if (kstrtol(buf, 10, &temp))
...@@ -1725,7 +1700,7 @@ static SENSOR_DEVICE_ATTR(pwm3_auto_channels_temp, S_IWUSR | S_IRUGO, ...@@ -1725,7 +1700,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, static SENSOR_DEVICE_ATTR(pwm4_auto_channels_temp, S_IWUSR | S_IRUGO,
show_pwm_auto_temp, set_pwm_auto_temp, 3); show_pwm_auto_temp, set_pwm_auto_temp, 3);
static struct attribute *adt7462_attr[] = { static struct attribute *adt7462_attrs[] = {
&sensor_dev_attr_temp1_max.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr,
&sensor_dev_attr_temp2_max.dev_attr.attr, &sensor_dev_attr_temp2_max.dev_attr.attr,
&sensor_dev_attr_temp3_max.dev_attr.attr, &sensor_dev_attr_temp3_max.dev_attr.attr,
...@@ -1896,6 +1871,8 @@ static struct attribute *adt7462_attr[] = { ...@@ -1896,6 +1871,8 @@ static struct attribute *adt7462_attr[] = {
NULL NULL
}; };
ATTRIBUTE_GROUPS(adt7462);
/* Return 0 if detection is successful, -ENODEV otherwise */ /* Return 0 if detection is successful, -ENODEV otherwise */
static int adt7462_detect(struct i2c_client *client, static int adt7462_detect(struct i2c_client *client,
struct i2c_board_info *info) struct i2c_board_info *info)
...@@ -1926,46 +1903,41 @@ static int adt7462_detect(struct i2c_client *client, ...@@ -1926,46 +1903,41 @@ static int adt7462_detect(struct i2c_client *client,
static int adt7462_probe(struct i2c_client *client, static int adt7462_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device *dev = &client->dev;
struct adt7462_data *data; struct adt7462_data *data;
int err; struct device *hwmon_dev;
data = devm_kzalloc(&client->dev, sizeof(struct adt7462_data), data = devm_kzalloc(dev, sizeof(struct adt7462_data), GFP_KERNEL);
GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
i2c_set_clientdata(client, data); data->client = client;
mutex_init(&data->lock); mutex_init(&data->lock);
dev_info(&client->dev, "%s chip found\n", client->name); dev_info(&client->dev, "%s chip found\n", client->name);
/* Register sysfs hooks */ hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
data->attrs.attrs = adt7462_attr; data,
err = sysfs_create_group(&client->dev.kobj, &data->attrs); adt7462_groups);
if (err) return PTR_ERR_OR_ZERO(hwmon_dev);
return err;
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto exit_remove;
}
return 0;
exit_remove:
sysfs_remove_group(&client->dev.kobj, &data->attrs);
return err;
} }
static int adt7462_remove(struct i2c_client *client) static const struct i2c_device_id adt7462_id[] = {
{ { "adt7462", 0 },
struct adt7462_data *data = i2c_get_clientdata(client); { }
};
MODULE_DEVICE_TABLE(i2c, adt7462_id);
hwmon_device_unregister(data->hwmon_dev); static struct i2c_driver adt7462_driver = {
sysfs_remove_group(&client->dev.kobj, &data->attrs); .class = I2C_CLASS_HWMON,
return 0; .driver = {
} .name = "adt7462",
},
.probe = adt7462_probe,
.id_table = adt7462_id,
.detect = adt7462_detect,
.address_list = normal_i2c,
};
module_i2c_driver(adt7462_driver); module_i2c_driver(adt7462_driver);
......
This diff is collapsed.
This diff is collapsed.
...@@ -300,7 +300,7 @@ static ssize_t store_fan16(struct device *dev, ...@@ -300,7 +300,7 @@ static ssize_t store_fan16(struct device *dev,
* respectively. That doesn't mean that's what the motherboard provides. :) * respectively. That doesn't mean that's what the motherboard provides. :)
*/ */
static int asc7621_in_scaling[] = { static const int asc7621_in_scaling[] = {
2500, 2250, 3300, 5000, 12000 2500, 2250, 3300, 5000, 12000
}; };
...@@ -451,7 +451,7 @@ static ssize_t store_temp62(struct device *dev, ...@@ -451,7 +451,7 @@ static ssize_t store_temp62(struct device *dev,
* hwmon specs, we synthesize the auto_point_2 from them. * hwmon specs, we synthesize the auto_point_2 from them.
*/ */
static u32 asc7621_range_map[] = { static const u32 asc7621_range_map[] = {
2000, 2500, 3330, 4000, 5000, 6670, 8000, 10000, 2000, 2500, 3330, 4000, 5000, 6670, 8000, 10000,
13330, 16000, 20000, 26670, 32000, 40000, 53330, 80000, 13330, 16000, 20000, 26670, 32000, 40000, 53330, 80000,
}; };
...@@ -512,7 +512,7 @@ static ssize_t show_pwm_ac(struct device *dev, ...@@ -512,7 +512,7 @@ static ssize_t show_pwm_ac(struct device *dev,
{ {
SETUP_SHOW_DATA_PARAM(dev, attr); SETUP_SHOW_DATA_PARAM(dev, attr);
u8 config, altbit, regval; u8 config, altbit, regval;
u8 map[] = { const u8 map[] = {
0x01, 0x02, 0x04, 0x1f, 0x00, 0x06, 0x07, 0x10, 0x01, 0x02, 0x04, 0x1f, 0x00, 0x06, 0x07, 0x10,
0x08, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f 0x08, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f
}; };
...@@ -533,7 +533,7 @@ static ssize_t store_pwm_ac(struct device *dev, ...@@ -533,7 +533,7 @@ static ssize_t store_pwm_ac(struct device *dev,
SETUP_STORE_DATA_PARAM(dev, attr); SETUP_STORE_DATA_PARAM(dev, attr);
unsigned long reqval; unsigned long reqval;
u8 currval, config, altbit, newval; u8 currval, config, altbit, newval;
u16 map[] = { const u16 map[] = {
0x04, 0x00, 0x01, 0xff, 0x02, 0xff, 0x05, 0x06, 0x04, 0x00, 0x01, 0xff, 0x02, 0xff, 0x05, 0x06,
0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f,
0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
...@@ -651,7 +651,7 @@ static ssize_t store_pwm_enable(struct device *dev, ...@@ -651,7 +651,7 @@ static ssize_t store_pwm_enable(struct device *dev,
return count; return count;
} }
static u32 asc7621_pwm_freq_map[] = { static const u32 asc7621_pwm_freq_map[] = {
10, 15, 23, 30, 38, 47, 62, 94, 10, 15, 23, 30, 38, 47, 62, 94,
23000, 24000, 25000, 26000, 27000, 28000, 29000, 30000 23000, 24000, 25000, 26000, 27000, 28000, 29000, 30000
}; };
...@@ -700,7 +700,7 @@ static ssize_t store_pwm_freq(struct device *dev, ...@@ -700,7 +700,7 @@ static ssize_t store_pwm_freq(struct device *dev,
return count; return count;
} }
static u32 asc7621_pwm_auto_spinup_map[] = { static const u32 asc7621_pwm_auto_spinup_map[] = {
0, 100, 250, 400, 700, 1000, 2000, 4000 0, 100, 250, 400, 700, 1000, 2000, 4000
}; };
...@@ -749,7 +749,7 @@ static ssize_t store_pwm_ast(struct device *dev, ...@@ -749,7 +749,7 @@ static ssize_t store_pwm_ast(struct device *dev,
return count; return count;
} }
static u32 asc7621_temp_smoothing_time_map[] = { static const u32 asc7621_temp_smoothing_time_map[] = {
35000, 17600, 11800, 7000, 4400, 3000, 1600, 800 35000, 17600, 11800, 7000, 4400, 3000, 1600, 800
}; };
......
...@@ -46,7 +46,7 @@ MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>"); ...@@ -46,7 +46,7 @@ MODULE_AUTHOR("Sebastian Witt <se.witt@gmx.net>");
static const unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END }; static const unsigned short normal_i2c[] = { 0x37, 0x4e, I2C_CLIENT_END };
struct atxp1_data { struct atxp1_data {
struct device *hwmon_dev; struct i2c_client *client;
struct mutex update_lock; struct mutex update_lock;
unsigned long last_updated; unsigned long last_updated;
u8 valid; u8 valid;
...@@ -61,11 +61,8 @@ struct atxp1_data { ...@@ -61,11 +61,8 @@ struct atxp1_data {
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 = dev_get_drvdata(dev);
struct atxp1_data *data; struct i2c_client *client = data->client;
client = to_i2c_client(dev);
data = i2c_get_clientdata(client);
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
...@@ -105,15 +102,12 @@ static ssize_t atxp1_storevcore(struct device *dev, ...@@ -105,15 +102,12 @@ static ssize_t atxp1_storevcore(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct atxp1_data *data; struct atxp1_data *data = atxp1_update_device(dev);
struct i2c_client *client; struct i2c_client *client = data->client;
int vid, cvid; int vid, cvid;
unsigned long vcore; unsigned long vcore;
int err; int err;
client = to_i2c_client(dev);
data = atxp1_update_device(dev);
err = kstrtoul(buf, 10, &vcore); err = kstrtoul(buf, 10, &vcore);
if (err) if (err)
return err; return err;
...@@ -184,14 +178,11 @@ static ssize_t atxp1_storegpio1(struct device *dev, ...@@ -184,14 +178,11 @@ static ssize_t atxp1_storegpio1(struct device *dev,
struct device_attribute *attr, const char *buf, struct device_attribute *attr, const char *buf,
size_t count) size_t count)
{ {
struct atxp1_data *data; struct atxp1_data *data = atxp1_update_device(dev);
struct i2c_client *client; struct i2c_client *client = data->client;
unsigned long value; unsigned long value;
int err; int err;
client = to_i2c_client(dev);
data = atxp1_update_device(dev);
err = kstrtoul(buf, 16, &value); err = kstrtoul(buf, 16, &value);
if (err) if (err)
return err; return err;
...@@ -234,7 +225,7 @@ static ssize_t atxp1_storegpio2(struct device *dev, ...@@ -234,7 +225,7 @@ static ssize_t atxp1_storegpio2(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct atxp1_data *data = atxp1_update_device(dev); struct atxp1_data *data = atxp1_update_device(dev);
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = data->client;
unsigned long value; unsigned long value;
int err; int err;
...@@ -260,17 +251,13 @@ static ssize_t atxp1_storegpio2(struct device *dev, ...@@ -260,17 +251,13 @@ static ssize_t atxp1_storegpio2(struct device *dev,
*/ */
static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2); static DEVICE_ATTR(gpio2, S_IRUGO | S_IWUSR, atxp1_showgpio2, atxp1_storegpio2);
static struct attribute *atxp1_attributes[] = { static struct attribute *atxp1_attrs[] = {
&dev_attr_gpio1.attr, &dev_attr_gpio1.attr,
&dev_attr_gpio2.attr, &dev_attr_gpio2.attr,
&dev_attr_cpu0_vid.attr, &dev_attr_cpu0_vid.attr,
NULL NULL
}; };
ATTRIBUTE_GROUPS(atxp1);
static const struct attribute_group atxp1_group = {
.attrs = atxp1_attributes,
};
/* Return 0 if detection is successful, -ENODEV otherwise */ /* Return 0 if detection is successful, -ENODEV otherwise */
static int atxp1_detect(struct i2c_client *new_client, static int atxp1_detect(struct i2c_client *new_client,
...@@ -314,50 +301,30 @@ static int atxp1_detect(struct i2c_client *new_client, ...@@ -314,50 +301,30 @@ static int atxp1_detect(struct i2c_client *new_client,
return 0; return 0;
} }
static int atxp1_probe(struct i2c_client *new_client, static int atxp1_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device *dev = &client->dev;
struct atxp1_data *data; struct atxp1_data *data;
int err; struct device *hwmon_dev;
data = devm_kzalloc(&new_client->dev, sizeof(struct atxp1_data), data = devm_kzalloc(dev, sizeof(struct atxp1_data), GFP_KERNEL);
GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
/* Get VRM */ /* Get VRM */
data->vrm = vid_which_vrm(); data->vrm = vid_which_vrm();
i2c_set_clientdata(new_client, data); data->client = client;
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
/* Register sysfs hooks */ hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
err = sysfs_create_group(&new_client->dev.kobj, &atxp1_group); data,
if (err) atxp1_groups);
return err; if (IS_ERR(hwmon_dev))
return PTR_ERR(hwmon_dev);
data->hwmon_dev = hwmon_device_register(&new_client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto exit_remove_files;
}
dev_info(&new_client->dev, "Using VRM: %d.%d\n",
data->vrm / 10, data->vrm % 10);
return 0;
exit_remove_files:
sysfs_remove_group(&new_client->dev.kobj, &atxp1_group);
return err;
};
static int atxp1_remove(struct i2c_client *client)
{
struct atxp1_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev); dev_info(dev, "Using VRM: %d.%d\n", data->vrm / 10, data->vrm % 10);
sysfs_remove_group(&client->dev.kobj, &atxp1_group);
return 0; return 0;
}; };
...@@ -374,7 +341,6 @@ static struct i2c_driver atxp1_driver = { ...@@ -374,7 +341,6 @@ static struct i2c_driver atxp1_driver = {
.name = "atxp1", .name = "atxp1",
}, },
.probe = atxp1_probe, .probe = atxp1_probe,
.remove = atxp1_remove,
.id_table = atxp1_id, .id_table = atxp1_id,
.detect = atxp1_detect, .detect = atxp1_detect,
.address_list = normal_i2c, .address_list = normal_i2c,
......
...@@ -67,7 +67,7 @@ static const u8 DS620_REG_TEMP[3] = { ...@@ -67,7 +67,7 @@ static const u8 DS620_REG_TEMP[3] = {
/* Each client has this additional data */ /* Each client has this additional data */
struct ds620_data { struct ds620_data {
struct device *hwmon_dev; struct i2c_client *client;
struct mutex update_lock; struct mutex update_lock;
char valid; /* !=0 if following fields are valid */ char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */ unsigned long last_updated; /* In jiffies */
...@@ -106,8 +106,8 @@ static void ds620_init_client(struct i2c_client *client) ...@@ -106,8 +106,8 @@ static void ds620_init_client(struct i2c_client *client)
static struct ds620_data *ds620_update_client(struct device *dev) static struct ds620_data *ds620_update_client(struct device *dev)
{ {
struct i2c_client *client = to_i2c_client(dev); struct ds620_data *data = dev_get_drvdata(dev);
struct ds620_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
struct ds620_data *ret = data; struct ds620_data *ret = data;
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
...@@ -158,8 +158,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, ...@@ -158,8 +158,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
long val; long val;
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct i2c_client *client = to_i2c_client(dev); struct ds620_data *data = dev_get_drvdata(dev);
struct ds620_data *data = i2c_get_clientdata(client); struct i2c_client *client = data->client;
res = kstrtol(buf, 10, &val); res = kstrtol(buf, 10, &val);
...@@ -181,13 +181,15 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da, ...@@ -181,13 +181,15 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
{ {
struct sensor_device_attribute *attr = to_sensor_dev_attr(da); struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
struct ds620_data *data = ds620_update_client(dev); struct ds620_data *data = ds620_update_client(dev);
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client;
u16 conf, new_conf; u16 conf, new_conf;
int res; int res;
if (IS_ERR(data)) if (IS_ERR(data))
return PTR_ERR(data); return PTR_ERR(data);
client = data->client;
/* reset alarms if necessary */ /* reset alarms if necessary */
res = i2c_smbus_read_word_swapped(client, DS620_REG_CONF); res = i2c_smbus_read_word_swapped(client, DS620_REG_CONF);
if (res < 0) if (res < 0)
...@@ -213,7 +215,7 @@ static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, ...@@ -213,7 +215,7 @@ static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL,
static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL,
DS620_REG_CONFIG_THF); DS620_REG_CONFIG_THF);
static struct attribute *ds620_attributes[] = { static struct attribute *ds620_attrs[] = {
&sensor_dev_attr_temp1_input.dev_attr.attr, &sensor_dev_attr_temp1_input.dev_attr.attr,
&sensor_dev_attr_temp1_min.dev_attr.attr, &sensor_dev_attr_temp1_min.dev_attr.attr,
&sensor_dev_attr_temp1_max.dev_attr.attr, &sensor_dev_attr_temp1_max.dev_attr.attr,
...@@ -222,55 +224,28 @@ static struct attribute *ds620_attributes[] = { ...@@ -222,55 +224,28 @@ static struct attribute *ds620_attributes[] = {
NULL NULL
}; };
static const struct attribute_group ds620_group = { ATTRIBUTE_GROUPS(ds620);
.attrs = ds620_attributes,
};
static int ds620_probe(struct i2c_client *client, static int ds620_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device *dev = &client->dev;
struct device *hwmon_dev;
struct ds620_data *data; struct ds620_data *data;
int err;
data = devm_kzalloc(&client->dev, sizeof(struct ds620_data), data = devm_kzalloc(dev, sizeof(struct ds620_data), GFP_KERNEL);
GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
i2c_set_clientdata(client, data); data->client = client;
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
/* Initialize the DS620 chip */ /* Initialize the DS620 chip */
ds620_init_client(client); ds620_init_client(client);
/* Register sysfs hooks */ hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
err = sysfs_create_group(&client->dev.kobj, &ds620_group); data, ds620_groups);
if (err) return PTR_ERR_OR_ZERO(hwmon_dev);
return err;
data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto exit_remove_files;
}
dev_info(&client->dev, "temperature sensor found\n");
return 0;
exit_remove_files:
sysfs_remove_group(&client->dev.kobj, &ds620_group);
return err;
}
static int ds620_remove(struct i2c_client *client)
{
struct ds620_data *data = i2c_get_clientdata(client);
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &ds620_group);
return 0;
} }
static const struct i2c_device_id ds620_id[] = { static const struct i2c_device_id ds620_id[] = {
...@@ -287,7 +262,6 @@ static struct i2c_driver ds620_driver = { ...@@ -287,7 +262,6 @@ static struct i2c_driver ds620_driver = {
.name = "ds620", .name = "ds620",
}, },
.probe = ds620_probe, .probe = ds620_probe,
.remove = ds620_remove,
.id_table = ds620_id, .id_table = ds620_id,
}; };
......
...@@ -416,7 +416,7 @@ static bool emc1403_regmap_is_volatile(struct device *dev, unsigned int reg) ...@@ -416,7 +416,7 @@ static bool emc1403_regmap_is_volatile(struct device *dev, unsigned int reg)
} }
} }
static struct regmap_config emc1403_regmap_config = { static const struct regmap_config emc1403_regmap_config = {
.reg_bits = 8, .reg_bits = 8,
.val_bits = 8, .val_bits = 8,
.cache_type = REGCACHE_RBTREE, .cache_type = REGCACHE_RBTREE,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -52,6 +52,7 @@ enum lm75_type { /* keep sorted in alphabetical order */ ...@@ -52,6 +52,7 @@ enum lm75_type { /* keep sorted in alphabetical order */
tmp100, tmp100,
tmp101, tmp101,
tmp105, tmp105,
tmp112,
tmp175, tmp175,
tmp275, tmp275,
tmp75, tmp75,
...@@ -255,6 +256,12 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -255,6 +256,12 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
data->sample_time = HZ; data->sample_time = HZ;
clr_mask |= 1 << 7; /* not one-shot mode */ clr_mask |= 1 << 7; /* not one-shot mode */
break; break;
case tmp112:
set_mask |= 3 << 5; /* 12-bit mode */
clr_mask |= 1 << 7; /* not one-shot mode */
data->resolution = 12;
data->sample_time = HZ / 4;
break;
case tmp105: case tmp105:
case tmp175: case tmp175:
case tmp275: case tmp275:
...@@ -323,6 +330,7 @@ static const struct i2c_device_id lm75_ids[] = { ...@@ -323,6 +330,7 @@ static const struct i2c_device_id lm75_ids[] = {
{ "tmp100", tmp100, }, { "tmp100", tmp100, },
{ "tmp101", tmp101, }, { "tmp101", tmp101, },
{ "tmp105", tmp105, }, { "tmp105", tmp105, },
{ "tmp112", tmp112, },
{ "tmp175", tmp175, }, { "tmp175", tmp175, },
{ "tmp275", tmp275, }, { "tmp275", tmp275, },
{ "tmp75", tmp75, }, { "tmp75", tmp75, },
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment