[PATCH v2 1/1] nvme: use macro definitions for setting reservation values

Max Gurtovoy mgurtovoy at nvidia.com
Mon Oct 3 03:16:36 PDT 2022


On 10/3/2022 1:03 PM, Sagi Grimberg wrote:
>
>> This makes the code more readable.
>>
>> Signed-off-by: Max Gurtovoy <mgurtovoy at nvidia.com>
>> ---
>> Changes from v1:
>>   - remove comments (Sagi/Keith)
>>   - use tabs for constants alignment, similar to 'enum pr_type' (Keith)
>> ---
>>   drivers/nvme/host/core.c | 12 ++++++------
>>   include/linux/nvme.h     |  9 +++++++++
>>   2 files changed, 15 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
>> index 3f1a7dc2a2a3..50668e1bd9f1 100644
>> --- a/drivers/nvme/host/core.c
>> +++ b/drivers/nvme/host/core.c
>> @@ -2068,17 +2068,17 @@ static char nvme_pr_type(enum pr_type type)
>>   {
>>       switch (type) {
>>       case PR_WRITE_EXCLUSIVE:
>> -        return 1;
>> +        return NVME_PR_WRITE_EXCLUSIVE;
>>       case PR_EXCLUSIVE_ACCESS:
>> -        return 2;
>> +        return NVME_PR_EXCLUSIVE_ACCESS;
>>       case PR_WRITE_EXCLUSIVE_REG_ONLY:
>> -        return 3;
>> +        return NVME_PR_WRITE_EXCLUSIVE_REG_ONLY;
>>       case PR_EXCLUSIVE_ACCESS_REG_ONLY:
>> -        return 4;
>> +        return NVME_PR_EXCLUSIVE_ACCESS_REG_ONLY;
>>       case PR_WRITE_EXCLUSIVE_ALL_REGS:
>> -        return 5;
>> +        return NVME_PR_WRITE_EXCLUSIVE_ALL_REGS;
>>       case PR_EXCLUSIVE_ACCESS_ALL_REGS:
>> -        return 6;
>> +        return NVME_PR_EXCLUSIVE_ACCESS_ALL_REGS;
>>       default:
>>           return 0;
>>       }
>> diff --git a/include/linux/nvme.h b/include/linux/nvme.h
>> index ae53d74f3696..4f777d8621a7 100644
>> --- a/include/linux/nvme.h
>> +++ b/include/linux/nvme.h
>> @@ -238,6 +238,15 @@ enum {
>>       NVME_CAP_CRMS_CRIMS    = 1ULL << 60,
>>   };
>>   +enum {
>
> I'd make this named nvme_pr_type

Most of the enums of this header are not named.

I don't understand what is the convention here.

Usually, if it's not a new header file I'm trying to keep the file 
convention and this is what I did.

If all agree on named, I'll send another version.





More information about the Linux-nvme mailing list