* [lm-sensors] [PATCH] f75375s allow setting up fans with
@ 2007-09-26 10:14 Riku Voipio
0 siblings, 0 replies; 2+ messages in thread
From: Riku Voipio @ 2007-09-26 10:14 UTC (permalink / raw)
To: lm-sensors
Allow initializing fans on systems where BIOS does not do that by
default.
- define f75375s_platform_data in new file f75375s.h
- if platform_data was provided, set fans accordingly in f75375_init()
- split set_pwm_enable() to a sysfs callback and directly usable
set_pwm_enable_direct()
Signed-off-by: Riku Voipio <riku.voipio@movial.fi>
---
drivers/hwmon/f75375s.c | 42 +++++++++++++++++++++++++++++++++++-------
include/linux/f75375s.h | 21 +++++++++++++++++++++
2 files changed, 56 insertions(+), 7 deletions(-)
create mode 100644 include/linux/f75375s.h
diff --git a/drivers/hwmon/f75375s.c b/drivers/hwmon/f75375s.c
index 9336f5e..3074f74 100644
--- a/drivers/hwmon/f75375s.c
+++ b/drivers/hwmon/f75375s.c
@@ -34,6 +34,7 @@
#include <linux/i2c.h>
#include <linux/err.h>
#include <linux/mutex.h>
+#include <linux/f75375s.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2d, 0x2e, I2C_CLIENT_END };
@@ -287,19 +288,14 @@ static ssize_t show_pwm_enable(struct device *dev, struct device_attribute
return sprintf(buf, "%d\n", data->pwm_enable[nr]);
}
-static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
- const char *buf, size_t count)
+static int set_pwm_enable_direct(struct i2c_client *client, int nr, int val)
{
- int nr = to_sensor_dev_attr(attr)->index;
- struct i2c_client *client = to_i2c_client(dev);
struct f75375_data *data = i2c_get_clientdata(client);
- int val = simple_strtoul(buf, NULL, 10);
u8 fanmode;
if (val < 0 || val > 4)
return -EINVAL;
- mutex_lock(&data->update_lock);
fanmode = f75375_read8(client, F75375_REG_FAN_TIMER);
fanmode = ~(3 << FAN_CTRL_MODE(nr));
@@ -321,8 +317,22 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
}
f75375_write8(client, F75375_REG_FAN_TIMER, fanmode);
data->pwm_enable[nr] = val;
+ return 0;
+}
+
+static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int nr = to_sensor_dev_attr(attr)->index;
+ struct i2c_client *client = to_i2c_client(dev);
+ struct f75375_data *data = i2c_get_clientdata(client);
+ int val = simple_strtoul(buf, NULL, 10);
+ int err = 0;
+
+ mutex_lock(&data->update_lock);
+ err = set_pwm_enable_direct(client, nr, val);
mutex_unlock(&data->update_lock);
- return count;
+ return err ? err : count;
}
static ssize_t set_pwm_mode(struct device *dev, struct device_attribute *attr,
@@ -604,9 +614,24 @@ static int f75375_detach_client(struct i2c_client *client)
return 0;
}
+static void f75375_init(struct i2c_client *client, struct f75375_data *data,
+ struct f75375s_platform_data *f75375s_pdata)
+{
+ int nr;
+ set_pwm_enable_direct(client, 0, f75375s_pdata->pwm_enable[0]);
+ set_pwm_enable_direct(client, 1, f75375s_pdata->pwm_enable[1]);
+ for (nr = 0; nr < 2; nr++) {
+ data->pwm[nr] = SENSORS_LIMIT(f75375s_pdata->pwm[nr], 0, 255);
+ f75375_write8(client, F75375_REG_FAN_PWM_DUTY(nr),
+ data->pwm[nr]);
+ }
+
+}
+
static int f75375_probe(struct i2c_client *client)
{
struct f75375_data *data = i2c_get_clientdata(client);
+ struct f75375s_platform_data *f75375s_pdata = client->dev.platform_data;
int err;
if (!i2c_check_functionality(client->adapter,
@@ -637,6 +662,9 @@ static int f75375_probe(struct i2c_client *client)
goto exit_remove;
}
+ if (f75375s_pdata != NULL)
+ f75375_init(client, data, f75375s_pdata);
+
return 0;
exit_remove:
diff --git a/include/linux/f75375s.h b/include/linux/f75375s.h
new file mode 100644
index 0000000..e99e225
--- /dev/null
+++ b/include/linux/f75375s.h
@@ -0,0 +1,21 @@
+/*
+ * f75375s.h - platform data structure for f75375s sensor
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2007, Riku Voipio <riku.voipio@iki.fi>
+ */
+
+#ifndef __LINUX_F75375S_H
+#define __LINUX_F75375S_H
+
+/* We want to set fans spinning on systems where there is no
+ * BIOS to do that for us */
+struct f75375s_platform_data {
+ u8 pwm[2];
+ u8 pwm_enable[2];
+};
+
+#endif /* __LINUX_F75375S_H */
--
1.5.3.1
--
"rm -rf" only sounds scary if you don't have backups
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [lm-sensors] [PATCH] f75375s allow setting up fans with
@ 2007-10-25 11:38 Mark M. Hoffman
0 siblings, 0 replies; 2+ messages in thread
From: Mark M. Hoffman @ 2007-10-25 11:38 UTC (permalink / raw)
To: lm-sensors
Hi:
* Riku Voipio <riku.voipio@iki.fi> [2007-09-26 13:14:40 +0300]:
> Allow initializing fans on systems where BIOS does not do that by
> default.
>
> - define f75375s_platform_data in new file f75375s.h
> - if platform_data was provided, set fans accordingly in f75375_init()
> - split set_pwm_enable() to a sysfs callback and directly usable
> set_pwm_enable_direct()
>
> Signed-off-by: Riku Voipio <riku.voipio@movial.fi>
> ---
> drivers/hwmon/f75375s.c | 42 +++++++++++++++++++++++++++++++++++-------
> include/linux/f75375s.h | 21 +++++++++++++++++++++
> 2 files changed, 56 insertions(+), 7 deletions(-)
> create mode 100644 include/linux/f75375s.h
Applied to hwmon-2.6.git/testing, thanks.
--
Mark M. Hoffman
mhoffman@lightlink.com
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-10-25 11:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-26 10:14 [lm-sensors] [PATCH] f75375s allow setting up fans with Riku Voipio
-- strict thread matches above, loose matches on Subject: below --
2007-10-25 11:38 Mark M. Hoffman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.