From: Jean Delvare <khali@linux-fr.org>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] PATCH:
Date: Thu, 01 Nov 2007 23:00:34 +0000 [thread overview]
Message-ID: <20071102000034.0b613a38@hyperion.delvare> (raw)
In-Reply-To: <46F3DD44.4070307@hhs.nl>
Hi Hans,
On Wed, 31 Oct 2007 16:29:44 +0100, Hans de Goede wrote:
> Jean Delvare wrote:
> > Assuming that you definitely excluded the possibility to retrieve the
> > DMI data from the kernel
>
> Definitely is a big word, I've looked at the DMI parser currently in the
> kernel, tried to come up with a way to get the info there which would be more
> generic then just being an fschmd specific hack and couldn't. Then I slept a
> night on it and still couldn't come up with something clean, esp since there
> are many type 185 entries in the DMI table of FSC machines, of which we need
> only one.
Please take a look at this completely untested patch. It might need
some cleanups before it's ready for submission, but is there any reason
why something like this wouldn't do the job?
---
drivers/firmware/dmi_scan.c | 50 ++++++++++++++++++++++++++++++++++++++++++-
drivers/hwmon/fschmd.c | 9 +++++++
include/linux/dmi.h | 3 ++
3 files changed, 61 insertions(+), 1 deletion(-)
--- linux-2.6.24-rc1.orig/drivers/firmware/dmi_scan.c 2007-10-24 09:59:28.000000000 +0200
+++ linux-2.6.24-rc1/drivers/firmware/dmi_scan.c 2007-11-01 23:51:46.000000000 +0100
@@ -86,6 +86,50 @@ static int __init dmi_checksum(const u8
static char *dmi_ident[DMI_STRING_MAX];
static LIST_HEAD(dmi_devices);
int dmi_available;
+static u32 dmi_base;
+static u16 dmi_len;
+static u16 dmi_num;
+
+/* Similar to dmi_table, but for use at a later time */
+int dmi_walk(void (*decode)(const struct dmi_header *))
+{
+ u8 *buf, *data;
+ int i = 0;
+
+ if (!dmi_available)
+ return -1;
+
+ buf = ioremap(dmi_base, dmi_len);
+ if (buf = NULL)
+ return -1;
+
+ data = buf;
+
+ /*
+ * Stop when we see all the items the table claimed to have
+ * OR we run off the end of the table (also happens)
+ */
+ while ((i < dmi_num) &&
+ (data - buf + sizeof(struct dmi_header)) <= dmi_len) {
+ const struct dmi_header *dm = (const struct dmi_header *)data;
+
+ /*
+ * We want to know the total length (formated area and strings)
+ * before decoding to make sure we won't run off the table in
+ * dmi_decode or dmi_string
+ */
+ data += dm->length;
+ while ((data - buf < dmi_len - 1) && (data[0] || data[1]))
+ data++;
+ if (data - buf < dmi_len - 1)
+ decode(dm);
+ data += 2;
+ i++;
+ }
+ iounmap(buf);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(dmi_walk);
/*
* Save a DMI string
@@ -287,8 +331,12 @@ static int __init dmi_present(const char
buf[14] >> 4, buf[14] & 0xF);
else
printk(KERN_INFO "DMI present.\n");
- if (dmi_table(base,len, num, dmi_decode) = 0)
+ if (dmi_table(base,len, num, dmi_decode) = 0) {
+ dmi_base = base;
+ dmi_len = len;
+ dmi_num = num;
return 0;
+ }
}
return 1;
}
--- linux-2.6.24-rc1.orig/drivers/hwmon/fschmd.c 2007-11-01 23:16:54.000000000 +0100
+++ linux-2.6.24-rc1/drivers/hwmon/fschmd.c 2007-11-01 23:56:02.000000000 +0100
@@ -41,6 +41,7 @@
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>
+#include <linux/dmi.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x73, I2C_CLIENT_END };
@@ -768,8 +769,16 @@ static struct fschmd_data *fschmd_update
return data;
}
+static void __init fschmd_get_dmi_data(const struct dmi_header *h)
+{
+ if (h->type = 185) {
+ /* Do stuff */
+ }
+}
+
static int __init fschmd_init(void)
{
+ dmi_walk(fschmd_get_dmi_data);
return i2c_add_driver(&fschmd_driver);
}
--- linux-2.6.24-rc1.orig/include/linux/dmi.h 2007-10-24 09:59:51.000000000 +0200
+++ linux-2.6.24-rc1/include/linux/dmi.h 2007-11-01 23:52:54.000000000 +0100
@@ -78,6 +78,7 @@ extern const struct dmi_device * dmi_fin
extern void dmi_scan_machine(void);
extern int dmi_get_year(int field);
extern int dmi_name_in_vendors(const char *str);
+extern int dmi_walk(void (*decode)(const struct dmi_header *));
#else
@@ -87,6 +88,8 @@ static inline const struct dmi_device *
const struct dmi_device *from) { return NULL; }
static inline int dmi_get_year(int year) { return 0; }
static inline int dmi_name_in_vendors(const char *s) { return 0; }
+static inline int dmi_walk(void (*decode)(const struct dmi_header *))
+ { return -1; }
#endif
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2007-11-01 23:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-21 15:03 [lm-sensors] PATCH: Hans de Goede
2007-09-24 14:28 ` Jean Delvare
2007-10-07 8:19 ` Jean Delvare
2007-10-07 11:37 ` Hans de Goede
2007-10-07 18:24 ` Mark M. Hoffman
2007-10-07 18:28 ` Mark M. Hoffman
2007-10-07 20:41 ` Jean Delvare
2007-10-07 22:05 ` Jean Delvare
2007-10-31 8:42 ` Hans de Goede
2007-10-31 15:17 ` Jean Delvare
2007-11-01 23:00 ` Jean Delvare [this message]
2007-11-02 7:35 ` Hans de Goede
2007-11-02 9:44 ` Jean Delvare
2007-11-02 19:41 ` Hans de Goede
2007-11-03 16:29 ` Jean Delvare
2007-11-04 13:21 ` Hans de Goede
2007-12-17 15:56 ` Hans de Goede
2007-12-18 13:29 ` Jean Delvare
2008-06-30 14:53 ` Hans de Goede
2009-01-30 10:29 ` Hans de Goede
2009-01-30 11:06 ` Jean Delvare
-- strict thread matches above, loose matches on Subject: below --
2006-06-28 12:35 [lm-sensors] Patch: 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=20071102000034.0b613a38@hyperion.delvare \
--to=khali@linux-fr.org \
--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.