diff options
| -rw-r--r-- | modules/devices/dmi_memory.c | 13 | ||||
| -rw-r--r-- | modules/devices/spd-decode.c | 46 | 
2 files changed, 41 insertions, 18 deletions
| diff --git a/modules/devices/dmi_memory.c b/modules/devices/dmi_memory.c index f75c58ce..dfb9944f 100644 --- a/modules/devices/dmi_memory.c +++ b/modules/devices/dmi_memory.c @@ -640,8 +640,8 @@ gchar *make_spd_section(spd_data *spd) {                      "%s=%s\n" /* mfg date */                      "%s",                      _("Serial Presence Detect (SPD)"), -                    _("Source"), spd->dev, spd->spd_driver ? "ee1004" : "eeprom", -                        (spd->type == DDR4_SDRAM && !spd->spd_driver) ? problem_marker() : "", +                    _("Source"), spd->dev, spd->spd_driver, +                        (spd->type == DDR4_SDRAM && strcmp(spd->spd_driver, "ee1004") != 0) ? problem_marker() : "",                      _("SPD Revision"), spd->spd_rev_major, spd->spd_rev_minor,                      _("Form Factor"), UNKIFNULL2(spd->form_factor),                      _("Type"), UNKIFEMPTY2(spd->type_detail), @@ -995,12 +995,13 @@ static gchar note_state[note_max_len] = "";  gboolean memory_devices_hinote(const char **msg) {      gchar *want_dmi    = _(" <b><i>dmidecode</i></b> utility available");      gchar *want_root   = _(" ... <i>and</i> HardInfo running with superuser privileges"); -    gchar *want_eeprom = _(" <b><i>eeprom</i></b> module loaded (for SDR, DDR, DDR2, DDR3)"); +    gchar *want_at24   = _(" <b><i>at24</i></b> (or eeprom) module loaded (for SDR, DDR, DDR2, DDR3)");      gchar *want_ee1004 = _(" ... <i>or</i> <b><i>ee1004</i></b> module loaded <b>and configured!</b> (for DDR4)");      gboolean has_root = (getuid() == 0);      gboolean has_dmi = !no_handles; -    gboolean has_eeprom = g_file_test("/sys/bus/i2c/drivers/eeprom", G_FILE_TEST_IS_DIR); +    gboolean has_at24eep = g_file_test("/sys/bus/i2c/drivers/at24", G_FILE_TEST_IS_DIR) || +                           g_file_test("/sys/bus/i2c/drivers/eeprom", G_FILE_TEST_IS_DIR);      gboolean has_ee1004 = g_file_test("/sys/bus/i2c/drivers/ee1004", G_FILE_TEST_IS_DIR);      *note_state = 0; /* clear */ @@ -1010,7 +1011,7 @@ gboolean memory_devices_hinote(const char **msg) {      note_print(note_state, "<tt>   </tt>");      note_cond_bullet(has_root, note_state, want_root);      note_print(note_state, "<tt>2. </tt>"); -    note_cond_bullet(has_eeprom, note_state, want_eeprom); +    note_cond_bullet(has_at24eep, note_state, want_at24);      note_print(note_state, "<tt>   </tt>");      note_cond_bullet(has_ee1004, note_state, want_ee1004);      g_strstrip(note_state); /* remove last \n */ @@ -1019,7 +1020,7 @@ gboolean memory_devices_hinote(const char **msg) {      gboolean best_state = FALSE;      if (has_dmi && has_root && -        ((has_eeprom && !spd_ddr4_partial_data) +        ((has_at24eep && !spd_ddr4_partial_data)          || (has_ee1004 && !ddr3_ee1004) ) )          best_state = TRUE; diff --git a/modules/devices/spd-decode.c b/modules/devices/spd-decode.c index ed5fca60..70e24df6 100644 --- a/modules/devices/spd-decode.c +++ b/modules/devices/spd-decode.c @@ -66,7 +66,7 @@ struct dmi_mem_socket;  typedef struct {      unsigned char bytes[512];      char dev[32];  /* %1d-%04d\0 */ -    int spd_driver; /* 0 = eeprom, 1 = ee1004 */ +    const char *spd_driver;      int spd_size;      RamType type; @@ -1007,7 +1007,7 @@ static int read_spd(char *spd_path, int offset, size_t size, int use_sysfs,      return data_size;  } -static GSList *decode_dimms2(GSList *eeprom_list, gboolean use_sysfs, int max_size) { +static GSList *decode_dimms2(GSList *eeprom_list, const gchar *driver, gboolean use_sysfs, int max_size) {      GSList *eeprom, *dimm_list = NULL;      int count = 0;      int spd_size = 0; @@ -1090,8 +1090,7 @@ static GSList *decode_dimms2(GSList *eeprom_list, gboolean use_sysfs, int max_si          if (s) {              strncpy(s->dev, g_basename(spd_path), 31); -            if (strstr(spd_path, "ee1004")) -                s->spd_driver = 1; +            s->spd_driver = driver;              s->spd_size = spd_size;              s->type = ram_type;              spd_ram_types |= (1 << (ram_type-1)); @@ -1118,24 +1117,28 @@ static GSList *decode_dimms2(GSList *eeprom_list, gboolean use_sysfs, int max_si  }  struct SpdDriver { +    const char *driver;      const char *dir_path;      const gint max_size;      const gboolean use_sysfs; +    const char *spd_name;  };  static const struct SpdDriver spd_drivers[] = { -    { "/sys/bus/i2c/drivers/ee1004", 512, TRUE  }, -    { "/sys/bus/i2c/drivers/eeprom", 256, TRUE  }, -    { "/proc/sys/dev/sensors"      , 256, FALSE }, +    { "ee1004",      "/sys/bus/i2c/drivers/ee1004", 512, TRUE, "ee1004"}, +    { "at24",        "/sys/bus/i2c/drivers/at24"  , 256, TRUE, "spd"}, +    { "eeprom",      "/sys/bus/i2c/drivers/eeprom", 256, TRUE, "eeprom"}, +    { "eeprom-proc", "/proc/sys/dev/sensors"      , 256, FALSE, NULL},      { NULL }  };  GSList *spd_scan() {      GDir *dir = NULL;      GSList *eeprom_list = NULL, *dimm_list = NULL; -    gchar *dimm_list_entry, *dir_entry; +    gchar *dimm_list_entry, *dir_entry, *name_file, *name;      const struct SpdDriver *driver;      gboolean driver_found = FALSE; +    gboolean is_spd = FALSE;      spd_ddr4_partial_data = FALSE;      spd_no_driver = FALSE; @@ -1148,9 +1151,27 @@ GSList *spd_scan() {              driver_found = TRUE;              while ((dir_entry = (char *)g_dir_read_name(dir))) { -                if ((driver->use_sysfs && isdigit(dir_entry[0])) || -                    g_str_has_prefix(dir_entry, "eeprom-")) { +                is_spd = FALSE; +                if (driver->use_sysfs) { +                    name_file = NULL; +                    name = NULL; + +                    if (isdigit(dir_entry[0])) { +                        name_file = g_build_filename(driver->dir_path, dir_entry, "name", NULL); +                        g_file_get_contents(name_file, &name, NULL, NULL); + +                        is_spd = g_strcmp0(name, driver->spd_name); + +                        g_free(name_file); +                        g_free(name); +                    } +                } +                else { +                    is_spd = g_str_has_prefix(dir_entry, "eeprom-"); +                } + +                if (is_spd){                      dimm_list_entry = g_strdup_printf("%s/%s", driver->dir_path, dir_entry);                      eeprom_list = g_slist_prepend(eeprom_list, dimm_list_entry);                  } @@ -1159,7 +1180,7 @@ GSList *spd_scan() {              g_dir_close(dir);              if (eeprom_list) { -                dimm_list = decode_dimms2(eeprom_list, driver->use_sysfs, driver->max_size); +                dimm_list = decode_dimms2(eeprom_list, driver->driver, driver->use_sysfs, driver->max_size);                  g_slist_free(eeprom_list);                  eeprom_list = NULL;              } @@ -1168,7 +1189,8 @@ GSList *spd_scan() {      }      if (!driver_found) { -        if (!g_file_test("/sys/module/eeprom", G_FILE_TEST_EXISTS)) { +        if (!g_file_test("/sys/module/eeprom", G_FILE_TEST_EXISTS) && +            !g_file_test("/sys/module/at24", G_FILE_TEST_EXISTS)) {              spd_no_driver = TRUE; /* trigger hinote for no eeprom driver */          } else {              spd_no_support = TRUE; /* trigger hinote for unsupported system */ | 
