diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2017-02-01 11:53:43 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-02-10 09:19:48 -0500 |
commit | dd37eed7db0f7607fa41887c11c1e428faa15d0c (patch) | |
tree | 77f9408503ed7e2fb672dcfa88682bb2596e3a1c | |
parent | fda07a6c94ac5c9bd73d7b0134c6cc6861375341 (diff) |
drivers/fsi: add driver to device matches
Driver bind to devices based on the engine types & (optional) versions.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Chris Bostic <cbostic@us.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/fsi/fsi-core.c | 21 | ||||
-rw-r--r-- | include/linux/fsi.h | 21 |
2 files changed, 40 insertions, 2 deletions
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 3e45306359b3..3d55bd547178 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c | |||
@@ -19,8 +19,29 @@ | |||
19 | 19 | ||
20 | /* FSI core & Linux bus type definitions */ | 20 | /* FSI core & Linux bus type definitions */ |
21 | 21 | ||
22 | static 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 | |||
22 | struct bus_type fsi_bus_type = { | 42 | struct bus_type fsi_bus_type = { |
23 | .name = "fsi", | 43 | .name = "fsi", |
44 | .match = fsi_bus_match, | ||
24 | }; | 45 | }; |
25 | EXPORT_SYMBOL_GPL(fsi_bus_type); | 46 | EXPORT_SYMBOL_GPL(fsi_bus_type); |
26 | 47 | ||
diff --git a/include/linux/fsi.h b/include/linux/fsi.h index f73886a5af01..273cbf6400ea 100644 --- a/include/linux/fsi.h +++ b/include/linux/fsi.h | |||
@@ -18,11 +18,28 @@ | |||
18 | #include <linux/device.h> | 18 | #include <linux/device.h> |
19 | 19 | ||
20 | struct fsi_device { | 20 | struct fsi_device { |
21 | struct device dev; | 21 | struct device dev; |
22 | u8 engine_type; | ||
23 | u8 version; | ||
22 | }; | 24 | }; |
23 | 25 | ||
26 | struct fsi_device_id { | ||
27 | u8 engine_type; | ||
28 | u8 version; | ||
29 | }; | ||
30 | |||
31 | #define FSI_VERSION_ANY 0 | ||
32 | |||
33 | #define FSI_DEVICE(t) \ | ||
34 | .engine_type = (t), .version = FSI_VERSION_ANY, | ||
35 | |||
36 | #define FSI_DEVICE_VERSIONED(t, v) \ | ||
37 | .engine_type = (t), .version = (v), | ||
38 | |||
39 | |||
24 | struct fsi_driver { | 40 | struct fsi_driver { |
25 | struct device_driver drv; | 41 | struct device_driver drv; |
42 | const struct fsi_device_id *id_table; | ||
26 | }; | 43 | }; |
27 | 44 | ||
28 | #define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev) | 45 | #define to_fsi_dev(devp) container_of(devp, struct fsi_device, dev) |