* [PATCH v2 1/2 i2c-tools] decode-dimms: Complete check for out-of-bounds vendor ID
@ 2015-06-01 7:26 Jean Delvare
[not found] ` <20150601092614.539ebc75-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Jean Delvare @ 2015-06-01 7:26 UTC (permalink / raw)
To: Linux I2C; +Cc: Lubomir Rintel
We also need to discard vendor ID 0 and to report "Unknown" if the
vendor is in a page we don't support yet.
Additionally, check that data is present at all for DDR3 modules as we
already do for pre-DDR3 modules.
---
Changes since v1:
* Added check for data presence.
eeprom/decode-dimms | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--- i2c-tools.orig/eeprom/decode-dimms 2015-06-01 08:19:59.292190666 +0200
+++ i2c-tools/eeprom/decode-dimms 2015-06-01 09:14:30.899898763 +0200
@@ -344,8 +344,12 @@ sub manufacturer_ddr3($$)
my ($count, $code) = @_;
my $manufacturer;
- return "Invalid" if parity($code) != 1;
- return "Unknown" if ($code & 0x7F) - 1 >= @{$vendors[$count & 0x7F]};
+ return "Undefined" unless spd_written($count, $code);
+
+ return "Invalid" if parity($code) != 1
+ or ($code & 0x7F) == 0;
+ return "Unknown" if ($count & 0x7F) >= @vendors
+ or ($code & 0x7F) - 1 >= @{$vendors[$count & 0x7F]};
$manufacturer = $vendors[$count & 0x7F][($code & 0x7F) - 1];
$manufacturer =~ s/ \(former .*\)$// if $opt_side_by_side;
$manufacturer .= "? (Invalid parity)" if parity($count) != 1;
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2 i2c-tools] sensors-detect: Refactor manufacturer decoding
[not found] ` <20150601092614.539ebc75-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
@ 2015-06-01 7:27 ` Jean Delvare
0 siblings, 0 replies; 2+ messages in thread
From: Jean Delvare @ 2015-06-01 7:27 UTC (permalink / raw)
To: Linux I2C; +Cc: Lubomir Rintel
Instead of reencoding pre-DDR3 manufacturer code to DDR3 manufacturer
code, move the common decoding to a separate function.
---
eeprom/decode-dimms | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
--- i2c-tools.orig/eeprom/decode-dimms 2015-06-01 09:14:30.899898763 +0200
+++ i2c-tools/eeprom/decode-dimms 2015-06-01 09:19:01.931673815 +0200
@@ -336,6 +336,21 @@ sub parity($)
return ($parity & 1);
}
+# The code byte includes parity, the count byte does not.
+sub manufacturer_common($$)
+{
+ my ($count, $code) = @_;
+ my $manufacturer;
+
+ return "Invalid" if parity($code) != 1
+ or ($code &= 0x7F) == 0;
+ return "Unknown" if $count >= @vendors
+ or $code - 1 >= @{$vendors[$count]};
+ $manufacturer = $vendors[$count][$code - 1];
+ $manufacturer =~ s/ \(former .*\)$// if $opt_side_by_side;
+ return $manufacturer;
+}
+
# New encoding format (as of DDR3) for manufacturer just has a count of
# leading 0x7F rather than all the individual bytes. The count bytes includes
# parity!
@@ -346,12 +361,7 @@ sub manufacturer_ddr3($$)
return "Undefined" unless spd_written($count, $code);
- return "Invalid" if parity($code) != 1
- or ($code & 0x7F) == 0;
- return "Unknown" if ($count & 0x7F) >= @vendors
- or ($code & 0x7F) - 1 >= @{$vendors[$count & 0x7F]};
- $manufacturer = $vendors[$count & 0x7F][($code & 0x7F) - 1];
- $manufacturer =~ s/ \(former .*\)$// if $opt_side_by_side;
+ $manufacturer = manufacturer_common($count & 0x7F, $code);
$manufacturer .= "? (Invalid parity)" if parity($count) != 1;
return $manufacturer;
}
@@ -369,11 +379,7 @@ sub manufacturer(@)
}
return ("Invalid", []) unless defined $first;
- return ("Invalid", [$first, @bytes]) if parity($first) != 1;
- if (parity($ai) == 0) {
- $ai |= 0x80;
- }
- return (manufacturer_ddr3($ai, $first), \@bytes);
+ return (manufacturer_common($ai, $first), \@bytes);
}
sub manufacturer_data(@)
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-01 7:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-01 7:26 [PATCH v2 1/2 i2c-tools] decode-dimms: Complete check for out-of-bounds vendor ID Jean Delvare
[not found] ` <20150601092614.539ebc75-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2015-06-01 7:27 ` [PATCH 2/2 i2c-tools] sensors-detect: Refactor manufacturer decoding Jean Delvare
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox