All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <j.w.r.degoede@hhs.nl>
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] PATCH: hwmon-fscpos-individual-alarm-files-v2.patch
Date: Wed, 04 Jul 2007 14:42:57 +0000	[thread overview]
Message-ID: <468BB1F1.9010401@hhs.nl> (raw)
In-Reply-To: <468A46FC.5070505@hhs.nl>

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

Hi all,

This is version 2 (non incremental) of the patch adding individual alarm and
fault files to the fscpos driver. This driver uses the status registers for
the alarms instead of the global event register, allowing seperate alarms
for all sensors. Also it makes the _alarm files r/w, writing 0 to them
resets the alarm flag (this is not done automatically be the hardware once an
alarm condition is cleared).

Notice that:
- I now have an PDF so all used registers and masks are verified now
- Since I do not have a machine with such a beast this patch is NOT tested!
- Since writing the alarm files with 0 clears the alarm, the tempX_reset
   sysfs attributes may be removed

Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>


Regards,

Hans

[-- Attachment #2: hwmon-fscpos-individual-alarm-files-v2.patch --]
[-- Type: text/x-patch, Size: 5368 bytes --]

This is version 2 (non incremental) of the patch adding individual alarm and
fault files to the fscpos driver. This driver uses the status registers for
the alarms instead of the global event register, allowing seperate alarms
for all sensors. Also it makes the _alarm files r/w, writing 0 to them
resets the alarm flag (this is not done automatically be the hardware once an
alarm condition is cleared).

Notice that:
- I now have an PDF so all used registers and masks are verified now
- Since I do not have a machine with such a beast this patch is NOT tested!
- Since writing the alarm files with 0 clears the alarm, the tempX_reset
  sysfs attributes may be removed

Signed-off-by: Hans de Goede <j.w.r.degoede@hhs.nl>
diff -up linux-2.6.22-rc4/drivers/hwmon/fscpos.c~ linux-2.6.22-rc4/drivers/hwmon/fscpos.c
--- linux-2.6.22-rc4/drivers/hwmon/fscpos.c~	2007-07-03 14:34:43.000000000 +0200
+++ linux-2.6.22-rc4/drivers/hwmon/fscpos.c	2007-07-04 16:30:00.000000000 +0200
@@ -150,6 +150,15 @@ static ssize_t show_temp_status(struct f
 	return sprintf(buf, "%u\n", data->temp_status[nr - 1] & 0x03);
 }
 
+static ssize_t show_temp_fault(struct fscpos_data *data, char *buf, int nr)
+{
+	/* bit 0 set means sensor working ok, so no fault! */
+	if (data->temp_status[nr - 1] & 0x01)
+		return sprintf(buf, "0\n");
+	else
+		return sprintf(buf, "1\n");
+}
+
 static ssize_t show_temp_reset(struct fscpos_data *data, char *buf, int nr)
 {
 	return sprintf(buf, "1\n");
@@ -241,6 +250,60 @@ static ssize_t set_pwm(struct i2c_client
 	return count;
 }
 
+static ssize_t set_fan_alarm(struct i2c_client *client, struct fscpos_data *data,
+			      const char *buf, size_t count, int nr, int reg)
+{
+	unsigned long v = simple_strtoul(buf, NULL, 10);
+
+	if (v == 0) { /* clear alarm? */
+		mutex_lock(&data->update_lock);
+		fscpos_write_value(client, reg, 0x04);
+		data->fan_status[nr - 1] &= ~0x04;
+		mutex_unlock(&data->update_lock);
+	}
+	return count;
+}
+
+static ssize_t show_fan_alarm (struct fscpos_data *data, char *buf, int nr)
+{
+	if (data->fan_status[nr - 1] & 0x04)
+		return sprintf(buf, "1\n");
+	else
+		return sprintf(buf, "0\n");
+}
+
+static ssize_t set_temp_alarm(struct i2c_client *client, struct fschpos_data *data,
+			       const char *buf, size_t count, int nr, int reg)
+{
+	unsigned long v = simple_strtoul(buf, NULL, 10);
+
+	if (v == 0) { /* clear alarm? */
+		mutex_lock(&data->update_lock);
+		fscpos_write_value(client, reg, 0x02);
+		data->temp_status[nr - 1] &= ~0x02;
+		mutex_unlock(&data->update_lock);
+	}
+	return count;
+}
+
+static ssize_t show_temp_alarm (struct fscpos_data *data, char *buf, int nr)
+{
+	/* only signal an alarm if the sensor is working and alert == 1 */
+	if ((data->temp_status[nr - 1] & 0x03) == 0x03)
+		return sprintf(buf, "1\n");
+	else
+		return sprintf(buf, "0\n");
+}
+
+static ssize_t show_wdog_alarm (struct fscpos_data *data, char *buf)
+{
+	if (data->global_event & 0x08)
+		return sprintf(buf, "1\n");
+	else
+		return sprintf(buf, "0\n");
+}
+
+
 static void reset_fan_alarm(struct i2c_client *client, int nr)
 {
 	fscpos_write_value(client, FSCPOS_REG_FAN_STATE[nr], 4);
@@ -386,6 +449,10 @@ static ssize_t show_event(struct device 
 	create_getter_n(kind, offset, sub); \
 	create_sysfs_device_ro(kind, sub, offset);
 
+#define sysfs_ro(kind, sub) \
+	create_getter(kind, sub); \
+	create_sysfs_device_ro(kind, sub,);
+
 #define sysfs_rw_n(kind, sub, offset, reg) \
 	create_getter_n(kind, offset, sub); \
 	create_setter_n(kind, offset, sub, reg); \
@@ -403,14 +470,18 @@ static ssize_t show_event(struct device 
 #define sysfs_fan(offset, reg_status, reg_ripple) \
 	sysfs_ro_n(fan, _input, offset); \
 	sysfs_ro_n(fan, _status, offset); \
+	sysfs_rw_n(fan, _alarm, offset, reg_status); \
 	sysfs_rw_n(fan, _ripple, offset, reg_ripple);
 
 #define sysfs_temp(offset, reg_status) \
 	sysfs_ro_n(temp, _input, offset); \
 	sysfs_ro_n(temp, _status, offset); \
+	sysfs_rw_n(temp, _alarm, offset, reg_status); \
+	sysfs_ro_n(temp, _fault, offset); \
 	sysfs_rw_n(temp, _reset, offset, reg_status);
 
 #define sysfs_watchdog(reg_wdog_preset, reg_wdog_state, reg_wdog_control) \
+	sysfs_ro(wdog, _alarm); \
 	sysfs_rw(wdog, _control, reg_wdog_control); \
 	sysfs_rw(wdog, _preset, reg_wdog_preset); \
 	sysfs_rw(wdog, _state, reg_wdog_state);
@@ -442,28 +513,38 @@ static struct attribute *fscpos_attribut
 	&dev_attr_wdog_control.attr,
 	&dev_attr_wdog_preset.attr,
 	&dev_attr_wdog_state.attr,
+	&dev_attr_wdog_alarm.attr,
 
 	&dev_attr_temp1_input.attr,
 	&dev_attr_temp1_status.attr,
 	&dev_attr_temp1_reset.attr,
+	&dev_attr_temp1_fault.attr,
+	&dev_attr_temp1_alarm.attr,
 	&dev_attr_temp2_input.attr,
 	&dev_attr_temp2_status.attr,
 	&dev_attr_temp2_reset.attr,
+	&dev_attr_temp2_fault.attr,
+	&dev_attr_temp2_alarm.attr,
 	&dev_attr_temp3_input.attr,
 	&dev_attr_temp3_status.attr,
 	&dev_attr_temp3_reset.attr,
+	&dev_attr_temp3_fault.attr,
+	&dev_attr_temp3_alarm.attr,
 
 	&dev_attr_fan1_input.attr,
 	&dev_attr_fan1_status.attr,
 	&dev_attr_fan1_ripple.attr,
+	&dev_attr_fan1_alarm.attr,
 	&dev_attr_pwm1.attr,
 	&dev_attr_fan2_input.attr,
 	&dev_attr_fan2_status.attr,
 	&dev_attr_fan2_ripple.attr,
+	&dev_attr_fan2_alarm.attr,
 	&dev_attr_pwm2.attr,
 	&dev_attr_fan3_input.attr,
 	&dev_attr_fan3_status.attr,
 	&dev_attr_fan3_ripple.attr,
+	&dev_attr_fan3_alarm.attr,
 	NULL
 };
 

[-- Attachment #3: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

      reply	other threads:[~2007-07-04 14:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-03 12:54 [lm-sensors] PATCH: hwmon-fscpos-individual-alarm-files.patch Hans de Goede
2007-07-04 14:42 ` Hans de Goede [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=468BB1F1.9010401@hhs.nl \
    --to=j.w.r.degoede@hhs.nl \
    --cc=lm-sensors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.