Changeset 4474

Show
Ignore:
Timestamp:
06/26/07 13:33:09 (6 years ago)
Author:
khali
Message:

struct sensors_proc_chips_entry now has a single member, so we may
as well use this member directly for slightly more simple code.

Location:
lm-sensors/branches/lm-sensors-3.0.0/lib
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/branches/lm-sensors-3.0.0/lib/access.c

    r4465 r4474  
    305305        const sensors_chip_name *res; 
    306306        res = (*nr >= sensors_proc_chips_count ? 
    307                         NULL : &sensors_proc_chips[*nr].name); 
     307                        NULL : &sensors_proc_chips[*nr]); 
    308308        (*nr)++; 
    309309        return res; 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/data.c

    r4465 r4474  
    3737int sensors_config_busses_max = 0; 
    3838 
    39 sensors_proc_chips_entry *sensors_proc_chips = NULL; 
     39sensors_chip_name *sensors_proc_chips = NULL; 
    4040int sensors_proc_chips_count = 0; 
    4141int sensors_proc_chips_max = 0; 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/data.h

    r4473 r4474  
    119119} sensors_bus; 
    120120 
    121 /* /proc/sys/dev/sensors/chips line representation */ 
    122 typedef struct sensors_proc_chips_entry { 
    123   sensors_chip_name name; 
    124 } sensors_proc_chips_entry; 
    125  
    126121/* Internal data about a single chip feature. 
    127122   name is the string name used to refer to this feature (both in config 
     
    165160extern int sensors_config_busses_max; 
    166161 
    167 extern sensors_proc_chips_entry *sensors_proc_chips; 
     162extern sensors_chip_name *sensors_proc_chips; 
    168163extern int sensors_proc_chips_count; 
    169164extern int sensors_proc_chips_max; 
     
    171166#define sensors_add_proc_chips(el) sensors_add_array_el( \ 
    172167        (el), &sensors_proc_chips, &sensors_proc_chips_count,\ 
    173         &sensors_proc_chips_max, sizeof(struct sensors_proc_chips_entry)) 
     168        &sensors_proc_chips_max, sizeof(struct sensors_chip_name)) 
    174169 
    175170extern sensors_bus *sensors_proc_bus; 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/init.c

    r4462 r4474  
    2828#include "scanner.h" 
    2929 
    30 static void free_proc_chips_entry(sensors_proc_chips_entry entry); 
    3130static void free_chip_name(sensors_chip_name name); 
    3231static void free_bus(sensors_bus bus); 
     
    6261 
    6362  for (i = 0; i < sensors_proc_chips_count; i++) 
    64     free_proc_chips_entry(sensors_proc_chips[i]); 
     63    free_chip_name(sensors_proc_chips[i]); 
    6564  free(sensors_proc_chips); 
    6665  sensors_proc_chips = NULL; 
     
    8483  sensors_proc_bus = NULL; 
    8584  sensors_proc_bus_count = sensors_proc_bus_max = 0; 
    86 } 
    87  
    88 void free_proc_chips_entry(sensors_proc_chips_entry entry) 
    89 { 
    90     free_chip_name(entry.name); 
    9185} 
    9286 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c

    r4464 r4474  
    220220        struct sysfs_attribute *attr, *bus_attr; 
    221221        char bus_path[SYSFS_PATH_MAX]; 
    222         sensors_proc_chips_entry entry; 
     222        sensors_chip_name name; 
    223223 
    224224        /* ignore any device without name attribute */ 
     
    232232 
    233233        /* NB: attr->value[attr->len-1] == '\n'; chop that off */ 
    234         entry.name.prefix = strndup(attr->value, attr->len - 1); 
    235         if (!entry.name.prefix) 
     234        name.prefix = strndup(attr->value, attr->len - 1); 
     235        if (!name.prefix) 
    236236                sensors_fatal_error(__FUNCTION__, "out of memory"); 
    237237 
    238         entry.name.busname = strdup(dev->path); 
    239         if (!entry.name.busname) 
     238        name.busname = strdup(dev->path); 
     239        if (!name.busname) 
    240240                sensors_fatal_error(__FUNCTION__, "out of memory"); 
    241241 
    242         if (sscanf(dev->name, "%d-%x", &entry.name.bus, &entry.name.addr) == 2) { 
     242        if (sscanf(dev->name, "%d-%x", &name.bus, &name.addr) == 2) { 
    243243                /* find out if legacy ISA or not */ 
    244                 if (entry.name.bus == 9191) 
    245                         entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA; 
     244                if (name.bus == 9191) 
     245                        name.bus = SENSORS_CHIP_NAME_BUS_ISA; 
    246246                else { 
    247247                        snprintf(bus_path, sizeof(bus_path), 
    248248                                "%s/class/i2c-adapter/i2c-%d/device/name", 
    249                                 sensors_sysfs_mount, entry.name.bus); 
     249                                sensors_sysfs_mount, name.bus); 
    250250 
    251251                        if ((bus_attr = sysfs_open_attribute(bus_path))) { 
     
    255255                                if (bus_attr->value 
    256256                                 && !strncmp(bus_attr->value, "ISA ", 4)) 
    257                                         entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA; 
     257                                        name.bus = SENSORS_CHIP_NAME_BUS_ISA; 
    258258 
    259259                                sysfs_close_attribute(bus_attr); 
    260260                        } 
    261261                } 
    262         } else if (sscanf(dev->name, "%*[a-z0-9_].%d", &entry.name.addr) == 1) { 
     262        } else if (sscanf(dev->name, "%*[a-z0-9_].%d", &name.addr) == 1) { 
    263263                /* must be new ISA (platform driver) */ 
    264                 entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA; 
     264                name.bus = SENSORS_CHIP_NAME_BUS_ISA; 
    265265        } else if (sscanf(dev->name, "%x:%x:%x.%x", &domain, &bus, &slot, &fn) == 4) { 
    266266                /* PCI */ 
    267                 entry.name.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn; 
    268                 entry.name.bus = SENSORS_CHIP_NAME_BUS_PCI; 
     267                name.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn; 
     268                name.bus = SENSORS_CHIP_NAME_BUS_PCI; 
    269269        } else 
    270270                return -SENSORS_ERR_PARSE; 
     
    272272        /* check whether this chip is known in the static list */  
    273273        for (i = 0; sensors_chip_features_list[i].prefix; i++) 
    274                 if (!strcasecmp(sensors_chip_features_list[i].prefix, entry.name.prefix)) 
     274                if (!strcasecmp(sensors_chip_features_list[i].prefix, name.prefix)) 
    275275                        break; 
    276276 
     
    288288        } 
    289289                 
    290         sensors_add_proc_chips(&entry); 
     290        sensors_add_proc_chips(&name); 
    291291 
    292292        return 0;