devicelock.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 "devicelock.h"
  15. #include "log.h"
  16. static void default_event(struct devicelock *s)
  17. {
  18. }
  19. struct devicelock * devicelock_probe(void)
  20. {
  21. struct devicelock *s;
  22. const struct probe *probe;
  23. for_each_probe(probe, devicelock) {
  24. s = probe->func();
  25. if (s) {
  26. logdebug("Initialized devicelock driver \"%s\"\n",
  27. s->name);
  28. return s;
  29. }
  30. }
  31. logerr("Failed to find any devicelock controls.\n");
  32. return NULL;
  33. }
  34. void devicelock_destroy(struct devicelock *s)
  35. {
  36. if (s)
  37. s->destroy(s);
  38. }
  39. void devicelock_init(struct devicelock *s, const char *name)
  40. {
  41. memset(s, 0, sizeof(*s));
  42. s->name = name;
  43. s->event = default_event;
  44. }