Skip to content

Commit 075c3fd

Browse files
committed
libnvdimm/namespace: Clean up holder_class_store()
Use sysfs_streq() in place of open-coded strcmp()'s that check for an optional "\n" at the end of the input. Reviewed-by: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 316720b commit 075c3fd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/nvdimm/namespace_devs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,13 +1506,13 @@ static ssize_t __holder_class_store(struct device *dev, const char *buf)
15061506
if (dev->driver || ndns->claim)
15071507
return -EBUSY;
15081508

1509-
if (strcmp(buf, "btt") == 0 || strcmp(buf, "btt\n") == 0)
1509+
if (sysfs_streq(buf, "btt"))
15101510
ndns->claim_class = btt_claim_class(dev);
1511-
else if (strcmp(buf, "pfn") == 0 || strcmp(buf, "pfn\n") == 0)
1511+
else if (sysfs_streq(buf, "pfn"))
15121512
ndns->claim_class = NVDIMM_CCLASS_PFN;
1513-
else if (strcmp(buf, "dax") == 0 || strcmp(buf, "dax\n") == 0)
1513+
else if (sysfs_streq(buf, "dax"))
15141514
ndns->claim_class = NVDIMM_CCLASS_DAX;
1515-
else if (strcmp(buf, "") == 0 || strcmp(buf, "\n") == 0)
1515+
else if (sysfs_streq(buf, ""))
15161516
ndns->claim_class = NVDIMM_CCLASS_NONE;
15171517
else
15181518
return -EINVAL;

0 commit comments

Comments
 (0)