diff mbox series

libnvdimm/namespace: Clean up holder_class_store()

Message ID 155173044436.4154095.17954771880753980013.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Mainlined
Commit 075c3fdd56ac2e077f928353daf786341bbb6a52
Headers show
Series libnvdimm/namespace: Clean up holder_class_store() | expand

Commit Message

Dan Williams March 4, 2019, 8:14 p.m. UTC
Use sysfs_streq() in place of open-coded strcmp()'s that check for an
optional "\n" at the end of the input.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/nvdimm/namespace_devs.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Verma, Vishal L March 4, 2019, 8:36 p.m. UTC | #1
On Mon, 2019-03-04 at 12:14 -0800, Dan Williams wrote:
> Use sysfs_streq() in place of open-coded strcmp()'s that check for an
> optional "\n" at the end of the input.
> 
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  drivers/nvdimm/namespace_devs.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Looks good,
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>

> 
> diff --git a/drivers/nvdimm/namespace_devs.c
> b/drivers/nvdimm/namespace_devs.c
> index 3677b0c4a33d..17fb7f931f0c 100644
> --- a/drivers/nvdimm/namespace_devs.c
> +++ b/drivers/nvdimm/namespace_devs.c
> @@ -1506,13 +1506,13 @@ static ssize_t __holder_class_store(struct
> device *dev, const char *buf)
>  	if (dev->driver || ndns->claim)
>  		return -EBUSY;
>  
> -	if (strcmp(buf, "btt") == 0 || strcmp(buf, "btt\n") == 0)
> +	if (sysfs_streq(buf, "btt"))
>  		ndns->claim_class = btt_claim_class(dev);
> -	else if (strcmp(buf, "pfn") == 0 || strcmp(buf, "pfn\n") == 0)
> +	else if (sysfs_streq(buf, "pfn"))
>  		ndns->claim_class = NVDIMM_CCLASS_PFN;
> -	else if (strcmp(buf, "dax") == 0 || strcmp(buf, "dax\n") == 0)
> +	else if (sysfs_streq(buf, "dax"))
>  		ndns->claim_class = NVDIMM_CCLASS_DAX;
> -	else if (strcmp(buf, "") == 0 || strcmp(buf, "\n") == 0)
> +	else if (sysfs_streq(buf, ""))
>  		ndns->claim_class = NVDIMM_CCLASS_NONE;
>  	else
>  		return -EINVAL;
>
diff mbox series

Patch

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 3677b0c4a33d..17fb7f931f0c 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -1506,13 +1506,13 @@  static ssize_t __holder_class_store(struct device *dev, const char *buf)
 	if (dev->driver || ndns->claim)
 		return -EBUSY;
 
-	if (strcmp(buf, "btt") == 0 || strcmp(buf, "btt\n") == 0)
+	if (sysfs_streq(buf, "btt"))
 		ndns->claim_class = btt_claim_class(dev);
-	else if (strcmp(buf, "pfn") == 0 || strcmp(buf, "pfn\n") == 0)
+	else if (sysfs_streq(buf, "pfn"))
 		ndns->claim_class = NVDIMM_CCLASS_PFN;
-	else if (strcmp(buf, "dax") == 0 || strcmp(buf, "dax\n") == 0)
+	else if (sysfs_streq(buf, "dax"))
 		ndns->claim_class = NVDIMM_CCLASS_DAX;
-	else if (strcmp(buf, "") == 0 || strcmp(buf, "\n") == 0)
+	else if (sysfs_streq(buf, ""))
 		ndns->claim_class = NVDIMM_CCLASS_NONE;
 	else
 		return -EINVAL;