Merge pull request #12 from JeffCurless/support_trixie

Add support for Trixie.
This commit is contained in:
Jeff Curless
2025-10-28 20:10:44 -04:00
committed by GitHub
2 changed files with 147 additions and 150 deletions

View File

@@ -1,14 +1,8 @@
sudo cp -vf oneUpPower.ko /lib/modules/`uname -r`/kernel/drivers/power/supply/oneUpPower.ko
sudo depmod -a
ls /lib/modules/`uname -r`/kernel/drivers/power/supply/
sudo insmod oneUpPower.ko
#ls -l /sys/class/power_supply/BAT0
#cat /sys/class/power_supply/BAT0/uevent
#cat /sys/class/power_supply/BAT0/capacity
#cat /sys/class/power_supply/BAT0/status
#
#ls -l /sys/class/power_supply/AC0
#cat /sys/class/power_supply/AC0/ueven
sync

View File

@@ -67,7 +67,7 @@ struct PowerStatus {
} battery = {
.status = POWER_SUPPLY_STATUS_DISCHARGING,
.capacity = 90,
.capacity = 100,
.capacity_level = POWER_SUPPLY_CAPACITY_LEVEL_HIGH,
.health = POWER_SUPPLY_HEALTH_GOOD,
.present = 1,
@@ -239,7 +239,13 @@ static int check_ac_power( struct i2c_client *client )
if( ac_online != plugged_in ){
ac_online = plugged_in;
set_power_states();
//power_supply_changed( power_supplies[ONEUP_AC] );
if( ac_online ){
PR_INFO( "AC Power is connected.\n" );
}
else {
PR_INFO( "AC Power is disconnected.\n" );
}
power_supply_changed( power_supplies[ONEUP_AC] );
}
return plugged_in;
@@ -318,44 +324,42 @@ static int system_monitor( void *args )
PR_INFO( "Starting system monitor...\n" );
while( true ){
//
// Get an adapter so we can make an i2c client...
//
adapter = i2c_get_adapter( I2C_BUS );
if( adapter == NULL ){
PR_ERR( "Unable to get i2c adapter!\n" );
return -1;
//
// get an adapter
//
set_current_state( TASK_INTERRUPTIBLE );
adapter = i2c_get_adapter( I2C_BUS );
PR_INFO( "Adapter = %p\n",adapter);
}
PR_INFO( "Created an I2C adapter...\n" );
else if( client == NULL ){
//
// Build the i2c client...
// Get a i2c client
//
set_current_state( TASK_INTERRUPTIBLE );
client = i2c_new_client_device( adapter, &board_info );
if( client == NULL ){
PR_ERR( "Unable to create i2c client!\n" );
return -1;
PR_INFO( "Client = %p\n",client);
}
PR_INFO( "Created an I2C client device...\n" );
//
// Monitor until we are done...
//
while( true ){
else{
set_current_state( TASK_UNINTERRUPTIBLE );
if( kthread_should_stop() )
if( kthread_should_stop() ){
break;
}
plugged_in = check_ac_power( client );
soc = check_battery_state( client );
set_current_state( TASK_INTERRUPTIBLE );
if( !plugged_in && (soc <= critical_power_level) ){
// not pluggged in and below critical state, shutdown.
if( !plugged_in && (soc < critical_power_level) ){
// not pluggged in and below critical state, shutdown
PR_INFO( "Performing system shutdown unplugged and power is at %d\n",soc);
shutdown_helper();
}
}
schedule_timeout( HZ );
}
@@ -473,8 +477,7 @@ static int get_battery_int_property( struct power_supply *psy,
val->intval = battery.voltage;
break;
default:
PR_INFO("%s: some properties deliberately report errors.\n",
__func__);
PR_INFO("%s: some properties deliberately report errors.\n",__func__);
return -EINVAL;
}
@@ -540,8 +543,7 @@ static int __init oneup_power_init(void)
&power_descriptions[i],
&power_configs[i]);
if (IS_ERR(power_supplies[i])) {
PR_ERR("%s: failed to register %s\n", __func__,
power_descriptions[i].name);
PR_ERR("%s: failed to register %s\n", __func__, power_descriptions[i].name);
ret = PTR_ERR(power_supplies[i]);
goto failed;
}
@@ -563,8 +565,9 @@ failed:
monitor_task = NULL;
}
while (--i >= 0)
while (--i >= 0){
power_supply_unregister(power_supplies[i]);
}
return ret;
}
@@ -594,8 +597,8 @@ static void __exit oneup_power_exit(void)
for (i = 0; i < ARRAY_SIZE(power_supplies); i++)
power_supply_changed(power_supplies[i]);
PR_INFO("%s: 'changed' event sent, sleeping for 10 seconds...\n", __func__);
ssleep(10);
//PR_INFO("%s: 'changed' event sent, sleeping for 10 seconds...\n", __func__);
//ssleep(10);
for (i = 0; i < ARRAY_SIZE(power_supplies); i++)
power_supply_unregister(power_supplies[i]);