diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..768301d --- /dev/null +++ b/.gitignore @@ -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 diff --git a/debian/changelog b/debian/changelog index 3063b72..dcbc185 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Fri, 21 Aug 2026 21:20:15 +0200 + fake-battery-dkms (0.1.0-1) stable; urgency=low - * Initial release + * Initial release + + -- Vincent Schweiger Fri, 21 Aug 2026 19:39:00 +0200 - -- Vincent Schweiger Fri, 21 Aug 2026 19:39:00 - +0200 diff --git a/dkms.conf b/dkms.conf index e1fb232..75b2e87 100644 --- a/dkms.conf +++ b/dkms.conf @@ -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" diff --git a/fake-battery.c b/fake-battery.c index 9af7adf..e6d80bf 100644 --- a/fake-battery.c +++ b/fake-battery.c @@ -1,9 +1,12 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include #include +#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");