From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH] decode-dimms: Add support for at24 kernel driver
Date: Mon, 8 Mar 2010 10:36:43 +0100 [thread overview]
Message-ID: <20100308103643.5965454f@hyperion.delvare> (raw)
Add support for at24 kernel driver, in addition to the legacy eeprom
kernel driver.
---
eeprom/decode-dimms | 47 +++++++++++++++++++++++++++++++++++++----------
1 file changed, 37 insertions(+), 10 deletions(-)
--- i2c-tools.orig/eeprom/decode-dimms 2009-06-09 13:14:35.000000000 +0200
+++ i2c-tools/eeprom/decode-dimms 2010-03-08 09:00:05.000000000 +0100
@@ -1707,24 +1707,51 @@ printh('Memory Serial Presence Detect De
Jean Delvare, Trent Piepho and others');
+# From a sysfs device path and an attribute name, return the attribute
+# value, or undef (stolen from sensors-detect)
+sub sysfs_device_attribute
+{
+ my ($device, $attr) = @_;
+ my $value;
+
+ open(local *FILE, "$device/$attr") or return "";
+ $value = <FILE>;
+ close(FILE);
+ return unless defined $value;
+
+ chomp($value);
+ return $value;
+}
+
sub get_dimm_list
{
- my ($dir, $file, @files);
+ my (@dirs, $dir, $file, @files);
if ($use_sysfs) {
- $dir = '/sys/bus/i2c/drivers/eeprom';
+ @dirs = ('/sys/bus/i2c/drivers/eeprom', '/sys/bus/i2c/drivers/at24');
} else {
- $dir = '/proc/sys/dev/sensors';
+ @dirs = ('/proc/sys/dev/sensors');
}
- if (opendir(local *DIR, $dir)) {
- while (defined($file = readdir(DIR))) {
- next if $use_sysfs && $file !~ /^\d+-[\da-f]+$/i;
- next if !$use_sysfs && $file !~ /^eeprom-/;
- push @files, { eeprom => "$file",
- file => "$dir/$file" };
+ foreach $dir (@dirs) {
+ if (opendir(local *DIR, $dir)) {
+ while (defined($file = readdir(DIR))) {
+ if ($use_sysfs) {
+ next if $file !~ /^\d+-[\da-f]+$/i;
+ next if ! -d "$dir/$file";
+ my $attr = sysfs_device_attribute("$dir/$file", "name");
+ next unless defined $attr && ($attr eq "eeprom" || $attr eq "spd");
+ } else {
+ next if $file !~ /^eeprom-/;
+ }
+ push @files, { eeprom => "$file",
+ file => "$dir/$file" };
+ }
+ close(DIR);
}
- close(DIR);
+ }
+
+ if (@files) {
return sort { $a->{file} cmp $b->{file} } @files;
} elsif (! -d '/sys/module/eeprom') {
print "No EEPROM found, are you sure the eeprom module is loaded?\n";
--
Jean Delvare
reply other threads:[~2010-03-08 9:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20100308103643.5965454f@hyperion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.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.