Commit 367deba2 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by Greg Kroah-Hartman

[PATCH] I2C: use time_after instead of comparing jiffies

Signed-off-by: default avatarAlexey Dobriyan <adobriyan@mail.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent fc08381f
......@@ -23,6 +23,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -369,8 +370,8 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
dev_dbg(&client->dev, "Starting adm1021 update\n");
data->temp_input = adm1021_read_value(client, ADM1021_REG_TEMP);
......
......@@ -49,6 +49,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
......@@ -505,9 +506,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ * 2) ||
(jiffies < data->last_updated) ||
!data->valid) {
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int i;
dev_dbg(&client->dev, "Updating data.\n");
......
......@@ -27,6 +27,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
......@@ -573,7 +574,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)
down(&data->update_lock);
if (!data->valid
|| (jiffies - data->last_reading > ADM1026_DATA_INTERVAL)) {
|| time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) {
/* Things that change quickly */
dev_dbg(&client->dev,"Reading sensor values\n");
for (i = 0;i <= 16;++i) {
......@@ -620,8 +621,8 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)
data->last_reading = jiffies;
}; /* last_reading */
if (!data->valid || (jiffies - data->last_config >
ADM1026_CONFIG_INTERVAL)) {
if (!data->valid ||
time_after(jiffies, data->last_config + ADM1026_CONFIG_INTERVAL)) {
/* Things that don't change often */
dev_dbg(&client->dev, "Reading config values\n");
for (i = 0;i <= 16;++i) {
......
......@@ -24,6 +24,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -884,8 +885,8 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
dev_dbg(&client->dev, "Starting adm1031 update\n");
for (chan = 0;
......
......@@ -965,8 +965,8 @@ static struct asb100_data *asb100_update_device(struct device *dev)
down(&data->update_lock);
if (time_after(jiffies - data->last_updated, (unsigned long)(HZ+HZ/2))
|| time_before(jiffies, data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
dev_dbg(&client->dev, "starting device update...\n");
......
......@@ -24,6 +24,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include "lm75.h"
......@@ -284,8 +285,8 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
dev_dbg(&client->dev, "Starting ds1621 update\n");
......
......@@ -32,6 +32,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -86,8 +87,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice)
down(&data->update_lock);
if (!(data->valid & (1 << slice)) ||
(jiffies - data->last_updated[slice] > 300 * HZ) ||
(jiffies < data->last_updated[slice])) {
time_after(jiffies, data->last_updated[slice] + 300 * HZ)) {
dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice);
if (i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
......
......@@ -30,6 +30,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -411,8 +412,7 @@ static struct fscher_data *fscher_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > 2 * HZ) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
dev_dbg(&client->dev, "Starting fscher update\n");
......
......@@ -40,6 +40,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -505,8 +506,8 @@ static struct gl518_data *gl518_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
dev_dbg(&client->dev, "Starting gl518 update\n");
data->alarms = gl518_read_value(client, GL518_REG_INT);
......
......@@ -35,6 +35,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
......@@ -1083,8 +1084,8 @@ static struct it87_data *it87_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
if (update_vbat) {
/* Cleared after each update, so reenable. Value
......
......@@ -41,6 +41,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -492,9 +493,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ) ||
(jiffies < data->last_updated) ||
!data->valid) {
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
if (data->config & 0x04) { /* tachometer enabled */
/* order matters for fan1_input */
data->fan1_input = i2c_smbus_read_byte_data(client,
......
......@@ -22,6 +22,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include "lm75.h"
......@@ -259,8 +260,8 @@ static struct lm75_data *lm75_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
dev_dbg(&client->dev, "Starting lm75 update\n");
data->temp_input = lm75_read_value(client, LM75_REG_TEMP);
......
......@@ -29,6 +29,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -360,8 +361,8 @@ static struct lm77_data *lm77_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
dev_dbg(&client->dev, "Starting lm77 update\n");
data->temp_input =
LM77_TEMP_FROM_REG(lm77_read_value(client,
......
......@@ -22,6 +22,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <asm/io.h>
......@@ -704,8 +705,8 @@ static struct lm78_data *lm78_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
dev_dbg(&client->dev, "Starting lm78 update\n");
......
......@@ -25,6 +25,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -529,9 +530,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > 2 * HZ) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
dev_dbg(&client->dev, "Starting lm80 update\n");
for (i = 0; i <= 6; i++) {
data->in[i] =
......
......@@ -31,6 +31,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -362,9 +363,7 @@ static struct lm83_data *lm83_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ * 2) ||
(jiffies < data->last_updated) ||
!data->valid) {
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int nr;
dev_dbg(&client->dev, "Updating lm83 data.\n");
......
......@@ -27,6 +27,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
......@@ -1354,7 +1355,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
down(&data->update_lock);
if ( !data->valid ||
(jiffies - data->last_reading > LM85_DATA_INTERVAL ) ) {
time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) {
/* Things that change quickly */
dev_dbg(&client->dev, "Reading sensor values\n");
......@@ -1408,7 +1409,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
}; /* last_reading */
if ( !data->valid ||
(jiffies - data->last_config > LM85_CONFIG_INTERVAL) ) {
time_after(jiffies, data->last_config + LM85_CONFIG_INTERVAL) ) {
/* Things that don't change often */
dev_dbg(&client->dev, "Reading config values\n");
......
......@@ -56,6 +56,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
......@@ -713,9 +714,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
down(&data->update_lock);
if (jiffies - data->last_updated > HZ
|| jiffies < data->last_updated
|| !data->valid) {
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
int i, j;
dev_dbg(&client->dev, "Updating data.\n");
......
......@@ -66,6 +66,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -488,9 +489,7 @@ static struct lm90_data *lm90_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ * 2) ||
(jiffies < data->last_updated) ||
!data->valid) {
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
u8 oldh, newh;
dev_dbg(&client->dev, "Updating lm90 data.\n");
......
......@@ -30,6 +30,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -324,10 +325,7 @@ static struct max1619_data *max1619_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ * 2) ||
(jiffies < data->last_updated) ||
!data->valid) {
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
dev_dbg(&client->dev, "Updating max1619 data.\n");
data->temp_input1 = i2c_smbus_read_byte_data(client,
MAX1619_REG_R_LOCAL_TEMP);
......
......@@ -37,6 +37,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
......@@ -1174,8 +1175,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ * 2)
|| (jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
dev_dbg(&client->dev, "Data update\n");
/* Fans */
......
......@@ -29,6 +29,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/init.h>
......@@ -130,9 +131,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev)
down(&data->update_lock);
if (time_after(jiffies - data->last_updated, (unsigned long)HZ)
|| time_before(jiffies, data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
dev_dbg(&client->dev, "starting device update...\n");
/* 4 temperature inputs, 4 fan inputs */
......
......@@ -28,6 +28,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/init.h>
......@@ -527,8 +528,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || init) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) {
int i;
for (i = 0; i < 2; i++) {
......
......@@ -35,6 +35,7 @@
#include <linux/slab.h>
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/init.h>
......@@ -726,9 +727,8 @@ static struct via686a_data *via686a_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
for (i = 0; i <= 4; i++) {
data->in[i] =
via686a_read_value(client, VIA686A_REG_IN(i));
......
......@@ -40,6 +40,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
......@@ -1371,8 +1372,8 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
down(&data->update_lock);
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
(jiffies < data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
for (i = 0; i <= 8; i++) {
/* skip missing sensors */
if (((data->type == w83697hf) && (i == 1)) ||
......
......@@ -39,6 +39,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
......@@ -1609,9 +1610,8 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
down(&data->update_lock);
if (time_after
(jiffies - data->last_updated, (unsigned long) (HZ + HZ / 2))
|| time_before(jiffies, data->last_updated) || !data->valid) {
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
dev_dbg(dev, "Starting device update\n");
for (i = 0; i <= 8; i++) {
......
......@@ -35,6 +35,7 @@
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
......@@ -294,9 +295,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
down(&data->update_lock);
if (!data->valid
|| (jiffies - data->last_updated > HZ * 2)
|| (jiffies < data->last_updated)) {
if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) {
dev_dbg(&client->dev, "Updating w83l785ts data.\n");
data->temp = w83l785ts_read_value(client,
W83L785TS_REG_TEMP, data->temp);
......
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