Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 292166
b: refs/heads/master
c: a80b10c
h: refs/heads/master
v: v3
  • Loading branch information
Guenter Roeck authored and Guenter Roeck committed Mar 19, 2012
1 parent 63bef89 commit 7596990
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 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: 4d387df74e175659ad9c8a16ae8e5b364b7d3f56
refs/heads/master: a80b10ccac53087a6ad47f45e29a3800e84448fa
34 changes: 24 additions & 10 deletions trunk/drivers/hwmon/ultra45_env.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* ultra45_env.c: Driver for Ultra45 PIC16F747 environmental monitor.
/*
* ultra45_env.c: Driver for Ultra45 PIC16F747 environmental monitor.
*
* Copyright (C) 2008 David S. Miller <davem@davemloft.net>
*/
Expand Down Expand Up @@ -82,15 +83,17 @@ static void env_write(struct env *p, u8 ireg, u8 val)
spin_unlock(&p->lock);
}

/* There seems to be a adr7462 providing these values, thus a lot
/*
* There seems to be a adr7462 providing these values, thus a lot
* of these calculations are borrowed from the adt7470 driver.
*/
#define FAN_PERIOD_TO_RPM(x) ((90000 * 60) / (x))
#define FAN_RPM_TO_PERIOD FAN_PERIOD_TO_RPM
#define FAN_PERIOD_INVALID (0xff << 8)
#define FAN_DATA_VALID(x) ((x) && (x) != FAN_PERIOD_INVALID)

static ssize_t show_fan_speed(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t show_fan_speed(struct device *dev, struct device_attribute *attr,
char *buf)
{
int fan_nr = to_sensor_dev_attr(attr)->index;
struct env *p = dev_get_drvdata(dev);
Expand All @@ -111,10 +114,15 @@ static ssize_t set_fan_speed(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
int fan_nr = to_sensor_dev_attr(attr)->index;
int rpm = simple_strtol(buf, NULL, 10);
unsigned long rpm;
struct env *p = dev_get_drvdata(dev);
int period;
u8 val;
int err;

err = kstrtoul(buf, 10, &rpm);
if (err)
return err;

if (!rpm)
return -EINVAL;
Expand All @@ -126,7 +134,8 @@ static ssize_t set_fan_speed(struct device *dev, struct device_attribute *attr,
return count;
}

static ssize_t show_fan_fault(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t show_fan_fault(struct device *dev, struct device_attribute *attr,
char *buf)
{
int fan_nr = to_sensor_dev_attr(attr)->index;
struct env *p = dev_get_drvdata(dev);
Expand All @@ -148,7 +157,8 @@ fan(4);

static SENSOR_DEVICE_ATTR(psu_fan_fault, S_IRUGO, show_fan_fault, NULL, 6);

static ssize_t show_temp(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
char *buf)
{
int temp_nr = to_sensor_dev_attr(attr)->index;
struct env *p = dev_get_drvdata(dev);
Expand All @@ -168,7 +178,8 @@ static SENSOR_DEVICE_ATTR(lsi1064_local_temp, S_IRUGO, show_temp, NULL, 6);
static SENSOR_DEVICE_ATTR(front_panel_temp, S_IRUGO, show_temp, NULL, 7);
static SENSOR_DEVICE_ATTR(psu_temp, S_IRUGO, show_temp, NULL, 13);

static ssize_t show_stat_bit(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t show_stat_bit(struct device *dev, struct device_attribute *attr,
char *buf)
{
int index = to_sensor_dev_attr(attr)->index;
struct env *p = dev_get_drvdata(dev);
Expand All @@ -181,9 +192,11 @@ static ssize_t show_stat_bit(struct device *dev, struct device_attribute *attr,
static SENSOR_DEVICE_ATTR(fan_failure, S_IRUGO, show_stat_bit, NULL, 0);
static SENSOR_DEVICE_ATTR(env_bus_busy, S_IRUGO, show_stat_bit, NULL, 1);
static SENSOR_DEVICE_ATTR(env_data_stale, S_IRUGO, show_stat_bit, NULL, 2);
static SENSOR_DEVICE_ATTR(tpm_self_test_passed, S_IRUGO, show_stat_bit, NULL, 3);
static SENSOR_DEVICE_ATTR(tpm_self_test_passed, S_IRUGO, show_stat_bit, NULL,
3);

static ssize_t show_fwver(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t show_fwver(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct env *p = dev_get_drvdata(dev);
u8 val;
Expand All @@ -194,7 +207,8 @@ static ssize_t show_fwver(struct device *dev, struct device_attribute *attr, cha

static SENSOR_DEVICE_ATTR(firmware_version, S_IRUGO, show_fwver, NULL, 0);

static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t show_name(struct device *dev, struct device_attribute *attr,
char *buf)
{
return sprintf(buf, "ultra45\n");
}
Expand Down

0 comments on commit 7596990

Please sign in to comment.