Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 220455
b: refs/heads/master
c: 11e5781
h: refs/heads/master
i:
  220453: bc7777d
  220451: 2ff65d6
  220447: 0006193
v: v3
  • Loading branch information
Guenter Roeck authored and Jean Delvare committed Oct 28, 2010
1 parent 814ab76 commit 226a4d6
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 26 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 28e7438faacbd47aaf3e3b43c3074c64be98f5be
refs/heads/master: 11e578129af74c4866cf559e62e981c6415fffd9
76 changes: 51 additions & 25 deletions trunk/drivers/hwmon/lm90.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,13 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev);
struct lm90_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
int nr = attr->index;
long val;
int err;

err = strict_strtol(buf, 10, &val);
if (err < 0)
return err;

/* +16 degrees offset for temp2 for the LM99 */
if (data->kind == lm99 && attr->index == 3)
Expand Down Expand Up @@ -442,8 +447,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct i2c_client *client = to_i2c_client(dev);
struct lm90_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
int nr = attr->index;
long val;
int err;

err = strict_strtol(buf, 10, &val);
if (err < 0)
return err;

/* +16 degrees offset for temp2 for the LM99 */
if (data->kind == lm99 && attr->index <= 2)
Expand All @@ -469,7 +479,8 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
return count;
}

static ssize_t show_temphyst(struct device *dev, struct device_attribute *devattr,
static ssize_t show_temphyst(struct device *dev,
struct device_attribute *devattr,
char *buf)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
Expand All @@ -495,9 +506,14 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,
{
struct i2c_client *client = to_i2c_client(dev);
struct lm90_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
long val;
int err;
int temp;

err = strict_strtol(buf, 10, &val);
if (err < 0)
return err;

mutex_lock(&data->update_lock);
if (data->kind == adt7461)
temp = temp_from_u8_adt7461(data, data->temp8[2]);
Expand Down Expand Up @@ -600,7 +616,12 @@ static ssize_t set_pec(struct device *dev, struct device_attribute *dummy,
const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
long val = simple_strtol(buf, NULL, 10);
long val;
int err;

err = strict_strtol(buf, 10, &val);
if (err < 0)
return err;

switch (val) {
case 0:
Expand All @@ -622,29 +643,33 @@ static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec);
* Real code
*/

/* The ADM1032 supports PEC but not on write byte transactions, so we need
to explicitly ask for a transaction without PEC. */
/*
* The ADM1032 supports PEC but not on write byte transactions, so we need
* to explicitly ask for a transaction without PEC.
*/
static inline s32 adm1032_write_byte(struct i2c_client *client, u8 value)
{
return i2c_smbus_xfer(client->adapter, client->addr,
client->flags & ~I2C_CLIENT_PEC,
I2C_SMBUS_WRITE, value, I2C_SMBUS_BYTE, NULL);
}

/* It is assumed that client->update_lock is held (unless we are in
detection or initialization steps). This matters when PEC is enabled,
because we don't want the address pointer to change between the write
byte and the read byte transactions. */
static int lm90_read_reg(struct i2c_client* client, u8 reg, u8 *value)
/*
* It is assumed that client->update_lock is held (unless we are in
* detection or initialization steps). This matters when PEC is enabled,
* because we don't want the address pointer to change between the write
* byte and the read byte transactions.
*/
static int lm90_read_reg(struct i2c_client *client, u8 reg, u8 *value)
{
int err;

if (client->flags & I2C_CLIENT_PEC) {
err = adm1032_write_byte(client, reg);
if (err >= 0)
err = i2c_smbus_read_byte(client);
} else
err = i2c_smbus_read_byte_data(client, reg);
if (client->flags & I2C_CLIENT_PEC) {
err = adm1032_write_byte(client, reg);
if (err >= 0)
err = i2c_smbus_read_byte(client);
} else
err = i2c_smbus_read_byte_data(client, reg);

if (err < 0) {
dev_warn(&client->dev, "Register %#02x read failed (%d)\n",
Expand Down Expand Up @@ -826,16 +851,18 @@ static int lm90_probe(struct i2c_client *new_client,
lm90_init_client(new_client);

/* Register sysfs hooks */
if ((err = sysfs_create_group(&new_client->dev.kobj, &lm90_group)))
err = sysfs_create_group(&new_client->dev.kobj, &lm90_group);
if (err)
goto exit_free;
if (new_client->flags & I2C_CLIENT_PEC) {
if ((err = device_create_file(&new_client->dev,
&dev_attr_pec)))
err = device_create_file(&new_client->dev, &dev_attr_pec);
if (err)
goto exit_remove_files;
}
if (data->kind != max6657 && data->kind != max6646) {
if ((err = device_create_file(&new_client->dev,
&sensor_dev_attr_temp2_offset.dev_attr)))
err = device_create_file(&new_client->dev,
&sensor_dev_attr_temp2_offset.dev_attr);
if (err)
goto exit_remove_files;
}

Expand Down Expand Up @@ -883,9 +910,8 @@ static void lm90_init_client(struct i2c_client *client)
* 0.125 degree resolution) and range (0x08, extend range
* to -64 degree) mode for the remote temperature sensor.
*/
if (data->kind == max6680) {
if (data->kind == max6680)
config |= 0x18;
}

config &= 0xBF; /* run */
if (config != data->config_orig) /* Only write if changed */
Expand Down

0 comments on commit 226a4d6

Please sign in to comment.