fsi-core.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  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. #include <linux/device.h>
  16. #include <linux/fsi.h>
  17. #include <linux/module.h>
  18. /* FSI core & Linux bus type definitions */
  19. static int fsi_bus_match(struct device *dev, struct device_driver *drv)
  20. {
  21. struct fsi_device *fsi_dev = to_fsi_dev(dev);
  22. struct fsi_driver *fsi_drv = to_fsi_drv(drv);
  23. const struct fsi_device_id *id;
  24. if (!fsi_drv->id_table)
  25. return 0;
  26. for (id = fsi_drv->id_table; id->engine_type; id++) {
  27. if (id->engine_type != fsi_dev->engine_type)
  28. continue;
  29. if (id->version == FSI_VERSION_ANY ||
  30. id->version == fsi_dev->version)
  31. return 1;
  32. }
  33. return 0;
  34. }
  35. struct bus_type fsi_bus_type = {
  36. .name = "fsi",
  37. .match = fsi_bus_match,
  38. };
  39. EXPORT_SYMBOL_GPL(fsi_bus_type);
  40. static int fsi_init(void)
  41. {
  42. return bus_register(&fsi_bus_type);
  43. }
  44. static void fsi_exit(void)
  45. {
  46. bus_unregister(&fsi_bus_type);
  47. }
  48. module_init(fsi_init);
  49. module_exit(fsi_exit);