pci-hyperv-intf.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * Author:
  6. * Haiyang Zhang <haiyangz@microsoft.com>
  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. #include <linux/export.h>
  16. struct hyperv_pci_block_ops hvpci_block_ops;
  17. EXPORT_SYMBOL_GPL(hvpci_block_ops);
  18. int hyperv_read_cfg_blk(struct pci_dev *dev, void *buf, unsigned int buf_len,
  19. unsigned int block_id, unsigned int *bytes_returned)
  20. {
  21. if (!hvpci_block_ops.read_block)
  22. return -EOPNOTSUPP;
  23. return hvpci_block_ops.read_block(dev, buf, buf_len, block_id,
  24. bytes_returned);
  25. }
  26. EXPORT_SYMBOL_GPL(hyperv_read_cfg_blk);
  27. int hyperv_write_cfg_blk(struct pci_dev *dev, void *buf, unsigned int len,
  28. unsigned int block_id)
  29. {
  30. if (!hvpci_block_ops.write_block)
  31. return -EOPNOTSUPP;
  32. return hvpci_block_ops.write_block(dev, buf, len, block_id);
  33. }
  34. EXPORT_SYMBOL_GPL(hyperv_write_cfg_blk);
  35. int hyperv_reg_block_invalidate(struct pci_dev *dev, void *context,
  36. void (*block_invalidate)(void *context,
  37. u64 block_mask))
  38. {
  39. if (!hvpci_block_ops.reg_blk_invalidate)
  40. return -EOPNOTSUPP;
  41. return hvpci_block_ops.reg_blk_invalidate(dev, context,
  42. block_invalidate);
  43. }
  44. EXPORT_SYMBOL_GPL(hyperv_reg_block_invalidate);
  45. MODULE_DESCRIPTION("Hyper-V PCI Interface");
  46. MODULE_LICENSE("GPL v2");