summaryrefslogtreecommitdiff
path: root/drivers/trusty/trusty-fiq.c
blob: 1a031c67ea72c00a4edf8565827555b0f9f030dd (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * Copyright (C) 2013 Google, Inc.
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * 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 <linux/module.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/trusty/smcall.h>
#include <linux/trusty/trusty.h>

#include "trusty-fiq.h"

static int trusty_fiq_remove_child(struct device *dev, void *data)
{
	platform_device_unregister(to_platform_device(dev));
	return 0;
}

static int trusty_fiq_probe(struct platform_device *pdev)
{
	int ret;

	ret = trusty_fiq_arch_probe(pdev);
	if (ret)
		goto err_set_fiq_return;

	ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
	if (ret < 0) {
		dev_err(&pdev->dev, "Failed to add children: %d\n", ret);
		goto err_add_children;
	}

	return 0;

err_add_children:
	device_for_each_child(&pdev->dev, NULL, trusty_fiq_remove_child);
	trusty_fiq_arch_remove(pdev);
err_set_fiq_return:
	return ret;
}

static int trusty_fiq_remove(struct platform_device *pdev)
{
	device_for_each_child(&pdev->dev, NULL, trusty_fiq_remove_child);
	trusty_fiq_arch_remove(pdev);
	return 0;
}

static const struct of_device_id trusty_fiq_of_match[] = {
	{ .compatible = "android,trusty-fiq-v1", },
	{},
};

static struct platform_driver trusty_fiq_driver = {
	.probe = trusty_fiq_probe,
	.remove = trusty_fiq_remove,
	.driver	= {
		.name = "trusty-fiq",
		.owner = THIS_MODULE,
		.of_match_table = trusty_fiq_of_match,
	},
};

static int __init trusty_fiq_driver_init(void)
{
	return platform_driver_register(&trusty_fiq_driver);
}

static void __exit trusty_fiq_driver_exit(void)
{
	platform_driver_unregister(&trusty_fiq_driver);
}

subsys_initcall(trusty_fiq_driver_init);
module_exit(trusty_fiq_driver_exit);