From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Hannes Reinecke <hare@suse.de>,
Chaitanya Kulkarni <chaitanyak@nvidia.com>
Cc: "kbusch@kernel.org" <kbusch@kernel.org>,
"hch@lst.de" <hch@lst.de>, "sagi@grimberg.me" <sagi@grimberg.me>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Subject: Re: [RFC PATCH 1/2] nvme-core: factor out common code into helper
Date: Tue, 2 May 2023 06:48:14 +0000 [thread overview]
Message-ID: <8d4b2eb1-69a3-439e-4e2a-c5f044b448d4@nvidia.com> (raw)
In-Reply-To: <36388510-a053-14f6-654b-98317843f290@suse.de>
On 5/1/23 23:11, Hannes Reinecke wrote:
> On 4/27/23 10:02, Chaitanya Kulkarni wrote:
>> nvme_ctrl_dhchap_secrete_store() & nvme_ctrl_dhchap_ctrl_secret store()
>> share common code. Instead of repeating code into two functions factor
>> out into helper function.
>>
>> Signed-off-by: Chaitanya Kulkarni <kch@nvidia.com>
>> ---
>> drivers/nvme/host/core.c | 85 +++++++++++++++-------------------------
>> 1 file changed, 31 insertions(+), 54 deletions(-)
>>
>> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
>> index 44408c0c1762..171ae1f2197a 100644
>> --- a/drivers/nvme/host/core.c
>> +++ b/drivers/nvme/host/core.c
>> @@ -3779,6 +3779,7 @@ static ssize_t dctype_show(struct device *dev,
>> static DEVICE_ATTR_RO(dctype);
>> #ifdef CONFIG_NVME_AUTH
>> +
>> static ssize_t nvme_ctrl_dhchap_secret_show(struct device *dev,
>> struct device_attribute *attr, char *buf)
>> {
>> @@ -3790,41 +3791,40 @@ static ssize_t
>> nvme_ctrl_dhchap_secret_show(struct device *dev,
>> return sysfs_emit(buf, "%s\n", opts->dhchap_secret);
>> }
>> -static ssize_t nvme_ctrl_dhchap_secret_store(struct device *dev,
>> - struct device_attribute *attr, const char *buf, size_t count)
>> +static ssize_t nvme_dhchap_secret_store_common(struct nvme_ctrl *ctrl,
>> + char **dhchap_secret, struct nvme_dhchap_key **orig_key,
>> + const char *buf, size_t count)
>
> Hmm. I'm _not_ a big fan of using double pointer in arguments; is always
> feels to me like using the wrong abstraction.
> Can't you just pass in the ctrl and use a 'bool' variable to switch
> between host and controller secret?
> Interface is _far_ cleaner, and the resulting code will be, too, as we
> don't have to deal with pointer variables all the time ...
>
> Cheers,
>
> Hannes
sounds good, I don't see the reason why bool will not work,
I'll sendout v1 with bool and removing double pointer..
thanks for taking a look ..
-ck
next prev parent reply other threads:[~2023-05-02 6:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-27 8:02 [RFC COMPILE ONLY PATCH 0/2] nvme-core: dhchap_secret code cleanup Chaitanya Kulkarni
2023-04-27 8:02 ` [RFC PATCH 1/2] nvme-core: factor out common code into helper Chaitanya Kulkarni
2023-05-02 6:11 ` Hannes Reinecke
2023-05-02 6:48 ` Chaitanya Kulkarni [this message]
2023-04-27 8:02 ` [RFC PATCH 2/2] nvme-core: use macro defination to define dev attr Chaitanya Kulkarni
2023-05-02 6:12 ` Hannes Reinecke
2023-05-02 2:38 ` [RFC COMPILE ONLY PATCH 0/2] nvme-core: dhchap_secret code cleanup Chaitanya Kulkarni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8d4b2eb1-69a3-439e-4e2a-c5f044b448d4@nvidia.com \
--to=chaitanyak@nvidia.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox