Skip to content

Commit

Permalink
Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/groeck/linux-staging

Pull hwmon updates from Guenter Roeck:
 "New drivers for DA9052/53 PMIC as well as HIH-6130/HIH-6131 humidity
  and temperature sensors.

  Convert drivers to use devm_ functions and to use dev_pm_ops.  Address
  a couple of Coverity errors/warnings as well as compile warnings.
  Some functional improvements in applesmc driver."

* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (72 commits)
  hwmon: (applesmc) Ignore some temperature registers
  hwmon: (applesmc) Allow negative temperature values
  hwmon: (s3c-hwmon) Use devm_kzalloc instead of kzalloc
  hwmon: (w83781d) Fix compile warning
  hwmon: (applesmc) Shorten minimum wait time
  hwmon: (exynos4_tmu) Use struct dev_pm_ops for power management
  hwmon: (gpio-fan) Use struct dev_pm_ops for power management
  hwmon: (abituguru3) Use struct dev_pm_ops for power management
  hwmon: (abituguru) Use struct dev_pm_ops for power management
  hwmon: (acpi_power_meter) Fix unintentional integer overflow
  hwmon: (acpi_power_meter) Cleanup and optimizations
  hwmon: Honeywell Humidicon HIH-6130/HIH-6131 humidity and temperature sensor driver
  hwmon: (applesmc) Skip sensor mapping
  hwmon: (ntc_thermistor) Ensure that data->name string is terminated
  hwmon: (w83l785ts) Convert to use devm_ functions
  hwmon: (w83l785ts) Simplify code and improve readability
  hwmon: (smsc47m192) Convert to use devm_ functions
  hwmon: (smsc47m1) Convert to use devm_ functions
  hwmon: (smsc47b397) Convert to use devm_ functions
  hwmon: (k8temp) Convert to use devm_ functions
  ...
  • Loading branch information
Linus Torvalds committed Jul 24, 2012
2 parents 3539fc5 + e30bca1 commit 0cd5ff5
Show file tree
Hide file tree
Showing 68 changed files with 1,220 additions and 846 deletions.
61 changes: 61 additions & 0 deletions Documentation/hwmon/da9052
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
Supported chips:
* Dialog Semiconductors DA9052-BC and DA9053-AA/Bx PMICs
Prefix: 'da9052'
Datasheet: Datasheet is not publicly available.

Authors: David Dajun Chen <dchen@diasemi.com>

Description
-----------

The DA9052/53 provides an Analogue to Digital Converter (ADC) with 10 bits
resolution and track and hold circuitry combined with an analogue input
multiplexer. The analogue input multiplexer will allow conversion of up to 10
different inputs. The track and hold circuit ensures stable input voltages at
the input of the ADC during the conversion.

The ADC is used to measure the following inputs:
Channel 0: VDDOUT - measurement of the system voltage
Channel 1: ICH - internal battery charger current measurement
Channel 2: TBAT - output from the battery NTC
Channel 3: VBAT - measurement of the battery voltage
Channel 4: ADC_IN4 - high impedance input (0 - 2.5V)
Channel 5: ADC_IN5 - high impedance input (0 - 2.5V)
Channel 6: ADC_IN6 - high impedance input (0 - 2.5V)
Channel 7: XY - TSI interface to measure the X and Y voltage of the touch
screen resistive potentiometers
Channel 8: Internal Tjunc. - sense (internal temp. sensor)
Channel 9: VBBAT - measurement of the backup battery voltage

By using sysfs attributes we can measure the system voltage VDDOUT, the battery
charging current ICH, battery temperature TBAT, battery junction temperature
TJUNC, battery voltage VBAT and the back up battery voltage VBBAT.

Voltage Monitoring
------------------

Voltages are sampled by a 10 bit ADC.

The battery voltage is calculated as:
Milli volt = ((ADC value * 1000) / 512) + 2500

The backup battery voltage is calculated as:
Milli volt = (ADC value * 2500) / 512;

The voltages on ADC channels 4, 5 and 6 are calculated as:
Milli volt = (ADC value * 2500) / 1023

Temperature Monitoring
----------------------

Temperatures are sampled by a 10 bit ADC. Junction and battery temperatures
are monitored by the ADC channels.

The junction temperature is calculated:
Degrees celsius = 1.708 * (TJUNC_RES - T_OFFSET) - 108.8
The junction temperature attribute is supported by the driver.

The battery temperature is calculated:
Degree Celcius = 1 / (t1 + 1/298)- 273
where t1 = (1/B)* ln(( ADCval * 2.5)/(R25*ITBAT*255))
Default values of R25, B, ITBAT are 10e3, 3380 and 50e-6 respectively.
37 changes: 37 additions & 0 deletions Documentation/hwmon/hih6130
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Kernel driver hih6130
=====================

Supported chips:
* Honeywell HIH-6130 / HIH-6131
Prefix: 'hih6130'
Addresses scanned: none
Datasheet: Publicly available at the Honeywell website
http://sensing.honeywell.com/index.php?ci_id=3106&la_id=1&defId=44872

Author:
Iain Paton <ipaton0@gmail.com>

Description
-----------

The HIH-6130 & HIH-6131 are humidity and temperature sensors in a SO8 package.
The difference between the two devices is that the HIH-6131 has a condensation
filter.

The devices communicate with the I2C protocol. All sensors are set to the same
I2C address 0x27 by default, so an entry with I2C_BOARD_INFO("hih6130", 0x27)
can be used in the board setup code.

Please see Documentation/i2c/instantiating-devices for details on how to
instantiate I2C devices.

sysfs-Interface
---------------

temp1_input - temperature input
humidity1_input - humidity input

Notes
-----

Command mode and alarms are not currently supported.
3 changes: 3 additions & 0 deletions Documentation/hwmon/submitting-patches
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ increase the chances of your change being accepted.
review more difficult. It may also result in code which is more complicated
than necessary. Use inline functions or just regular functions instead.

* Use devres functions whenever possible to allocate resources. For rationale
and supported functions, please see Documentation/driver-model/devres.txt.

* If the driver has a detect function, make sure it is silent. Debug messages
and messages printed after a successful detection are acceptable, but it
must not print messages such as "Chip XXX not found/supported".
Expand Down
20 changes: 20 additions & 0 deletions drivers/hwmon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,16 @@ config SENSORS_DS1621
This driver can also be built as a module. If so, the module
will be called ds1621.

config SENSORS_DA9052_ADC
tristate "Dialog DA9052/DA9053 ADC"
depends on PMIC_DA9052
help
Say y here to support the ADC found on Dialog Semiconductor
DA9052-BC and DA9053-AA/Bx PMICs.

This driver can also be built as module. If so, the module
will be called da9052-hwmon.

config SENSORS_EXYNOS4_TMU
tristate "Temperature sensor on Samsung EXYNOS4"
depends on ARCH_EXYNOS4
Expand Down Expand Up @@ -433,6 +443,16 @@ config SENSORS_GPIO_FAN
This driver can also be built as a module. If so, the module
will be called gpio-fan.

config SENSORS_HIH6130
tristate "Honeywell Humidicon HIH-6130 humidity/temperature sensor"
depends on I2C && EXPERIMENTAL
help
If you say yes here you get support for Honeywell Humidicon
HIH-6130 and HIH-6131 Humidicon humidity sensors.

This driver can also be built as a module. If so, the module
will be called hih6130.

config SENSORS_CORETEMP
tristate "Intel Core/Core2/Atom temperature sensor"
depends on X86 && PCI && EXPERIMENTAL
Expand Down
2 changes: 2 additions & 0 deletions drivers/hwmon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ obj-$(CONFIG_SENSORS_APPLESMC) += applesmc.o
obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o
obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o
obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o
obj-$(CONFIG_SENSORS_DME1737) += dme1737.o
obj-$(CONFIG_SENSORS_DS620) += ds620.o
obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
Expand All @@ -58,6 +59,7 @@ obj-$(CONFIG_SENSORS_G760A) += g760a.o
obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o
obj-$(CONFIG_SENSORS_GL520SM) += gl520sm.o
obj-$(CONFIG_SENSORS_GPIO_FAN) += gpio-fan.o
obj-$(CONFIG_SENSORS_HIH6130) += hih6130.o
obj-$(CONFIG_SENSORS_ULTRA45) += ultra45_env.o
obj-$(CONFIG_SENSORS_I5K_AMB) += i5k_amb.o
obj-$(CONFIG_SENSORS_IBMAEM) += ibmaem.o
Expand Down
19 changes: 10 additions & 9 deletions drivers/hwmon/abituguru.c
Original file line number Diff line number Diff line change
Expand Up @@ -1513,10 +1513,10 @@ static struct abituguru_data *abituguru_update_device(struct device *dev)
return NULL;
}

#ifdef CONFIG_PM
static int abituguru_suspend(struct platform_device *pdev, pm_message_t state)
#ifdef CONFIG_PM_SLEEP
static int abituguru_suspend(struct device *dev)
{
struct abituguru_data *data = platform_get_drvdata(pdev);
struct abituguru_data *data = dev_get_drvdata(dev);
/*
* make sure all communications with the uguru are done and no new
* ones are started
Expand All @@ -1525,29 +1525,30 @@ static int abituguru_suspend(struct platform_device *pdev, pm_message_t state)
return 0;
}

static int abituguru_resume(struct platform_device *pdev)
static int abituguru_resume(struct device *dev)
{
struct abituguru_data *data = platform_get_drvdata(pdev);
struct abituguru_data *data = dev_get_drvdata(dev);
/* See if the uGuru is still ready */
if (inb_p(data->addr + ABIT_UGURU_DATA) != ABIT_UGURU_STATUS_INPUT)
data->uguru_ready = 0;
mutex_unlock(&data->update_lock);
return 0;
}

static SIMPLE_DEV_PM_OPS(abituguru_pm, abituguru_suspend, abituguru_resume);
#define ABIT_UGURU_PM &abituguru_pm
#else
#define abituguru_suspend NULL
#define abituguru_resume NULL
#define ABIT_UGURU_PM NULL
#endif /* CONFIG_PM */

static struct platform_driver abituguru_driver = {
.driver = {
.owner = THIS_MODULE,
.name = ABIT_UGURU_NAME,
.pm = ABIT_UGURU_PM,
},
.probe = abituguru_probe,
.remove = __devexit_p(abituguru_remove),
.suspend = abituguru_suspend,
.resume = abituguru_resume,
};

static int __init abituguru_detect(void)
Expand Down
19 changes: 10 additions & 9 deletions drivers/hwmon/abituguru3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,10 +1141,10 @@ static struct abituguru3_data *abituguru3_update_device(struct device *dev)
return NULL;
}

#ifdef CONFIG_PM
static int abituguru3_suspend(struct platform_device *pdev, pm_message_t state)
#ifdef CONFIG_PM_SLEEP
static int abituguru3_suspend(struct device *dev)
{
struct abituguru3_data *data = platform_get_drvdata(pdev);
struct abituguru3_data *data = dev_get_drvdata(dev);
/*
* make sure all communications with the uguru3 are done and no new
* ones are started
Expand All @@ -1153,26 +1153,27 @@ static int abituguru3_suspend(struct platform_device *pdev, pm_message_t state)
return 0;
}

static int abituguru3_resume(struct platform_device *pdev)
static int abituguru3_resume(struct device *dev)
{
struct abituguru3_data *data = platform_get_drvdata(pdev);
struct abituguru3_data *data = dev_get_drvdata(dev);
mutex_unlock(&data->update_lock);
return 0;
}

static SIMPLE_DEV_PM_OPS(abituguru3_pm, abituguru3_suspend, abituguru3_resume);
#define ABIT_UGURU3_PM &abituguru3_pm
#else
#define abituguru3_suspend NULL
#define abituguru3_resume NULL
#define ABIT_UGURU3_PM NULL
#endif /* CONFIG_PM */

static struct platform_driver abituguru3_driver = {
.driver = {
.owner = THIS_MODULE,
.name = ABIT_UGURU3_NAME,
.pm = ABIT_UGURU3_PM
},
.probe = abituguru3_probe,
.remove = __devexit_p(abituguru3_remove),
.suspend = abituguru3_suspend,
.resume = abituguru3_resume
};

static int __init abituguru3_dmi_detect(void)
Expand Down
8 changes: 3 additions & 5 deletions drivers/hwmon/acpi_power_meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct acpi_power_meter_resource {
unsigned long sensors_last_updated;
struct sensor_device_attribute sensors[NUM_SENSORS];
int num_sensors;
int trip[2];
s64 trip[2];
int num_domain_devices;
struct acpi_device **domain_devices;
struct kobject *holders_dir;
Expand Down Expand Up @@ -237,7 +237,7 @@ static ssize_t set_cap(struct device *dev, struct device_attribute *devattr,
if (res)
return res;

temp /= 1000;
temp = DIV_ROUND_CLOSEST(temp, 1000);
if (temp > resource->caps.max_cap || temp < resource->caps.min_cap)
return -EINVAL;
arg0.integer.value = temp;
Expand Down Expand Up @@ -307,9 +307,7 @@ static ssize_t set_trip(struct device *dev, struct device_attribute *devattr,
if (res)
return res;

temp /= 1000;
if (temp < 0)
return -EINVAL;
temp = DIV_ROUND_CLOSEST(temp, 1000);

mutex_lock(&resource->lock);
resource->trip[attr->index - 7] = temp;
Expand Down
18 changes: 7 additions & 11 deletions drivers/hwmon/adm1021.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,11 @@ static int adm1021_probe(struct i2c_client *client,
struct adm1021_data *data;
int err;

data = kzalloc(sizeof(struct adm1021_data), GFP_KERNEL);
data = devm_kzalloc(&client->dev, sizeof(struct adm1021_data),
GFP_KERNEL);
if (!data) {
pr_debug("adm1021: detect failed, kzalloc failed!\n");
err = -ENOMEM;
goto error0;
pr_debug("adm1021: detect failed, devm_kzalloc failed!\n");
return -ENOMEM;
}

i2c_set_clientdata(client, data);
Expand All @@ -384,21 +384,18 @@ static int adm1021_probe(struct i2c_client *client,
/* Register sysfs hooks */
err = sysfs_create_group(&client->dev.kobj, &adm1021_group);
if (err)
goto error1;
return err;

data->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev);
goto error3;
goto error;
}

return 0;

error3:
error:
sysfs_remove_group(&client->dev.kobj, &adm1021_group);
error1:
kfree(data);
error0:
return err;
}

Expand All @@ -418,7 +415,6 @@ static int adm1021_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &adm1021_group);

kfree(data);
return 0;
}

Expand Down
15 changes: 5 additions & 10 deletions drivers/hwmon/adm1025.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,10 @@ static int adm1025_probe(struct i2c_client *client,
int err;
u8 config;

data = kzalloc(sizeof(struct adm1025_data), GFP_KERNEL);
if (!data) {
err = -ENOMEM;
goto exit;
}
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);
Expand All @@ -492,7 +491,7 @@ static int adm1025_probe(struct i2c_client *client,
/* Register sysfs hooks */
err = sysfs_create_group(&client->dev.kobj, &adm1025_group);
if (err)
goto exit_free;
return err;

/* Pin 11 is either in4 (+12V) or VID4 */
config = i2c_smbus_read_byte_data(client, ADM1025_REG_CONFIG);
Expand All @@ -513,9 +512,6 @@ static int adm1025_probe(struct i2c_client *client,
exit_remove:
sysfs_remove_group(&client->dev.kobj, &adm1025_group);
sysfs_remove_group(&client->dev.kobj, &adm1025_group_in4);
exit_free:
kfree(data);
exit:
return err;
}

Expand Down Expand Up @@ -569,7 +565,6 @@ static int adm1025_remove(struct i2c_client *client)
sysfs_remove_group(&client->dev.kobj, &adm1025_group);
sysfs_remove_group(&client->dev.kobj, &adm1025_group_in4);

kfree(data);
return 0;
}

Expand Down
Loading

0 comments on commit 0cd5ff5

Please sign in to comment.