1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef LINUX_OPAL_H
19#define LINUX_OPAL_H
20
21#include <uapi/linux/sed-opal.h>
22#include <linux/kernel.h>
23
24struct opal_dev;
25
26typedef int (sec_send_recv)(void *data, u16 spsp, u8 secp, void *buffer,
27 size_t len, bool send);
28
29#ifdef CONFIG_BLK_SED_OPAL
30void free_opal_dev(struct opal_dev *dev);
31bool opal_unlock_from_suspend(struct opal_dev *dev);
32struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv);
33int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr);
34
35static inline bool is_sed_ioctl(unsigned int cmd)
36{
37 switch (cmd) {
38 case IOC_OPAL_SAVE:
39 case IOC_OPAL_LOCK_UNLOCK:
40 case IOC_OPAL_TAKE_OWNERSHIP:
41 case IOC_OPAL_ACTIVATE_LSP:
42 case IOC_OPAL_SET_PW:
43 case IOC_OPAL_ACTIVATE_USR:
44 case IOC_OPAL_REVERT_TPR:
45 case IOC_OPAL_LR_SETUP:
46 case IOC_OPAL_ADD_USR_TO_LR:
47 case IOC_OPAL_ENABLE_DISABLE_MBR:
48 case IOC_OPAL_ERASE_LR:
49 case IOC_OPAL_SECURE_ERASE_LR:
50 return true;
51 }
52 return false;
53}
54#else
55static inline void free_opal_dev(struct opal_dev *dev)
56{
57}
58
59static inline bool is_sed_ioctl(unsigned int cmd)
60{
61 return false;
62}
63
64static inline int sed_ioctl(struct opal_dev *dev, unsigned int cmd,
65 void __user *ioctl_ptr)
66{
67 return 0;
68}
69static inline bool opal_unlock_from_suspend(struct opal_dev *dev)
70{
71 return false;
72}
73#define init_opal_dev(data, send_recv) NULL
74#endif
75#endif
76