summaryrefslogtreecommitdiff
path: root/lib/device/dev_util.c
blob: 2302df46265bf72e3eb0db799d93e7f6c00102e3 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright (C) 2013 Red Hat, Inc. All rights reserved.
 *
 * This file is part of LVM2.
 *
 * This copyrighted material is made available to anyone wishing to use,
 * modify, copy, or redistribute it subject to the terms and conditions
 * of the GNU Lesser General Public License v.2.1.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "base/memory/zalloc.h"
#include "lib/misc/lib.h"
#include "lib/device/device.h"

int device_id_list_remove(struct dm_list *list, struct device *dev)
{
	struct device_id_list *dil;

	dm_list_iterate_items(dil, list) {
		if (dil->dev == dev) {
			dm_list_del(&dil->list);
			return 1;
		}
	}
	return 0;
}

struct device_id_list *device_id_list_find_dev(struct dm_list *list, struct device *dev)
{
	struct device_id_list *dil;

	dm_list_iterate_items(dil, list) {
		if (dil->dev == dev)
			return dil;
	}
	return NULL;
}

int device_list_remove(struct dm_list *list, struct device *dev)
{
	struct device_list *devl;

	dm_list_iterate_items(devl, list) {
		if (devl->dev == dev) {
			dm_list_del(&devl->list);
			return 1;
		}
	}
	return 0;
}

struct device_list *device_list_find_dev(struct dm_list *list, struct device *dev)
{
	struct device_list *devl;

	dm_list_iterate_items(devl, list) {
		if (devl->dev == dev)
			return devl;
	}
	return NULL;
}