summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--block/sed-opal.c24
-rw-r--r--include/linux/sed-opal.h1
-rw-r--r--include/uapi/linux/sed-opal.h1
3 files changed, 26 insertions, 0 deletions
diff --git a/block/sed-opal.c b/block/sed-opal.c
index 55c8a0953d78..53a73422911e 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -3116,6 +3116,27 @@ static int opal_setup_locking_range_start_length(struct opal_dev *dev,
return ret;
}
+static int opal_enable_disable_range(struct opal_dev *dev,
+ struct opal_user_lr_setup *opal_lrs)
+{
+ const struct opal_step lr_steps[] = {
+ { start_auth_opal_session, &opal_lrs->session },
+ { setup_enable_range, opal_lrs },
+ { end_opal_session, }
+ };
+ int ret;
+
+ ret = opal_get_key(dev, &opal_lrs->session.opal_key);
+ if (ret)
+ return ret;
+ mutex_lock(&dev->dev_lock);
+ setup_opal_dev(dev);
+ ret = execute_steps(dev, lr_steps, ARRAY_SIZE(lr_steps));
+ mutex_unlock(&dev->dev_lock);
+
+ return ret;
+}
+
static int opal_locking_range_status(struct opal_dev *dev,
struct opal_lr_status *opal_lrst,
void __user *data)
@@ -3459,6 +3480,9 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg)
case IOC_OPAL_LR_SET_START_LEN:
ret = opal_setup_locking_range_start_length(dev, p);
break;
+ case IOC_OPAL_ENABLE_DISABLE_LR:
+ ret = opal_enable_disable_range(dev, p);
+ break;
default:
break;
diff --git a/include/linux/sed-opal.h b/include/linux/sed-opal.h
index a0df6819b0a9..1d63479838cf 100644
--- a/include/linux/sed-opal.h
+++ b/include/linux/sed-opal.h
@@ -55,6 +55,7 @@ static inline bool is_sed_ioctl(unsigned int cmd)
case IOC_OPAL_SET_SID_PW:
case IOC_OPAL_REACTIVATE_LSP:
case IOC_OPAL_LR_SET_START_LEN:
+ case IOC_OPAL_ENABLE_DISABLE_LR:
return true;
}
return false;
diff --git a/include/uapi/linux/sed-opal.h b/include/uapi/linux/sed-opal.h
index 82de38f3fbeb..bde023ae2295 100644
--- a/include/uapi/linux/sed-opal.h
+++ b/include/uapi/linux/sed-opal.h
@@ -231,5 +231,6 @@ struct opal_revert_lsp {
#define IOC_OPAL_SET_SID_PW _IOW('p', 241, struct opal_new_pw)
#define IOC_OPAL_REACTIVATE_LSP _IOW('p', 242, struct opal_lr_react)
#define IOC_OPAL_LR_SET_START_LEN _IOW('p', 243, struct opal_user_lr_setup)
+#define IOC_OPAL_ENABLE_DISABLE_LR _IOW('p', 244, struct opal_user_lr_setup)
#endif /* _UAPI_SED_OPAL_H */