All of lore.kernel.org
 help / color / mirror / Atom feed
From: "corentin.labbe" <corentin.labbe@geomatys.fr>
To: lm-sensors@vger.kernel.org
Subject: [lm-sensors] [PATCH] hwmon/adm1029 Use mask for fan_div value
Date: Mon, 13 Oct 2008 19:45:21 +0000	[thread overview]
Message-ID: <48F3A551.1050705@geomatys.fr> (raw)

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

Hello

This is my patch for testing correct values of fan div in adm1029 and
prevent a division by 0 for some (unlikely) register values.


Signed off by LABBE Corentin <corentin.labbe@geomatys.fr>

[-- Attachment #2: adm1029.patch --]
[-- Type: text/plain, Size: 877 bytes --]

--- linux/drivers/hwmon/adm1029.orig	2008-05-17 13:25:59.000000000 +0200
+++ linux/drivers/hwmon/adm1029.c	2008-05-18 13:04:42.000000000 +0200
@@ -170,7 +170,8 @@
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
 	struct adm1029_data *data = adm1029_update_device(dev);
 	u16 val;
-	if (data->fan[attr->index] == 0 || data->fan_div[attr->index] == 0
+	if (data->fan[attr->index] == 0
+	    || (data->fan_div[attr->index] & 0xC0) == 0
 	    || data->fan[attr->index] == 255) {
 		return sprintf(buf, "0\n");
 	}
@@ -185,7 +186,7 @@
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
 	struct adm1029_data *data = adm1029_update_device(dev);
-	if (data->fan_div[attr->index] == 0)
+	if ((data->fan_div[attr->index] & 0xC0) == 0)
 		return sprintf(buf, "0\n");
 	return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[attr->index]));
 }

[-- 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:[~2008-10-13 19:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-13 19:45 corentin.labbe [this message]
2008-10-13 20:50 ` [lm-sensors] [PATCH] hwmon/adm1029 Use mask for fan_div value Jean Delvare

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=48F3A551.1050705@geomatys.fr \
    --to=corentin.labbe@geomatys.fr \
    --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.