| 73 | #if SENSORS_API_VERSION & 0x400 |
| 74 | void initLmSensors( struct SensorModul* sm ) |
| 75 | { |
| 76 | const sensors_chip_name* scn; |
| 77 | int nr = 0; |
| 78 | |
| 79 | if ( sensors_init( NULL ) ) { |
| 80 | LmSensorsOk = -1; |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | LmSensors = new_ctnr(); |
| 85 | while ( ( scn = sensors_get_detected_chips( NULL, &nr ) ) != NULL ) { |
| 86 | int nr1 = 0; |
| 87 | const sensors_feature* sf; |
| 88 | |
| 89 | while ( ( sf = sensors_get_features( scn, &nr1 ) ) != 0 ) { |
| 90 | const sensors_subfeature *ssubf; |
| 91 | LMSENSOR *p; |
| 92 | char *s, *label; |
| 93 | |
| 94 | switch( sf->type ) |
| 95 | { |
| 96 | case SENSORS_FEATURE_IN: |
| 97 | ssubf = sensors_get_subfeature( scn, sf, |
| 98 | SENSORS_SUBFEATURE_IN_INPUT ); |
| 99 | break; |
| 100 | |
| 101 | case SENSORS_FEATURE_FAN: |
| 102 | ssubf = sensors_get_subfeature( scn, sf, |
| 103 | SENSORS_SUBFEATURE_FAN_INPUT ); |
| 104 | break; |
| 105 | |
| 106 | case SENSORS_FEATURE_TEMP: |
| 107 | ssubf = sensors_get_subfeature( scn, sf, |
| 108 | SENSORS_SUBFEATURE_TEMP_INPUT ); |
| 109 | break; |
| 110 | } |
| 111 | |
| 112 | if ( !ssubf ) |
| 113 | continue; |
| 114 | |
| 115 | label = sensors_get_label( scn, sf ); |
| 116 | p = (LMSENSOR*)malloc( sizeof( LMSENSOR ) ); |
| 117 | p->fullName = (char*)malloc( strlen( "lmsensors/" ) + |
| 118 | strlen( scn->prefix ) + 1 + |
| 119 | strlen( label ) + 1 ); |
| 120 | sprintf( p->fullName, "lmsensors/%s/%s", scn->prefix, label ); |
| 121 | |
| 122 | /* Make sure that name contains only proper characters. */ |
| 123 | for ( s = p->fullName; *s; s++ ) |
| 124 | if ( *s == ' ' ) |
| 125 | *s = '_'; |
| 126 | |
| 127 | p->scn = scn; |
| 128 | p->sf = sf; |
| 129 | p->sfd = ssubf; |
| 130 | |
| 131 | /* Note a name collision should never happen with the lm_sensors-3x code, |
| 132 | but it does in the case of k8temp, when there are 2 identical labeled |
| 133 | sensors per CPU. This are really 2 distinct sensors measuring the |
| 134 | same thing, but fullName must be unique so we just drop the second |
| 135 | sensor */ |
| 136 | if ( search_ctnr( LmSensors, sensorCmp, p ) < 0 ) { |
| 137 | push_ctnr( LmSensors, p ); |
| 138 | registerMonitor( p->fullName, "float", printLmSensor, printLmSensorInfo, sm ); |
| 139 | } else { |
| 140 | free( p->fullName ); |
| 141 | free( p ); |
| 142 | } |
| 143 | free( label ); |
| 144 | } |
| 145 | } |
| 146 | bsort_ctnr( LmSensors, sensorCmp ); |
| 147 | } |
| 148 | #else /* SENSORS_API_VERSION & 0x400 */ |