My kernel driver needs to access battery's properties (get_property, set_property).
Problem: How to find the battery's struct power_supply?
I only find power_supply_get_by_name
but there can be different names for the battery. I need to check the power_supply's type but this is where I am stuck.
A direct get_by_type
or a get_all_power_supplies
to check the type on my own or also a get_power_supply_names
to pass to power_supply_get_by_name would be fine for me.
I want to avoid file accesses in the kernel so what is a better way to find the type="battery" power_supply?
I suspect I should grab the supply every time again because it may change or vanish / reappear? This driver can access the supply every couple of seconds in some situations so it would be nice to not spend a long time finding the battery.