summaryrefslogtreecommitdiffstats
path: root/backend/devicelock.c
blob: dc2cc779022a8d4b042bfcbef2f88db68dbf3a0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 *   Copyright (C) 2010 Michael Buesch <m@bues.ch>
 *
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation; either version 2
 *   of the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 */

#include "devicelock.h"
#include "log.h"


static void default_event(struct devicelock *s)
{
}

struct devicelock * devicelock_probe(void)
{
	struct devicelock *s;
	const struct probe *probe;

	for_each_probe(probe, devicelock) {
		s = probe->func();
		if (s) {
			logdebug("Initialized devicelock driver \"%s\"\n",
				 s->name);
			return s;
		}
	}

	logerr("Failed to find any devicelock controls.\n");
	return NULL;
}

void devicelock_destroy(struct devicelock *s)
{
	if (s)
		s->destroy(s);
}

void devicelock_init(struct devicelock *s, const char *name)
{
	memset(s, 0, sizeof(*s));
	s->name = name;
	s->event = default_event;
}
bues.ch cgit interface