blob: 3d55bd547178249192ea62a7fd21dd0085420a06 [file] [log] [blame]
Jeremy Kerr0508ad12017-02-01 10:53:41 -06001/*
2 * FSI core driver
3 *
4 * Copyright (C) IBM Corporation 2016
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <linux/device.h>
17#include <linux/fsi.h>
18#include <linux/module.h>
19
20/* FSI core & Linux bus type definitions */
21
Jeremy Kerrdd37eed2017-02-01 10:53:43 -060022static int fsi_bus_match(struct device *dev, struct device_driver *drv)
23{
24 struct fsi_device *fsi_dev = to_fsi_dev(dev);
25 struct fsi_driver *fsi_drv = to_fsi_drv(drv);
26 const struct fsi_device_id *id;
27
28 if (!fsi_drv->id_table)
29 return 0;
30
31 for (id = fsi_drv->id_table; id->engine_type; id++) {
32 if (id->engine_type != fsi_dev->engine_type)
33 continue;
34 if (id->version == FSI_VERSION_ANY ||
35 id->version == fsi_dev->version)
36 return 1;
37 }
38
39 return 0;
40}
41
Jeremy Kerr0508ad12017-02-01 10:53:41 -060042struct bus_type fsi_bus_type = {
43 .name = "fsi",
Jeremy Kerrdd37eed2017-02-01 10:53:43 -060044 .match = fsi_bus_match,
Jeremy Kerr0508ad12017-02-01 10:53:41 -060045};
46EXPORT_SYMBOL_GPL(fsi_bus_type);
47
48static int fsi_init(void)
49{
50 return bus_register(&fsi_bus_type);
51}
52
53static void fsi_exit(void)
54{
55 bus_unregister(&fsi_bus_type);
56}
57
58module_init(fsi_init);
59module_exit(fsi_exit);