mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
block/sed-opal: allocate struct opal_dev dynamically
Insted of bloating the containing structure with it all the time this allocates struct opal_dev dynamically. Additionally this allows moving the definition of struct opal_dev into sed-opal.c. For this a new private data field is added to it that is passed to the send/receive callback. After that a lot of internals can be made private as well. Signed-off-by: Christoph Hellwig <[email protected]> Tested-by: Scott Bauer <[email protected]> Reviewed-by: Scott Bauer <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
f5b37b7c23
commit
4f1244c829
6 changed files with 131 additions and 140 deletions
|
|
@ -789,7 +789,7 @@ static int nvme_ioctl(struct block_device *bdev, fmode_t mode,
|
|||
return nvme_nvm_ioctl(ns, cmd, arg);
|
||||
#endif
|
||||
if (is_sed_ioctl(cmd))
|
||||
return sed_ioctl(&ns->ctrl->opal_dev, cmd,
|
||||
return sed_ioctl(ns->ctrl->opal_dev, cmd,
|
||||
(void __user *) arg);
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
|
@ -1059,18 +1059,17 @@ static const struct pr_ops nvme_pr_ops = {
|
|||
};
|
||||
|
||||
#ifdef CONFIG_BLK_SED_OPAL
|
||||
int nvme_sec_submit(struct opal_dev *dev, u16 spsp, u8 secp,
|
||||
void *buffer, size_t len, bool send)
|
||||
int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
|
||||
bool send)
|
||||
{
|
||||
struct nvme_ctrl *ctrl = data;
|
||||
struct nvme_command cmd;
|
||||
struct nvme_ctrl *ctrl = NULL;
|
||||
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
if (send)
|
||||
cmd.common.opcode = nvme_admin_security_send;
|
||||
else
|
||||
cmd.common.opcode = nvme_admin_security_recv;
|
||||
ctrl = container_of(dev, struct nvme_ctrl, opal_dev);
|
||||
cmd.common.nsid = 0;
|
||||
cmd.common.cdw10[0] = cpu_to_le32(((u32)secp) << 24 | ((u32)spsp) << 8);
|
||||
cmd.common.cdw10[1] = cpu_to_le32(len);
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ struct nvme_ctrl {
|
|||
struct list_head node;
|
||||
struct ida ns_ida;
|
||||
|
||||
struct opal_dev opal_dev;
|
||||
struct opal_dev *opal_dev;
|
||||
|
||||
char name[12];
|
||||
char serial[20];
|
||||
|
|
@ -278,16 +278,8 @@ int nvme_init_identify(struct nvme_ctrl *ctrl);
|
|||
void nvme_queue_scan(struct nvme_ctrl *ctrl);
|
||||
void nvme_remove_namespaces(struct nvme_ctrl *ctrl);
|
||||
|
||||
#ifdef CONFIG_BLK_SED_OPAL
|
||||
int nvme_sec_submit(struct opal_dev *dev, u16 spsp, u8 secp,
|
||||
void *buffer, size_t len, bool send);
|
||||
#else
|
||||
static inline int nvme_sec_submit(struct opal_dev *dev, u16 spsp, u8 secp,
|
||||
void *buffer, size_t len, bool send)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BLK_DEV_SED_OPAL */
|
||||
int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer, size_t len,
|
||||
bool send);
|
||||
|
||||
#define NVME_NR_AERS 1
|
||||
void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,
|
||||
|
|
|
|||
|
|
@ -1742,6 +1742,7 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl)
|
|||
if (dev->ctrl.admin_q)
|
||||
blk_put_queue(dev->ctrl.admin_q);
|
||||
kfree(dev->queues);
|
||||
kfree(dev->ctrl.opal_dev);
|
||||
kfree(dev);
|
||||
}
|
||||
|
||||
|
|
@ -1791,10 +1792,13 @@ static void nvme_reset_work(struct work_struct *work)
|
|||
if (result)
|
||||
goto out;
|
||||
|
||||
init_opal_dev(&dev->ctrl.opal_dev, &nvme_sec_submit);
|
||||
if (!dev->ctrl.opal_dev) {
|
||||
dev->ctrl.opal_dev =
|
||||
init_opal_dev(&dev->ctrl, &nvme_sec_submit);
|
||||
}
|
||||
|
||||
if (was_suspend)
|
||||
opal_unlock_from_suspend(&dev->ctrl.opal_dev);
|
||||
opal_unlock_from_suspend(dev->ctrl.opal_dev);
|
||||
|
||||
result = nvme_setup_io_queues(dev);
|
||||
if (result)
|
||||
|
|
|
|||
Loading…
Reference in a new issue