+unsigned char pnd_device_get_charge_current ( int *result ) {
+ char buffer [ 100 ];
+
+ if ( pnd_device_open_read_close ( PND_DEVICE_CHARGE_CURRENT, buffer, 100 ) ) {
+ *result = atoi ( buffer );
+ return ( 1 );
+ }
+
+ return ( 0 );
+}
+
+int pnd_device_get_charger_enable ( const char *devices ) {
+ char fullname [ 100 ];
+ char buffer [ 100 ];
+
+ while ( 1 ) {
+ if ( sscanf ( devices, "%99s", buffer ) != 1 ) {
+ break;
+ }
+
+ while ( isspace ( *devices ) )
+ devices++;
+ devices += strlen ( buffer );
+ snprintf ( fullname, sizeof ( fullname ), PND_DEVICE_POWER_BASE "/%s/enable", buffer );
+
+ /* XXX: only ckecks first good device, but that should be enough for our needs */
+ if ( pnd_device_open_read_close ( fullname, buffer, 100 ) ) {
+ return ( atoi ( buffer ) );
+ }
+ }
+
+ return ( -1 );
+}
+
+unsigned char pnd_device_set_charger_enable ( const char *devices, unsigned char v ) {
+ char fullname [ 100 ];
+ char buffer [ 100 ];
+ int ret = 0;
+
+ while ( 1 ) {
+ if ( sscanf ( devices, "%99s", buffer ) != 1 ) {
+ break;
+ }
+
+ while ( isspace ( *devices ) )
+ devices++;
+ devices += strlen ( buffer );
+ snprintf ( fullname, sizeof ( fullname ), PND_DEVICE_POWER_BASE "/%s/enable", buffer );
+
+ sprintf ( buffer, "%u", v );
+ ret |= pnd_device_open_write_close ( fullname, buffer );
+ }
+
+ return ( ret );
+}
+