Show
Ignore:
Timestamp:
09/23/07 14:00:59 (6 years ago)
Author:
khali
Message:

Split sensors_get_all_features() into two distinct functions, one to
get the list of all main features, and one to get the list of all the
subfeatures of a given main feature. This is a more logical interface for
applications to use. The current implementation is admittedly less than
optimal, because the storage structures weren't meant for it, but this
issue can (and will) be addressed later.

Files:
1 modified

Legend:

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

    r4830 r4831  
    344344} 
    345345 
    346 /* nr-1 is the last feature returned */ 
    347 const sensors_feature_data *sensors_get_all_features(const sensors_chip_name *name, 
    348                                                      int *nr) 
     346static const sensors_feature_data * 
     347sensors_get_all_features(const sensors_chip_name *name, int *nr) 
    349348{ 
    350349        sensors_feature_data *feature_list; 
     
    362361                } 
    363362        return NULL; 
     363} 
     364 
     365const sensors_feature_data * 
     366sensors_get_features(const sensors_chip_name *name, int *nr) 
     367{ 
     368        const sensors_feature_data *feature; 
     369 
     370        while ((feature = sensors_get_all_features(name, nr))) { 
     371                if (feature->mapping == SENSORS_NO_MAPPING) 
     372                        return feature; 
     373        } 
     374        return NULL;    /* end of list */ 
     375} 
     376 
     377const sensors_feature_data * 
     378sensors_get_all_subfeatures(const sensors_chip_name *name, int feature, int *nr) 
     379{ 
     380        const sensors_feature_data *subfeature; 
     381 
     382        /* Seek directly to the first subfeature */ 
     383        if (*nr < feature) 
     384                *nr = feature; 
     385 
     386        subfeature = sensors_get_all_features(name, nr); 
     387        if (!subfeature) 
     388                return NULL;    /* end of list */ 
     389        if (subfeature->number == feature || 
     390            subfeature->mapping == feature) 
     391                return subfeature; 
     392        return NULL;            /* end of subfeature list */ 
    364393} 
    365394