From 691b44e7cba10446b7f8dc3df83e312ab63f97d9 Mon Sep 17 00:00:00 2001 From: Peter Schiffer Date: Wed, 22 Jan 2014 18:37:13 +0100 Subject: Hardware: updated LMI_PhysicalMemoryProvider * be more picky when choosing bank locator * take into account Configured Clock Speed field from dmidecode * display speed only if the data is available --- src/hardware/LMI_PhysicalMemoryProvider.c | 7 ++++-- src/hardware/dmidecode.c | 36 +++++++++++++++---------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/hardware/LMI_PhysicalMemoryProvider.c b/src/hardware/LMI_PhysicalMemoryProvider.c index c65cd20..9413967 100644 --- a/src/hardware/LMI_PhysicalMemoryProvider.c +++ b/src/hardware/LMI_PhysicalMemoryProvider.c @@ -87,8 +87,6 @@ static CMPIStatus LMI_PhysicalMemoryEnumInstances( get_form_factor(dmi_memory.modules[i].form_factor)); LMI_PhysicalMemory_Set_MemoryType(&lmi_phys_mem, get_memory_type(dmi_memory.modules[i].type)); - LMI_PhysicalMemory_Set_Speed(&lmi_phys_mem, - dmi_memory.modules[i].speed_time); LMI_PhysicalMemory_Set_BankLabel(&lmi_phys_mem, dmi_memory.modules[i].bank_label); LMI_PhysicalMemory_Set_ElementName(&lmi_phys_mem, @@ -111,6 +109,11 @@ static CMPIStatus LMI_PhysicalMemoryEnumInstances( LMI_PhysicalMemory_Set_DataWidth(&lmi_phys_mem, dmi_memory.modules[i].data_width); + if (dmi_memory.modules[i].speed_time) { + LMI_PhysicalMemory_Set_Speed(&lmi_phys_mem, + dmi_memory.modules[i].speed_time); + } + KReturnInstance(cr, lmi_phys_mem); } diff --git a/src/hardware/dmidecode.c b/src/hardware/dmidecode.c index 7f5c6d4..a457db0 100644 --- a/src/hardware/dmidecode.c +++ b/src/hardware/dmidecode.c @@ -918,25 +918,19 @@ short dmi_get_memory(DmiMemory *memory) } continue; } - if (strstr(buffer[i], "Locator:")) { - if (strstr(buffer[i], "Bank Locator:")) { - /* Memory Module Bank Label */ - buf = copy_string_part_after_delim(buffer[i], "Bank Locator: "); - if (buf) { - memory->modules[curr_mem].bank_label = buf; - buf = NULL; - continue; - } - } else { - /* Slot */ - buf = copy_string_part_after_delim(buffer[i], "Locator: "); - if (buf) { - sscanf(buf, "%*s %d", &memory->modules[curr_mem].slot); - free(buf); - buf = NULL; - continue; - } + /* Memory Module Bank Label and Slot ID */ + buf = copy_string_part_after_delim(buffer[i], "Locator: "); + if (buf) { + if (memory->modules[curr_mem].slot != -1) { + continue; + } + if (strncasecmp(buf, "bank ", 5) != 0) { + continue; } + sscanf(buf, "%*s %d", &memory->modules[curr_mem].slot); + memory->modules[curr_mem].bank_label = buf; + buf = NULL; + continue; } /* Form Factor */ buf = copy_string_part_after_delim(buffer[i], "Form Factor: "); @@ -969,7 +963,11 @@ short dmi_get_memory(DmiMemory *memory) /* Speed in MHz */ buf = copy_string_part_after_delim(buffer[i], "Speed: "); if (buf) { - sscanf(buf, "%u", &memory->modules[curr_mem].speed_clock); + if (strstr(buffer[i], "Configured Clock Speed: ")) { + sscanf(buf, "%u", &memory->modules[curr_mem].speed_clock); + } else if (memory->modules[curr_mem].speed_clock == 0) { + sscanf(buf, "%u", &memory->modules[curr_mem].speed_clock); + } free(buf); buf = NULL; continue; -- cgit