Scott Bauer | 455a7b2 | 2017-02-03 12:50:31 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2016 Intel Corporation |
| 3 | * |
| 4 | * Authors: |
| 5 | * Rafael Antognolli <rafael.antognolli@intel.com> |
| 6 | * Scott Bauer <scott.bauer@intel.com> |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms and conditions of the GNU General Public License, |
| 10 | * version 2, as published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 15 | * more details. |
| 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 | |
Scott Bauer | 455a7b2 | 2017-02-03 12:50:31 -0700 | [diff] [blame] | 24 | struct opal_dev; |
| 25 | |
Christoph Hellwig | 4f1244c | 2017-02-17 13:59:39 +0100 | [diff] [blame] | 26 | typedef int (sec_send_recv)(void *data, u16 spsp, u8 secp, void *buffer, |
| 27 | size_t len, bool send); |
Scott Bauer | 455a7b2 | 2017-02-03 12:50:31 -0700 | [diff] [blame] | 28 | |
| 29 | #ifdef CONFIG_BLK_SED_OPAL |
Scott Bauer | 7d6d157 | 2017-02-22 10:15:06 -0700 | [diff] [blame] | 30 | void free_opal_dev(struct opal_dev *dev); |
Scott Bauer | 455a7b2 | 2017-02-03 12:50:31 -0700 | [diff] [blame] | 31 | bool opal_unlock_from_suspend(struct opal_dev *dev); |
Christoph Hellwig | 4f1244c | 2017-02-17 13:59:39 +0100 | [diff] [blame] | 32 | struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv); |
Scott Bauer | e225c20 | 2017-02-14 17:29:36 -0700 | [diff] [blame] | 33 | int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr); |
Scott Bauer | 455a7b2 | 2017-02-03 12:50:31 -0700 | [diff] [blame] | 34 | |
| 35 | static 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 |
Scott Bauer | 7d6d157 | 2017-02-22 10:15:06 -0700 | [diff] [blame] | 55 | static inline void free_opal_dev(struct opal_dev *dev) |
| 56 | { |
| 57 | } |
| 58 | |
Scott Bauer | 455a7b2 | 2017-02-03 12:50:31 -0700 | [diff] [blame] | 59 | static inline bool is_sed_ioctl(unsigned int cmd) |
| 60 | { |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | static inline int sed_ioctl(struct opal_dev *dev, unsigned int cmd, |
Scott Bauer | e225c20 | 2017-02-14 17:29:36 -0700 | [diff] [blame] | 65 | void __user *ioctl_ptr) |
Scott Bauer | 455a7b2 | 2017-02-03 12:50:31 -0700 | [diff] [blame] | 66 | { |
| 67 | return 0; |
| 68 | } |
| 69 | static inline bool opal_unlock_from_suspend(struct opal_dev *dev) |
| 70 | { |
| 71 | return false; |
| 72 | } |
Christoph Hellwig | 4f1244c | 2017-02-17 13:59:39 +0100 | [diff] [blame] | 73 | #define init_opal_dev(data, send_recv) NULL |
Scott Bauer | 455a7b2 | 2017-02-03 12:50:31 -0700 | [diff] [blame] | 74 | #endif /* CONFIG_BLK_SED_OPAL */ |
| 75 | #endif /* LINUX_OPAL_H */ |