Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 117824
b: refs/heads/master
c: be821b7
h: refs/heads/master
v: v3
  • Loading branch information
Jean Delvare committed Oct 26, 2008
1 parent deea774 commit 1b7cecd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 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: 97ae60bb38279e1941c738b1037a57e6b14efeaf
refs/heads/master: be821b78af9de886571e3565515a59f966d66f42
29 changes: 9 additions & 20 deletions trunk/drivers/hwmon/adt7473.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,35 +319,24 @@ static struct adt7473_data *adt7473_update_device(struct device *dev)
}

/*
* On this chip, voltages are given as a count of steps between a minimum
* and maximum voltage, not a direct voltage.
* Conversions
*/
static const int volt_convert_table[][2] = {
{2997, 3},
{4395, 4},

/* IN are scaled acording to built-in resistors */
static const int adt7473_scaling[] = { /* .001 Volts */
2250, 3300
};
#define SCALE(val, from, to) (((val) * (to) + ((from) / 2)) / (from))

static int decode_volt(int volt_index, u8 raw)
{
int cmax = volt_convert_table[volt_index][0];
int cmin = volt_convert_table[volt_index][1];
return ((raw * (cmax - cmin)) / 255) + cmin;
return SCALE(raw, 192, adt7473_scaling[volt_index]);
}

static u8 encode_volt(int volt_index, int cooked)
{
int cmax = volt_convert_table[volt_index][0];
int cmin = volt_convert_table[volt_index][1];
u8 x;

if (cooked > cmax)
cooked = cmax;
else if (cooked < cmin)
cooked = cmin;

x = ((cooked - cmin) * 255) / (cmax - cmin);

return x;
int raw = SCALE(cooked, adt7473_scaling[volt_index], 192);
return SENSORS_LIMIT(raw, 0, 255);
}

static ssize_t show_volt_min(struct device *dev,
Expand Down

0 comments on commit 1b7cecd

Please sign in to comment.