sed-opal.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright © 2016 Intel Corporation
  4. *
  5. * Authors:
  6. * Rafael Antognolli <rafael.antognolli@intel.com>
  7. * Scott Bauer <scott.bauer@intel.com>
  8. */
  9. #ifndef LINUX_OPAL_H
  10. #define LINUX_OPAL_H
  11. #include <uapi/linux/sed-opal.h>
  12. #include <linux/kernel.h>
  13. struct opal_dev;
  14. typedef int (sec_send_recv)(void *data, u16 spsp, u8 secp, void *buffer,
  15. size_t len, bool send);
  16. #ifdef CONFIG_BLK_SED_OPAL
  17. void free_opal_dev(struct opal_dev *dev);
  18. bool opal_unlock_from_suspend(struct opal_dev *dev);
  19. struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv);
  20. int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr);
  21. static inline bool is_sed_ioctl(unsigned int cmd)
  22. {
  23. switch (cmd) {
  24. case IOC_OPAL_SAVE:
  25. case IOC_OPAL_LOCK_UNLOCK:
  26. case IOC_OPAL_TAKE_OWNERSHIP:
  27. case IOC_OPAL_ACTIVATE_LSP:
  28. case IOC_OPAL_SET_PW:
  29. case IOC_OPAL_ACTIVATE_USR:
  30. case IOC_OPAL_REVERT_TPR:
  31. case IOC_OPAL_LR_SETUP:
  32. case IOC_OPAL_ADD_USR_TO_LR:
  33. case IOC_OPAL_ENABLE_DISABLE_MBR:
  34. case IOC_OPAL_ERASE_LR:
  35. case IOC_OPAL_SECURE_ERASE_LR:
  36. case IOC_OPAL_PSID_REVERT_TPR:
  37. case IOC_OPAL_MBR_DONE:
  38. case IOC_OPAL_WRITE_SHADOW_MBR:
  39. case IOC_OPAL_GENERIC_TABLE_RW:
  40. return true;
  41. }
  42. return false;
  43. }
  44. #else
  45. static inline void free_opal_dev(struct opal_dev *dev)
  46. {
  47. }
  48. static inline bool is_sed_ioctl(unsigned int cmd)
  49. {
  50. return false;
  51. }
  52. static inline int sed_ioctl(struct opal_dev *dev, unsigned int cmd,
  53. void __user *ioctl_ptr)
  54. {
  55. return 0;
  56. }
  57. static inline bool opal_unlock_from_suspend(struct opal_dev *dev)
  58. {
  59. return false;
  60. }
  61. #define init_opal_dev(data, send_recv) NULL
  62. #endif /* CONFIG_BLK_SED_OPAL */
  63. #endif /* LINUX_OPAL_H */