Skip to contentSkip to conversation

clk-si5341: replace snprintf in show functions with sysfs_emit

PATCH RESEND Applied Qing Wang 3 participants 4 messages Oct 15, 2021 – Jan 25, 2022 Common clk

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore

Qing Wang

author
#0 lore raw

PATCH RESEND 1/1 clk-si5341: replace snprintf in show functions with sysfs_emit

coccicheck complains about the use of snprintf() in sysfs show functions.

Fix the following coccicheck warning:
drivers/clk/clk-si5341.c:1471: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1486: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1501: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1516: WARNING: use scnprintf or sprintf.

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

---
 drivers/clk/clk-si5341.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/clk-si5341.c +4 -4
index 57ae183..5d62ddb 100644
@@ -1468,7 +1468,7 @@ static ssize_t input_present_show(struct device *dev,
 	if (res < 0)
 		return res;
 	res = !(status & SI5341_STATUS_LOSREF);
-	return snprintf(buf, PAGE_SIZE, "%d\n", res);
+	return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(input_present);
 
@@ -1483,7 +1483,7 @@ static ssize_t input_present_sticky_show(struct device *dev,
 	if (res < 0)
 		return res;
 	res = !(status & SI5341_STATUS_LOSREF);
-	return snprintf(buf, PAGE_SIZE, "%d\n", res);
+	return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(input_present_sticky);
 
@@ -1498,7 +1498,7 @@ static ssize_t pll_locked_show(struct device *dev,
 	if (res < 0)
 		return res;
 	res = !(status & SI5341_STATUS_LOL);
-	return snprintf(buf, PAGE_SIZE, "%d\n", res);
+	return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(pll_locked);
 
@@ -1513,7 +1513,7 @@ static ssize_t pll_locked_sticky_show(struct device *dev,
 	if (res < 0)
 		return res;
 	res = !(status & SI5341_STATUS_LOL);
-	return snprintf(buf, PAGE_SIZE, "%d\n", res);
+	return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(pll_locked_sticky);
 
Signature · 1 line
2.7.4
maintainer
#1 lore raw

+Robert

Quoting Qing Wang (2021-10-14 23:45:28)

Quoted 58 lines

coccicheck complains about the use of snprintf() in sysfs show functions.

Fix the following coccicheck warning:
drivers/clk/clk-si5341.c:1471: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1486: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1501: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1516: WARNING: use scnprintf or sprintf.

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

---
 drivers/clk/clk-si5341.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/clk-si5341.c +4 -4
index 57ae183..5d62ddb 100644
@@ -1468,7 +1468,7 @@ static ssize_t input_present_show(struct device *dev,
        if (res < 0)
                return res;
        res = !(status & SI5341_STATUS_LOSREF);
-       return snprintf(buf, PAGE_SIZE, "%d\n", res);
+       return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(input_present);
 
@@ -1483,7 +1483,7 @@ static ssize_t input_present_sticky_show(struct device *dev,
        if (res < 0)
                return res;
        res = !(status & SI5341_STATUS_LOSREF);
-       return snprintf(buf, PAGE_SIZE, "%d\n", res);
+       return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(input_present_sticky);
 
@@ -1498,7 +1498,7 @@ static ssize_t pll_locked_show(struct device *dev,
        if (res < 0)
                return res;
        res = !(status & SI5341_STATUS_LOL);
-       return snprintf(buf, PAGE_SIZE, "%d\n", res);
+       return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(pll_locked);
 
@@ -1513,7 +1513,7 @@ static ssize_t pll_locked_sticky_show(struct device *dev,
        if (res < 0)
                return res;
        res = !(status & SI5341_STATUS_LOL);
-       return snprintf(buf, PAGE_SIZE, "%d\n", res);
+       return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(pll_locked_sticky);
 
Signature · 1 line
2.7.4
Reviewed-by
#2 lore raw
Quoted 50 lines · Stephen Boyd

+Robert

Quoting Qing Wang (2021-10-14 23:45:28)

Quoted 47 lines

coccicheck complains about the use of snprintf() in sysfs show functions.

Fix the following coccicheck warning:
drivers/clk/clk-si5341.c:1471: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1486: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1501: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1516: WARNING: use scnprintf or sprintf.

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

---
 drivers/clk/clk-si5341.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/clk-si5341.c +3 -3
index 57ae183..5d62ddb 100644
@@ -1468,7 +1468,7 @@ static ssize_t input_present_show(struct device *dev,
        if (res < 0)
                return res;
        res = !(status & SI5341_STATUS_LOSREF);
-       return snprintf(buf, PAGE_SIZE, "%d\n", res);
+       return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(input_present);
 
@@ -1483,7 +1483,7 @@ static ssize_t input_present_sticky_show(struct
 device *dev,
        if (res < 0)
                return res;
        res = !(status & SI5341_STATUS_LOSREF);
-       return snprintf(buf, PAGE_SIZE, "%d\n", res);
+       return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(input_present_sticky);
@@ -1498,7 +1498,7 @@ static ssize_t pll_locked_show(struct device *dev,
        if (res < 0)
                return res;
        res = !(status & SI5341_STATUS_LOL);
-       return snprintf(buf, PAGE_SIZE, "%d\n", res);
+       return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(pll_locked);
 
Quoted 9 lines

drivers/clk/clk-si5341.c static ssize_t pll_locked_sticky_show(struct device · line 1519

Quoted 9 lines
drivers/clk/clk-si5341.c +1 -1
@@ -1513,7 +1513,7 @@ static ssize_t pll_locked_sticky_show(struct device
 *dev,
        if (res < 0)
                return res;
        res = !(status & SI5341_STATUS_LOL);
-       return snprintf(buf, PAGE_SIZE, "%d\n", res);
+       return sysfs_emit(buf, "%d\n", res);
 }
 static DEVICE_ATTR_RO(pll_locked_sticky);

Looks good to me.

Quoted 4 lines
Quoted 4 lines
Signature · 2 lines
-- 
2.7.4
Signature · 3 lines
Robert Hancock
Senior Hardware Designer, Calian Advanced Technologies
www.calian.com
maintainer Applied
#3 lore raw
In reply to Qing Wang

Quoting Qing Wang (2021-10-14 23:45:28)

Quoted 8 lines

coccicheck complains about the use of snprintf() in sysfs show functions.

Fix the following coccicheck warning:
drivers/clk/clk-si5341.c:1471: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1486: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1501: WARNING: use scnprintf or sprintf. drivers/clk/clk-si5341.c:1516: WARNING: use scnprintf or sprintf.

Quoted 4 lines

Use sysfs_emit instead of scnprintf or sprintf makes more sense.

---

Applied to clk-next