mirror of
https://github.com/lretq/fake-battery-linux.git
synced 2026-08-22 13:27:19 +00:00
add gitignore, update module with additional properties
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
# Kernel module build artifacts
|
||||
*.o
|
||||
*.ko
|
||||
*.cmd
|
||||
.*.cmd
|
||||
*.mod
|
||||
*.mod.c
|
||||
*.mod.o
|
||||
*.symvers
|
||||
*.order
|
||||
*.markers
|
||||
.tmp_versions/
|
||||
.cache.mk
|
||||
|
||||
# Backup files
|
||||
*~
|
||||
.#*
|
||||
|
||||
# clangd
|
||||
.cache/
|
||||
compile_commands.json
|
||||
Vendored
+9
-2
@@ -1,6 +1,13 @@
|
||||
fake-battery-dkms (0.1.1-1) stable; urgency=low
|
||||
|
||||
* Add manufacturer, model name and serial number
|
||||
* Remove duplicated log prefixes
|
||||
|
||||
-- Vincent Schweiger <vincent.schweiger@icloud.com> Fri, 21 Aug 2026 21:20:15 +0200
|
||||
|
||||
fake-battery-dkms (0.1.0-1) stable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
||||
-- Vincent Schweiger <vincent.schweiger@icloud.com> Fri, 21 Aug 2026 19:39:00
|
||||
+0200
|
||||
-- Vincent Schweiger <vincent.schweiger@icloud.com> Fri, 21 Aug 2026 19:39:00 +0200
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
PACKAGE_VERSION="0.1.0"
|
||||
PACKAGE_VERSION="0.1.1"
|
||||
PACKAGE_NAME="fake-battery"
|
||||
CLEAN=true
|
||||
BUILT_MODULE_NAME[0]="fake-battery"
|
||||
|
||||
+21
-7
@@ -1,9 +1,12 @@
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/power_supply.h>
|
||||
#include <linux/init.h>
|
||||
|
||||
#define VERSION_STR "0.1.1"
|
||||
|
||||
static struct power_supply *fake_battery;
|
||||
static struct power_supply_desc battery_desc;
|
||||
|
||||
@@ -20,6 +23,9 @@ static enum power_supply_property fake_battery_props[] = {
|
||||
POWER_SUPPLY_PROP_VOLTAGE_NOW,
|
||||
POWER_SUPPLY_PROP_CURRENT_NOW,
|
||||
POWER_SUPPLY_PROP_TEMP,
|
||||
POWER_SUPPLY_PROP_MODEL_NAME,
|
||||
POWER_SUPPLY_PROP_MANUFACTURER,
|
||||
POWER_SUPPLY_PROP_SERIAL_NUMBER,
|
||||
};
|
||||
|
||||
static int fake_battery_get_property(struct power_supply *psy,
|
||||
@@ -61,7 +67,16 @@ static int fake_battery_get_property(struct power_supply *psy,
|
||||
val->intval = 0; /* Not charging */
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_TEMP:
|
||||
val->intval = 250; /* 25°C in 0.1°C units */
|
||||
val->intval = 253; /* 25°C in 0.1°C units */
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_MODEL_NAME:
|
||||
val->strval = "Fake Battery v" VERSION_STR;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_MANUFACTURER:
|
||||
val->strval = "Thin Air";
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_SERIAL_NUMBER:
|
||||
val->strval = "deadbeef";
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
@@ -73,7 +88,7 @@ static int __init fake_battery_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
pr_info("fake_battery: Loading fake battery module\n");
|
||||
pr_debug("loading fake battery module\n");
|
||||
|
||||
// Initialize the power supply descriptor
|
||||
battery_desc.name = "fake-battery";
|
||||
@@ -86,19 +101,18 @@ static int __init fake_battery_init(void)
|
||||
fake_battery = power_supply_register(NULL, &battery_desc, NULL);
|
||||
if (IS_ERR(fake_battery)) {
|
||||
ret = PTR_ERR(fake_battery);
|
||||
pr_err("fake_battery: Failed to register power supply: %d\n", ret);
|
||||
pr_err("failed to register power supply: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
pr_info("fake_battery: Fake battery registered successfully\n");
|
||||
pr_info("fake_battery: Battery status: 100%% charged\n");
|
||||
pr_debug("fake battery registered successfully\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit fake_battery_exit(void)
|
||||
{
|
||||
pr_info("fake_battery: Unloading fake battery module\n");
|
||||
pr_debug("unloading fake battery module\n");
|
||||
if (fake_battery)
|
||||
power_supply_unregister(fake_battery);
|
||||
}
|
||||
@@ -108,5 +122,5 @@ module_exit(fake_battery_exit);
|
||||
|
||||
MODULE_AUTHOR("Vincent Schweiger");
|
||||
MODULE_DESCRIPTION("Fake battery module that reports a fully charged battery");
|
||||
MODULE_VERSION("0.1.0");
|
||||
MODULE_VERSION(VERSION_STR);
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
Reference in New Issue
Block a user