From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933138AbcLTGVJ (ORCPT ); Tue, 20 Dec 2016 01:21:09 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:40610 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753494AbcLTGVG (ORCPT ); Tue, 20 Dec 2016 01:21:06 -0500 Date: Mon, 19 Dec 2016 22:21:04 -0800 From: Christoph Hellwig To: Scott Bauer Cc: linux-nvme@lists.infradead.org, Rafael.Antognolli@intel.com, axboe@fb.com, keith.busch@intel.com, jonathan.derrick@intel.com, viro@zeniv.linux.org.uk, hch@infradead.org, linux-kernel@vger.kernel.org, sagi@grimberg.me Subject: Re: [PATCH v3 4/5] nvme: Implement resume_from_suspend and SED Allocation code. Message-ID: <20161220062104.GC4765@infradead.org> References: <1482176149-2257-1-git-send-email-scott.bauer@intel.com> <1482176149-2257-5-git-send-email-scott.bauer@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1482176149-2257-5-git-send-email-scott.bauer@intel.com> User-Agent: Mutt/1.6.1 (2016-04-27) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +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. From mboxrd@z Thu Jan 1 00:00:00 1970 From: hch@infradead.org (Christoph Hellwig) Date: Mon, 19 Dec 2016 22:21:04 -0800 Subject: [PATCH v3 4/5] nvme: Implement resume_from_suspend and SED Allocation code. In-Reply-To: <1482176149-2257-5-git-send-email-scott.bauer@intel.com> References: <1482176149-2257-1-git-send-email-scott.bauer@intel.com> <1482176149-2257-5-git-send-email-scott.bauer@intel.com> Message-ID: <20161220062104.GC4765@infradead.org> > +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.