pci-hyperv-intf.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * Author:
  6. * Haiyang Zhang <[email protected]>
  7. *
  8. * This small module is a helper driver allows other drivers to
  9. * have a common interface with the Hyper-V PCI frontend driver.
  10. */
  11. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  12. #include <linux/kernel.h>
  13. #include <linux/module.h>
  14. #include <linux/hyperv.h>
  15. struct hyperv_pci_block_ops hvpci_block_ops;
  16. EXPORT_SYMBOL_GPL(hvpci_block_ops);
  17. int hyperv_read_cfg_blk(struct pci_dev *dev, void *buf, unsigned int buf_len,
  18. unsigned int block_id, unsigned int *bytes_returned)
  19. {
  20. if (!hvpci_block_ops.read_block)
  21. return -EOPNOTSUPP;
  22. return hvpci_block_ops.read_block(dev, buf, buf_len, block_id,
  23. bytes_returned);
  24. }
  25. EXPORT_SYMBOL_GPL(hyperv_read_cfg_blk);
  26. int hyperv_write_cfg_blk(struct pci_dev *dev, void *buf, unsigned int len,
  27. unsigned int block_id)
  28. {
  29. if (!hvpci_block_ops.write_block)
  30. return -EOPNOTSUPP;
  31. return hvpci_block_ops.write_block(dev, buf, len, block_id);
  32. }
  33. EXPORT_SYMBOL_GPL(hyperv_write_cfg_blk);
  34. int hyperv_reg_block_invalidate(struct pci_dev *dev, void *context,
  35. void (*block_invalidate)(void *context,
  36. u64 block_mask))
  37. {
  38. if (!hvpci_block_ops.reg_blk_invalidate)
  39. return -EOPNOTSUPP;
  40. return hvpci_block_ops.reg_blk_invalidate(dev, context,
  41. block_invalidate);
  42. }
  43. EXPORT_SYMBOL_GPL(hyperv_reg_block_invalidate);
  44. static void __exit exit_hv_pci_intf(void)
  45. {
  46. }
  47. static int __init init_hv_pci_intf(void)
  48. {
  49. return 0;
  50. }
  51. module_init(init_hv_pci_intf);
  52. module_exit(exit_hv_pci_intf);
  53. MODULE_DESCRIPTION("Hyper-V PCI Interface");
  54. MODULE_LICENSE("GPL v2");