battery_dummy.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (C) 2010 Michael Buesch <m@bues.ch>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #include "battery_dummy.h"
  15. #include "util.h"
  16. static int battery_dummy_max_level(struct battery *b)
  17. {
  18. return 0;
  19. }
  20. static void battery_dummy_destroy(struct battery *b)
  21. {
  22. struct battery_dummy *bd = container_of(b, struct battery_dummy, battery);
  23. free(bd);
  24. }
  25. static struct battery * battery_dummy_probe(void)
  26. {
  27. struct battery_dummy *bd;
  28. bd = zalloc(sizeof(*bd));
  29. if (!bd)
  30. return NULL;
  31. battery_init(&bd->battery, "dummy");
  32. bd->battery.destroy = battery_dummy_destroy;
  33. bd->battery.max_level = battery_dummy_max_level;
  34. return &bd->battery;
  35. }
  36. BATTERY_PROBE(dummy, battery_dummy_probe);