Merge pull request #12 from JeffCurless/support_trixie
Add support for Trixie.
This commit is contained in:
@@ -1,14 +1,8 @@
|
|||||||
|
|
||||||
sudo cp -vf oneUpPower.ko /lib/modules/`uname -r`/kernel/drivers/power/supply/oneUpPower.ko
|
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/
|
ls /lib/modules/`uname -r`/kernel/drivers/power/supply/
|
||||||
sudo insmod oneUpPower.ko
|
sudo insmod oneUpPower.ko
|
||||||
|
sync
|
||||||
#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
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ struct PowerStatus {
|
|||||||
|
|
||||||
} battery = {
|
} battery = {
|
||||||
.status = POWER_SUPPLY_STATUS_DISCHARGING,
|
.status = POWER_SUPPLY_STATUS_DISCHARGING,
|
||||||
.capacity = 90,
|
.capacity = 100,
|
||||||
.capacity_level = POWER_SUPPLY_CAPACITY_LEVEL_HIGH,
|
.capacity_level = POWER_SUPPLY_CAPACITY_LEVEL_HIGH,
|
||||||
.health = POWER_SUPPLY_HEALTH_GOOD,
|
.health = POWER_SUPPLY_HEALTH_GOOD,
|
||||||
.present = 1,
|
.present = 1,
|
||||||
@@ -239,7 +239,13 @@ static int check_ac_power( struct i2c_client *client )
|
|||||||
if( ac_online != plugged_in ){
|
if( ac_online != plugged_in ){
|
||||||
ac_online = plugged_in;
|
ac_online = plugged_in;
|
||||||
set_power_states();
|
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;
|
return plugged_in;
|
||||||
@@ -318,44 +324,42 @@ static int system_monitor( void *args )
|
|||||||
|
|
||||||
PR_INFO( "Starting system monitor...\n" );
|
PR_INFO( "Starting system monitor...\n" );
|
||||||
|
|
||||||
|
while( true ){
|
||||||
//
|
//
|
||||||
// Get an adapter so we can make an i2c client...
|
// Get an adapter so we can make an i2c client...
|
||||||
//
|
//
|
||||||
adapter = i2c_get_adapter( I2C_BUS );
|
|
||||||
if( adapter == NULL ){
|
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 );
|
client = i2c_new_client_device( adapter, &board_info );
|
||||||
if( client == NULL ){
|
PR_INFO( "Client = %p\n",client);
|
||||||
PR_ERR( "Unable to create i2c client!\n" );
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
PR_INFO( "Created an I2C client device...\n" );
|
|
||||||
|
|
||||||
//
|
|
||||||
// Monitor until we are done...
|
|
||||||
//
|
|
||||||
while( true ){
|
|
||||||
set_current_state( TASK_UNINTERRUPTIBLE );
|
set_current_state( TASK_UNINTERRUPTIBLE );
|
||||||
if( kthread_should_stop() )
|
if( kthread_should_stop() ){
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
plugged_in = check_ac_power( client );
|
plugged_in = check_ac_power( client );
|
||||||
soc = check_battery_state( client );
|
soc = check_battery_state( client );
|
||||||
|
|
||||||
set_current_state( TASK_INTERRUPTIBLE );
|
set_current_state( TASK_INTERRUPTIBLE );
|
||||||
if( !plugged_in && (soc <= critical_power_level) ){
|
if( !plugged_in && (soc < critical_power_level) ){
|
||||||
// not pluggged in and below critical state, shutdown.
|
// not pluggged in and below critical state, shutdown
|
||||||
PR_INFO( "Performing system shutdown unplugged and power is at %d\n",soc);
|
PR_INFO( "Performing system shutdown unplugged and power is at %d\n",soc);
|
||||||
shutdown_helper();
|
shutdown_helper();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
schedule_timeout( HZ );
|
schedule_timeout( HZ );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,8 +477,7 @@ static int get_battery_int_property( struct power_supply *psy,
|
|||||||
val->intval = battery.voltage;
|
val->intval = battery.voltage;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PR_INFO("%s: some properties deliberately report errors.\n",
|
PR_INFO("%s: some properties deliberately report errors.\n",__func__);
|
||||||
__func__);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,8 +543,7 @@ static int __init oneup_power_init(void)
|
|||||||
&power_descriptions[i],
|
&power_descriptions[i],
|
||||||
&power_configs[i]);
|
&power_configs[i]);
|
||||||
if (IS_ERR(power_supplies[i])) {
|
if (IS_ERR(power_supplies[i])) {
|
||||||
PR_ERR("%s: failed to register %s\n", __func__,
|
PR_ERR("%s: failed to register %s\n", __func__, power_descriptions[i].name);
|
||||||
power_descriptions[i].name);
|
|
||||||
ret = PTR_ERR(power_supplies[i]);
|
ret = PTR_ERR(power_supplies[i]);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@@ -563,8 +565,9 @@ failed:
|
|||||||
monitor_task = NULL;
|
monitor_task = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (--i >= 0)
|
while (--i >= 0){
|
||||||
power_supply_unregister(power_supplies[i]);
|
power_supply_unregister(power_supplies[i]);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -594,8 +597,8 @@ static void __exit oneup_power_exit(void)
|
|||||||
for (i = 0; i < ARRAY_SIZE(power_supplies); i++)
|
for (i = 0; i < ARRAY_SIZE(power_supplies); i++)
|
||||||
power_supply_changed(power_supplies[i]);
|
power_supply_changed(power_supplies[i]);
|
||||||
|
|
||||||
PR_INFO("%s: 'changed' event sent, sleeping for 10 seconds...\n", __func__);
|
//PR_INFO("%s: 'changed' event sent, sleeping for 10 seconds...\n", __func__);
|
||||||
ssleep(10);
|
//ssleep(10);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(power_supplies); i++)
|
for (i = 0; i < ARRAY_SIZE(power_supplies); i++)
|
||||||
power_supply_unregister(power_supplies[i]);
|
power_supply_unregister(power_supplies[i]);
|
||||||
|
|||||||
Reference in New Issue
Block a user