battery driver: simplify code