[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161220062104.GC4765@infradead.org>
Date: Mon, 19 Dec 2016 22:21:04 -0800
From: Christoph Hellwig <hch@...radead.org>
To: Scott Bauer <scott.bauer@...el.com>
Cc: linux-nvme@...ts.infradead.org, Rafael.Antognolli@...el.com,
axboe@...com, keith.busch@...el.com, jonathan.derrick@...el.com,
viro@...iv.linux.org.uk, hch@...radead.org,
linux-kernel@...r.kernel.org, sagi@...mberg.me
Subject: Re: [PATCH v3 4/5] nvme: Implement resume_from_suspend and SED
Allocation code.
> +static int nvme_sec_send(void *ctrl_data, u16 spsp, u8 secp,
> + void *buf, size_t len)
> +{
> + return nvme_sec_submit(ctrl_data, spsp, secp, buf, len,
> + nvme_admin_security_send);
> +}
> +
> +static int nvme_sec_recv(void *ctrl_data, u16 spsp, u8 secp,
> + void *buf, size_t len)
> +{
> + return nvme_sec_submit(ctrl_data, spsp, secp, buf, len,
> + nvme_admin_security_recv);
> +}
> +
> +static const struct sec_ops nvme_sec_ops = {
> + .sec_send = nvme_sec_send,
> + .sec_recv = nvme_sec_recv,
> +};
Just make sec_submit the callback passed to the core and avoid
this boiler-plate code.
>
> +int nvme_opal_initialize(struct nvme_ctrl *ctrl)
> +{
> + /* Opal dev has already been allocated for this controller */
> + if (ctrl->sed_ctx.dev)
> + return 0;
> +
> + ctrl->sed_ctx.dev = alloc_opal_dev(ctrl->admin_q);
> + if (!ctrl->sed_ctx.dev)
> + return -ENOMEM;
> + ctrl->sed_ctx.ops = &nvme_sec_ops;
> + ctrl->sed_ctx.sec_data = ctrl;
No need for sec_data callback, just pass the sed_ctx to the driver
and use container_of to get at the containing structure.
Powered by blists - more mailing lists