[PATCH] coresight-tpdm: clean up sanity checks in dsb_mode_store()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The (val < 0) check can't be true because "val" is an unsigned long.
Fortunately, that check is not required because the MODE_MASK check works.
Ideally, we would return the error from kstrtoul().  Let's clean this
up a little bit.

Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
---
 drivers/hwtracing/coresight/coresight-tpdm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
index b25284e06395..8c2fd4318ac9 100644
--- a/drivers/hwtracing/coresight/coresight-tpdm.c
+++ b/drivers/hwtracing/coresight/coresight-tpdm.c
@@ -457,9 +457,12 @@ static ssize_t dsb_mode_store(struct device *dev,
 {
 	struct tpdm_drvdata *drvdata = dev_get_drvdata(dev->parent);
 	unsigned long val;
+	int ret;
 
-	if ((kstrtoul(buf, 0, &val)) || (val < 0) ||
-			(val & ~TPDM_DSB_MODE_MASK))
+	ret = kstrtoul(buf, 0, &val);
+	if (ret)
+		return ret;
+	if (val & ~TPDM_DSB_MODE_MASK)
 		return -EINVAL;
 
 	spin_lock(&drvdata->spinlock);
-- 
2.39.2





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux